NI Instrument Simulator
- Power off the NI Instrument Simulator and configure it to communicate through the serial port by setting the following switches on the side of the box.These switch settings configure the instrument as a serial device with the following settings:
Figure 1 Handshaking is a means of data flow control. Software handshaking involves embedding control characters in transmitted data. For example, XON/XOFF flow control works by enclosing a transmitted message between the two control characters XON and XOFF. Hardware handshaking uses voltages on physical wires to control data flow. The RTS and CTS lines of the RS-232 device are frequently used for this purpose. Most lab equipment uses hardware handshaking.- Baud rate=9,600
- Data bits=8
- Parity=no parity
- Stop bits=1
- Flow control parameters=hardware handshaking
- Make sure the NI Instrument Simulator is connected to a serial port on the computer with a serial cable. Make a note of the port number.
- Power on the NI Instrument Simulator. The Power, Ready, and Listen LEDs are lit to indicate that the device is in serial communication mode.
Block Diagram
- Open a blank VI and build the block diagram shown in Figure 2.
Figure 2 Place the
Instrument I/OExpress VI, located on theFunctions>>Inputpalette, on the block diagram. Complete the following steps in theInstrument I/O Assistantdialog box that appears to configure the Express VI.- Choose
COM1(orCOM2depending on the connection port of the NI Instrument Simulator) from theSelect an instrumentpull-down menu. - Click the
Add Stepbutton and clickWrite. In the command field, type*IDN?and select\nas theTermination character. - Click the
Add Stepbutton and clickRead and Parse. - Click the
Add Stepbutton and clickRead and Parseagain.NOTE:
The Instrument Simulator returns the byte size of the response, the termination character, the response, then another termination character. Therefore, after*IDN?is sent to the instrument, the response must be read twice. - Click the
Run button(not theRun this stepbutton). TheRunbutton runs the entire sequence. - Return to the first
Read and Parsestep. - Click the
Auto parsebutton. The value returned is the size in bytes of the query response. - Rename
TokentoString Lengthin theToken nametext box. - Select the second
Read and Parsestep. - Click the
Auto parsebutton. The value returned is the identification string of the NI Instrument Simulator. - Rename
TokentoStringin theTokenname text box. The configuration window should be similar to the Figure 3.Figure 3 - Select
OKto return to the block diagram.
- Choose
- Right-click the
Stringoutput and selectCreate>>Indicatorfrom the shortcut menu. - Right-click the
String Lengthoutput and selectCreate>>Indicatorfrom the shortcut menu.TIP:
Since LabVIEW is set to handle errors automatically, there is no need to connect aSimple Error HandlerVI to error out.
- Display the front panel and run the VI.
- Save the VI as
Serial Communication.viin theC:\Exercises\LabVIEW Basics Idirectory. - Close the VI when finished.
No comments:
Post a Comment