Quick Basic Serial Interface Program Setup - Lakeshore 340 User Manual

Hide thumbs Also See for 340:
Table of Contents

Advertisement

9.2.7.2

Quick Basic Serial Interface Program Setup

The serial interface program listed in Table 9-7 works with QuickBasic 4.0/4.5 or Qbasic on an IBM PC (or
compatible) running DOS or in a DOS window with a serial interface. It uses the COM1 communication port at
9600 Baud. Use the following procedure to develop the Serial Interface Program in Quick Basic.
1. Start the Basic program.
2. Enter the program exactly as presented in Table 9-7.
3. Adjust the Com port and Baud rate in the program as necessary.
4. Lengthen the "TIMEOUT" count if necessary.
5. Save the program.
6. Run the program.
7. Type a command query as described in Paragraph 9.2.7.3.
8. Type "EXIT" to quit the program.
CLS
PRINT " SERIAL COMMUNICATION PROGRAM"
PRINT
TIMEOUT = 2000
BAUD$ = "9600"
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)
IN$ = INPUT$(LOC(1), #1)
IF IN$ = "" THEN N = N + 1 ELSE N = 0
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
Lake Shore Model 340 Temperature Controller User's Manual
Table 9-7. Quick Basic Serial Interface Program
'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
'Wait for response
'Get one character at a time
'Add 1 to timeout if no chr
'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
9-19

Advertisement

Table of Contents
loading

Table of Contents