![background image](http://html1.mh-extra.com/html/campbell/sr50at/sr50at_instruction-manual_488987051.webp)
Appendix B. Example Programs
B-17
Sample
(1,AirTempC,FP2)
Sample
(1,TCDT,IEEE4)
Sample
(1,Q,FP2)
EndTable
PreserveVariables
'Main Program
BeginProg
'Main Scan
n = 1
Scan
(10,Sec,1,0)
'Battery Voltage measurement 'BattV'
Battery
(BattV)
'Wiring Panel Temperature measurement 'PnlTmp_C'
PanelTemp
(PnlTmp_C,_60Hz)
'Automated snow depth measurement. Must occur two minutes before
'actual storage time to get 11 measurements completed.
If TimeIntoInterval
(58,60,Min)
Then
SR50ATCtrl = True
EndIf
'Set this flag to true to get the initial distance from the SR50AT
'to the ground.
If
SR50AT_MID
Then
SR50ATCtrl = True
'Logic to make 11 snow depth measurements, sort them, and store
'the corrected values.
If
SR50ATCtrl
Then
'SR50AT Sonic Ranging Sensor (SDI-12 Output) measurements
'MDT', 'MQ', & MAir
SDI12Recorder
(SR50AT_M(),1,"0","M3!",1,0)
'Load the array to be sorted.
SR50AT(n,1) = SR50AT_M(1)
SR50AT(n,2) = SR50AT_M(2)
SR50AT(n,3) = SR50AT_M(3)
n += 1
If
n > 11
Then
n = 1
SR50ATCtrl = False
SortSpa
(Result_SR50AT(1,1),11,SR50AT(1,1),2)
TCDT = Result_SR50AT(6,1)
Q = Result_SR50AT(6,2)
AirTempC = Result_SR50AT(6,3)
If
SR50AT_MID
Then
Inital_Dist = TCDT
SR50AT_MID = False
EndIf
Snow_Depth = Inital_Dist - TCDT
EndIf
EndIf
'SR50ATH heater control. Voltage must be above 11.7 vdc and the
'air temperature less than 2°C to turn on the heater.
If
BattV >= 11.7
Then
If
AirTempC <= 2
Then
HtrCntrl = True
If
AirTempC > 3
Then
HtrCntrl = False
Else
HtrCntrl = False
EndIf
SW12
(HtrCntrl)
'Call Data Tables and Store Data
CallTable
Daily
CallTable
Hour
NextScan
EndProg