Programmatically Change Address of GPIB Device

Updated Aug 19, 2019

Reported In

Hardware

  • GPIB-RS232

Software

  • Measurement & Automation Explorer (MAX)

Driver

  • NI-488.2
  • NI-VISA

Operating System

  • Windows

Issue Details

I have a GPIB-RS232 device and I have trouble changing the primary address programmatically. How can I proceed?

Solution

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 is the article Changing a GPIB Interface in NI MAX.