How to Synchronize Analog and Digital Output Tasks in NI-DAQmx With LabVIEW

Updated Feb 24, 2018

Reported In

Software

  • LabVIEW

Driver

  • NI-DAQmx

Issue Details

I would like to synchronize my analog output and digital output tasks in LabVIEW so that I can output digital pulses exactly when my analog signal goes above/below a certain level.  How should I do this?

Solution

There are many applications which require synchronization between analog output and digital output tasks.  For example, one might need to output a digital pulse whenever an analog output signal goes above 4.5V or when it goes below 0.5V, as shown in the mixed signal graph below:
 

 

To achieve this synchronized performance, we need two accomplish two goals:

  1. Generate two waveforms that are correlated in the desired way (e.g. create a digital waveform that is high whenever the analog waveform is outside of a specified range)
  2. Output these waveforms in two separate DAQmx tasks using some form of hardware-timed synchronization

In the VI example below, the correlated signals are generated by deriving a digital output waveform from the analog output waveform using LabVIEW Comparison Nodes.  Sample clock synchronization is achieved by specifying the analog output task's sample clock as the sample clock source for the digital output task.  See the snippet below or the attached example for more details:  



When the analog output task is started (assuming that the digital output task is already started and waiting for a sample clock), the tasks will run in a synchronized fashion, operating using the same sample clock, until the user stops the application.  

Additional Information

A start trigger is not needed in the above snippet since a sample clock is already being used to ensure that each output sample is synchronized between the tasks.

WAS THIS ARTICLE HELPFUL?

Not Helpful