Example Code

NI-HSDIO Stream to Disk: Queue Binary File I/O

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

  • Modular Instrumentation

    Software

  • LabVIEW

    Driver

  • Other

Code and Documents

Attachment

Overview
    This example allows a user to stream from an HSDIO device (654x/655x/656x) to disk.  A queue is used as a buffer between the HSDIO device and the binary file on disk.


Description
    This example demonstrates using continuous dynamic acquisition to fetch a user-defined, but quite large record of data all while continuously streaming the data to a binary file using the Win32 File I/O VIs. 
    This example uses a producer/consumer architecture to efficiently transfer data from the onboard memory of the device into LabVIEW memory and then stream that data to disk. The producer loop continuously fetches data from onboard memory into the LabVIEW memory using DMA transfers. This data is placed into a queue in order to efficiently transfer the data to a parallel consumer loop where it is written file. If the sampling rate is low, the computer can fetch all the data from the device, so data is never overwritten.  However, at faster sampling rates, the computer will not be able to fetch the data before it is overwritten by new data. This results in the "data overwritten" error.
    The consumer loop continuously empties data from the queue and writes data to disk using the Win32 Write File.vi. The file is opened using the Win32 Open File.vi, which disables Windows caching during the write process, resulting in increased performance. However when Windows caching is disabled, data must be written to file in a multiple of the sector size of the disk (typically 512 bytes).
    More in-depth details can be found on the Block Diagram of the VI.

 

Requirements
    Software
        LabVIEW 2012 (or compatible)
        NI-HSDIO driver which is compatible with your hardware and version of LabVIEW
    Hardware
        NI HSDIO device (654x/655x/656x)

 
Instructions

1. Open niHSDIO Stream to Disk Queues Binary File IO.vi
2. Set the front panel controls to the desired values (Resource Name, Destination File, etc.)
3. Run the VI

 

Additional Information or References

 

Stream to Disk Binary.png

 

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

Customer Education Product Marketing Manager
National Instruments

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