EasyManua.ls Logo

Ametek Thermox TM2000 - Page 158

Ametek Thermox TM2000
170 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
A-14 | Thermox TM 2000 Oxygen Analyzer
Sample Program
This section provides a sample Quick Basic program that reads and writes
to the serial port:
DECLARE FUNCTION Checksum$ (M$)
‘Serial test routine
‘ Continuously sends a message and prints the string returned
CLS
Open the communications port
OPEN “COM2:9600,N,8,1 “FOR RANDOM AS #1
‘String to be echoed
T$ = “Test message”
Address of the series 2000 controller
Address% = 254
Build the message
M$ = “>” = HEX$(Address%) = “A” = T$
M$ = M$ + Checksum$(M$)
Continue sending message until key pressed
‘(Assumes that Series 2000 controller is connected)
WHILE (INKEY$ = “”)
PRINT #1, M$
LINE INPUT #1, A$
‘Show results
PRINT “Sent…..”; M$
PRINT “Returned…”; A$
PRINT
WEND
CLOSE #1
STOP
FUNCTION Checksum$ (M$)
DIM Sum AS LONG
Sum = 0
‘Skip >
FOR I% = 2 TO LEN(M$)
Sum = Sum + ASC(MID$(M$, i%,1)
NEXT I%
Get low byte of checksum
Checksum$ = HEX$(Sum MOD 256)
END FUNCTION

Table of Contents