beautypg.com

Campbell Scientific PS200/CH200 12 V Charging Regulators User Manual

Page 97

background image

Appendix A. Advanced Programming Techniques


'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


DataTable (Amp_hr,True,-1)
DataInterval (0,1,Hr,10)

Totalize (3,Amp_Hour(),FP2,False)
Sample (1,Qloss,FP2)
EndTable


DataTable (Amp_Day,True,-1)

DataInterval (0,1,Day,10)
Totalize (3,Amp_Hour(),FP2,False)
Sample (1,Qloss,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


'SlowSequence with RS-232 measurements

SlowSequence
'Configure the COM port used with the PS/CH200
SerialOpen (COMPRT,9600,3,0,150)

Scan(SlowScan,sec,0,0)
'Get the PS/CH200 status information.
'Call WAKEUP to wake up the PS/CH200.

Call WAKEUP
'Send "read status" command to PS200 followed by a carriage return.
SerialOut (COMPRT,CH200STATS_CMD,"",1,3)

SerialOut (COMPRT,CR,"",1,3)
'Discard characters in the receiver buffer up to and including asterisks "*"
SerialIn (xmit_str,COMPRT,50,"*",40)

'Capture the PS/CH200 response string after the asterisks and including the
'string terminator hexadecimal zero (&H00).

SerialIn (CH200string,COMPRT,50,&H00,140)
Check_sum = CheckSum (CH200string,5,0 )

A-35