![background image](http://html1.mh-extra.com/html/campbell/sr50at/sr50at_instruction-manual_488987040.webp)
Appendix B. Example Programs
B-6
'distance in non-volatile memory. If power is lost at the site, the
'initial distance value will be restored.'
'A control flag is used to initiate the SR50AT measurement cycle. This
'allows for manual control in the field to check distances without
'waiting for the correct time interval to occur. It is also used by
'the datalogger to initiate an automated measurement cycle.
'
'Every measurement cycle is composed of 11 individual measurements
'that are spatially sorted to eliminate any low or high values.
'One measurement is made with each scan. This program has a 10
'second scan rate so it will take 100 seconds to do all 11 scans or
'1 minute and 40 seconds.
'Declare Constants
'Default serial address of SR50AT is 33. Polling command consists of
'a lower case 'p' followed by the address and a carriage return.
Const
POLL_A = "p33" &
CHR
(13)
'Declare Variables and Units
Public
BattV :
Units
BattV
= Volts
'CR1000 battery voltage
Public
PnlTmp_C :
Units
PnlTmp_C = °C
'CR1000 panel temperature
'Controls SR50A measurement. This flag can be manually controlled to
'run tests in the field or is automatically set 2 minutes before the
'hourly data storage interval. This is done so 11 measurements can
'be made and sorted before the values are stored.
Public
SR50ATCtrl A
s Boolean
'Set this flag to measure and store the initial distance from the
'SR50A to the ground.
Public
SR50AT_MID
As Boolean
'Declare SR50AData as a dimensioned string of maximum 50 chrs
Public
SR50ATData
As String
* 50
'Values returned from the SR50AT.
Public
ParseValsT(6)
As Float
Alias
ParseValsT(1)=SerialAddressT :
Units
SerialAddressT = addr
Alias
ParseValsT(2)=Dist_To_SurfaceT :
Units
Dist_To_SurfaceT = meters
Alias
ParseValsT(3)=SignalQualityT :
Units
SignalQualityT = value
Alias
ParseValsT(4)=SR50AT_Temp
:
Units
SR50AT_Temp
= °C
Alias
ParseValsT(5)=DiagnosticsT :
Units
DiagnosticsT
= value
Alias
ParseValsT(6)=ChcksumT
:
Units
ChcksumT
= value
'SR50AT diagnostic counters. Values are incremented if an error occurs.
Public
ROM_Cntr :
Units
ROM_Cntr = value
Public
SR50AT_WtchDg_Cntr :
Units
SR50AT_WtchDg_Cntr = value
Dim
scratch
'Array to hold 11 SR50AT measurements composed of a distance and
'quality number, and air temperature.
Public
SR50AT(11,3)
'Sorted array of 11 SR50AT measurements composed of a distance and
'quality number, and temperature. Measurements are sorted by the
'distance value from smallest to largest.
Public
Result_SR50AT(11,3)
Public
TCDT
:
Units
TCDT
= meters
'Temperature corrected distance
Public
Q
:
Units
Q
= unitless
'Quality number
Public
AirTempC :
Units
AirTempC = °C
'Air temperature
Public
Inital_Dist :
Units
Inital_Dist = meters
'Distance to ground.
Public
Snow_Depth :
Units
Snow_Depth = meters
'Snow depth.
Dim
n
'used as a counter