Appendix a: sample communication program – LumaSense Technologies M310 User Manual
Page 25

M310 Manual
Appendix A: Sample Communication Program 25
Appendix A: Sample Communication
Program
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.
'********Test program for new line of Athena controllers*******
'
CLS
OPEN "com1:1200,O,7,1,RS,CS,DS" FOR RANDOM AS #1
PRINT "Communication test program for new Athena controller"
LOCATE 5, 1
PRINT "SETPOINT = "
LOCATE 6, 1
PRINT "Source Temperature = "
LOCATE 5, 22
FOR setpoint = 30 TO 90 STEP 10
LOCATE 5, 22
PRINT USING "##.###"; setpoint
sp$ = STR$(setpoint) + ".000"
spcomm$ = "0101W09" + LTRIM$(sp$)
'calculate checksµm
sµm = 0
FOR i = 1 TO LEN(spcomm$)
sµm = sµm + ASC(MID$(spcomm$, i, 1))
NEXT i
sµm = sµm MOD 256
newsµm$ = STR$(sµm)
IF sµm > 99 THEN
sµm1 = FIX(sµm / 10) + 55
newsµm$ = CHR$(sµm1) + RIGHT$(newsµm$, 1)
END IF
'send command to change setpoint
spcomm$ = "$0101W09" + LTRIM$(sp$) + newsµm$
PRINT #1, spcomm$
'FOR x = 1 TO 500: NEXT x
INPUT #1, spcomm$
FOR pvloop = 1 TO 10
FOR x = 1 TO 1000: NEXT x
'get process variable from controller
PRINT #1, "$0101R05C1"
'FOR x = 1 TO 500: NEXT x
INPUT #1, pvresponse$
getpval = VAL(MID$(pvresponse$, 9, 7))
LOCATE 6, 22