Example Code

Parsing a Digital Waveform Editor ASCII file in LabVIEW

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Hardware

  • Modular Instrumentation

    Software

  • LabVIEW

    Driver

  • Other

Code and Documents

Attachment

Overview
    This example explains how to perform this process so you can use this instead of the HWS file.

 

Description

    During this Example, we will discuss how to parse an ASCII file created in the Digital Waveform Editor. This example is extremely important for customers using the 64-bit HSDIO driver in LabVIEW 2009 or 2010 64-bit because HWS files are not supported in these versions of LabVIEW. Please see the Readme for the HSDIO driver for more details.

    When the Digital Waveform Editor creates an ASCII file with this information, the editor formats it so the first line is the name of all the signals (or name of all the DO channels) and the rest is a 2D array of digital boolean values (0s or 1s) that the card will output. After the 2D array of digital values are extracted, we then need to convert it into the format the HSDIO Write can accept. The HSDIO Write can accept a 1D array of integers where this integer represents all the digital values for all the channels that are active. Knowing this, we need to convert each row (the digital signals for all the channels) into 1 integer number to represent all the channels present.

 

Requirements
    Software
        LabVIEW 2012 (or compatible)
        NI-HSDIO driver which is compatible with your hardware and version of LabVIEW
    Hardware
        NI-HSDIO devices


Instructions
    1. Select the ASCII file.
    2. Run the VI.

 

Additional Information or References

 

In this example, we assume that we want to write out to 16 channels

1.) Opens/Reads/Closes the ASCII file for the Digital Waveform editor.
2.) Parses the First line of the data which contains the name of all the signals.
3.) Changes all the data for all the DIO channels to a 2D array of U16 (16 bits for 16 channels).
4.) Changes the string with all the channel names to an array of channel names
5.) In order to convert the channels to an array that will be accept by the HSDIO Write, the two for loops combines each row in the array to 1 integer number and creates an array of those numbers.

 

convertDigWavASCII.png

 

Additional Notes

    When considering to use this example, you will need to think about the number of channels your application needs. The reason for this is that you will need to choose the correct integer representation for the constant array integer. A list below should assist you with this:

  •  Channels between 0-8 choose U8 (8 bit number)
  •  Channels between 9-16 choose U16 (16 bit number)
  •  Channels between 16-32 choose U32 (32 bit number)

Jim St
National Instruments
RF Product Support Engineer

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.