From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Example Code

Scope Streaming Examples


Scope Streaming

When looking at a NI-Scope streaming application most people start with either the niScope EX Fetch Forever or niScope EX Multi Record Fetch More Than Available Memory VIs. Both of these examples do a good job of demonstrating different methods for bringing a great deal of information from a digitizer into LabVIEW.


Continuous Streaming

The niScope EX Fetch Forever example demonstrates moving data continuosly from onboard memory to LabVIEW memory. It does this by continuosly acquiring pretrigger samples without ever recieving a trigger. By fetching this pretrigger data at the same rate data is acquired by the digitizer a continuous stream of data can be digitzed and transfered to your computer.

There are two important pieces to the code that allow this to happen.

fetch forever.png

The first is step 4, where a software reference trigger is configured but never sent. This allows the driver to continuously acquire pretrigger samples, waiting for a reference trigger that will never happen. In order to fetch the data however, you need to properly configure the read pointer (step 6). The read pointer will start at the first sample of data acquired and will be automatically incremented on each fetch. This allows you to move through the circular buffer, continuously acquiring data.

Considerations

There are two main considerations for this type of acquisition. First, you need to make sure that the bus over which you are transfering data (PCI, PCIe, PXI, PXIe) can handle the amount of data you are trying to transfer. If it cannot your acquisition will eventually suffer a buffer overrun.

The second consideration in this type of application involve what you are actually doing with it. If you try to display the information, perform signal processing and analysis or write it to disk, difficulties can arise due to limited resources on your PC. In general you should limit the data you display. For signal processing and analysis you may want to use post processing or peer-to-peer streaming. As far as streaming to disk, RAID may be necessary.

Examples

There are many options for expanding on this example to highlight features or optimize performance.

Here are two examples that demonstarate the maximum ability of the bus to transfer data to LabVIEW memory.

Developer Zone Community: niScope Single Channel Stream to Memory Maximum Transfer Rate

Developer Zone Community: niScope Multiple Channel Stream to Memory Maximum Transfer Rate

These examples do the same as those above, except that new data is fetched each iteration rather than simply fetching the same data each fetch.

Developer Zone Community: niScope Single Channel Stream to Memory Continuous Data

Developer Zone Community: niScope Multiple Channel Stream to Memory Continuous Data

Finally, these examples take in data from a digitizer and stream it to disk.

Developer Zone Community: niScope Single Channel Stream to Disk

Developer Zone Community: niScope Multiple Channel Stream to Disk


Multi-Recod Fetch

The niScope EX Multi Record Fetch More Than Available Memory example demonstrates moving data continuosly from onboard memory to LabVIEW memory in seperate, triggered, records. It does this by continuosly acquiring records from the digitizers onboard memory, opening up room for future records to acquire. This modifies the default behavior of a digitizer, in which all records are acquired before fetching them as a group.

There are three important properties within the code that allow this to happen.

fetch number.png

The first two properties that need to be set are the Enable Records Greater Than Memory and the Fetch Number of Records properties. The first is simply a flag that turns on the ability for this type of operation. The second specifies the number of records fetched from memory on each Multi Record Fetch.

Once these properties are set in configuration, there is another that needs to be used as well.

fetch record.png

The Fetch Record Number property needs to be called before every fetch to specifiy the record index to acquire on each fetch. By writing to this terminal you are specifying the first record to fetch in a given multi record fetch. So, if you have configure 10 records to fetch and you write 100 to this terminal, you will fetch records 100-109, inclusive.

Considerations

Outside of the considerations for continuous streaming above, which Multi Record Fetch shares, there is another that is unique to this method.

When fetching multiple records there is a great deal of overhead that will reduce your aggregate rate compared to continuous fetch. This reduction has been seen to be up to 40-60% of the continuous fetch rate. This is usually not a problem, but it is something that should be aware of.

Examples

There are many options for expanding on this example to highlight features or optimize performance.

Here is an example that expands on the functionality of the original, increasing it's capabilities.

Developer Zone Community: niScope Multi Record Stream to Memory

This example includes code for streaming the records to disk.

Developer Zone Community: niScope Multi Record Stream to Disk

Regards,
Dan King

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

Comments
UMASO
Member
Member
on

Hello, thanks for organizing multiple scattered examples into one place here.  

I was looking for a simple example for streaming PXIe-5170 data into binary file (not TDMS) and ran into this page.  

While this page provides good reference, I noticed Sample Finder (Scope 17.0 installed in my environment) provides an example named "niScope EX Stream to Disk.vi".  

I guess this example VI in Sample Finder is also a good reference.  

 

Thanks, 

skk1
Member
Member
on

Hi,

Can you provide the above labview examples to support labview 8.6 version.

ctressle
Member
Member
on
Contributors