Programmatically Change Address of GPIB Device

Updated Jan 20, 2022

Environment

Hardware

  • GPIB-RS232

Software

  • Measurement & Automation Explorer (MAX)

Driver

  • NI-488.2
  • NI-VISA

Operating System

  • Windows

This article explains how to change primary address of a GPIB-RS232 device programmatically.


If your device is used in the S mode converter, you have a set of S mode functions that are available and lets you change the primary address. The function that should be used in this case is caddr [addr]<CR>.

addr is the argument that specifies the new GPIB address for the GPIB-RS232. The argument consists of a primary address and an optional secondary address. The secondary address is separated from the primary address by a plus sign (+). Both addresses are expressed as numeric strings.

If you specify a primary address without a secondary address, secondary addressing is disabled.
If you call caddr without an argument, the GPIB-RS232/485/422 returns its current GPIB address.

This is an example on how to call the function:
char  buffer [] = "caddr 0+22\r";
viWrite(instr, buffer, strlen(buffer), &retCount);


Additional Information

The address can also be changed using NI MAX as shown in the article Changing a GPIB Interface in NI MAX.