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

Appendix A. Advanced Programming Techniques
'Variables & constants used to write the new battery capacity
'to the PS/CH200.
'Command sent to the PS/CH200 to write external battery temperature.
'Instruction responds with "OK" if all went well.
Const WRITE_BATT_CAP_CMD = "WR_BC("
Public NewBattCap
'New battery capacity.
'String storing the formatted ASCII equivalent of the ext battery
'temp.
Public NewBattString As String * 5
'String coming back from either the "WR_BT" or "RS_INTBT" command.
Public ReturnStr As String * 40
'Command to get extended status information.
Const EXTSTATS_CMD = "RD_SPECIAL>"
'Array to hold extended data from the PS200/CH200
Public CH200_MX(4) As String * 20
Public BattTargV
'Battery charging target voltage.
Public DgtlPotSet
'Digital potentiometer setting.
Public BattCap
'Present battery capacity.
Public Qloss
'Battery charge deficit.
'Stored hourly data.
DataTable (Hour,1,-1)
DataInterval (0,1,Hr,10)
Minimum (1,VBatt,FP2,0,False)
Minimum (1,IBatt,FP2,0,False)
Minimum (1,ILoad,FP2,0,False)
Minimum (1,V_in_chg,FP2,0,False)
Minimum (1,I_in_chg,FP2,0,False)
Minimum (1,Chg_TmpC,FP2,0,False)
Maximum (1,VBatt,FP2,False,False)
Maximum (1,IBatt,FP2,False,False)
Maximum (1,ILoad,FP2,False,False)
Maximum (1,V_in_chg,FP2,False,False)
Maximum (1,I_in_chg,FP2,False,False)
Maximum (1,Chg_TmpC,FP2,False,False)
Minimum (1,PanelTempC(),FP2,0,False)
Maximum (1,PanelTempC(),FP2,False,False)
EndTable
'Save time stamp and changes to battery capacity for record
'keeping.
DataTable (BattCap,True,100)
Sample (1,BattCap,FP2)
Sample (1,NewBattCap,FP2)
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
'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
A-9