Saturday, September 25, 2010

Waveform Example VI

Summary: In this exercise, the objective is to graph a waveform that an instrument such as a digital oscilloscope returns as an ASCII or binary string.

EXERCISE 1

For the ASCII waveform string, the waveform consists of 128 points. Up to four ASCII characters separated by commas represent each point. The following header precedes the data points:

     CURVE {12,28,63,...128 points in total...,}CR LF
   
For the binary waveform string, the waveform consists of 128 points. Each point is represented as a 1-byte unsigned integer. The following header precedes the data points:

     CURVE % {Bin Count MSB}{Bin Count LSB}{åå¤Å...128 bytes in total...} {Checksum} CR LF
   
Complete the following steps to examine a VI that converts the waveform to an array of numbers. The VI graphs the array and reads the waveform string from the NI Instrument Simulator or from a previously stored array.

1.A) NI Instrument Simulator

  1. Power off the NI Instrument Simulator and configure it to communicate through the GPIB by setting the switches on the side of the box.
    Figure 1
    Figure 1 (simgpib.png)
    These switch settings configure the instrument as a GPIB device with an address of 2.
  2. Power on the NI Instrument Simulator. Only the Power and Ready LEDs are lit to indicate that the NI Instrument Simulator is in GPIB communication mode.

1.B) Front Panel

  1. Open the Waveform Example VI located in the C:\Exercises\LabVIEW Basics I directory. The front panel shown in Figure 2 is already built.
    Figure 2
    Figure 2 (waveex.png)
    Data Format specifies an ASCII waveform or a binary waveform. Data Source specifies whether the data is simulated or read from the NI Instrument Simulator through the GPIB.

1.C) Block Diagram

  1. Display and examine the block diagram shown in Figure 3.
    Figure 3
    Figure 3 (waveexbd.png)
    • strsubseticon.png The String Subset function located on the Functions>>All Functions>>String palette returns a substring of 128 elements starting from the fifth byte of the binary waveform string, excluding the header and trailer bytes.
    • strtobyteicon.png The String to Byte Array function, located on the Functions>>All Functions>>String>>String/Array/Path Conversion palette, converts the binary string to an array of unsigned integers.
    • strglengthicon.png The String Length function, located on the Functions>>All Functions>>String palette, returns the number of characters in the waveform string.
    • extrctnumdblicon.png The Extract Numbers VI, located in the Exercises directory, extracts numbers from the ASCII waveform string and places them in an array. Non-numeric characters, such as commas, separate numbers in the string.
    • The VISA Write and VISA Read functions, located on the Functions>>All Functions>>Instrument I/O>>VISA palette, query the NI Instrument Simulator for a square wave in either ASCII or 1-byte binary format.
    • Error.png The Simple Error Handler VI, located on the Functions>>All Functions>>Time & Dialog palette, reports any errors.
  2. Display the front panel and run the VI. The True case acquires and converts the binary waveform string to an array of numeric values. The False case acquires and converts the ASCII waveform string to an array of numeric values.
  3. Set Data Format to ASCII and run the VI. The ASCII waveform string displays, the VI converts the values to a numeric array, and displays the string length and numeric array.
  4. Set Data Format to Binary and run the VI again. The binary waveform string and string length display, the VI converts the string to a numeric array, and displays it in the graph.

    NOTE: 

    The binary waveform is similar to the ASCII waveform. However, the number of bytes in the string is significantly lower. It is more efficient to transfer waveforms as binary strings than as ASCII strings because binary encoding requires fewer bytes to transfer the same information.
  5. Close the VI. Do not save changes.

Content actions

GIVE FEEDBACK:

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...

Popular Projects

My Blog List

Give support

Give support
Encourage Me through Comments & Followers

Followers