visadev 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
ResourceName
— VISA resource name
string scalar
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 |
|
USB | USB[board]::vendor_ID::product_ID::serial_number[::interface_number]::INSTR |
GPIB | GPIB[board]::primary_address[::secondary_address]::INSTR |
Serial | ASRL[port_number]::INSTR |
VXI | VXI[chassis]::VXI_logical_address::INSTR |
PXI |
|
The resource name parameters are described as follows. Each parameter corresponds to
one of the visadev
properties.
Interface | Parameter | Description |
---|---|---|
All |
| Board index (default value of 0) |
TCP/IP (using VXI-11 or HiSLIP) and TCP/IP Socket |
| Remote host name or IP address of the instrument |
| Local Area Network (LAN) device name (default value of inst0) | |
| Remote host port for TCP/IP socket | |
USB |
| Manufacturer ID of the USB instrument |
| Model code for the USB instrument | |
| Index of the instrument on the USB hub | |
| USB interface | |
GPIB |
| Primary address of the GPIB instrument |
| Secondary address of the GPIB instrument (default value of 0) | |
Serial |
| Serial port number (default value of 1) |
VXI and PXI |
| VXI or PXI chassis index (default value of 0 for VXI) |
| Logical address of the VXI instrument | |
| PCI bus number | |
| PCI device number | |
| PCI function number (default value of 0) | |
| 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
Alias
— VISA alias associated with resource
string scalar
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
Type
— Type of VISA resource
gpib
| pxi
| serial
| socket
| tcpip
| usb
| vxi
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.
Vendor
— Instrument manufacturer
string scalar
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
Model
— Instrument model
string scalar
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
SerialNumber
— Unique serial number associated with instrument
string scalar
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
Tag
— Label for identifying connection
""
(default) | string
Since R2024a
Label for identifying connection, specified as a string. Use Tag
to apply a label to a connection that you can use later to access the connection using
visadevfind
. Doing so can be useful when you open a connection in one
function and use a different function to perform operations on the connection. It is
also useful for locating and accessing connections in app callbacks.
Example: v.Tag = "Scope"
sets the label to
"Scope"
.
Data Types: string
Read and Write Properties
ByteOrder
— Sequential order of bytes
"little-endian"
(default) | "big-endian"
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
Timeout
— Allowed time to complete operations
10 (default) | numeric
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
— Terminator character for data
"LF"
(default) | "CR"
| "CR/LF"
| 0 to 255
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
NumBytesWritten
— Total number of bytes written
0 (default) | numeric
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
ErrorOccurredFcn
— Callback function triggered by error event
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
UserData
— General purpose property for user data
any type
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
LANName
— LAN device name
string scalar
This property is read-only.
LAN device name, returned as a string.
Example: v.LANName
returns the LAN device name.
Data Types: string
InstrumentAddress
— TCP/IP address of instrument
string scalar
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
BoardIndex
— Index number of network board associated with instrument
numeric
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
IPAddress
— TCP/IP address of socket
string scalar
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
Port
— Port number for given TCP/IP address
string scalar
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
VendorID
— Manufacturer ID number of device
string scalar
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
ProductID
— Model code of device
string scalar
This property is read-only.
Model code of device (PID), returned as a string.
Example: v.ProductID
returns the product ID.
Data Types: string
BoardIndex
— USB board number
numeric
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
InterfaceIndex
— USB interface number
numeric
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
BoardIndex
— GPIB board index
numeric
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
PrimaryAddress
— GPIB primary address
numeric
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
SecondaryAddress
— GPIB secondary address
numeric
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
EOIMode
— EOI Mode
"on"
(default) | "off"
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
Port
— Serial communication port
string scalar
This property is read-only.
Serial communication port, returned as a string.
Example: v.Port
returns the serial communication
port.
Data Types: string
BaudRate
— Communication speed
9600 (default) | double
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
DataBits
— Number of bits to represent one character of data
8
(default) | 7
| 6
| 5
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
StopBits
— Pattern of bits that indicates the end of a character
1
(default) | 1.5
| 2
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 DataBits | Supported Values of StopBits |
---|---|
8 , 7 , or 6 | 1 and 2 |
5 | 1 and 1.5 |
Example:
v.StopBits = 2
sets the number of stop bits to 2.
Data Types: double
Parity
— Parity bit type
"none"
(default) | "even"
| "odd"
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 Type | Parity Bit Value | |
---|---|---|
If number of 1s is even | If number of 1s is odd | |
none | No parity bit set | No parity bit set |
even | 0 | 1 |
odd | 1 | 0 |
Example: v.Parity = "even"
sets the parity bit type to
even.
Data Types: char
| string
FlowControl
— Mode for managing data transmission rate
"none"
(default) | "hardware"
| "software"
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
Bus
— PCI bus number
numeric
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
DeviceIndex
— PXI device number
numeric
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
FunctionIndex
— PXI function number
numeric
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
ChassisIndex
— PXI or VXI chassis index number
numeric
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
LogicalAddress
— VXI instrument logical address
numeric
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
Slot
— PXI or VXI instrument slot location
numeric
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
EOIMode
— EOI Mode
"on"
(default) | "off"
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
Version History
Introduced in R2021aR2024a: New Tag
Property
Use the new Tag
property to apply a label to a connection that you
can use later to access the connection using visadevfind
.
R2022a: visadev
interface no longer supports callback functions
Callback functions are no longer supported for the visadev
interface.
The configureCallback
function and the
NumBytesAvailable
, BytesAvailableFcnMode
,
BytesAvailableFcnCount
, and BytesAvailableFcn
properties and are no longer supported for visadev
objects.
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)