Can anyone help clarify the meaning of the PWR and CHG digital pins on a Xenon? From reading the forums, I have picked up the following:
CHG active low, high when there is power coming from USB.
PWR && !CHG will provide the actual charging status.
From that I’m assuming that means:
CHG = 0 - Charging
CHG = 1 - Not charging
PWR = 0 - No USB power
PWR = 1 - USB Power
PWR | CHG |
0 | 0 | No USB power, battery charging
0 | 1 | No USB power, battery not charging
1 | 0 | USB power, battery charging
1 | 1 | USB power, battery not charging
I currently have a solar panel connected via a INA219 module where I can read the incoming voltage (busVoltage). The load goes to the VUSB pin on my xenon. As it got dark this evening, I recorded:
17:00 : Bus voltage 2.96. PWR=1, CHG=1 - USB power, battery not charging
17:19 : Bus voltage 2.09. PWR=1, CHG=0 - USB power, battery charging
17:21 : Bus voltage 1.96. PWR=0, CHG=0 - No USB power, battery charging
Looking at that, it suggests that CHG is 1 when charging and 0 when not. I would expect that it was receiving power and charging at 17:00, the sunlight dropped to where VUSB power was detected but not enough to charge the battery and 2 minutes later the solar cell neither charged or powered the battery.
The truth table above says the battery only charged for 2 minutes as it was getting dark, which does not make much sense.
This is the code I use in a Xenon to determine the battery SoC and power state.
// Determines powerState: [BATTERY, MAINS, RECHARGING] from reading digital pins PWR and CHG
// Determines SoC: [UNKNOWN, EMPTY, RECHARGE, NOMINAL, FULL] battery voltage level from reading analog pin BATT
void checkBattery()
{
batteryVoltage = analogRead(BATT) * 0.0011224;
if (batteryVoltage >= 4.1) SoC = FULL;
else if (batteryVoltage >= 3.7) SoC = NOMINAL;
else if (batteryVoltage >= 3.6) SoC = RECHARGE;
else if (batteryVoltage >= 3.3) SoC = EMPTY;
else SoC = UNKNOWN;
powerState = (digitalRead(PWR) == 1)?((digitalRead(CHG) == 0)?RECHARGING:MAINS):BATTERY;
}
The main difference in the logic is that if PWR is 0 then it is battery. If PWR is 1 then it may be recharging or not. Do you have a diode on the solar panel output or a voltage regulator?
That suggests the panel is powering the xenon. This surprises me as I didn't think the panel had enough power. However if I pull the battery out, I get the same result.
For interest, I added the output from the INA219 board I'm using to the micro USB connector, rather than the VUSB pin. That does not seem to make much difference.