3 cr10x example (sdi-12 “m1!”) – Campbell Scientific SR50A Distance Sensor User Manual
Page 34

SR50A Sonic Ranging Sensor
'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_Distance*(SQR((Air_Temp+273.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.1.3 CR10X Example (SDI-12 “M1!”)
;{CR10X}
;
;In this example, the SR50A is mounted 2.5 meters above the ground.
;The CR10X sends an SDI-12 command to the SR50A, which outputs a
;non-temperature compensated distance value (Raw_Dist) and signal quality value.
;Two input locations are used to store incoming data.
*Table 1 Program
01: 60
Execution
Interval
(seconds)
;Measure the 107 temperature probe:
1: Temp (107) (P11)
1: 1
Reps
2: 1
SE
Channel
;SE channel 1 used for this example
3: 1
Excite
all
reps
w/E1
;Excite channel 1 used for this example
4: 1
Loc [ T_Kelvin ]
5: 1.0
Multiplier
6: 273.15 Offset
;This converts the value to degrees Kelvin
;Use SDI-12 command "M1!" to receive Distance and Signal Quality from the SR50A
2: SDI-12 Recorder (P105)
1: 0
SDI-12
Address
2: 1
Start
Measurement
(aM1!)
3: 1
Port
;Use Ports 5-8 for CR23X
4: 3
Loc [ Raw_Dist ]
5: 1.0
Multiplier
6: 0.0
Offset
;Apply air temperature compensation to distance:
3: Z=F x 10^n (P30)
1: 273.15 F
2: 0
n,
Exponent
of
10
3: 5
Z Loc [ Ref_Temp ]
4: Z=X/Y (P38)
1: 9
X Loc [ T_Kelvin ]
2: 5
Y Loc [ Ref_Temp ]
3: 6
Z Loc [ Mult1 ]
28