E-8 Example Programs
Controlling the Model 2182 via the RS-232 COM2 port
This example program illustrates the use of the Keithley Model 2182 interfaced to the RS-232
COM2 port. The Model 2182 is set up to take 100 readings at the fastest possible rate (2000 per
second). The readings are taken, sent across the serial port, and displayed on the screen.
' Example program controlling the Model 2182 via the RS-232 COM2 port
' For QuickBASIC 4.5 and CEC PC488 interface card
RD$=SPACE$(1500) ' Set string space
CLS ' CLear screen
PRINT "Set COM2 baud rate to 19200"
PRINT "Set no flow control, and CR as Terminator"
' Configure serial port parameters
ComOpen$="COM2:19200,N,8,1,ASC,CD0,CS0,DS0,LF,OP0,RS,TB8192,RB8192"
OPEN ComOpen$ FOR RANDOM AS #1
' Model 2182 setup commands
' Note Serial communications only operate with SCPI mode....
PRINT #1, "*RST" ' Clear registers
PRINT #1, "*CLS" ' Clear Model 2182
PRINT #1, ":INIT:CONT OFF;:ABORT" ' Init off
PRINT #1, ":SENS:FUNC 'VOLT:DC" ' DCV
PRINT #1, ":SENS:CHAN 1" ' Channel 1
PRINT #1, ":SYST:AZER:STAT OFF" ' Auto zero off
PRINT #1, ":SENS:VOLT:CHAN1:LPAS:STAT OFF" ' Analog filter off
PRINT #1, ":SENS:VOLT:CHAN1:DFIL:STAT OFF" ' Digital filter off
PRINT #1, ":SENS:VOLT:DC:NPLC 0.01" ' NPLC = 0.1
PRINT #1, ":SENS:VOLT:CHAN1:RANG 10" ' 10V range
PRINT #1, ":SENS:VOLT:DC:DIG 4" ' 4 digit
PRINT #1, ":FORM:ELEM READ" ' Reading only
PRINT #1, ":TRIG:COUN 1" ' Trig count 1
PRINT #1, ":SAMP:COUN 100" ' Sample count 100
PRINT #1, ":TRIG:DEL 0" ' No trigger delay
PRINT #1, ":TRIG:SOUR IMM" ' Immediate trigger
PRINT #1, ":DISP:ENAB OFF" ' No display
PRINT #1, ":INIT" ' Send init
SLEEP 1 ' Wait one second
PRINT #1, ":FETCH?" ' Read query
LINE INPUT #1, RD$ ' Get data
PRINT RD$ ' Display data
PRINT #1, ":DISP:ENAB ON" ' Turn on display
PRINT #1, ":SYST:AZER:STAT ON" ' Auto zero on
'Clean up and quit.
finish:
CLOSE #1 ' Close file
CLEAR ' Interface clear
END