Streaming
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.
Note Streaming is supported on NI 5421/5422/5441/5442 signal generators. |
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, space in the onboard memory becomes free and fill that space with new waveform data. Repeat the process of filling the freed onboard memory in blocks of new waveform data until the waveform is complete.
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 5421 signal 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.
- Specify the amount of onboard memory to be used for streaming.
Use 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.
- 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.
- 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. Tip NI-FGEN requires the quotient of the waveform size divided by the data transfer block size to be an integer value. If the waveform size is not an integer multiple of the block size, change either the waveform size or the block size. A fractional number of data blocks in the waveform returns an error message. - 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.
- As the waveform generates, monitor available memory.
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. After a certain amount, say 10 percent, of the allocated onboard memory becomes available, you can write a block of waveform data to the streaming waveform in onboard memory.
Note The Space Available in Streaming Waveform property or the NIFGEN_ATTR_STREAMING_SPACE_AVAILABLE_IN_WAVEFORM attribute specifies the total amount of space available in the streaming waveform. During generation, this available space may be in multiple locations with, for example, part of the available space at the end of the streaming waveform and the rest at the beginning. In this situation, writing a block of waveform data the size of the total space available in the streaming waveform causes NI-FGEN to return an error, as NI-FGEN will not wrap the data from the end of the waveform to the beginning and cannot write data past the end of the waveform buffer. To avoid writing data past the end of the waveform, write new data to the waveform in a fixed size that is an integer divisor of the total size of the streaming waveform.
- 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.
-
Repeat the process of monitoring the available memory and writing waveform data in blocks as free space becomes available.
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 Rate1 | |
---|---|---|
MS/s | MB/s | |
Host memory on desktop computer or PXI embedded controller | ~45 to 47.5 | ~90 to 115 |
Desktop IDE or SATA hard drive | ~27.5 to 35 | ~55 to 702 |
Laptop or low RPM hard drive | 12.5 to 15 | 25 to 302 |
Host memory on desktop across MXI-3 to PXI board | 12.5 | 25 |
Host memory on desktop across MXI-4 to PXI board | 12.5 | 25 |
1 All data rates highly dependent on chipset. 2 Measurements were taken using the Windows API for unbuffered file I/O. For more information, refer to High Speed Streaming Solutions. |
PXI Express
Data Source | Data Rate1 | |
---|---|---|
MS/s | MB/s | |
Host memory on desktop computer or PXI embedded controller | ~262 | ~524 |
Desktop IDE or SATA hard drive | ~155 | ~310 |
1All data rates highly dependant on chipset. |
Note These numbers were obtained using several file I/O optimizations. For more information about this streaming process, refer to High Speed Streaming Solutions. |
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.
- When streaming from hard drives, consider the hard drive speed for maximum sustainable rates. Laptop hard drives typically have a data transfer rate of 5 to 10 MB/s. Desktop hard drives often can meet 20 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 RAID (redundant array of independent disks) 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.