Download Operators Manual

Transcript
5790A
Operators Manual
5-50. Writing an SRQ and Error Handler
It is good practice to include fault (error) handling routines in your applications. The
following sample program lines show a method for halting program execution on
occurrence of an SRQ (Service Request) on the bus, checking to see if the 5790A is the
source of the SRQ, retrieving its fault messages, and acting on the faults. You should
modify and extend this code as necessary for your application.
If you want to use SRQs, first use the *SRE, *ESE, and ISCE commands to enable the
desired event. Refer to "Checking the Instrument Status" earlier in this section for more
information.
10
INIT PORT0
! IFC the bus
20
CLEAR PORT0
! DCL the bus
30
! INITIALIZE THE 5790A SRQ HANDLER
40
PRINT @6, "*SRE 8"
50
ON SRQ GOTO 1100
60
! Body of the application goes here
! Enable STB.EAV (error available)
! Install SRQ handler
1100
! Bus SRQ handler
1110
CLEAR PORT0
1120
IF (SPL(6) AND 64) THEN GOSUB 1200
1130
! TEST OTHER DEVICES RQS BITS IF DESIRED
1140
RESUME
1200
! 5790A SRQ handler
1210
IF (SPL(6) AND 8) THEN GOSUB 1300
1220
! Test other STB bits if desired here
1299
RETURN
1300
! 5790A STB.EAV (error) handler
1320
PRINT @6, "ERR?"
!
1330
INPUT @6, E%, E$
!
1340
PRINT "Error# :";E, E$
1350
IF (E% <> 0) THEN GOTO 1320
1360
STOP
1370
END
! Make sure devices are not confused
! If (STB.RQS) call 5790A SRQ
! If (STB.EAV) call error handler
Read and clear error
Read in error # and explanation
!
Print error # and explanation
!
Other commands for your app
!
Until no more errors
5-51. Taking a Measurement
The following program takes one measurement at a time.
10 REM Set Bus Timeout to 20 seconds, Init IEEE Bus
20 TIMEOUT 20 * 1000
30 INIT PORT 0
40 CLEAR @6
100 REM Reset 5790A, INPUT2, EXTERNAL Trigger
110 PRINT @6,"*RST; INPUT INPUT2; EXTRIG ON"
200 PRINT "Hit Carriage Return to take a Reading"
210 INPUTLINE A$
220 REM Trigger and wait for measurement, timeout after 15 seconds
230 PRINT @6, "MEAS? 15"
240 REM Read Magnitude,Frequency,Status
250 INPUT @6, V,F,S
260 IF S <> 0 THEN PRINT "Bad MEAS? Status"
270 PRINT V,F,S
280 GOTO 40
5-24