Solution
The default example VI is not designed to handle a large amount of data. We should implement the following changes to the Host VI (Getting Started <Device Name>- Basic.vi) in order to save the data to file for post processing.
- Change Polymorphic Selector of Read Stream.vi from "Array of Waveforms" to 2D > I16 in order to reduce the total data saved.
- Create two For Loops, one around Read Stream.vi and another just below the first For loop. Create a queue of I16 2D array and enqueue the data from Read Stream.vi in the first For loop.
- Place Open File.vi, Write Binary File.vi, and Close File.vi and place Write Binary File.vi and Dequeue Element.vi in the second For loop to save the data to a binary file. You may want to set "prepend array or string size" to false to avoid placing size data into the file.
- Add a logic to divide the data entered into "num samples" control into a group of 100MB chunks. 100MB was chosen arbitrarily to efficiently save the data to file, but this number can be adjusted based on your PC's stream bandwidth. The result of "num samples" divided by 100MB should be wired to the For Loops as the number of loop iterations.
- Cut the wire connecting "num samples" and "samples" terminal of Read Stream.vi. Wire the result of "num samples" divided by "num samples" multiplied by the number of channels used divided by 100MB to "samples" terminal of Read Stream.vi.
An example VI with the modification is displayed below.
Note: This image is a LabVIEW snippet, which includes LabVIEW code that you can reuse in your project. To use a snippet, right-click the image, save it to your computer, and drag the file onto your LabVIEW diagram.
To run this example VI, you should do the following.
- If you have not created an example LabVIEW project for your device, open NI Example Finder from LabVIEW menu bar and select Hardware Input and Output > FlexRIO > Integrated IO > Getting Started > Getting Started FlexRIO Integrated IO.vi. When the window named "FlexRIO with Integrated IO Project Creator" opens, select your FlexRIO device and click OK. It may take several minutes for the example project to be automatically created.
- Once the project is created, open the project folder with Windows file explorer. Open "Host" folder. Right click on "GettingStarted_<Device Name>_Host.lvlib" and open Properties. If the "Read-only" attribute is selected, uncheck and click Apply button.
- Open the LabVIEW project. Expand GettingStarted_<Device Name>_Host.lvlib and make the abovementioned modification to "Getting Started <Device Name> - Basic.vi or create a new VI and paste the content of the VI snippet above and add to GettingStarted_<Device Name>_Host.lvlib.
- On the front panel of the VI, set "num samples" as the total number of samples you would like to acquire per channel. For instance, if you need to acquire 1G samples per channel and you have AI0 and AI1 enabled, you should enter "1G" in num samples. You should also specify the file to store the data in "file path" control.
- Run VI.
Note: When you run this VI, the graph will not update for every iteration of the For loop since the loop runs too fast with too much data. This is expected behavior. Although the graph will not update, the binary file should contain all data acquired. For example, if you specified the VI to acquire 1G samples in two channels, the file size will be 4GB. This is because each sample of data is 2-bytes and the VI was set to acquire a total of 2G samples.