Main Content

visadev Properties

Access VISA resource properties

Configure your VISA resource and its communication settings using its properties. After you create a visadev object, you can use dot notation to read and set properties.

Object Creation Properties

expand all

VISA resource name, returned as a string scalar. Identify the resource name of the device you want to connect to using the information returned by visadevlist. This property can be set only at object creation.

Each type of VISA interface has a different format, described in the following table. The VISA resource name format and its parameters are defined by the VISA standard specifications. Replace the italicized text with values for the specified parameters. The parameters in brackets are optional.

Interface

Resource Name

TCP/IP (using VXI-11 or HiSLIP)TCPIP[board]::remote_host[::lan_device_name]::INSTR
TCP/IP Socket

TCPIP[board]::remote_host::port::SOCKET

USBUSB[board]::vendor_ID::product_ID::serial_number[::interface_number]::INSTR
GPIBGPIB[board]::primary_address[::secondary_address]::INSTR
SerialASRL[port_number]::INSTR
VXIVXI[chassis]::VXI_logical_address::INSTR
PXI

PXI[bus]::device[::function][::INSTR]

PXI[bus]::CHASSISchassis::SLOTslot[::FUNCfunction][::INSTR]

The resource name parameters are described as follows. Each parameter corresponds to one of the visadev properties.

Interface

Parameter

Description

All

board

Board index (default value of 0)

TCP/IP (using VXI-11 or HiSLIP) and TCP/IP Socket

remote_host

Remote host name or IP address of the instrument

lan_device_name

Local Area Network (LAN) device name (default value of inst0)

port

Remote host port for TCP/IP socket
USB

vendor_ID

Manufacturer ID of the USB instrument

product_ID

Model code for the USB instrument

serial_number

Index of the instrument on the USB hub

interface_number

USB interface

GPIB

primary_address

Primary address of the GPIB instrument

secondary_address

Secondary address of the GPIB instrument (default value of 0)

Serial

port_number

Serial port number (default value of 1)

VXI and PXI

chassis

VXI or PXI chassis index (default value of 0 for VXI)

VXI_logical_address

Logical address of the VXI instrument

bus

PCI bus number

device

PCI device number

function

PCI function number (default value of 0)

slot

Slot number

Example: gpibdev = visadev("GPIB0::5::INSTR") connects to the GPIB device specified by the VISA resource name GPIB0::5::INSTR.

Data Types: char | string

VISA alias associated with resource, returned as a string scalar. Identify the alias of the device you want to connect to using the information returned by visadevlist. The alias is defined in your VISA vendor's configuration utility software. This property can be set only at object creation.

Example: serialdev = visadev("COM4") connects to the serial device specified by the VISA resource alias COM4.

Data Types: char | string

This property is read-only.

Type of VISA resource, returned as one of the supported VISA interfaces. Some properties and object functions are specific to an interface type.

Example: v.Type returns the type of VISA resource.

This property is read-only.

Instrument manufacturer, returned as a character vector or string scalar. This property is empty if the VISA interface type does not provide information about the manufacturer.

Example: v.Vendor returns the name of the instrument manufacturer.

Data Types: string

This property is read-only.

Instrument model, returned as a character vector or string scalar. This property is empty if the VISA interface type does not provide information about the model.

Example: v.Model returns the name of the instrument model.

Data Types: string

This property is read-only.

Unique serial number associated with instrument, returned as a character vector or string scalar. This property is empty if the VISA interface type does not provide information about the serial number.

Example: v.SerialNumber returns the instrument serial number.

Data Types: string

Read and Write Properties

expand all

Sequential order in which bytes are arranged into larger numerical values, returned as "little-endian" or "big-endian".

Example: v.ByteOrder = "big-endian" sets the byte order to big-endian.

Data Types: char | string

Allowed time in seconds to complete read and write operations, returned as a numeric value.

Example: v.Timeout = 20 sets the timeout period to 20 seconds.

Data Types: double

Terminator character for reading and writing ASCII-terminated data, returned as "LF", "CR", "CR/LF", or a number from 0 to 255, inclusive. If the read and write terminators are different, Terminator is returned as a 1x2 cell array of these values. Set this property with the configureTerminator function.

Example: configureTerminator(v,"CR") sets both the read and write terminators to "CR".

Example: configureTerminator(v,"CR",10) sets the read terminator to "CR" and the write terminator to 10.

Data Types: double | char | string

This property is read-only.

Number of bytes available to read, returned as a numeric value.

Example: v.NumBytesAvailable returns the number of bytes available to read.

Data Types: double

This property is read-only.

Total number of bytes written, returned as a numeric value.

Example: v.NumBytesWritten returns the number of bytes written.

Data Types: double

Callback Properties

expand all

Bytes available callback trigger mode, returned as "off", "byte", or "terminator". This setting determines if the callback is off, triggered by the number of bytes specified by BytesAvailableFcnCount, or triggered by the terminator specified by Terminator. Set this property with the configureCallback function.

Example: configureCallback(v,"byte",50,@callbackFcn) sets the callbackFcn callback to trigger each time 50 bytes of new data are available to be read.

Example: configureCallback(v,"terminator",@callbackFcn) sets the callbackFcn callback to trigger when a terminator is available to be read.

Example: configureCallback(v,"off") turns off callbacks.

Data Types: char | string

Number of bytes of data to trigger the callback specified by BytesAvailableFcn, returned as a double. This value is used only when the BytesAvailableFcnMode property is "byte". Set these properties with the configureCallback function.

Example: configureCallback(v,"byte",50,@callbackFcn) sets the callbackFcn callback to trigger each time 50 bytes of new data are available to be read.

Data Types: double

Callback function triggered by a bytes available event, returned as a function handle. A bytes available event is generated by receiving a certain number of bytes or a terminator. This property is empty until you assign a function handle. Set this property with the configureCallback function.

Example: configureCallback(v,"byte",50,@callbackFcn) sets the callbackFcn callback to trigger each time 50 bytes of new data are available to be read.

Data Types: function_handle

Callback function triggered by an error event, returned as a function handle. An error event is generated when the connection to your VISA resource is interrupted or when an asynchronous read error occurs. This property is empty until you assign a function handle.

Example: v.ErrorOccurredFcn = @myErrorFcn

Data Types: function_handle

General purpose property for user data, returned as any MATLAB® data type. For example, you can use this property to store data when an event is triggered from a callback function.

Example: v.UserData

VISA-TCP/IP

expand all

This property is read-only.

LAN device name, returned as a string.

Example: v.LANName returns the LAN device name.

Data Types: string

This property is read-only.

TCP/IP address of instrument in dot-decimal notation, returned as a string.

Example: v.InstrumentAddress returns the IP address of the instrument.

Data Types: string

This property is read-only.

Index number of network board associated with instrument, returned as a positive integer value.

Example: v.BoardIndex returns the network board index number.

Data Types: double

VISA-Socket

expand all

This property is read-only.

TCP/IP address of socket in dot-decimal notation, returned as a string.

Example: v.IPAddress returns the IP address of the socket.

Data Types: string

This property is read-only.

Port number for given TCP/IP address, returned as a string.

Example: v.Port returns the port number associated with the TCP/IP address.

Data Types: string

VISA-USB Properties

expand all

This property is read-only.

Manufacturer ID number of device (VID), returned as a string.

Example: v.VendorID returns the vendor ID.

Data Types: string

This property is read-only.

Model code of device (PID), returned as a string.

Example: v.ProductID returns the product ID.

Data Types: string

This property is read-only.

USB board number, returned as a positive integer value.

Example: v.BoardIndex returns the USB board number.

Data Types: double

This property is read-only.

USB interface number, returned as a positive integer value.

Example: v.InterfaceIndex returns the USB interface number.

Data Types: double

VISA-GPIB Properties

expand all

This property is read-only.

GPIB board index, returned as a positive integer value.

Example: v.BoardIndex returns the GPIB board index.

Data Types: double

This property is read-only.

GPIB primary address associated with instrument, returned as an integer from 0 to 30, inclusive.

Example: v.PrimaryAddress returns the GPIB primary address.

Data Types: double

This property is read-only.

GPIB secondary address associated with instrument, returned as an integer from 0 to 30, inclusive.

Example: v.SecondaryAddress returns the GPIB secondary address.

Data Types: double

EOI mode, returned as on or off. This property specifies whether the EOI (end or identify) line is asserted at the end of a write operation.

Example: v.EOIMode = "off" does not assert an EOI line at the end of a write.

Data Types: char | string

VISA-Serial

expand all

This property is read-only.

Serial communication port, returned as a string.

Example: v.Port returns the serial communication port.

Data Types: string

Speed of serial communication in bits per second, returned as a positive integer.

Example: v.BaudRate = 14400 sets the baud rate to 14400.

Data Types: double

Number of bits to represent one character of data, returned as 8, 7, 6, or 5.

Example: v.DataBits = 5 sets the number of data bits to 5 bits.

Data Types: double

Pattern of bits that indicates the end of a character or of the whole transmission, returned as 1, 1.5, or 2. This property depends on the value of the DataBits property as follows.

Value of DataBitsSupported Values of StopBits
8, 7, or 61 and 2
51 and 1.5

Example: v.StopBits = 2 sets the number of stop bits to 2.

Data Types: double

Parity bit type added to data transmitted by serial port, returned as "none", "even", or "odd". You can use this property to add a parity bit (also referred to as a check bit) to your data. Adding a parity bit to a string of binary code is a method of detecting errors in data transmission by ensuring that the total number of 1-bits is even or odd.

The value of the parity bit is determined by the number of 1s in a given set of bits and is set as follows.

Parity Bit TypeParity Bit Value
If number of 1s is evenIf number of 1s is odd
noneNo parity bit setNo parity bit set
even01
odd10

Example: v.Parity = "even" sets the parity bit type to even.

Data Types: char | string

Mode for managing data transmission rate, returned as "none", "hardware", or "software". Specify "none" to have no flow control, "hardware" to let your hardware determine the flow control, and "software" to let your software determine the flow control.

Example: v.FlowControl = "hardware" sets the flow control to hardware.

Data Types: char | string

VISA-VXI and VISA-PXI Properties

expand all

This property is read-only.

PCI bus number for device, returned as a positive number. This property is only for VISA-PXI interface objects.

Example: v.Bus returns the device's PCI bus number.

Data Types: double

This property is read-only.

PXI device number, returned as a positive number. This property is only for VISA-PXI interface objects.

Example: v.DeviceIndex returns the PXI device number.

Data Types: double

This property is read-only.

PXI function number, returned as a positive number. This property is only for VISA-PXI interface objects.

Example: v.FunctionIndex returns the PXI function number.

Data Types: double

This property is read-only.

PXI or VXI chassis index number, returned as a positive number.

Example: v.ChassisIndex returns the PXI or VXI chassis index number.

Data Types: double

This property is read-only.

VXI instrument logical address, returned as a positive number. This property is only for VISA-VXI interface objects.

Example: v.LogicalAddress returns the VXI instrument logical address.

Data Types: double

This property is read-only.

PXI or VXI instrument slot location, returned as a positive number.

Example: v.Slot returns the PXI or VXI instrument slot location.

Data Types: double

EOI mode, returned as on or off. This property specifies whether the EOI (end or identify) line is asserted at the end of a write operation.

Example: v.EOIMode = "off" does not assert an EOI line at the end of a write.

Data Types: char | string

Introduced in R2021a