Lakeshore 330 User Manual page 51

Autotuning temperature controller
Table of Contents

Advertisement

Lake Shore Model 330 Autotuning Temperature Controller User's Manual
'
SEREXAM.BAS
'
This program works with QuickBasic 4.0/4.5 or Qbasic on an IBM PC or compatible
'
with a serial interface. It uses the COM1 communication port at 1200 BAUD. Enter
'
an instrument command or query at the prompt. The command transmits to the
'
instrument which displays any query response. Type "EXIT" to exit the program.
'
NOTE: The INPUT instruction in this example accepts no commas as part of an input
'
string. If a comma appears in an instrument command, replace it with a space.
'
CLS
PRINT " SERIAL COMMUNICATION PROGRAM"
PRINT
TIMEOUT = 2000
BAUD$ = "1200"
TERM$ = CHR$(13) + CHR$(10)
OPEN "COM1:" + BAUD$ + ",O,7,1,RS" FOR RANDOM AS #1 LEN = 256
LOOP1: LINE INPUT "ENTER COMMAND (or EXIT):"; CMD$
CMD$ = UCASE$(CMD$)
IF CMD$ = "EXIT" THEN CLOSE #1: END
CMD$ = CMD$ + TERM$
PRINT #1, CMD$;
IF INSTR(CMD$, "?") <> 0 THEN
RS$ = ""
N = 0
WHILE (N < TIMEOUT) AND (INSTR(RS$, TERM$) = 0) 'Wait for response
IN$ = INPUT$(LOC(1), #1)
IF IN$ = "" THEN N = N + 1 ELSE N = 0 'Add 1 to timeout if no chr
RS$ = RS$ + IN$
WEND
IF RS$ <> "" THEN
RS$ = MID$(RS$, 1, (INSTR(RS$, TERM$) - 1)) 'Strip off terminators
PRINT "RESPONSE:"; RS$
ELSE
PRINT "NO RESPONSE"
END IF
END IF
GOTO LOOP1
Remote Operation
Table 4-3 Sample BASIC Serial Interface Program
EXAMPLE PROGRAM FOR SERIAL INTERFACE
'Clear screen
'Read timeout (may need more)
'Terminators are <CR><LF>
'Get command from keyboard
'Change input to upper case
'Get out on Exit
'Send command to instrument
'Test for query
'If query, read response
'Clr return string and count
'Get one character at a time
'Add next chr to string
'Get chrs until terminators
'See if return string is empty
'Print response to query
'No response to query
'Get next command
4-9

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents