Dynamic/Programmatic Analog Output Using NI-DAQ™mx

Updated Nov 21, 2022

Reported In

Driver

  • NI-DAQmx

Issue Details

I want to perform continuous analog output and programmatically change the waveform during the output task using NI-DAQ™mx. How can I program the device to output new data continuously? Why does it take several seconds before the new waveform actually appears on the output when I am able to get the device to output new data? 

Solution

In order to configure your DAQ device to perform analog output of a waveform that you can programmatically change as the waveform is output, you need to set the regeneration mode property of your device to Do Not Allow Regeneration. This is done with a DAQmx Write Property Node. Setting this property to Do Not Allow Regeneration forces the board to request new data from the PC buffer as the board's onboard FIFO outputs the old data.
​C#.NET: myTask.Stream.WriteRegenerationMode = WriteRegenerationMode.DoNotAllowRegeneration
When regeneration mode is disallowed, you need to have a DAQmxWrite function in a loop that will continuously update the buffer.

Note: For this property to work properly, you must download a waveform (Analog Write.vi) prior to starting the AO task (Start Task.vi).
 

Additional Information

When you set this property to Do Not Allow Regeneration you can also configure the Data Transfer Request Condition property. This property is found under the DAQmx Channel Property Node at Analog Output » General Properties » Advanced » Data Transfer and Memory » Data Transfer Request Condition. Setting this property determines how quickly the changed waveform actually appears at the output. The three different values to which you can set this property are described below.
  1. Onboard Memory Less than Full
    When the Regeneration Mode is set to Onboard Memory Less than Full, the board will request new data to be sent to the card each time the board's onboard FIFO is less than full. This means that if you want to change the waveform output, it will take several seconds for the change to be seen on the output because the new waveform data will need to propagate through the board's entire FIFO. With this setting the board's FIFO stays full.

    C#.NET: myTask.Stream.AODataTransferRequestCondition = AODataTransferRequestCondition.OnBoardMemoryNotFull;

  2. Onboard Memory Empty
    When this property is set to Onboard Memory Empty, the board will request new data when its onboard FIFO is empty. This means that when you want to change the waveform output, the new waveform will be seen quickly on the output. Since the board's FIFO is nearly empty when the new data is sent to it, the new data does not need to propagate through the entire FIFO before is output. The new data is already at the end of the FIFO when it gets to the DAQ board and appears immediately at the output.

    C#.NET: myTask.Stream.AODataTransferRequestCondition = AODataTransferRequestCondition.OnBoardMemoryEmpty;

  3. Onboard Memory Half Full or Less
    When using Onboard Memory Half Full or Less, you need to set your buffer to be at least as large as your device's onboard FIFO. Setting this property means that your board is operating with a much smaller portion of its FIFO. Because of this you can set the buffer size to be much smaller. It is suggested that you start with a buffer size of 500 and increase or decrease the number for best performance.

    C#.NET: myTask.Stream.AODataTransferRequestCondition = AODataTransferRequestCondition.OnBoardMemoryHalfFullOrLess;