Streaming is a way to generate waveforms that are too large to fit in the onboard memory of the signal generator. Streaming can be used in Arbitrary Waveform, Arbitrary Sequence, or Script output modes.

To stream waveform data, allocate and identify all or a portion of the signal generator onboard memory to act as an onboard waveform for streaming. Before initiating waveform generation, fill that onboard memory with the first part of your waveform. As the waveform is generated, continuously write the remaining waveform data until the waveform is complete.
Note Streaming should not be used if the data to be generated is less than or equal to the size of the streaming waveform.

Streaming Waveform Data

The following instructions are a guide for configuring your application for streaming. For a programmatic example, refer to Fgen Arb Waveform Streaming.vi for LabVIEW or ArbitraryWaveformStreaming.prj for LabWindows/CVI.

As an example, we have a 1.6 GB waveform we want to generate and an NI arbitrary waveform generator with 256 MB of onboard memory. This 1.6 GB waveform may be in the host memory, on disk, or data that your application generates dynamically during generation.

  1. Specify the amount of onboard memory to be used for streaming—Call the niFgen Allocate Waveform VI or the niFgen_AllocateWaveform function to specify the amount of onboard memory to reserve for streaming. The allocated memory, known as the streaming waveform, serves as a buffer for the streaming process. The size of the waveform you wish to stream must be evenly divisible by the amount of onboard memory allocated for streaming to prevent the streaming waveform from being overwritten before it has generated.
  2. Identify the streaming waveform—Set the Streaming Waveform Handle property or the NIFGEN_ATTR_STREAMING_WAVEFORM_HANDLE attribute to the waveform handle returned in Step 1. Setting this property or attribute ensures that none of your streaming data is overwritten before it is generated. NI-FGEN monitors your progress to ensure that you write fresh data fast enough to keep up with the generation. If your application fails to keep up or attempts to write fresh data over data that has not been generated, NI-FGEN returns an error.
  3. Fill the streaming waveform with initial data—Call the niFgen Write Waveform VI or the niFgen_WriteWaveform function to write the first part of the waveform data to the streaming waveform in onboard memory.
    Tip   When transferring large blocks of waveform data, break the data into smaller blocks and call the niFgen Write Waveform VI or the niFgen_WriteWaveform function multiple times. The data is appended sequentially. A computer can allocate smaller blocks of a large waveform faster than allocating a single large contiguous block in memory. Depending on the amount of RAM on the computer, transferring ten 16 MB blocks may be faster than transferring one 160 MB block.
  1. Begin generating the waveform—Call the niFgen Initiate Generation VI or the niFgen_InitiateGeneration function to begin the waveform generation. As the waveform generates, space in the streaming waveform becomes free.
  2. (Optional) Monitor available memory as the waveform generates—Use the Space Available in Streaming Waveform property or the NIFGEN_ATTR_STREAMING_SPACE_AVAILABLE_IN_WAVEFORM attribute to determine how much of the streaming waveform is free for writing new data. As the waveform generates, space becomes available to write more waveform data.
  1. Write a block of waveform data—Call niFgen Write Waveform VI or the niFgen_WriteWaveform function to write a new block of waveform data to the streaming waveform in onboard memory. If the size of the new block of waveform data is larger than the space available, NI-FGEN waits until sufficient space becomes available or the streaming write time expires. Use the Streaming Write Timeout property or the NIFGEN_ATTR_STREAMING_WRITE_TIMEOUT attribute to change the streaming write time.
  2. Repeat steps 5 and 6 until all waveform data is written.

Streaming to Multiple Channels

To stream data to multiple channels, you must provide interleaved data. You cannot stream to two or more channels with individual, non-interleaved writes for each channel.

Average Performance Rates

The following tables list the average data rates possible for PXI, PCI, and PXI Express signal generators. Average data transfer rates are highly system dependent. The following table is intended to give you an idea of the average sustainable transfer rates using 16-bit (or 2 byte) samples.

PXI and PCI

Data Source Data Rate (MB/s) *
Host memory on desktop computer or PXI embedded controller ~90 to 115
Desktop IDE or SATA hard drive ~55 to 70
Laptop or low RPM hard drive 25 to 30
Host memory on desktop across MXI-3 to PXI device 25
Host memory on desktop across MXI-4 to PXI device 25
* All data rates highly dependent on chip set. Measurements were taken using the Windows API for unbuffered file I/O. For more information about streaming, refer to Data Streaming Architecture in PXI Systems.

PXI Express

Data Source Data Rate (MB/s)*
From disk, such as a redundant array of independent disks (RAID). > 600
* Data transfer rates are limited by the speed of your streaming storage solution. Refer to Data Streaming for more information. These numbers were obtained using several file I/O optimizations. For more information about this streaming process, refer to Stream to Disk Using Win32 File IO.

Improving Streaming Performance

To improve your maximum sustainable transfer rate for streaming, consider the following recommendations:

  • Adjust the Data Transfer Block Size property or the NIFGEN_ATTR_DATA_TRANSFER_BLOCK_SIZE attribute. The default data transfer block size for NI-FGEN is 2 MS (or 4 MB). If you were to write a 16 MB waveform to the signal generator, the complete transfer would occur using four separate DMA transfers. If you modify the data transfer block size to 8 MS (16 MB), for example, the data transfer is more efficient and is instead accomplished in a single transfer.
  • Configure advanced streaming properties by calling the Maximum In-Flight Read Requests, PCI DMA Optimization Enabled, or Preferred Packet Size property or the NIFGEN_ATTR_DATA_TRANSFER_MAXIMUM_IN_FLIGHT_READS, NIFGEN_ATTR_DATA_TRANSFER_PCI_DMA_OPTIMIZATIONS, or NIFGEN_ATTR_DATA_TRANSFER_PREFERRED_PACKET_SIZE attributes.
  • Optimize the bus bandwidth usage for multi-device streaming applications by calling the Maximum Bandwidth property or the NIFGEN_ATTR_DATA_TRANSFER_MAXIMUM_BANDWIDTH attribute.
  • When streaming from hard drives, consider the hard drive speed for maximum sustainable rates. Laptop hard drives typically have a data transfer rate of 25 to 30 MB/s. Desktop hard drives often can meet 55 to 70 MB/s.

    Transfer rates from hard drives can vary for a number of reasons, including where the data is physically stored on the hard drive and how much data is stored. Storing your waveform files on a fairly empty, defragmented hard drive may help increase performance.

  • Consider using a redundant array of independent disks (RAID) configuration to utilize striping to increase data transfer rates from disk.
  • When using 18-slot PXI chassis, install the signal generator used for streaming in the first segment (Slots 2 to 6) of the PXI chassis.
  • Utilize Direct DMA.