myWRIO
C++ framework for NationalInstruments myRIO
example_aio.cpp
#include "MyRIO.h"
using namespace myRIO;
using namespace std;
int main() {
if(!myRIO_init()) {cout << "Error initializing myRIO"; return -1;}
double fq = 100;
double vpp = 4;
double outputFq = 100e3;
Time timer = Time::stopwatch();
timer.reset();
while(1) {
AIO::writePin(CO0, (vpp/2)*sin(2*3.141592653*fq*timer.elapsed_ns()*1e-9));
// we cannot measure more than 2 seconds ; reset it before it's too late
if(timer.elapsed_ns() >= 1e9L)
timer.reset();
// convert the frequency to time, then the time to µs
Time::wait_us(1e6/outputFq);
}
return 0;
}