Campbell Scientific CS125 Present Weather Sensor User Manual
Page 60

CS125 Present Weather Sensor
C-6
CheckVal = CheckSum (TempStringFunc,1,0) ' Use the CCITT CRC16 checksum
' Create final string going out to CS125 including start characters and end
characters
CS125CommandString = CHR(2) + TempStringFunc + ":" + FormatLong (CheckVal,"%04X") +
":" + CHR(3) + CHR(13) + CHR(10)
'CS125CommandString = CHR(2) + TempStringFunc + CHR(3) + CHR(13) + CHR(10) ' Use
this line if no checksum is desired
Return(CS125CommandString)
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
CS125CArray(1) = 0 ' Set ID to 0
CS125CArray(2) = 1 ' Enable alarm 1
CS125CArray(3) = 1 ' Set alarm 1 to if greater than
CS125CArray(4) = 1000 ' Set alarm 1 trigger distance to 1000
CS125CArray(5) = 1 ' Enable alarm 2
CS125CArray(6) = 0 ' Set alarm 2 to if less than
CS125CArray(7) = 15000 ' Set alarm 2 trigger distance to 15000
CS125CArray(8) = 2 ' Set serial baud rate to 38400bps
CS125CArray(9) = 0 ' Read only so dummy value added here, but not needed
CS125CArray(10) = "M" ' Set unit type to metres (use upper case)
CS125CArray(11) = 60 ' Set output period to 60 seconds
CS125CArray(12) = 1 ' Polling mode
CS125CArray(13) = 2 ' Set FULL output message format
CS125CArray(14) = 0 ' Set RS232 serial mode
CS125CArray(15) = 1 ' Set averaging over one minute
CS125CArray(16) = 1 ' Set sample timing to one second
CS125CArray(17) = 0 ' Set dew heaters to automatic
CS125CArray(18) = 0 ' Set hood heaters to automatic
CS125CArray(19) = 0 ' Don't use dirty window compensation
CS125CArray(20) = 1 ' Use CRC checking on incoming command line data
CS125CArray(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 = CS125_SETCommand() ' Create the outgoing string
SerialOut (Com1,TempString,"",0,100) ' Send SET command to the CS125
Delay (1,1,Sec)
SerialIn (InString,Com1,100,0,1000) ' Grab retuned data from the CS125
' Returned data is identical to the
' data a GET command would return
NextScan
EndProg