beautypg.com

Campbell Scientific PS200/CH200 12 V Charging Regulators User Manual

Page 56

background image

PS200/CH200 12 V Charging Regulators

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

'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

SerialOpen (COMPRT,9600,3,0,150)
Scan(30,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 )

'For the string to be correct the check sum must be zero.
If Check_sum = 0 Then
'Split up the main string from PS/CH200 into separate components.

SplitStr (CH200_M0(),CH200string,COMMA,9,4)
'Sort out the components to specific variables.

VBatt = CH200_M0(1)
IBatt = CH200_M0(2)
ILoad = CH200_M0(3)

V_in_chg = CH200_M0(4)
I_in_chg = CH200_M0(5)
Chg_TmpC = CH200_M0(6)

ChargeState = CH200_M0(7)
ChargeSource = CH200_M0(8)
Ck_Batt = CH200_M0(9)

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

EndIf
NextScan
EndProg

48