'************************************************************************* '** ** '** 232COM.BAS ** '** This example program illustrates the use of the Keithley ** '** Model 2000 DMM interfaced to the RS-232C bus. The example ** '** is a simple interactive programming example. The program can be ** '** expanded to perform other functions. ** '** ** '** Copyright (c) 1994, Keithley Instruments, Inc. ** '** AC,JT ** '************************************************************************* Response$ = SPACE$(1000 * 17) Cmd$ = SPACE$(256) LastCmd$ = SPACE$(256) CLS PRINT "Enter COM1 baud rate 19200" PRINT " 9600" PRINT " 4800" PRINT " 2400" PRINT " 1200" PRINT " 600" INPUT " 300 :"; BaudRate$ ComOpen$ = "COM2:" + BaudRate$ + ",N,8,1,ASC,CD0,CS0,DS0,LF,OP0,RS,TB8192,RB8192" OPEN ComOpen$ FOR RANDOM AS #1 PRINT "" PRINT "NOTE: Make sure Model 2000 is configured for "; BaudRate$; " baud" PRINT " no flow control, and CR as terminator." PRINT "" PRINT "(type HELP for help)" PRINT "" WHILE (1) ' ' Grab input and send to instrument unless special command. ' LINE INPUT "SEND: "; Cmd$ ' ' Trap special commands. ' SELECT CASE UCASE$(Cmd$) CASE "0" PRINT "Enter COM1 baud rate 19200" PRINT " 9600" PRINT " 4800" PRINT " 2400" PRINT " 1200" PRINT " 600" INPUT " 300 :"; BaudRate$ ComOpen$ = "COM1:" + BaudRate$ + ",N,8,1,ASC,CD0,CS0,DS0,LF,OP0,RS,TB8192,RB8192" CLOSE #1 OPEN ComOpen$ FOR RANDOM AS #1 PRINT "" PRINT "NOTE: Make sure Model 2000 is configured for "; BaudRate$; " baud" PRINT " no flow control, and CR as terminator." PRINT "" PRINT "(type HELP for help)" PRINT "" INPUT YorN$ Cmd$ = "" CASE "1" Cmd$ = LastCmd$ CASE "2" Cmd$ = "*IDN?" CASE "3" Cmd$ = ":SYST:ERR?" CASE "4" Cmd$ = "*STB?" CASE "HELP" PRINT "" PRINT "0 - Change baud rate" PRINT "1 - (Cmd$ last command)" PRINT "2 - Instrument ID query(*IDN?)" PRINT "3 - Error query" PRINT "4 - Status byte query(*STB?)" PRINT "HELP - (this screen)" PRINT "EXIT - quit" PRINT "CLS - clear the screen" PRINT "" Cmd$ = "" CASE "CLS" CLS Cmd$ = "" CASE "QUIT", "EXIT", "BYE" GOTO finish END SELECT ' ' Send command out 232. ' LastCmd$ = Cmd$ PRINT #1, Cmd$ ' ' If command was a query, fetch response, display, and parse. ' IF INSTR(1, Cmd$, "?") THEN LINE INPUT #1, Response$ PRINT Response$ RespCount = 0 length = LEN(Response$) i = 1 parsenotdone = 1 WHILE (parsenotdone) WHILE (MID$(Response$, i, 1) <> "," AND MID$(Response$, i, 1) <> ";" AND i < length) i = i + 1 WEND RespCount = RespCount + 1 i = i + 1 IF i > length THEN parsenotdone = 0 END IF WEND PRINT "("; RespCount; ")" END IF WEND ' ' Clean up and quit. ' finish: CLOSE #1 CLEAR END