Chapter 6 Application Programs
Using the Status Registers
137
6
Using the Status Registers
This program teaches the following concepts:
• How to use the Status Registers to generate an interrupt if a SCPI error occurs. The
program sets up the Status Byte and Standard Event register and interrupts the
controller if an error is detected.
• How to service the interrupt if an error occurs and read the power supply's error
queue using the SYST:ERR? command.
Agilent BASIC / GPIB (Program 3)
10 !
20 ! This program uses the status registers to generate an
30 ! interrupt if a SCPI error occurs. The power supply
40 ! is programmed to output a 3V/0.5A for +6V output,
50 ! 10V/0.8A for +25V output, and -15V/0.2A for -25V output.
60 !
70 ASSIGN @Psup TO 705 ! Assign I/O path to address 705
80 COM @Psup ! Use same address in subprogram
90 INTEGER Gpib,Mask,Value,B ! Declare integer variables
100 CLEAR 7 ! Clear interface
110 OUTPUT @Psup;"*RST" ! Reset power supply
120 !
130 ! Set up error checking
140 !
150 Gpib=7 ! GPIB select code is "7"
160 ON INTR Gpib CALL Err_msg ! Call subprogram if error occurs
170 Mask=2 ! Bit 1 is SRQ
180 ENABLE INTR Gpib;Mask ! Enable SRQ to interrupt program
190 !
200 OUTPUT @Psup;"*SRE 32" ! Enable "Standard Event" bit in Status Byte
210 ! to pull the IEEE-488 SRQ line
220 OUTPUT @Psup;"*ESE 60" ! Enable error bits (2, 3, 4, or 5) to set
230 ! "Standard Event" bit in Status Byte
240 ! and wait for operation complete
250 OUTPUT @Psup;"*CLS" ! Clear status registers