CompactRIO Stream to Disk Reference Example
Overview
This simple example illustrates how to stream data from the FPGA to RT and straight to a file on the local hard disk (flash memory). The data is buffered in the DMA memory on the host computer before being written to disk in small chunks.
Downloads
Filename: crio_stream_to_disk10.zip
Requirements: View
Example Description
This example performs the following operations:
FPGA
- Simulates acquisition of 24 channels of data - replace this code with the I/O node for your input module
- Streams data to DMA FIFO
- Acquisition is started with the Start Acq button/register
- If Num Scans = 0 the acquisition runs continuously until Stop Acq is set
- If Num > 0 the acquisition acquires the number of scans specified and then stops. It will also stop if Stop Acq is set.
- If there is a DMA overflow at any point the acquisition stops immediately and sets the DMa Overflow flag/indicator
- The acquisition period is set using Scan Period. During acquisition the code verifies that the desired loop rate is achieved.
RT
- Configures the DMA buffer on the host and starts the DMA process
- Configures the number of scans and scan period on the FPGA
- Starts an acquisition on the FPGA
- Reads the expected number of data points from the DMA buffer. The VI calculates the total number of data points based on the number of channels (24) and the number of scans. During the read process the VI reads a maximum of 1024 samples from the DMA buffer at a time until all of the scans have been read back.
- Each block of data from the DMA buffer is written directly to a file that is opened once at the beginning of the acquisition. Setting the block size to a known value (1024 samples) optimizes the write-to-disk speed as multiples of 512 bytes are the optimal block size for disk access.
- Close the file at the end of the acquisition
Hardware Configuration
This VI is configured to use a CompactRIO RT controller and CompactRIO 9103 chassis, but it can be customized to any RT target and FPGA-based RIO device (compactRIO, R series card, etc.).
Requirements
Filename: crio_stream_to_disk10.zip
Software Requirements
Application Software: LabVIEW Full Development System 8.5.1
Toolkits and Add-Ons: LabVIEW Real-Time Module 8.5.1, LabVIEW FPGA Module 8.5.1
Language(s): LabVIEW
Hardware Requirements
Hardware Group: CompactRIO
Hardware Model: cRIO-9002, cRIO-9014, cRIO-9012, cRIO-9004
Driver: NI-RIO 2.4
Reader Comments | Submit a comment »
Legal
This example program (this "program") was developed by a National Instruments ("NI") Applications Engineer. Although technical support of this program may be made available by National Instruments, this program may not be completely tested and verified, and NI does not guarantee its quality in any way or that NI will continue to support this program with each new revision of related products and drivers. THIS EXAMPLE PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND AND SUBJECT TO CERTAIN RESTRICTIONS AS MORE SPECIFICALLY SET FORTH IN NI.COM'S TERMS OF USE (http://ni.com/legal/termsofuse/unitedstates/us/).
