Example Code

Using a LabVIEW Queue as a FIFO for DAQmx Data

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Hardware

  • Data Acquisition (DAQ)

    Software

  • LabVIEW

    Driver

  • NI DAQmx

Code and Documents

Attachment

Overview

This example VI enables the user to use a queue as a FIFO and store only the N most recently acquired points.


Description

Some data acquisition applications require storing only the N most recently acquired points.  While it may be acceptable to store all the points in array and pull the final N points off the array after acquisition, this becomes impractical if the application is to run for a long time due to wasteful memory usage.  This example code leverages the LabVIEW Queue as a FIFO to keep only the N most recently acquired points.  This implementation is much faster than using an array due to the constant element shifting required in the array implementation.


  1. This VI initializes a queue and sets the max queue size and element type.
  2. Then the VI dequeues an element if the queue is full.
  3. Takes the data from the DAQmx Read.vi and adds it to the queue.
  4. The represented data is taken from the queue and put into an array.

Requirements to Run

Software

  • LabVIEW 2009 or compatible
  • DAQmx 8.9.5 or compatible


Hardware

  • Most NI DAQ devices

Steps to Implement or Execute Code

  1. Download the VI
  2. Wire your data acquisition initialization and configuration code to the currently unwired DAQmx Start Task VI on the left
  3. You may need to change the polymorphic type of the DAQmx Read which will require changing the queue type
  4. After you have made the necessary changes run the VI

Additional Information or References

Block Diagram

DAQ_FIFO_Example.png

**This document has been updated to meet the current required format for the NI Code Exchange.**

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Contributors