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
1005 OPTION BASE 1
1010 DIM Codes$[80],Response$[80],Mode$[32]
1015 !
1020 !Program dc source to CV mode with following voltage and current
1025 OUTPUT 706;"VOLTAGE MAX;CURRENT MAX"
1030 !
1035 !Query dc source outputs and print to screen
1040 OUTPUT 706;"MEASURE:VOLTAGE?;CURRENT?" !Query output levels
1045 ENTER 706;Vout,Iout
1050 PRINT "The output levels are ";Vout;" Volts and ";Iout" Amps"
1055 !
1060 !Program current triggered level to a value insufficient to maintain
1065 !supply within its CV operating characteristic
1070 OUTPUT 706;"CURR:TRIG MIN"
1075 !
1080 !Set operation status mask to detect mode change from CV to CC
1085 OUTPUT 706;"STAT:OPER:ENAB 1024;PTR 1024"
1090 !
1095 !Enable Status Byte OPER summary bit
1100 OUTPUT 706;"*SRE 128"
1105 !
1110 !Arm trigger circuit and send trigger to dc source
1115 OUTPUT 706;"INITIATE:SEQUENCE1;TRIGGER"
1130 !Poll for interrupt caused by change to CC mode and print to screen
1135 Response=SPOLL(706)
1140 IF NOT BIT (Response,7) THEN GOTO 1130 !No OPER event to report
1145 OUTPUT 706;"STAT:OPER:EVEN?" !Query status operation register
1150 ENTER 706;Oevent !Read back event bit
1155 IF BIT(Oevent,10) THEN PRINT "Supply switched to CC mode."
1160 !
1165 !Clear status
1170 OUTPUT 706;"*CLS"
1175 !
1180 !Disable output and save present state in location 2
1185 OUTPUT 706;"OUTPUT OFF;*SAV 2"
1190 END