M310-HT Manual
Appendix B: Sample Communication Program
•
25
Appendix B: Sample Communication
Program
This is a typical QBASIC program that reads current temperature.
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.
CLS
'-------set comm port to 9600, 7,E,1----------
OPEN "COM1:9600,E,7,1,CD,CS,DS,RS" FOR RANDOM AS #1 LEN = 512
'-------make a request for blackbody temperature string----
w$ = CHR$(4) + "0011PV" + CHR$(5)
'----chr$(4) is ascii diamond symbol-
'----chr$(5) is ascii club symbol-
'-----chr$(n) is the hex value of n taken from the table section 4.1.5 in Eurotherm
'-----comm instruction manual
'-----send request string(w$) to comm port------------
PRINT #1, w$
'-----display the string (w$)--------
PRINT w$
'-----waste time for return data from controller-------
FOR y = 0 TO 100000
NEXT y
BEEP
'-----clear input reading string (R$)-------
R$ = ""
'-----collect input data from controller one byte at a time----
WHILE LOC(1) = 0
WEND
C = LOC(1)
PRINT C
R$ = R$ + INPUT$(C, #1)
BEEP
'------display the string from received from controller--------
PRINT R$
'-----format the string to real numbers to display bb temperature---
'WEND
'pv$ = getread$
'pv = VAL(MID$(pv$, 4, 6))
'PRINT pv$, pv