Introduction to Programming GPIB Devices in VISA

NI-VISA

Introduction to Programming GPIB Devices in VISA

For novice GPIB users, the VISA API presents a simple interface for device communication. Most GPIB devices allow you to set a primary address via either a DIP switch or via front panel selectors. This primary address is the same one used in the VISA resource string to viOpen(). The simplest and most common GPIB resource string is "GPIB::<primary address>::INSTR". Recall that the "INSTR" resource class informs VISA that you are doing instrument (device) communication. Most GPIB programs perform simple message-based transfers (write command, read response). For more information about VISA message-based functionality, see Message-Based Communication.

There are several VISA attributes specific to the GPIB INSTR resource. The VI_ATTR_GPIB_PRIMARY_ADDR and VI_ATTR_GPIB_SECONDARY_ADDR attributes are read-only, and these return the same values that were used in the resource string passed to viOpen(). If the specified device does not have a secondary address, that attribute query will succeed and return a value of –1. The attribute VI_ATTR_GPIB_READDR_EN controls whether each message to or from the same device will cause the driver to readdress the device. This attribute is true (enabled) by default, and disabling this attribute (setting it to false) may provide a slight performance increase by removing unnecessary bus-level readdressing to the same device. The attribute VI_ATTR_GPIB_UNADDR_EN controls whether the driver will follow each message to or from the specified device with untalk (UNT) and unlisten (UNL) commands. This attribute is false (disabled) by default, which is the most optimal setting. Changing the values of these attributes may be necessary for certain older non-IEEE 488.2-compliant devices.

More complex GPIB systems often include multiple GPIB controllers (or boards) and devices with both primary and secondary addresses. The canonical form of a complex GPIB instrument resource string is "GPIB<controller>::<primary address>::<secondary address>::INSTR". The controller number is the same as used in the GPIB configuration utility (MAX on Windows, the GPIB Control Panel applet on Macintosh, or ibconf on UNIX). If not specified, the controller number defaults to 0.