I am in the middle of converting some Traditional NI-DAQ code to the
DAQmx API (I am using C++). Most of it is going quite well: my
code complexity has been greatly reduced and (since upgrading to 7.4)
my CPU usage has plummeted. However, in one particular case I
need my input and output buffers to be synchronized. I.e. sample
0 of my input buffer should be read at the same instant sample 0 of my
output buffer went out on the line. In Traditional NI-DAQ, I
synchronized my input and output start triggers using the following
method (which I believe I found in an example somewhere):
error = Select_Signal(addr, ND_PFI_6, ND_OUT_START_TRIGGER, ND_LOW_TO_HIGH);
error = Select_Signal(addr, ND_IN_START_TRIGGER, ND_PFI_6, ND_LOW_TO_HIGH);
This then allowed me to setup my input thread, then initialize
everything in my output thread and when my output got the start
command, so did my input. The result was that I could perfectly
match buffers of output data to buffers of input data (after taking all
the appropriate buffering into account).
When I try the same method with the DAQmxConnectTerms function, my
buffers don't line up. They are off by 15-20 ms out of a 400ms
buffer (sampling at 10kHz). I tried cutting out the middle man of
PFI6 with similar results. So my current "synchronize" block
looks like this:
error = m_fnConnectTerms("/Dev1/ao/StartTrigger", "/Dev1/ai/StartTrigger", 0);
I get no error. This also seems to cause my output loop to hang
after a few seconds, although that could be a side effect of something
else that I haven't tracked down yet. Is there a better way to do
what I'm trying to do here? Perhaps it is a misunderstanding of
the way buffering works on the M series cards (I am currently using a
6221).