Specifications

204 Chapter 11
Error Handling
Example Program for Error Handling
Example Program for Error Handling
Using HTBasic
Example 11-1 shows a program that uses SRQ to detect an error. This program is saved as
error.htb on the sample programs disk.
After setting SRQ, this program intentionally generates an error by issuing an invalid
command not provided by the E4991A and performs error handling. In the error handling,
it reads the error queue to investigate and display an error number and an error message as
well as outputs a message to the effect that the program will be aborted.
Line 40 Sets the GPIB address of the E4991A attached to the GPIB interface
card with the select code of 7.
Lines 60 - 70 Enables the bits 2,3,4, and 5 of the Standard Event Status Register and
sets the bit 5 of the Service Request Enable Register to 1.
Lines 80 - 100 Clears the Status Byte Register, the Standard Event Status Register,
and the error queue.
Lines 120 - 130 Causes a branch when an interrupt is generated on the interface card
with the select code of 7 and enables SRQ interrupt.
Lines 140 - 210 Sets sweep type and start and stop values of the frequency sweep
range, but the invalid command to set the stop value causes an error.
Line 220 Skips the error handling process when no error occurs.
Lines 230 - 250 Error handling. The GO TO statement defined in Line 120 causes the
program to branch here. The number and the message of the error that
has occurred are read.
Lines 260 - 280 Displays a message saying that an error has occurred, an error number,
error description, and a message saying that the program is aborted.
Line 300 Displays a message saying that the program has ended. However, the
program does not actually reach this point unless you repair the
program and rerun it.
Example 11-1 Error Detection Using SRQ
10 DIM Buff$[9],Err_mes$[50]
20 INTEGER Err_no
30 !
40 ASSIGN @Agte4991a TO 717
50 !
60 OUTPUT @Agte4991a;"*ESE 60"
70 OUTPUT @Agte4991a;"*SRE 32"
80 OUTPUT @Agte4991a;"*CLS"
90 OUTPUT @Agte4991a;"*OPC?"
100 ENTER @Agte4991a;Buff$
110 !
120 ON INTR 7 GOTO Err_proc
130 ENABLE INTR 7;2
140 OUTPUT @Agte4991a;"SWE:TYPE LOG"
150 PRINT "Set Sweep Type :LOG"