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/O
Express VI, located on theFunctions>>Input
palette, on the block diagram. Complete the following steps in theInstrument I/O Assistant
dialog box that appears to configure the Express VI.- Choose
COM1
(orCOM2
depending on the connection port of the NI Instrument Simulator) from theSelect an instrument
pull-down menu. - Click the
Add Step
button and clickWrite
. In the command field, type*IDN?
and select\n
as theTermination character
. - Click the
Add Step
button and clickRead and Parse
. - Click the
Add Step
button and clickRead and Parse
again.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 step
button). TheRun
button runs the entire sequence. - Return to the first
Read and Parse
step. - Click the
Auto parse
button. The value returned is the size in bytes of the query response. - Rename
Token
toString Length
in theToken name
text box. - Select the second
Read and Parse
step. - Click the
Auto parse
button. The value returned is the identification string of the NI Instrument Simulator. - Rename
Token
toString
in theToken
name text box. The configuration window should be similar to the Figure 3.Figure 3 - Select
OK
to return to the block diagram.
- Choose
- Right-click the
String
output and selectCreate>>Indicator
from the shortcut menu. - Right-click the
String Length
output and selectCreate>>Indicator
from the shortcut menu.TIP:
Since LabVIEW is set to handle errors automatically, there is no need to connect aSimple Error Handler
VI to error out.
- Place the
- Display the front panel and run the VI.
- Save the VI as
Serial Communication.vi
in theC:\Exercises\LabVIEW Basics I
directory. - Close the VI when finished.
No comments:
Post a Comment