Remote Control
Programming Examples
6
6-45
SUB SendCmd (WR$)
'Send command string to instrument via GPIB without response
SHARED GEN%
CALL IBWRT(GEN%, WR$) 'output command string
CALL ErrChk(3, IBSTA%) 'check error
END SUB
SUB SendStr (WR$)
'Send command string to instrument via GPIB with response
SHARED GEN%
qry = 0 'query flag
qer = 0 'error query flag
CALL IBWRT(GEN%, WR$) 'output command string
IF IBSTA% < 0 THEN
CALL ErrChk(3, IBSTA%) 'check error
ELSE
Stat = 0
CALL IBRSP(GEN%, Stat%) 'get status byte from instrument
CALL ErrChk(3, IBSTA%) 'check error
IF (Stat% AND 16) THEN 'checks whether MAV is set
qry = 1
END IF
IF (Stat% AND 32) THEN 'checks whether ESB is set
BEEP
WR$ = "err?" 'error query
CALL IBWRT(GEN%, WR$) 'output command string
qry = 1
qer = 1
END IF
END IF
IF INSTR(WR$, "?") > 0 OR qry = 1 THEN 'check if query command
MaxLen = 164 'max. length of response string
RD$ = SPACE$(MaxLen) 'clear response string
CALL IBRD(GEN%, RD$) 'get response string
IF IBSTA% < 0 THEN
CALL ErrChk(3, IBSTA%) 'check error
ELSE
PRINT
PRINT "RESPONSE : " + RD$ 'response string
IF qer = 1 THEN
WR$ = "*cls" 'clear status register
CALL IBWRT(GEN%, WR$) 'output command string
END IF
END IF
END IF
END SUB