Communicating with a USB Instrument Using VISA
This section contains information that applies to both Windows and Linux.
To establish communications with a USB device using VISA, you can either use the full VISA resource string for the device or use the alias provided by VISA. Using the alias is recommended, for reasons described below.
Using the full VISA resource string, a viOpen call would look something like this:
viOpen( . . ., "USB0::2391::1031::0000000123::0::INSTR", . . . );
Following is a summary of the components of this call.
Value |
Description |
Data Type |
---|---|---|
2391 |
Manufacturer ID |
16-bit unsigned integer |
1031 |
Model Code |
16-bit unsigned integer |
0000000123 |
Serial Number |
string value |
0 |
USBTMC Interface Number |
8-bit unsigned integer |
This string uniquely identifies the USB device. The values needed for the resource string are displayed in a dialog box when the device is plugged into the computer.
To simplify the way a USB device is identified, Keysight VISA also provides an alias which can be used in place of this resource string. The first USB device that is plugged in is assigned a default alias of USBInstrument1. Additional devices are assigned aliases of USBInstrument2, USBInstrument3, etc. You can modify the default alias name by running Keysight Connection Expert and editing the VISA alias.
Although the case of a VISA alias is preserved, case is ignored when the alias is used in place of the full resource string in a viOpen call. For example, UsbInstrument1, usbinstrument1 and USBInstrument1 all refer to the same device.
Using the alias, a viOpen call would look something like this:
viOpen( . . ., "USBInstrument1", . . . );
This is much simpler than having to use the full resource string for a USB device.
Using the alias in a program also makes it more portable. For example, two identical USB function generators have different resource strings because they have different serial numbers. If these function generators are used in two different test systems and you use the full resource string to access the function generator in the test program, you cannot use that same program for both test systems, since the function generators’ full resource strings are different. By using the alias in the program, however, you can use the same program in both test systems. All you need to do is make sure the same alias is used for the function generator in both systems.