Hi,
Referring to the previously asked question regarding how to detect if a mains power connection exists based on battery controller status, I'm still having some issues as shown in the Example Result below. I'd appreciate if anyone could offer additional advice.
Problem:
Using the proposed method for detecting mains power does not correctly report expected result as shown in the example provided.
System Overview:
Hardware:
2 battery packs, each configured with an independent BQ40Z50-R1 battery controller
Software:
Polling each controller independently to determine charge status for battery 1 and battery 2.
Pseudocode:
def poll_battery_status(): get_absolute_state_of_charge() get_relative_state_of_charge() get_remaining_capacity() get_full_charge_capacity() get_charging_current() get_charging_voltage() get_is_charging() get_mains_power_exists() def get_mains_power_exists(): if self.get_is_charging() \ or (not self.get_is_charging() and self.get_charging_current_mA() == 0 and self.get_charging_voltage_mV() == 0): return True else: return False
Example Result with Mains Power Connected:
Battery 1 Report:
Mode: 0x6001
Status: 0xE0
Relative state of charge: 91%
Charging: False
Charging Voltage: 16.8 V
Charging Current: 2 A
Mains power connected: False
Battery 2:
Mode: 0x6001
Status: 0xE0
Relative state of charge: 100%
Charging: False
Charging Voltage: 16.8 V
Charging Current: 44 mA
Mains power connected: False
--- Original Thread ---
Hi Folks,
I am already able to detect if a device is charging, but is there a method to detect a device is connected to external power but not charging?
Some examples:
Battery is 100% charged, and connected to an external power source.
Battery is <100% charged, and connected to external power, but not charging.
Thanks for your suggestions.
From: Andy
Apr 22, 2020 10:11 PM
You can check the OperationStatus()[XCHG] bit, ChargingCurrent() and ChargingVoltage().
100% RSOC usually occurs when a valid charge termination is detected and then the CHG FET turns off. OperationStatus()[XCHG] will be set to 1, which means charging is disabled. Both ChargingCurrent() and ChargingVoltage() should return 0.
Andy