Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

syncing AO and AI in real time

Hi scorpsjl,

Take a look at \Program Files\National Instruments\MeasurementStudioVS2003\DotNET\Examples\DAQmx\Synchronization\Multi-Function\SyncAIAO_DigStart.

If you do not have this example, please modify the installation of NI-DAQmx and choose to install support for Visual Studio so that your example programs properly install.  Note that you do not need Measurement Studio to have these examples.

Regards,
Laura

0 Kudos
Message 11 of 15
(1,941 Views)
Hi Laura,

That's the one I've looked at. However, that has  both tasks starting from an external digital trigger. I want one task to be triggered by the other task, with no external trigger. I suppose I can have one task be triggered via an analog output from the other, but that would only take effect when the output reached a certain voltage, and not immediately. Alternatively I suppose I could use the example and externally wire a DO channel to the appropriate input channel, and then start an output from the DO via a separate task. However, these all seem inefficient and contrived. Is there no direct way to do it?

Maybe I'm missing something.

-scorpsjl
0 Kudos
Message 12 of 15
(1,937 Views)

Hi scorpsjl,

Sorry, I missed this part of the question.  You can start one task with the DAQmxStartTask call and set the other one off to trigger off of the digital edge start trigger of the other task which is an internal signal that happens when the task starts.  For example, if you are going to have the AO task be the one that starts the other, you would set the AI task up to use the ao/StartTrigger and start the AI task first, and then the AO task.  The AI and AO tasks will then start synchronously. 

Regards,
Laura

0 Kudos
Message 13 of 15
(1,930 Views)
Hello All,
 
I am working on a similar example but a VC++ version.
When you mean sync, based from this example, is because of the start trigger
or because you have the AO task start and AI task start written together?
 
What are the code requirements to be synch?
 
I am using cDAQ-9172, VC++.
 
Thanks again,
A
 
0 Kudos
Message 14 of 15
(1,624 Views)
In regards to A's post,
 
To expand on what Laura said above, when a task starts, an internal line is asserted: xx/StartTrigger, where 'xx' can be ai or ao, corresponding to the respective task type. So you can set up a task to start when another task's StartTrigger is asserted as Laura said.
 
Because two tasks are written close together in code does not mean they are synchronized. To do this, you must set up one task to be armed and waiting for the other task's StartTrigger to be asserted. For example, if you want your AO to start the moment your AI starts, you'd set up your AO with a DAQmxCfgDigEdgeStartTrig (and configured to be triggered off the digital edge of the ai/StartTrigger which is local to the board) and then call DAQmxStartTask which will arm the AO task. The AO task is now simply waiting for the digital ai/StartTrigger line to go high. So now you'll set up your AI task and the moment you start it, the ai/StartTrigger digital line will assert and thus start your AO task immediately.
 
This will start the two tasks at the same time. To be synchronize the measurements, you'll need to share the sample clock. This is done in very much the same way by setting up one of the tasks to use the sample clock of the other task. In the above example, you'd set the AO task to use the ai/SampleClock line by setting the source parameter on DAQmxCfgSampClkTiming to ai/SampleClock and then setting the same parameters as the timing on the AI task.
PBear
NI RF
Message 15 of 15
(1,612 Views)