Low-battery interrupt with the PowerBoost 500C (SAM4S Example)

Recently I attempted to use an Adafruit PowerBoost 500C to power a small MCU-based mobile robot. Specifically, I wanted it to:

  • Supply 5v to the system out of a 3.7v LiPo battery.
  • Charge the battery like if it was a smartphone
  • Shut power down when wheels get stuck, and
  • Trigger an interrupt software when battery is low.

It is this last which gave me some problems. Documentation states the Low battery (LB) pin goes to ground when the battery voltage drops below 3.2v. That sounds just fine, except that there are many things that can make the battery voltage drop briefly below 3.2v, specially as it gets closer to the “low battery” point. In this specific case, even though the battery was “decently” charged, motors running would make the LB pin flicker between High and Low, thus generating a train of false interrupts.  As the battery continued to discharge, the flickering continued and the Low LED in the PowerBoost board became brighter. I suspect the duty-cycle of the flickering (so to speak) increased. (I might be wrong on this, a quick look in the oscilloscope would dissipate doubts, but who has time for that). From this explanation, the solution is simple: a low-pass filter. One just needs to adjust the cut-off frequency to let only the low-battery flickering pass, and not those generated by the motors when the battery is still charged.


Low-pass filter solution

My first solution was to filter the flickering in software, and it worked fine. The problem was that no matter what the MCU was getting interrupted no less than 15 times in a second when charged.  My second solution was to use a RC filter, with the RC filter I was able to reduce the number of false interrupts to around 1 to 2  per second when charged. (I’m not an expert on this matters, and I’m guessing with the right RC values, the flickering can be entirely removed. Either way, 1 to 2 times per second was good enough for me, and I did not have capacitors of other values at hand.) Then I simply filtered the 1 to 2 false interrupts using the built-in de-bounce filter in the SAM4S and an old trick used for de-bouncing buttons by checking ,waiting, and checking again (a bunch of nested if statements and delays)… after that no more false interrupts.


RC Circuit

It’s really just one resistor and a capacitor. I used a 1 uF capacitor and 22 kohms resistor. This tutorial shows more information about it. It even shows the cut-off frequency equation to find the right values for R and C.





Demo code



By |2016-07-25T08:54:09+00:00July 25th, 2016|Prototyping, SAM4S Xpro|0 Comments

Leave A Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.