A.5.2 – Campbell Scientific PS200/CH200 12 V Charging Regulators User Manual
Page 95

Appendix A. Advanced Programming Techniques
Scan (5,Sec,0,0)
PanelTemp (PanelTempC,250)
Battery (Batt_Volt)
CallTable Hour
NextScan
SlowSequence
Scan (SlowScan,Sec,3,0)
'Get extended status values.
SDI12Recorder (CH200_MX(),3,0,"M6!",1.0,0)
'Get PS200/CH200 values.
SDI12Recorder (CH200_M0(),3,0,"MC!",1.0,0)
'Values for the following parameters start at -1 for the charge state and 0 for
'the charge source and check battery. Array locations start with one. Have to
'shift the returned values so they start with one.
ChargeState = ChargeStateArr(Chg_State + 2)
ChargeSource = ChargeSourceArr(Chg_Source + 1)
CheckBattery = CheckBatteryArr(Ck_Batt + 1)
'Add up the current being consumed by the system. Include battery current in
'the calculation ONLY when it is positive - going into the battery.
'Current values coming from the PS/CH200 are in amps. Have to convert that to
'amp-hours based on the slow scan rate.
Sys_Amp_hr = Sys_Amp_hr + ILoad
If IBatt > 0 Then
Sys_Amp_hr = Sys_Amp_hr + IBatt
Batt_Amp_hr = IBatt
EndIf
Load_Amp_hr = ILoad
For n = 1 To 3
Amp_Hour(n) = Amp_Hour(n) * SlowScan/3600
Next n
'Must call these tables from the slow scan or the values will be wrong!
CallTable Amp_hr
CallTable Amp_Day
NextScan
EndProg
A.5.2 Station Power Usage RS-232 Programming Example
'CR1000 Series Datalogger
'Program: RS-232__Amp-Hr_Test.CR1
'Date: 8.Nov.2010
'Ver: A
'
'Notes: This program measures and records current usage by the station
'in amp-hours. Data is stored for hourly and daily values as well as
'PS/CH200 status variables.
'In order to calculate amp-hour capacity the measured currents coming
'from the PS/CH200 must be modified to include the scan rate and then
'totalled over the data table interval.
'Use Campbell Scientific RS-232 cable part # 25356.
'
'RS-232 CABLE TO CR1000 WIRING
'-----------------------------
'GREEN: C3 (TX)
'WHITE: C4 (RX)
'BLACK: G
'CLEAR: G
'
'Public Variables
PipeLineMode
'Constants & Public Variables
Const SlowScan = 30 'scan rate used with the slow scan section.
'Change this constant if using a different com port on the CR1000.
A-33