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
- Power off the NI Instrument Simulator and configure it to communicate through the GPIB by setting the switches on the side of the box.These switch settings configure the instrument as a GPIB device with an address of 2.
Figure 1 - 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
- Open the
Waveform Example
VI located in theC:\Exercises\LabVIEW Basics I
directory. The front panel shown in Figure 2 is already built.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.Figure 2
1.C) Block Diagram
- Display and examine the block diagram shown in Figure 3.
Figure 3 - The
String Subset
function located on theFunctions>>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. - The
String to Byte Array
function, located on theFunctions>>All Functions>>String>>String/Array/Path Conversion
palette, converts the binary string to an array of unsigned integers. - The
String Length
function, located on theFunctions>>All Functions>>String
palette, returns the number of characters in the waveform string. - The
Extract Numbers
VI, located in theExercises
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
andVISA Read
functions, located on theFunctions>>All Functions>>Instrument I/O>>VISA
palette, query the NI Instrument Simulator for a square wave in either ASCII or 1-byte binary format. - The
Simple Error Handler
VI, located on theFunctions>>All Functions>>Time & Dialog
palette, reports any errors.
- The
- 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.
- Set
Data Format
toASCII
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. - Set
Data Format
toBinary
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. - Close the VI. Do not save changes.
No comments:
Post a Comment