LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

analog input and output synchronization

Solved!
Go to solution
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);
0 Kudos
Message 1 of 3
(2,325 Views)

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);

0 Kudos
Message 2 of 3
(2,324 Views)
Solution
Accepted by topic author Concordian07

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

0 Kudos
Message 3 of 3
(2,295 Views)