Appendix a: pc communications sample – LumaSense Technologies M340 User Manual
Page 21

M340 Manual
Appendix A: PC Communications sample 21
Appendix A: PC Communications sample
This is a typical QBASIC program that reads current temperature and increments setpoint at 10C
intervals:
This program is provided for example only for extraction of code lines for your use. It is not
intended to be an attractive user interface program. It is, however, a working program.
'ATHNSET.BAS RS232 mgm 12/11/97 rev 1/9/98 mgm added switch for no decimal
CLS
OPEN "COM1:1200,O,7,1,RS,CS,DS" FOR RANDOM AS #1 'uses com1 12.o.7 setting
'----set up screen, draw box with MIKRON name in it
SCREEN 13
WIDTH 40
PRINT "ATHNSET: RS232 TEST MIKRON VER 1.1"
PRINT "rs232 com1 1200,O,7,1 ID#01"
INPUT "Does it have decimal point (Y/N)"; dp$
LOCATE 23, 5
PRINT "Press space bar to quit."
LINE (70, 30)-(170, 30), 3 '
LINE (70, 30)-(70, 150), 3
LINE (170, 30)-(170, 150), 3
LINE (70, 150)-(170, 150), 3
LOCATE 18, 13
COLOR 3
PRINT "MIKRON"
'------set up loop for with or without decimal points, initialize starts & ends
dp$ = UCASE$(dp$)
IF dp$ = "N" THEN beginsp = 30: endsp = 140: dpswitch = 0: readlen = 6
IF dp$ = "Y" THEN beginsp = 30.1: endsp = 140.1: dpswitch = 100: readlen = 7
LOCATE 6, 1
'-------main setpoint stepping loop----------------------------------------
setpointloop:
FOR sp = beginsp TO endsp STEP 10
BEEP
'-------put setpoint writing string in correct format for decimal or no decimal
IF sp < dpswitch THEN
sp$ = " 0" + RIGHT$(STR$(sp), 4)
ELSE
sp$ = STR$(sp)
END IF
'-------create reading and setpoint output strings
reading$ = "#01R00" + CHR$(13) + CHR$(10) 'grab a reading string
setpoint$ = "#01M01" + sp$ + "C" + CHR$(13) + CHR$(10) 'change setpoint string
'-------display and send setpoint value to controller
COLOR 2
LOCATE 9, 15
PRINT sp
PRINT #1, setpoint$ 'send sp to controller
'------wait some time
FOR y = 0 TO 200000