Sample Program - Ametek Thermox Series 2000 WDG-IV User Manual

Table of Contents

Advertisement

Sample Program

A-24 | Thermox Series 2000 WDG-IV /I VC / IVCM
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 sent
T$ = "08"
' A ddress of the analyzer
Address% = 0
'Build the message
M$ = ">" + HEX$(Address%) + "F" + T$
M$ = M$ + Checksum$(M$)
'Continue sending message until key pressed
' (Assumes that analyzer 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<P255D>

Advertisement

Table of Contents
loading

Table of Contents