Example Code

niScope Single Channel Stream to Memory Continuous Data

Code and Documents

Attachment

This example demonstrates using continuous multi channel acquisition to fetch a user-defined, but quite large record of data all while continuously streaming the data to a binary file. The digitizer is configured using the Configure Vertical and Configure Horizontal VI's. Auto setup in this case may not be useful, as it may choose a horizontal rate that exceeds the computer's streaming capabilities.

In this example, continuous acquisition is used. This allows the user to start the digitizer, and continuously fetch data without losing any points. This is accomplished by configuring a software reference trigger and never sending the software trigger. Therefore, the digitizer will continuously acquire data into its onboard memory until Abort or Close is called.

front panel.png

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 to file. If the sampling rate is low, the computer can fetch all the data from the digitizer, 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 Write to Binary File.vi. The file is opened using the disable buffering input on the 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).

Regards,
Dan King

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

Contributors