SDMS-30 Multipoint Scanning Snow Depth Sensor
13
10. Sample CRBasic Programs
10.1 RS-232 Sample Program
Use the sample program in CRBasic Example 10-1 when setting up the sensor
to communicate with a datalogger via RS-232.
CRBasic Example 10-1. RS-232 Sample Program for CR1000
'SDMS30 RS232 Sample Program (CR1000)
SequentialMode
'User entered constants
Const SDMS30_Interval = 1 'measurement and data output interval (in minutes)
Const SDMS30_COMport = COM1 'Communications port used for connection to SDMS30
Const SDMS30_baud_rate = 57600
'-------------------------------------------------------------------------------
'Wiring for SDMS30
'-------------------------------------------------------------------------------
'The sensor measurement takes about 30 seconds and it is done in the program's
slow sequence
'Blue ------------------------> C1 (RS232 RX) -- if using COM1 as your port
'Yellow ----------------------> C2 (RS232 TX) -- if using COM1 as your port
'Brown ----------------------> G (digital ground)
'Red -------------------------> +12V
'Black -----------------------> G (Power Ground)
'-------------------------------------------------------------------------------
'Diagnostic variables
'-------------------------------------------------------------------------------
Public PTemp, batt_volt
Units PTemp = deg C
Units batt_volt = volts
'-------------------------------------------------------------------------------
' Variables for WeatherPia SDMS30 Scanning Laser Sensor
'-------------------------------------------------------------------------------
Public SDMS30_Measure_Now As Boolean 'the user can set this to TRUE to request a
measurement
Public SDMS30_Calibrate_Now As Boolean 'the user can set this to TRUE to calibrate
the sensor
Public SDMS30_Install_Height
Units SDMS30_Install_Height = mm
ReadOnly SDMS30_Install_Height
Public SDMS30_Install_Angle
Units SDMS30_Install_Angle = degrees
ReadOnly SDMS30_Install_Angle
Public SDMS30_Depth_Avg
Units SDMS30_Depth_Avg = mm
Public SDMS30_Temperature(2)
Units SDMS30_Temperature = deg C
Alias SDMS30_Temperature(1) = SDMS30_Board_Temperature
Alias SDMS30_Temperature(2) = SDMS30_Laser_Temperature
Public SDMS30_Depth_Points(36)
Units SDMS30_Depth_Points() = mm
Public SDMS30_Distance_Points(36)
Units SDMS30_Distance_Points() = mm
Dim SDMS30_string As String * 2000 'string to hold data string received from
SDMS30
Dim SDMS30_string_temp As String * 2000
Dim SDMS30_Serial_Check