This content is not available in your preferred language.

The content is shown in another available language. Your browser may include features that can help translate the text.

Avoid DAQmx Buffer Overflow by Adjusting Buffer Size in LabVIEW

Updated Dec 22, 2022

Reported In

Software

  • LabVIEW

Driver

  • NI-DAQmx

Issue Details

I am experiencing a buffer overflow or crash of my analog, digital or counter task. How do I manually override NI-DAQ™mx's choice of buffer size in LabVIEW?

Solution

Memory allocation is typically handled automatically by DAQmx. However, You can manually override NI-DAQmx's choice of buffer size by calling the DAQmx Configure Input Buffer VI (or DAQmx Configure Output Buffer VI for output operations) found on the functions palette under Measurement I/O»DAQmx - Data Acquisition»DAQmx Advanced Task Options. This VI overrides the automatic buffer allocation that NI-DAQmx performs. The DAQmx Configure Input Buffer VI allocates the acquisition buffer based on its input parameter buffer size, which is specified in terms of the number of samples the buffer can hold for each channel in the task.

The snippet below shows a common way of adding the DAQmx Configure Input Buffer VI into a DAQmx task code. The buffer needs to be manually overridden before the task starts so it is common to place it after the virtual channel is configured but before the task starts.
 
analog input buffer size.png
 

Additional Information

You can also use the DAQmx Buffer Property Node to query the amount of memory currently allocated by DAQmx. 

For more information, refer to the LabVIEW Help for the DAQmx Configure Input Buffer VI and to the NI-DAQmx Help. You can access the help for the DAQmx Configure Input Buffer VI by right-clicking on top of the VI and selecting the Help option.

For more information about how DAQmx automatically allocates the buffer see: DAQmx Buffer Size Allocation for Finite or Continuous Acquisitions