M310-HT Manual
Appendix B: Sample Communication Program
•
26
'-----close the comm port (if finished)----------
CLOSE #1
The following program writes setpoint value.
CLS
'-----open comm port 1 for 9600 baud, 7,E,1-----
OPEN "COM1:9600,E,7,1,RS,CS,DS" FOR RANDOM AS #1
inman:
'-----enter desired setpoint as a string---
INPUT "Enter setpoint temperature (EXIT to quit) "; sp$
'-----always make it upper case for text entry---
IF UCASE$(sp$) = "EXIT" THEN GOTO endman
'-----make the setpoint a number----
sp = VAL(sp$)
'-----retry if the entry was out of range of the blackbody--
IF sp < 10 OR sp > 750 THEN PRINT "invalid entry": GOTO inman
'format setpoint to match controller
'---display the setpoint--
PRINT sp
'-----make a string that is 100 times the sp value---
sp = sp * 100
spi = FIX(sp)
spi$ = STR$(spi)
'-----extract the two decimal values (.nn) from the string--
decpt$ = RIGHT$(spi$, 2)
'-----extract the integer values from the string--
integer$ = MID$(spi$, 2, LEN(spi$) - 3)
'-----generate the variable setpoint set string (SLnn.nn(ascii 'heart symbol'))
setpoint$ = "SL" + integer$ + "." + decpt$ + CHR$(3) 'generate partial sp string
'-----chr$(n) is the hex value of n taken from the table section 4.1.5 in 'Eurotherm
'-----comm instruction manual
'generate checksum (if needed)
x = 0
FOR c = 1 TO LEN(setpoint$)
x = x XOR ASC(MID$(setpoint$, c, 1))
NEXT c
' The "0011" in the string below is address 01. To talk to address 02, use 0022
' (Each address digit is reapeated for confirmation)
' To send to address 03, use "0033".
' To send to address 04, use "0044".
' To send to address 15, use "1155", etc.