Appendix C. Example CRBasic programs
C-5
CheckVal = CheckSum (TempStringFunc,1,0) ' Use the CCITT CRC16 checksum
' Create final string going out to CS120A including start characters and end
characters
CS120ACommandString = CHR(2) + TempStri ":" + FormatLong (CheckVal,"%04X")
+ ":" + CHR(3) + CHR(13) + CHR(10)
'CS120ACommandString = CHR(2) + TempStri CHR(3) + CHR(13) + CHR(10) ' Use
this line if no checksum is desired
Return(CS120ACommandString)
EndFunction
'-------------------------------------------------------
'Main Program
BeginProg
' open port to the visibility sensor using Com1
SerialOpen (Com1,38400,3,0,10000)
' Note: Change the following array variable to suit your own application
' load example/dummy values into the array
CS120ACArray(1) = 0 ' Set ID to 0
CS120ACArray(2) = 1 ' Enable alarm 1
CS120ACArray(3) = 1 ' Set alarm 1 to if greater than
CS120ACArray(4) = 1000 ' Set alarm 1 trigger distance to 1000
CS120ACArray(5) = 1 ' Enable alarm 2
CS120ACArray(6) = 0 ' Set alarm 2 to if less than
CS120ACArray(7) = 15000 ' Set alarm 2 trigger distance to 15000
CS120ACArray(8) = 2 ' Set serial baud rate to 38400bps
CS120ACArray(9) = 0 ' Read only so dummy value added here, but not needed
CS120ACArray(10) = "M" ' Set unit type to metres (use upper case)
CS120ACArray(11) = 60 ' Set output period to 60 seconds
CS120ACArray(12) = 1 ' Polling mode
CS120ACArray(13) = 2 ' Set FULL output message format
CS120ACArray(14) = 0 ' Set RS232 serial mode
CS120ACArray(15) = 1 ' Set averaging over one minute
CS120ACArray(16) = 1 ' Set sample timing to one second
CS120ACArray(17) = 0 ' Set dew heaters to automatic
CS120ACArray(18) = 0 ' Set hood heaters to automatic
CS120ACArray(19) = 0 ' Don't use dirty window compensation
CS120ACArray(20) = 1 ' Use CRC checking on incoming command line data
CS120ACArray(21) = 7.0 ' Set Low voltage battery shutdown to a very low value so
it doesn't trigger
' Send information once every 10 seconds
Scan (10,Sec,0,0)
TempString = CS120A_SETCommand() ' Create the outgoing string
SerialOut (Com1,TempString,"",0,100) ' Send SET command to the CS120A
Delay (1,1,Sec)
SerialIn (InString,Com1,100,0,1000) ' Grab retuned data from the CS120A
' Returned data is identical to the
' data a GET command would return
NextScan
EndProg
Summary of Contents for CS120A
Page 2: ......
Page 4: ......
Page 6: ......
Page 8: ......
Page 23: ...User Guide 13...
Page 24: ...CS120A Visibility Sensor 14...
Page 25: ...User Guide 15...
Page 50: ...CS120A Visibility Sensor A 2...
Page 52: ...CS120A Visibility Sensor B 2...