![background image](http://html1.mh-extra.com/html/campbell/cs451/cs451_product-manual_3793103037.webp)
B-1
Appendix B. Example Programs
CRBasic Example B-1. CS451 SDI-12 Program for CR1000X Data Logger
'CR1000X Series
'Declare Variables and Units
Dim
FRun
Dim
Old
Dim
Changed
Public
BattV
Public
PTemp_C
Public
CS451(2)
Public
Observed
Public
Lvl_corr
Public
Offset
Alias
CS451(1)=Lvl_ft
Alias
CS451(2)=Temp_C
Units
BattV=Volts
Units
PTemp_C=Deg C
Units
Lvl_ft=feet
Units
Temp_C=deg C
'Define Data Tables
DataTable
(Hourly,True,-1)
DataInterval
(0,60,Min,10)
Maximum
(1,Lvl_ft,FP2,False,True)
Minimum
(1,Lvl_ft,FP2,False,True)
Maximum
(1,Temp_C,FP2,False,True)
Minimum
(1,Temp_C,FP2,False,True)
EndTable
DataTable
(Daily,True,-1)
DataInterval
(0,1440,Min,10)
Minimum
(1,BattV,FP2,False,False)
EndTable
PreserveVariables
'Main Program
BeginProg
'Main Scan
Scan
(60,Sec,1,0)
'Default CR1000X Data Logger Battery Voltage measurement 'BattV'
Battery
(BattV)
'Default CR1000X Data Logger Wiring Panel Temperature measurement 'PTemp_C'
PanelTemp
(PTemp_C,60)
'CS451 Pressure Transducer measurements 'Lvl_ft' and 'Temp_C'
SDI12Recorder
(Lvl_ft,C1,"0","M1!",1,0,-1)
Lvl_ft=Lvl_ft*2.30666
'Offset calculation 'Offset'
If
FRun=0
Then
Observed=NAN
FRun=1
EndIf
Changed=Observed-Old
If
Changed=0
Then
Lvl_corr=Offset
Else
Offset=Observed-Lvl_ft
Lvl_corr=Offset
Old=Observed