Can I Stop NI-DAQmx Analog Output Regeneration at a Particular Cycle?

Updated Dec 8, 2023

Reported In

Programming Language

  • LabVIEW G

Issue Details

  • I am generating a continuous pattern using regeneration on a Analog Output DAQmx channel in LabVIEW. I would like to stop the pattern if regeneration reaches a particular cycle number. Is this possible?
  • I have configured a DAQmx task for regeneration and would like a way to count how many times the samples have been regenerated so that I can stop the task at the end of the buffered data. How can I do this?

Solution

When using a DAQmx task in Regeneration Mode, it is not possible to determine which sample is currently being generated or to overwrite particular samples in the circular buffer.

In order to stop regeneration after a particular number of cycles, one of the following options can be used as an alternative:
  • Use a counter as the sample clock for the Analog Output task.
  • If the number of cycles are known beforehand, configure the Analog Output task for Finite Samples.



Using a Counter Task

  1. Create a counter that generates a finite pulse of (number of samples in the Analog Output waveform) x (number of cycles required) length.
  2. Configure the counter as the sample clock for the Analog Output task.
  3. When the pulse generation is complete, the Analog Output task can be stopped.
Counter Pulse Regeneration.png
Note: This image is a LabVIEW snippet, which includes LabVIEW code that you can reuse in your project. To use a snippet, right-click the image, save it to your computer, and drag the file onto your LabVIEW diagram.



Generating Finite Samples

If the number of cycles are known beforehand, configure an Analog Output task with (number of samples in the waveform) x (number of cycles required) finite samples.

Analog Output Finite Samples.png
Note: This image is a LabVIEW snippet, which includes LabVIEW code that you can reuse in your project. To use a snippet, right-click the image, save it to your computer, and drag the file onto your LabVIEW diagram.