visa

Create VISA object

Syntax

obj = visa('vendor','rsrcname')

Arguments

'vendor'

A supported VISA vendor.

'rsrcname'

The resource name of the VISA instrument.

'PropertyName'

A VISA property name.

PropertyValue

A property value supported by PropertyName.

obj

The VISA object.

Description

obj = visa('vendor','rsrcname') creates the VISA object obj with a resource name given by rsrcname for the vendor specified by vendor.

You must first configure your VISA resources in the vendor's tool first, and then you create these VISA objects. Use instrhwinfo to find the commands to configure the objects:

vinfo = instrhwinfo('visa','agilent');
vinfo.ObjectConstructorName

If an invalid vendor or resource name is specified, an error is returned and the VISA object is not created. For a list of supported vales for vendor see Supported Vendor and Resource Names.

Examples

Create a VISA-serial object connected to serial port COM1 using National Instruments® VISA interface.

vs = visa('ni','ASRL1::INSTR');

Create a VISA-GPIB object connected to board 0 with primary address 1 and secondary address 30 using Agilent Technologies® VISA interface.

vg = visa('agilent','GPIB0::1::30::INSTR');

Create a VISA-VXI object connected to a VXI instrument located at logical address 8 in the first VXI chassis.

vv = visa('agilent','VXI0::8::INSTR');

Create a VISA-GPIB-VXI object connected to a GPIB-VXI instrument located at logical address 72 in the second VXI chassis.

vgv = visa('agilent','GPIB-VXI1::72::INSTR');

Create a VISA-RSIB object connected to an instrument configured with IP address 192.168.1.33.

vr = visa('ni', 'RSIB::192.168.1.33::INSTR')

Create a VISA-TCPIP object connected to an instrument configured with IP address 216.148.60.170.

vt = visa('tek', 'TCPIP::216.148.60.170::INSTR')

Create a VISA-USB object connected to a USB instrument with manufacturer ID 0x1234, model code 125, and serial number A22-5.

vu = visa('agilent', 'USB::0x1234::125::A22-5::INSTR')

More About

expand all

Tips

At any time, you can use the instrhelp function to view a complete listing of properties and functions associated with VISA objects.

instrhelp visa

You can specify the property names and property values using any format supported by the set function. For example, you can use property name/property value cell array pairs. Additionally, you can specify property names without regard to case, and you can make use of property name completion. For example, the following commands are all valid.

v = visa('ni','GPIB0::1::INSTR','SecondaryAddress', 96);
v = visa('ni','GPIB0::1::INSTR','secondaryaddress', 96);
v = visa('ni','GPIB0::1::INSTR','SECOND', 96);

Before you can communicate with the instrument, it must be connected to obj with the fopen function. A connected VISA object has a Status property value of open. An error is returned if you attempt a read or write operation while obj is not connected to the instrument. You cannot connect multiple VISA objects to the same instrument.

Creating a VISA-GPIB Object

When you create a VISA-GPIB object, these properties are automatically configured:

  • Type is given by visa-gpib.

  • Name is given by concatenating VISA-GPIB with the board index, the primary address, and the secondary address.

  • BoardIndex, PrimaryAddress, SecondaryAddress, and RsrcName are given by the values specified during object creation.

Creating a VISA-GPIB-VXI Object

When you create a VISA-GPIB-VXI object, these properties are automatically configured:

  • Type is given by visa-gpib-vxi.

  • Name is given by concatenating VISA-GPIB-VXI with the chassis index and the logical address specified in the visa function.

  • ChassisIndex, LogicalAddress, and RsrcName are given by the values specified during object creation.

  • BoardIndex, PrimaryAddress, and SecondaryAddress are given by the visa driver after the object is connected to the instrument with fopen.

Creating a VISA-RSIB Object

When you create a VISA-RSIB object, these properties are automatically configured:

  • Type is given by visa-rsib.

  • Name is given by concatenating VISA-RSIB with the remote host specified in the visa function.

  • RemoteHost and RsrcName are given by the values specified during object creation.

Creating a VISA-Serial Object

When you create a VISA-serial object, these properties are automatically configured:

  • Type is given by visa-serial.

  • Name is given by concatenating VISA-Serial with the port specified in the visa function.

  • Port and RsrcName are given by the values specified during object creation.

Creating a VISA-TCPIP Object

When you create a VISA-TCPIP object, these properties are automatically configured:

  • Type is given by visa-tcpip.

  • Name is given by concatenating VISA-TCPIP with the board index, remote host, and LAN device name specified in the visa function.

  • BoardIndex, RemoteHost, LANNAme, and RsrcName are given by the values specified during object creation.

Creating a VISA-USB Object

When you create a VISA-USB object, these properties are automatically configured:

  • Type is given by visa-usb.

  • Name is given by concatenating VISA-USB with the board index, manufacturer ID, model code, serial number, and interface number specified in the visa function.

  • BoardIndex, ManufacturerID, ModelCode, SerialNumber, InterfaceIndex, and RsrcName are given by the values specified during object creation.

Creating a VISA-VXI Object

When you create a VISA-VXI object, these properties are automatically configured:

  • Type is given by visa-vxi.

  • Name is given by concatenating VISA-VXI with the chassis index and the logical address specified in the visa function.

  • ChassisIndex, LogicalAddress, and RsrcName are given by the values specified during object creation.

Was this topic helpful?