CRBasic Example 2: CR1000X RS-232 program to measure the SDMS40
Public
SDMS40_Calibrate_Now
As Boolean
'the user can set this to TRUE to calibrate the sensor
Public
SDMS40_Install_Height
Units
SDMS40_Install_Height = mm
ReadOnly
SDMS40_Install_Height
Public
SDMS40_Install_Angle
Units
SDMS40_Install_Angle = degrees
ReadOnly
SDMS40_Install_Angle
Public
SDMS40_Depth_Avg
Units
SDMS40_Depth_Avg = mm
Public
SDMS40_Temperature(3)
Units
SDMS40_Temperature () = Deg C
Alias
SDMS40_Temperature (1) = SDMS40_Board_Temperature
Alias
SDMS40_Temperature (2) = SDMS40_Heater_Low_Threshold_Temperature
Alias
SDMS40_Temperature (3)= SDMS40_Laser_Temperature
Public
Verbose_Mode
Public
SDMS40_Depth_Points(36)
Units
SDMS40_Depth_Points() = mm
Public
SDMS40_Distance_Points(36)
Units
SDMS40_Distance_Points() = mm
Dim
SDMS40_string
As String
* 2000
'string to hold data string received from SDMS40
Dim
SDMS40_string_temp
As String
* 2000
Dim
SDMS40_Serial_Check
'**************************************************************************
'Snow depth data table
'**************************************************************************
DataTable
(SnowDepth,1,-1)
DataInterval
(0,SDMS40_Interval,Min,10)
Sample
(1,SDMS40_Depth_Avg,FP2)
Sample
(3,SDMS40_Temperature(),FP2)
Sample
(36,SDMS40_Depth_Points(),FP2)
Sample
(36,SDMS40_Distance_Points(),FP2)
EndTable
'Main Program
BeginProg
'Open COM port for SDMS40
SerialOpen
(SDMS40_COMport,SDMS40_baud_rate,0,10,2000)
SerialFlush
(SDMS40_COMport)
' Force the verbose mode to 1
SerialOut
(SDMS40_COMport,
"@v 1"
+
CHR
(13),
""
,0,0)
SerialIn
(SDMS40_string,SDMS40_COMport,10,
""
,2000)
SplitStr
(Verbose_Mode,SDMS40_string,
""
,1,0)
SerialFlush
(SDMS40_COMport)
'Retrieve install angle and height from the sensor
SerialOut
(SDMS40_COMport,
"@s"
+
CHR
(13),
""
,0,0)
SerialIn
(SDMS40_string,SDMS40_COMport,1000,
""
,2000)
SDMS40 Multipoint Scanning Snowfall Sensor
28