Solved! Go to Solution.
Sorry about the editing mishap... hope this is more clear:
Hello everyone, I seem to have some problem synchronizing the analog input and output on my M-series USB-6211.
My application is fairly simple. I would like to output and acquire a sinewave at the same time. Theoretically, I should have the same 4000 data points going through the output and input channels. The reality however, captured on a oscilloscope, shows that the analog output is putting out more than 4000 data points. The input (acquisition) shows 4000 samples. Please see below for a snippet of the task creation, timing and execution. I'm afraid that the analog input and output are not tied together correctly. Do you see anything suspicious? Many thanks!
//Analog output channel setup, with 20Ksamples/sec:
DAQmxCreateAOVoltageChan (outTaskHandle, physChanOut, "", -10, 10, DAQmx_Val_Volts, NULL); DAQmxCfgSampClkTiming (outTaskHandle, "OnboardClock", 20000,DAQmx_Val_Rising, DAQmx_Val_ContSamps, 4000);
//Analog input channel setup:
DAQmxCreateAIVoltageChan (inTaskHandle, physChanIn, "", DAQmx_Val_RSE ,-10, 10, DAQmx_Val_Volts, "");
DAQmxCfgSampClkTiming (inTaskHandle, "OnboardClock", 20000,DAQmx_Val_Rising, DAQmx_Val_ContSamps, 4000);
//Set up trigger:
sprintf (local_port, "/%s/ai/StartTrigger", deviceName);
DAQmxCfgDigEdgeStartTrig (outTaskHandle, local_port,DAQmx_Val_Rising);
DAQmxWriteAnalogF64 (outTaskHandle, (numberOfSamples*overSample),1, 40, DAQmx_Val_GroupByChannel, input, &sampsPerChanWritten, NULL);
DAQmxReadAnalogF64 (inTaskHandle, 4000, 40, DAQmx_Val_GroupByChannel , readArray, 8000, &sampsPerChanRead, NULL);
Changing the sample method from continuous to finite seems to fix the problem:
DAQmxCfgSampClkTiming (inTaskHandle, "OnboardClock", 20000,DAQmx_Val_Rising, DAQmx_Val_FiniteSamps, 4000);
Also I meant earlier to write 4000 samples in:
DAQmxWriteAnalogF64 (outTaskHandle, 4000,1, 40, DAQmx_Val_GroupByChannel, input, &sampsPerChanWritten, NULL);