![Campbell SR50AT Скачать руководство пользователя страница 45](http://html1.mh-extra.com/html/campbell/sr50at/sr50at_instruction-manual_488987045.webp)
Appendix B. Example Programs
B-11
'Subroutine to sum up errors from the SR50AT across the day.
Sub
Diag
scratch =
INT
(DiagnosticsT/1000)
Select Case
scratch
Case
0
SR50AT_WtchD= 1
RO= 1
Case
1
SR50AT_WtchD= 1
Case
10
RO= 1
EndSelect
EndSub
PreserveVariables
'Main Program
BeginProg
'Main Scan
n = 1
'Open and configure C1 and C2 for RS232 communication.
'9600 BAUD is the default:
SerialOpen
(Com1,9600,0,0,200)
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
'Transmit serial command "p33<CR>"
SerialOut
(Com1,POLL_A,"",0,0)
'Flush the serial buffer
SerialFlush
(Com1)
'Recieve serial string from SR50A
SerialIn
(SR50ATData,Com1,200,
CHR
(13),50)
'Pars string into separate values.
SplitStr
(ParseValsT(),SR50ATData,"",5,0)
'Calculate the temperature corrected distance.
SR50AT(n,1) = ParseValsT(2)
SR50AT(n,2) = ParseValsT(3)
SR50AT(n,3) = ParseValsT(4)
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