01-16-2012 02:08 PM
Solved! Go to Solution.
01-16-2012 02:23 PM
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!
//Task creation:
DAQmxCreateTask("",&inTaskHandle);
DAQmxCreateTask("",&outTaskHandle);
//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);
//Output:
DAQmxWriteAnalogF64 (outTaskHandle, (numberOfSamples*overSample),1, 40, DAQmx_Val_GroupByChannel, input, &sampsPerChanWritten, NULL);
//Acquire:
DAQmxReadAnalogF64 (inTaskHandle, 4000, 40, DAQmx_Val_GroupByChannel , readArray, 8000, &sampsPerChanRead, NULL);
//Stop Tasks:
DAQmxStopTask (outTaskHandle);
DAQmxStopTask (inTaskHandle);
01-17-2012 03:48 PM
Hi,
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:
//Output:
DAQmxWriteAnalogF64 (outTaskHandle, 4000,1, 40, DAQmx_Val_GroupByChannel, input, &sampsPerChanWritten, NULL);
thanks