beautypg.com

Campbell Scientific PS200/CH200 12 V Charging Regulators User Manual

Page 69

background image

Appendix A. Advanced Programming Techniques

Public CH200_MX(4)

'Array to hold extended data from the PS200/CH200

'Alias names for array elements.

Alias CH200_MX(1) = BattTargV 'Battery charging target voltage.
Alias CH200_MX(2) = DgtlPotSet 'Digital potentiometer setting.
Alias CH200_MX(3) = BattCap

'Present battery capacity.

Alias CH200_MX(4) = Qloss

'Battery charge deficit.


'SDI-12 formatted battery capacity value.

Public SDI12command As String
'Response from PS/CH200. Returns the address of the unit and "OK" if
'all went well.

Public SDI12result As String
Public NewBattCap

'New battery capacity.


'Define Data Tables
'Stored hourly data.

DataTable (Hour,1,-1)
DataInterval (0,1,Hr,10)
Minimum (6,CH200_M0(),FP2,0,False)

Maximum (6,CH200_M0(),FP2,False,False)
Minimum (1,PanelTempC(),FP2,0,False)
Maximum (1,PanelTempC(),FP2,False,False)

EndTable

'Save the new and old battery capacity values and a time

'stamp indicating when it was changed.
DataTable (BattCapChng,True,48)

Sample (1,NewBattCap,FP2)
Sample (1,BattCap,FP2)
EndTable


'Main Program
BeginProg

'For this exercise change the battery capacity to 12 Amp-hours.
'Value can be changed on the fly by changing the variable.
NewBattCap = 12

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

NextScan

SlowSequence
Scan (30,Sec,3,0)
'Get PS200/CH200 values.

SDI12Recorder (CH200_M0(),3,0,"M3!",1.0,0)
'Get present battery capacity settings.
SDI12Recorder (CH200_MX(),3,0,"M6!",1.0,0)

'If the present battery capacity is not the same as the new
'battery capacity then send the new one to the charger.
If BattCap <> NewBattCap Then

CallTable BattCapChng
SDI12command = "XC" & FormatFloat (NewBattCap,"%4.1f") & "!"

SDI12Recorder (SDI12result,3,0,SDI12command,1.0,0)
EndIf
NextScan
EndProg

A-7