LumaSense Technologies M390S User Manual
Page 31
M390 Manual
Appendix B: ASCII/BASIC 31
A simple BASIC program to send blackbody setpoint:
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 < 600 OR sp > 3000 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.
'-----generate the full setpoint string--
setpoints$ = CHR$(4) + "0011" + CHR$(2) + setpoint$ + CHR$(x)
'full setpoint string
'-----chr$(4) is diamond symbol
'-----chr$(2) is 'happy face' symbol
'---display the setpoint string---
PRINT "string sent="; setpoints$
'----send the string to controller---
start:
PRINT #1, setpoints$ 'send to controller
'---repeat as required--
GOTO inman
endman: CLOSE 1