Remote Programming 57
Assigning the GPIB Address In Programs
The Agilent SAS address cannot be set remotely; it must be set from the front panel. Once the address is set, you can assign
it inside programs. Refer to chapter 5 under “Setting the GPIB Address” for more information. The following example
assumes that the GPIB select code is 7, the primary address is 6, and that the Agilent SAS address will be assigned to the
variable @PS.
1000 !Stand-alone address. The unit will respond if it is set to 6
1010 PS=706 ! Statement for Agilent 82335A Interface
1010 ASSIGN @PS TO 706 ! Statement for Agilent BASIC Interface
1020 !Direct address. The unit will respond if it is set to 6. or 6.0
1030 PS-70600 ! Statement for Agilent 82335A Interface
1030 ASSIGN @PS TO 70600 ! Statement for Agilent BASIC Interface
1040 !Linked address 1. The unit responds if it is set to address .1 and is serially connected to a unit at direct address 6.0
1050 PS=706.01 ! Agilent 82335A Interface
1090 ASSIGN @PS TO 706.01 ! Agilent BASIC Interface
For systems using the National Instruments DOS driver, the address is specified in the software configuration program
(IBCONFIG.EXE) and assigned a symbolic name. The address then is referenced only by this name within the application
program (see the National Instruments GP-IB documentation).
Agilent
82335A Driver Considerations
For GW-BASIC programming, the GPIB library is implemented as a series of subroutine calls. To access these subroutines,
your application program must include the header file SETUP.BAS, which is part of the DOS driver software.
SETUP.BAS starts at program line 5 and can run up to line 999. Your application programs must begin at line 1000.
SETUP.BAS has built-in error checking routines that provide a method to check for GPIB errors during program execution.
You can use the error-trapping code in these routines or write your own code using the same variables as used by
SETUP.BAS. If there is no error-handling code in your program, undetected errors can cause unpredictable results.
National Instruments GP-IB Driver Considerations
Your program must include the National Instruments header file DECL.BAS. This contains the initialization code for the
interface. Prior to running any applications programs, you must set up the interface with the configuration program
(IBCONF.EXE).
Your application program will not include the unit’s symbolic name and GPIB address. These must be specified during
configuration (when you run IBCONF.EXE). Note that the primary address range is from 0 to 30 but any secondary address
must be specified in the address range of 96 to 126. The Agilent SAS expects a message termination on EOI or line feed, so
set EOI w/last byte of Write. It is also recommended that you set Disable Auto Serial Polling.
All function calls return the status word IBSTA%, which contains a bit (ERR) that is set if the call results in an error. When
ERR is set, an appropriate code is placed in variable IBERR%. Be sure to check IBSTA% after every function call. If it is
not equal to zero, branch to an error handler that reads IBERR% to extract the specific error. If there is no error-handling
code in your program, undetected errors can cause unpredictable results.
BASIC Considerations
The Agilent BASIC Programming Language provides access to GPIB functions at the operating system level. This makes it
unnecessary to have the header files required in front of DOS applications programs. Also, you do not have to be concerned
about controller "hangups" as long as your program includes a timeout statement. Because the Agilent SAS can be
programmed to generate SRQ on errors, your program can use an SRQ service routine for decoding detected errors. The
detectable errors are listed in appendix D.