SR50A Sonic Ranging Sensor
- 47 -
'In this example, the SR50A is mounted 2.5 meters above the ground.
'The CR1000 sends an 'SDI12 command to the SR50A,
'which outputs a raw distance value and a signal quality.
'Declare Public Variables:
Public
SR50(2)
Alias
SR50(1)=Raw_Dist
Alias
SR50(2)=SignalQuality
Public
Temp_Corr_Distance
Public
Air_Temp
Public
Snow_Depth
'Declare the initial distance of the SR50A from the ground in meters:
Const
Initial_Distance = 2.5
'Define Data Tables:
DataTable
(Table1,True,-1)
DataInterval
(0,60,Min,10)
Sample
(1,Snow_Depth,FP2)
EndTable
'Main Program:
BeginProg
Scan
(60,Sec,0,0)
'Measure the SR50A:
'Use SDI12 command "M1!" to receive Distance
'and Signal quality from the SR50AT
SDI12Recorder
(SR50(),1,0,"M1!",1,0)
'Measure the 107 temperature sensor:
Therm107
(Air_Temp,1,1,Vx1,0,250,1.0,0)
'Use Air_Temp to calculate corrected distance:
Temp_Corr_Distance=Raw_Dist*(SQR((A273.15)/273.15))
'Subtract the corrected distance from the initial distance of the SR50A to the ground:
Snow_Depth=Initial_Distance-Temp_Corr_Distance
'Call Data Table and Store Data:
CallTable
(Table1)
NextScan
EndProg
10.4 Programming Example 4
SR50AT SDI-
12 “M4!” Snow Depth Output CR1000