Campbell Scientific PS200/CH200 12 V Charging Regulators User Manual
Page 76

Appendix A. Advanced Programming Techniques
'Only save this information when the TestBatt flag
'is on.
DataTable (DischargeTest,TestBatt,144)
DataInterval (0,10,Min,10)
Sample (1,ElapsedHrs,FP2)
Average (1,Chg_TmpC,FP2,False)
Average (1,VBatt,FP2,False)
Average (1,IBatt,FP2,False)
Minimum (1,VBatt,FP2,False,False)
Sample (1,Qloss,FP2)
Sample (1,ChargeState,String)
Sample (1,ChargeSource,String)
Sample (1,CheckBattery,String)
EndTable
'Main Program
BeginProg
'Put length of battery test in hours here. Can also be modified on
'the fly.
TestLengthHrs = 3
'Load arrays with words to associate with the charge state, charge
'source and check battery values from the PS/CH200.
ChargeStateArr(1) = "Regulator Fault"
ChargeStateArr(2) = "No Charge"
ChargeStateArr(3) = "Current Limited"
ChargeStateArr(4) = "Cycle Charging"
ChargeStateArr(5) = "Float Charging"
ChargeStateArr(6) = "Battery Test"
ChargeSourceArr(1) = "None"
ChargeSourceArr(2) = "Solar"
ChargeSourceArr(3) = "Continuous"
CheckBatteryArr(1) = "Normal"
CheckBatteryArr(2) = "Check Battery"
Scan (5,Sec,0,0)
PanelTemp (PanelTempC,250)
CallTable Hour
NextScan
SlowSequence
Scan (30,Sec,3,0)
RealTime (rTime())
ElapsedHrs = Timer (1,Hr,4) 'timer for elapsed time of test.
'Run this section of code if elapsed time is less than the
'set amount of time for the test and the battery voltage has not
'dropped below 11.7 vdc. The PS/CH200 will not let the battery drop
'below 11.5 vdc.
If ElapsedHrs <= TestLengthHrs AND VBatt >= 11.7 Then
'For this exercise the datalogger will automatically
'start a test on the 17th of each month @ 8 AM OR when
'the ManualTest flag is set to on. Have to turn on the
'timer when the test begins.
If ManualTest = On OR (DOM = 17 AND Hour = 8) Then
ManualTest=Off
TestBatt = On
Timer (1,Hr,0)
EndIf
'Battery test command will be sent every 30 seconds. Must send it at
'least every 90 seconds or the PS/CH200 will automatically reset!
If TestBatt Then
SDI12Recorder (SDI12Result,3,0,"XB!",1.0,0)
EndIf
Else
'When the test is over reset the timer and turn of the TestBatt flag.
Timer (1,Hr,3)
A-14