Campbell Scientific SR50A Distance Sensor User Manual

Page 37

Advertising
background image

SR50A Sonic Ranging Sensor

'Main Program
BeginProg

Scan

(60,Sec,0,0)

PanelTemp

(PTemp,250)

Battery

(Batt_volt)

'Once installed enter the actual distance from the SR50AT to the Ground with

'no snow present. If in doubt it is better to use a slightly larger value

'than a smaller value. Errors in the value will show up as an offset error

'in the snow depth values

'If a new value for the variable NewDistanceToGround is entered (non zero)

'The following code will send that value to the SR50AT.

If

NewDistanceToGround

>

0.0

then


'Convert the floating point value to a text string for the SDI-12 command

XtendedDistValStr

=

FormatFloat

(NewDistanceToGround,"%4.3f")

'To send the Distance to ground (in meters) value to the SR50A the

'SDI-12 extended command is as follows:

'aXDM.MMM!-

where

M.MMM

is

the value such as 2.345 Meters

SDI12commandstring = "XM;" + XtendedDistValStr + "!"

'Send out the SDI-12 command to the sensor

SDI12Recorder

(ExtendedCMDResult,1,0,SDI12commandstring,1.0,0)

'Read

back

the

Distance

to

Ground value in the SR50A to confirm

SDI12Recorder

(SR50ADistanceToGround,1,0,"R0!",1.0,0)

'If the Sensor is present confirm the value was sent correctly

'Never

use

more

than

3

deciaml

places of precision for the new value

If

ExtendedCMDResult

=

1.0

then

'Reset the value so that no more attempts will be made to update the

'Distance

to

Ground

value.

NewDistanceToGround

=

0.0


'Read back the Distance to Ground value from the SR50A to confirm.

'This

is

not

necessary

but

recommended.

SDI12Recorder

(SR50ADistanceToGround,1,0,"R0!",1.0,0)


EndIf

EndIf


'Read the Snow depth from the SR50A "M4!" command returns depth with

'quality

and

temperature

SDI12Recorder

(SR50AReturnValues,1,0,"M4!",1.0,0)


'Call

Output

Tables

'Example:

CallTable

Test

NextScan
EndProg

31

Advertising