Academic Company Events NI Developer Zone Support Solutions Products & Services Contact NI MyNI

Document Type: Tutorial
NI Supported: Yes
Publish Date: Sep 6, 2006


Feedback


Yes No

Related Categories

Products

Related Links - Developer Zone

Related Links - Products and Services

Importing Binary Files Into Diadem

21 ratings | 4.57 out of 5
Print

Overview

This document explains how to use DIAdem to read binary files stored in two common storage formats: channel mode and block mode. While the examples read files written by LabVIEW, the information is applicable for importing any binary data files into DIAdem.

Binary Data Storage

Binary data is most commonly stored in one of two modes: channel or block mode.

When data is stored in channel mode, the complete data set of one channel is stored successively, followed by the complete data set of the next channel. The table below represents a data set of four two channels with n values stored in channel mode:

Channel 1 Value 1
Channel 1 Value 2
Channel 1 Value 3
...
Channel 1 Value n
Channel 2 Value 1
Channel 2 Value 2
Channel 2 Value 3
...
Channel 2 Value n
Channel 3 Value 1
Channel 3 Value 2
Channel 3 Value 3
...
Channel 3 Value n
Channel 4 Value 1
Channel 4 Value 2
Channel 4 Value 3
...
Channel 4 Value n

Channel mode is typically useful for data sets where the number of values can vary and the data set will not be added to. Channel mode corresponds to row oriented data.

When data is stored in block mode the values of each channel are interleaved. The table below represents a data set of four channels with n values stored in block mode.

Channel 1 Value 1
Channel 2 Value 1
Channel 3 Value 1
Channel 4 Value 1
Channel 1 Value 2
Channel 2 Value 2
Channel 3 Value 2
Channel 4 Value 2
...
...
...
...
Channel 1 Value n
Channel 2 Value n
Channel 3 Value n
Channel 4 Value n

Block mode is typically useful for data sets where the number of values is equal and more data will be appended to the file.

Be aware that binary files do not have spaces between data points or linefeeds between rows, rather one must know the format of the data to properly extract it. To read the data the size of the data set and the number of rows and columns must be known previously.

Importing a Binary File in Channel Mode


Take for example a VI that writes a binary file data.bin of single precision 32 bit floating point numbers with no header. The data is written in channel mode (refer to the section Binary Data Storage earlier in this document for an explanation of channel mode storage).


[+] Enlarge Image

This data can easily be imported into DIAdem. The following steps show how to import this data:

1. Go to the Data Window by clicking on the Data icon:

2. Open a new data file by clicking on the New icon:

3. Select Import via header from the File menu:

4. We need to generate a "*.DAT" header file to be able to read this in DIAdem. Click on the Edit button in the Import via header dialog box:



5. Enter the specifications of this data file for each channel we are importing:


[+] Enlarge Image


  • Storage mode: Specifies the order of data. Channel mode refers to row oriented data; the data order is: all samples of channel 1; all samples of channel 2, and so on. Block Mode refers to column oriented data; the data order is: sample 1 from channel 1, sample 1 from channel 2, sample 2 from channel 1, sample 2 from channel 2, and so on. For an example of importing binary data stored in block mode refer to the Example 2.

  • Type of Data: specifies that we are importing 32 bit floating point numbers.

  • No. of values: specifies the number of time/data points in the channel.

  • Offset: specifies the scalar DC offset to be applied to the data.

  • Factor: specifies a scale to be applied to the data

  • First data point in this line of the file: specifies the offset where the data begins for this channel. Each unit will represent one 32 bit entry. Since the data channel begins after 10 Time points, we select this channel to start at the 11th value.


After entering the specifications, click on the Close button to return to the Import via Header window.

6. In the Import via Header window select Data Set Properties:


Since LabVIEW stores data in low to high (Big-Endian) format the appropriate Byte Order is selected.




7. Save this header information as the corresponding data.dat file in the same directory as the data file data.bin.




8. Finally import the data by selecting Execute:




9. The data will now appear in the Data Window and can be seen in the View Window after configuring the data trace. This data can be retrieved by opening the data.dat file.


[+] Enlarge Image

Importing a Binary File Stored in Block Mode and Generating an Implicit Time Channel

Take for example a VI that acquires data and logs it to a binary file of single precision 32 bit floating point Numbers with no header. The data is written in block mode (refer to the section Binary Data Storage earlier in this document for an explanation of block mode storage). Let’s suppose the file is named datablock.bin.


1. Repeat steps 1 - 4 of Example 1 to begin creating a header file for this data.

2. We will first generate a time channel to go along with this data. Select Generate in the Import via header window:




3. Enter the parameters for the time channel we will generate.




Click Continue and set up the initial time and the step width.



4. After clicking OK, we will need to setup the import of the two data channels by choosing Edit in the Import via header window:



5. Edit the settings for the two data channels we will be importing.


[+] Enlarge Image


  • Storage mode: Specifies the order of data. Channel mode refers to row oriented data; the data order is: all samples of channel 1; all samples of channel 2, and so on. Block Mode refers to column oriented data; the data order is: sample 1 from channel 1, sample 1 from channel 2, sample 2 from channel 1, sample 2 from channel 2, and so on.

  • Type of Data: specifies that we are importing 32 bit floating point numbers.

  • No. of values: specifies the number of time/data points in the channel.

  • Offset: specifies the scalar DC offset to be applied to the data.

  • Factor: specifies a scale to be applied to the data

  • First data point in this line of the file: specifies the offset where the data begins for this channel. Each unit will represent one 32 bit entry. The Analog In 1 channel starts at the first data point, while Analog In 2 channel starts at the next data point.

  • Offset between 2 values of one channel: Since every other point corresponds to each channel, we choose an offset of 2.

After entering the specifications, click on the Close button to return to the Import via Header window.

6. In the Import via Header window select Data Set Properties:




Since LabVIEW stores data in low to high (Big-Endian) format the appropriate Byte Order is selected.




7. Save this header information as the corresponding datablock.dat file in the same directory as the data file datablock.bin.




8. Finally import the data by selecting Execute:




9. The data will now appear in the Data Window and can be seen in the View Window after configuring the data traces. This data can be retrieved by opening the datablock.dat


[+] Enlarge Image

21 ratings | 4.57 out of 5
Print

Reader Comments | Submit a comment »

Update Example For most recent version of DIADEM
- Aug 31, 2004

 

Legal
This tutorial (this "tutorial") was developed by National Instruments ("NI"). Although technical support of this tutorial may be made available by National Instruments, the content in this tutorial 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 content with each new revision of related products and drivers. THIS TUTORIAL 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/).