User`s guide
D – Example Programs
168
BASIC
The BASIC for controllers and BASIC for Windows both provide access to GPIB functions at the
operating system level. This makes it unnecessary to have the header files required in front of DOS
applications programs. Also, you do not have to be concerned about controller "hangups" as long as your
program includes a timeout statement. Because the dc source can be programmed to generate SRQ on
errors, your program can use an SRQ service routine for decoding detected errors. The detectable errors
are listed in Appendix C.
Example 2. Controller Using BASIC
1000 !Dc source at stand-alone address = 706
1010 OPTION BASE 1
1020 DIM Response$[80]
1030 ASSIGN @Ps TO 706
1040 CLEAR SCREEN
1050 !
1060 PRINT "Disconnect any load from output terminals and press CONTINUE..."
1070 PAUSE
1080 !
1090 !Program dc source with following voltage level and current limit
1100 OUTPUT @Ps;"VOLT MAX"
1110 OUTPUT @Ps;"CURR MAX"
1120 OUTPUT @Ps;"OUTP ON"
1130 !
1140 !Query dc source outputs and print to screen
1150 OUTPUT @Ps;"MEAS:VOLT?;CURR?"!Query output levels
1160 ENTER @Ps;Vout,Iout
1170 PRINT "The output levels are ";Vout;" Volts and ";Iout;" Amps"
1180 !
1190 !Program current triggered level to a value insufficient to maintain
1200 !supply within its CV operating characteristic
1210 OUTPUT @Ps;"CURR:TRIG MIN"
1220 !
1230 !Set operation status mask to detect mode change from CV to CC
1240 OUTPUT @Ps;"STAT:OPER:ENAB 1024;PTR 1024"
1250 !
1260 !Enable Status Byte OPER summary bit
1270 OUTPUT @Ps;"*SRE 128"
1280 !
1290 !Arm trigger circuit and send trigger to dc source
1300 OUTPUT @Ps;"INIT:NAME TRAN"
1310 OUTPUT @Ps;"TRIGGER"
1320 !Poll for interrupt caused by change to CC mode and print to screen
1330 PRINT "Connect 1K ohm load and hit CONTINUE..."
1340 PAUSE
1350 Response=SPOLL(@Ps)
1360 IF NOT BIT(Response,7) THEN !No OPER event to report
1370 PRINT "Supply not in CC mode!!!"
1380 GOTO 1320
1390 END IF
1400 OUTPUT @Ps;"STAT:OPER:EVEN?"!Query status operation register
1410 ENTER @Ps;Oevent!Read back event bit
1420 IF BIT(Oevent,10) THEN PRINT "Supply switched to CC mode."
1430 !
1440 !Clear status
1450 OUTPUT @Ps;"*CLS"
1460 !
1470 !Disable output and save present state in location 2
1480 OUTPUT @Ps;"OUTPUT OFF;*SAV 2"
1490 PRINT "Program terminated."
1500 END