The Basic Serial Read and Write example performs a Serial Port Read, a Serial Port Write, or a combination of these actions. The user selects the actions (read or write) on the front panel. If both are selected, the VI will write the data first, read data, and then close the VISA session that is opened to the port. This VI will wait until the specified number of bytes is received at the port. Only the number of bytes specified will be read.


1) Select the serial resource and configuration parameters (baud rate, data bits, parity, stop bits, flow control).

2) Select the operations to be performed.

3) Connect the serial port to your device. If no device is available, perform a loopback test by doing one of the following. Short pins 2 and 3 on a RS-232 cable or short pin 4 to pin 8 and pin 5 to pin 9 on a RS-485/422 cable.

4) Run the VI to see the data read. (The "read string" will match the "string to write" if a loopback test was performed.)

Note: The parameters set for the serial port must match the parameters of the connected instrument or device. In this example, the bytes to read parameter specifies the number of bytes that the serial port reads. If there were more bytes at the port than the number specified in bytes to read, those bytes would not be read. Also, if you specify to read more bytes than the number of bytes actually read, you might receive a timeout error message.

On the block diagram, the Configure Serial Port VI sets the configuration parameters. The front panel displays the controls used to configure the basic parameters, such as baud rate, data bits, and parity. Constants configure the other parameters the user probably does not need set. After the VISA Configure Serial Port VI opens the VISA session and configures the port, the VI passes the VISA resource name to other VIs that perform operations on that VISA resource. The VISA Write function sends a command to the serial device and the VISA Read function returns data based on the command. The VISA Close function then closes the reference to the serial device. It is important to close the reference; otherwise communication through with that port through protocols other than VISA might not be possible.




Liste des sous-VIs et VIs Express

Simple Error

Simple Error

C:\Program Files\National Instruments\LabVIEW 8.5\vi.lib\Utility\error.llb\Simple Error

VISA Configure Serial Port (Serial Instr).vi

VISA Configure Serial Port (Serial Instr).vi

C:\LABVIEW\VISA Configure Serial Port (Serial Instr).vi

VISA Configure Serial Port

VISA Configure Serial Port

C:\Program Files\National Instruments\LabVIEW 8.5\vi.lib\Instr\_visa.llb\VISA Configure Serial Port

Position dans la hiérarchie