Synchronizing Finite Analog and Digital Outputs in NI-DAQmx

Updated Aug 25, 2026

Reported In

Hardware

  • Multifunction I/O Device

Software

  • LabVIEW

Driver

  • NI-DAQmx

Issue Details

I am generating a finite analog output waveform and a synchronized digital output pulse in NI-DAQmx.
The analog output is generated, but the digital output pulse is not observed when the waveform frequency is lowered. In another case, changing only the frequency input of the Sine Waveform VI does not generate the expected number of cycles, such as 1.5 cycles.
How can I configure the analog output waveform and digital output pattern so that both outputs remain synchronized?

The following figure shows an example in which the sampling rate and sample count are fixed.

Figure 1. With Fs fixed at 1000 S/s and #s fixed at 1500 samples, the intended 1.5 cycles are generated only at a waveform frequency of 1 Hz.

Solution

Configure the AO task to use the DO Sample Clock.

In this example, ao quality defines the number of samples per analog waveform cycle. It is used to calculate both the AO sample rate and the total sample count for waveform generation. A higher value increases the waveform resolution by placing more samples in each cycle, which makes the generated sine wave smoother.

The VI generates 1.5 waveform cycles, so the total AO sample count is calculated as:
samples per channel = 1.5 × ao quality

The sample rate is calculated as:
sample rate = frequency × ao quality

This means that ao quality is effectively a samples-per-cycle setting, not a general analog accuracy or hardware quality setting.

To keep the analog waveform synchronized with the digital output pattern, set the source input of the AO DAQmx Timing VI to the DO Sample Clock terminal, such as /Dev1/do/SampleClock. In this configuration, the AO task uses the DO sample clock instead of its onboard sample clock, so each analog sample update occurs in step with the digital output pattern.

Start the AO task before the DO task so that the AO task is ready to receive the DO Sample Clock when the DO task begins generating it.

The following figure shows an example configuration that applies the calculated sample count and uses the DO Sample Clock for the AO task.



Figure 2. Example configuration for generating 1.5 cycles of an analog waveform with a synchronized digital output pattern. In this example, ao quality defines the number of AO samples per waveform cycle, so it is used to calculate both the sample rate and the total sample count. The calculated sample rate and sample count are applied consistently to waveform generation and DAQmx timing, and the AO task uses the DO Sample Clock as its sample clock source so that each analog sample update stays aligned with the digital output pattern.

The resulting analog output waveform is shown below.
Figure 3. Analog output waveform generated using the configuration in Figure 2. The graph shows 1.5 waveform cycles over the configured output duration.

Additional Information

A missing observed digital pulse does not always mean that the digital output task failed. The pulse may be too short, occur outside the oscilloscope observation window, or not meet the receiving device trigger condition.
When using low-frequency waveforms, the total output duration becomes longer. Configure timeout values long enough for the expected generation time.