beautypg.com

A.4 zero qloss, A.4.1 zero out qloss sdi12 programming example, A.4.1 – Campbell Scientific PS200/CH200 12 V Charging Regulators User Manual

Page 88

background image

Appendix A. Advanced Programming Techniques

'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_MX(),CH200string,COMMA,4,4)
'Sort out the components to specific variables.

BattTargV = CH200_MX(1)
DgtlPotSet = CH200_MX(2)

BattCap = CH200_MX(3)
Qloss = CH200_MX(4)
EndIf

CallTable (DischargeTest) 'write data before zeroing ElapsedHrs
NextScan
EndProg

A.4 Zero QLoss

Qloss is used to track current in amp-hours going in and out of the battery. It is
a handy way of monitoring the conditions of the entire system if using a solar
panel. It is not the best way to calculate a power budget – see Appendix A.5,
Station Power Usage,
for an example of measuring current used by the entire
system across a specified time.

The value for Qloss increases as the battery discharges and decreases as the
battery is charged. The value will never drop below zero. Depending on load
and charging characteristics this value may never approach zero. Also, if a
battery is replaced it is handy to zero out Qloss if it is being used.

An added bonus with this section is it uses the instructions to get
extended status information from the PS/CH200.

NOTE

A.4.1 Zero Out QLoss SDI12 Programming Example

'CR1000 Series Datalogger
'Program: SDI12_Clear_QLoss.CR1
'Date: 7.October.2010

'Ver: A
'
'Notes: This program sets QLoss back to zero using the SDI-12

'command XRQ! to set QLoss to zero.
'PS200/CH200 configured with SDI-12 address 0 (zero).
'

'Use Campbell Scientific SDI-12 cable part # 20769.
'
'SDI-12 CABLE TO CR1000 WIRING

'-----------------------------
'WHITE: C3

'BLACK: G
'CLEAR: G
'

'Setting the variable Clear_QLoss = True will clear QLoss.
Public Clear_QLoss As Boolean

A-26