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

Appendix A. Advanced Programming Techniques
'Only save this information when the TestBatt flag
'is on.
DataTable (DischargeTest,TestBatt,144)
DataInterval (0,1,Min,0)
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,BattTargV,FP2)
Sample (1,Qloss,FP2)
Sample (1,ChargeState,String)
Sample (1,ChargeSource,String)
Sample (1,CheckBattery,String)
EndTable
'Subroutine sends two back space characters to the PS/CH200 to
'wake it up and switch over to RS-232 mode.
Sub WAKEUP
SerialOut (COMPRT,CHR(&H08),"",1,3)
SerialOut (COMPRT,CHR(&H08),"",1,3)
EndSub
'Main Program
BeginProg
'Put length of battery test in hours here. Can also be modified on
'the fly.
TestLengthHrs = 5
'Load arrays with words to associated with the check battery values
'from the PS/CH200.
CheckBatteryArr(1) = "Normal"
CheckBatteryArr(2) = "Check Battery"
Scan (5,Sec,0,0)
PanelTemp(PanelTempC,_60Hz) 'Measure datalogger panel temperature.
CallTable Hour
NextScan
'SlowSequence with RS-232 measurements
SlowSequence
'Configure the COM port used with the PS/CH200
SerialOpen (COMPRT,9600,3,0,150)
Scan(30,sec,0,0)
RealTime (rTime())
ElapsedHrs = Timer (1,Min,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.
'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 TestBatt = Off Then
If ManualTest = On OR (DOM = 17 AND Hour = 8) Then
ManualTest=Off
TestBatt = On
Timer (1,Min,0)
EndIf
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=On AND ElapsedHrs <= TestLengthHrs AND VBatt >= 11.7 Then
'Call WAKEUP to wake up the PS/CH200.
A-20