Datalogger program examples, 1 sr50a examples, 1 cr1000 example (sdi-12 “m1!”) – Campbell Scientific SR50A Distance Sensor User Manual

Page 32

Advertising
background image

SR50A Sonic Ranging Sensor

10. Datalogger Program Examples

In the following datalogger program examples only the CR1000 and the
CR10X dataloggers are used. The programming of CR800, CR850 and the
CR3000 dataloggers are effectively the same as the CR1000. Also for a
CR23X datalogger refer to the CR10X programming examples.

10.1 SR50A Examples

10.1.1 CR1000 Example (SDI-12 “M1!”)

'CR1000 Series Datalogger

'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((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

26

Advertising