SME Programming Examples
1038.6002.02 9D.5 E-11
Reading out the status event registers, the output buffer and the error/event queue is effected in
subroutines.
REM ---------------- Subroutines for the individual STB bits --------------
Outputqueue: ’Reading the output buffer
Message$ = SPACE$(100) ’Make space for response
CALL IBRD(generator%, Message$)
PRINT "Message in output buffer :"; Message$
RETURN
Failure: ’Read error queue
ERROR$ = SPACE$(100) ’Make space for error variable
CALL IBWRT(generator%, "SYSTEM:ERROR?")
CALL IBRD(generator%, ERROR$)
PRINT "Error text :"; ERROR$
RETURN
Questionablestatus: ’Read questionable status register
Ques$ = SPACE$(20) ’Preallocate blanks to text variable
CALL IBWRT(generator%, "STATus:QUEStionable:EVENt?")
CALL IBRD(generator%, Ques$)
IF (VAL(Ques$) AND 128) > 0 THEN PRINT "Calibration ?" ’Calibration is questionable
IF (VAL(Ques$) AND 1) > 0 THEN PRINT "Voltage ?" ’Output level is questionable
RETURN
Operationstatus: ’Read operation status register
Oper$ = SPACE$(20) ’Preallocate blanks to text variable
CALL IBWRT(generator%, "STATus:OPERation:EVENt?")
CALL IBRD(generator%, Oper$)
IF (VAL(Oper$) AND 1) > 0 THEN PRINT "Calibration"
IF (VAL(Oper$) AND 2) > 0 THEN PRINT "Settling"
IF (VAL(Oper$) AND 8) > 0 THEN PRINT "Sweeping"
IF (VAL(Oper$) AND 32) > 0 THEN PRINT "Wait for trigger"
RETURN
Esrread: ’Read event status register
Esr$ = SPACE$(20) ’Preallocate blanks to text variable
CALL IBWRT(generator%, "*ESR?") ’Read ESR
CALL IBRD(generator%, Esr$)
IF (VAL(Esr$) AND 1) > 0 THEN PRINT "Operation complete"
IF (VAL(Esr$) AND 4) > 0 THEN GOTO Failure
IF (VAL(Esr$) AND 8) > 0 THEN PRINT "Device dependent error"
IF (VAL(Esr$) AND 16) > 0 THEN GOTO Failure
IF (VAL(Esr$) AND 32) > 0 THEN GOTO Failure
IF (VAL(Esr$) AND 64) > 0 THEN PRINT "User request"
IF (VAL(Esr$) AND 128) > 0 THEN PRINT "Power on"
RETURN
REM
**********************************************************************
REM --------------------------- Error routine --------------------------------
Error handling:
PRINT "ERROR" ’Output error message
STOP ’Stop software