This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

BQ25180: How to detect battery disconnection?

Part Number: BQ25180

Hello, let me put two questions about using BQ25180:


1. There are two use cases in my product, with battery or without battery but power adapter. How can I know if the battery is detached? Is it possible to catch it via I2C communication? or do I need additional circuit for that?


2. I'm using charging status interrupt to indicate battery status changes. As shown in the image below, the battery status of "charging" and "charging done" repeats infinitely when battery disconnected, causing continuously interrupts. Is this intended behavior? or am I missing something?

Thanks.

  • Hi Jun,

    Welcome to E2E!

    There are two use cases in my product, with battery or without battery but power adapter. How can I know if the battery is detached? Is it possible to catch it via I2C communication? or do I need additional circuit for that?

    I do have a working software routine that works that will allow you to detect if a battery is present or not. Another method I'm thinking is you could "debounce" the charge status similar to a button. The other method is disabling charge temporarily and seeing if the capacitor discharges below BUVLO. If the voltage drops below BUVLO, you can check the BUVLO status and before and after disabling charge. If they are different, then there is no battery.

    Let me write up a state machine diagram for you to follow the second method. 

    2. I'm using charging status interrupt to indicate battery status changes. As shown in the image below, the battery status of "charging" and "charging done" repeats infinitely when battery disconnected, causing continuously interrupts. Is this intended behavior? or am I missing something?

    Yes, the behavior of the VBAT waveform (and the status toggling between "charaging" and "charge done") are intended. This is due to the device charging and discharging the capacitor. 

  • Hi Jun,

    I'll have some flow charts for you to follow tomorrow. Apologies for the delay. 

    Best Regards,

    Anthony Pham

  • Hi Jun,

    I'm replying with a flow chart of the battery detect. Let me know if there are any questions.

    Best Regards,

    Anthony Pham

  • Thanks for your response.

    I've actually implemented the method you suggested with diagram. The downside of the method, at least with my implementation, was that enabling/disabling charging causes interrupt which I wanted to avoid. And should wait for voltage settled out before reading ADC.

    I think, I would implement a kind of debouncing the charge status as you mentioned. Or polling voltage level periodically with charge status interrupt disabled.

    This is driver that I'm using, battery present detection is not implemented there though: https://github.com/libmcu/bq25180.

    Thanks.

  • Hi Jun,

    That'd be correct. This would cause an interrupt whenever toggling charging. 

    Or polling voltage level periodically with charge status interrupt

    Do you mean polling when the charge status interrupt occurs when enabling or disabling charge? Are you using an ADC you have in your system? The BQ25180 does not have a built in ADC. 

    You'll also find that because the interrupts are happening when charge begins and completes because the capacitor is going between VBATREG and the recharge threshold, this may look like the same points periodically (charge complete will also be VBAT = VBATREG and Charge Begins will always look like VBAT = RECHARGE) which is why it is needed to disable and enable the charge so that the voltage at the battery pin can decay outside of this region.

    I can look through the driver but from what I can tell this only sets the device's register settings. I would need to see your code for implementing the actual routine.

    Best Regards,

    Anthony Pham

  • Yes, I have an ADC in my system to read the battery level since no built in ADC in BQ25180.

    I meant polling the battery level, reading ADC, with charge status interrupt disabled to avoid frequent interrupts.

    And I understand about periodic VBAT level changes. Let me put this thread as resolved. Thanks for your explanation.