beautypg.com

Campbell Scientific PS200/CH200 12 V Charging Regulators User Manual

Page 79

background image

Appendix A. Advanced Programming Techniques


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


'Set the day counter to one the first time the program is run.
DayCntr = 1

Scan (5,Sec,0,0)
PanelTemp (PanelTempC,250)
CallTable Hour

'Add one to DayCntr at midnight but only if not in a test mode.
If TestBatt = Off AND IfTime (0,1,Day) Then DayCntr = DayCntr + 1
NextScan


SlowSequence

Scan (30,Sec,3,0)
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.

'For this exercise the datalogger will automatically
'start a test on the 90th day from the time the program was started
'or if the ManualTest flag is set to on. Have to turn on the

'timer when the test begins.
If TestBatt = Off AND (ManualTest = On OR XDays >= DayCntr) Then
ManualTest=Off

TestBatt = On
DayCntr = 1

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= On AND ElapsedHrs <= TestLengthHrs AND VBatt >= 11.7 Then
SDI12Recorder (SDI12Result,3,0,"XB!",1.0,0)

Else

'When the test is over reset the timer and turn of the TestBatt flag.

Timer (1,Hr,3)

TestBatt = Off

EndIf

'Get PS200/CH200 values.

SDI12Recorder (CH200_M0(),3,0,"MC!",1.0,0)

'Array values start with one. Values for charge state start with -1.

'Have to shift the value by two to line it up with the correct words

'in the array.

ChargeState = ChargeStateArr(Chg_State + 2)

'Values for charge source start with zero. Have to shift the value

'by one to line it up with the correct words in the array.

ChargeSource = ChargeSourceArr(Chg_Source + 1)

'Values for check battery start with zero. Have to shift the value

'by one to line it up with the correct words in the array.

CheckBattery = CheckBatteryArr(Ck_Batt + 1)

'Get extended battery capacity settings.

SDI12Recorder (CH200_MX(),3,0,"M6!",1.0,0)

CallTable (DischargeTest)

'write data before zeroing ElapsedHrs

NextScan

EndProg

A-17