Instrument Control Toolbox | ![]() ![]() |
The Serial Port Interface
The serial port interface is supported through a VISA-serial object. The features associated with a VISA-serial object are similar to the features associated with a serial port object. Therefore, only functions and properties that are unique to VISA's serial port interface are discussed in this section. These unique features are associated with
Refer to Controlling Serial Port Instruments, to learn about writing and reading text and binary data, using events and callbacks, using serial port control lines, and so on.
Note
The VISA-serial object does not support the serialbreak function, the BreakInterruptFcn property, and the PinStatusFcn property.
|
Creating a VISA-Serial Object
You create a VISA-serial object with the visa
function. Each VISA-serial object is associated with an instrument connected to a serial port on your computer.
visa
requires the vendor name and the resource name as input arguments. The vendor name can be agilent
, ni
, or tek
. The resource name consists of the name of the serial port connected to your instrument. You can find the VISA-serial resource name for a given instrument with the configuration tool provided by your vendor, or with the instrhwinfo
function. As described in Configuring Properties During Object Creation, you can also configure property values during object creation.
For example, to create a VISA-serial object that is associated with the COM1 port, and that uses National Instruments VISA:
The VISA-serial object vs
now exists in the MATLAB workspace. You can display the class of vs
with the whos
command.
After you create the VISA-serial object, the properties listed below are automatically assigned values. These properties provide descriptive information about the object based on its class type and address information.
Property Name |
Description |
Name |
Specify a descriptive name for the VISA-serial object. |
Port |
Indicate the serial port name. |
RsrcName |
Indicate the resource name for a VISA instrument. |
Type |
Indicate the object type. |
You can display the values of these properties for vs
with the get
function.
get(vs,{'Name','Port','RsrcName','Type'}) ans = 'VISA-Serial-ASRL1' 'ASRL1' 'ASRL1::INSTR' 'visa-serial'
The VISA-Serial Object Display
The VISA-serial object provides you with a convenient display that summarizes important address and state information. You can invoke the display summary these three ways:
The display summary for the VISA-serial object vs
is given below.
VISA-Serial Object Using NI Adaptor : VISA-Serial-ASRL1 Communication Settings Port: ASRL1 BaudRate: 9600 Terminator: 'LF' Communication State Status: closed RecordStatus: off Read/Write State TransferStatus: idle BytesAvailable: 0 ValuesReceived: 0 ValuesSent: 0
![]() | The VISA-GPIB-VXI Address | Configuring Communication Settings | ![]() |