Remote Programming 23
Programming Some Power Supply Functions (continued)
1130 'Enable Status Byte OPER summary bit
1135 CODES$ = "*SRE 128" :GOSUB 2000
1140 ‘
1146 'Arm trigger circuit and send trigger to power supply
1150 CODES$ = "INITIATE;TRIGGER" :GOSUB 2000
1160 'Wait for supply to respond to trigger
1165 FOR I= 1 to 100 :NEXT I
1170 ‘
1175 'Poll for interrupt caused by change to CC mode and print to screen
1180 SPOL%=O
1186 CALL IBRSP(PS%,SPOL%)
1190 IF (SPOL% AND 128) = 128 THEN POLL = 1 'Set interrupt flag on OPER bit
1195 IF POLL < > 1 THEN GOTO 1230 'No interrupt to service
1200 "CODES$ = "STAT:OPER:EVEN?" :GOSUB 2000 'Query status oper register
1205 CALL IBRD(PS%,OEVENT$) 'Read back event bit
1210 IF IBSTA% <0 THEN GOTO 21OO
1215 OEVENT=VAL(OEVENT$)
1220 IF (OEVENT AND 1024) = 1024 THEN PRINT "Supply switched to CC mode."
1225 ‘
1230 'Clear status circuit
1235 CODES$="*CLS" :GOSUB 2000
1240 FOR I=1 TO 50 :NEXT I 'Wait for supply to clear
1245 ‘
1250 'Disable output and save present state to location 2
1255 CODES$ = "OUTPUT OFF;*SAV 2" :GOSUB 2000
1260 END
1265 ‘
2000 'Send command to power supply
2005 CALL IBWRT(PS%,CODES$)
2010 IF IBSTAT% < 0 THEN GOTO 2100 'Error detected
2015 RETURN
1250 'Disable output and save present state to location 2
1255 CODES$ = "OUTPUT OFF;*SAV 2" :GOSUB 2000
1260 END
1265 ‘
2000 'Send command to power supply
2005 CALL IBWRT(PS%,CODES$)
2010 IF IBSTAT% < 0 THEN GOTO 2100 'Error detected
2015 RETURN
2020 ‘
2100 'Error detection routine
2105 PRINT "GPIB error. IBSTAT%. = &H";HEX$(IBSTAT%)
2110 PRINT “ IBERR% = ";IBERR%" in line ";ERL
2115 STOP
2120 ‘
3000 'Get data from power supply
3005 CALL IBRD(PS%,OUTPUT$)
3010 IF IBSTA% < 0 THEN GOTO 2100
3015 I=1 ' 'Parse data string
3020 X=1
3025 C=INSTR(I,OUTPUT$,";")