Streaming is a method of generating waveforms that are too large to fit in the onboard memory of the device. Streaming can be used in dynamic generation sessions.

To stream waveform data, you allocate and identify all or a portion of the device onboard memory to act as an onboard waveform for streaming. Before initiating generation, you fill that onboard memory with the first part of your waveform. As the waveform is generated, space in the onboard memory becomes free and you fill that space with new waveform data. You repeat the process of filling the freed onboard memory in blocks of new waveform data until the waveform is complete.

The following instructions are a guide for configuring your application for streaming.

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

  1. Specify the amount of onboard memory used for streaming.

    Use the niHSDIO Allocate Named Waveform VI or the function to specify the amount of onboard memory to reserve for streaming. This memory serves as a buffer for the streaming process. The niHSDIO Allocate Waveform VI function returns a waveform handle.

  2. Identify the streaming waveform.

    Set the Streaming Waveform Name property or the NIHSDIO_ATTR_STREAMING_WAVEFORM_NAME attribute to the waveform handle returned in Step 1. Setting this property ensures that no streaming data is overwritten before it is generated. NI-HSDIO monitors your progress to ensure that you write fresh data fast enough to keep up with the generation. If your application cannot write data fast enough, or attempts to write fresh data on top of data that has not been generated, NI-HSDIO returns an error.

  3. Fill the streaming waveform with initial data.

    Call the niHSDIO Write Named Waveform VI or the one of the Write Named Waveform functions to write the first part of the waveform data to the streaming waveform in onboard memory.

    Tip When transferring large waveform data blocks, divide the data into smaller segments. Use the niHSDIO Write Named Waveform VI or one of the Write Named Waveform functions multiple times. Each call appends data sequentially. Computers typically allocate smaller blocks faster than a single large contiguous block. For example, transferring ten 16 MB blocks may be faster than transferring one 160 MB block, depending on the available RAM.
  4. Begin generating the waveform.

    Call the niHSDIO Init Generation Session VI or the niHSDIO_InitGenerationSession function to begin the waveform generation. As the waveform generates, space in the streaming waveform becomes free.

  5. As the waveform generates, monitor available memory.

    Use the Space Available in Streaming Waveform property or the NIHSDIO_ATTR_SPACE_AVAILABLE_IN_STREAMING_WAVEFORM attribute to determine how much of the onboard waveform is free for writing new data. As the waveform generates, space becomes available to write more waveform data. Once a certain amount of the onboard memory becomes available, you can write more of the waveform to the streaming waveform in onboard memory. In general, writing in larger blocks, such as 16 MB, results in more efficient streaming and faster streaming rates.

  6. Write a block of waveform data.

    Call the niHSDIO Write Named Waveform VI or the one of the Write Named Waveform functions to write a new block of waveform data to the streaming waveform in onboard memory.

  7. Repeat the process of monitoring the available memory and writing waveform data in blocks as free space becomes available.

Tip For an example of how this application can be written in LabVIEW, refer to the Continuous Generation - Stream From Memory VI. This VI is included in the Dynamic Generation.llb, which ships as part of the NI-HSDIO Examples.

Improving Streaming Performance

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

  • Adjust the Data Transfer Block Size property or the NIHSDIO_ATTR_DATA_TRANSFER_BLOCK_SIZE attribute to be closer to the waveform size. This change makes the data transfer more efficient and is accomplished in a single transfer instead of four transfers.
  • 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 typically meet or exceed 20 MB/s.
  • Transfer rates from hard drives vary for different reasons. For example, where the data is physically stored on the hard drive and how much data is stored can affect transfer rates. Storing your waveform files on a dedicated and defragmented hard drive might increase performance.
  • Consider using your hard drives in a RAID configuration. This allows for striping, which increases data transfer rates from the disk.
  • When using an 18-slot PXI chassis, install the device that is used for streaming in slots 2 to 6 of the chassis.
  • Utilize Direct DMA.