Battery Life Algorithm for Low-Power Microcontrollers

Microsoft Excel | August 8, 2011
In general, battery life calculations are done by running an application to draw a lot of power. However, this is not accurate for low-power microcontrollers, since they spend most of their time in sleep mode and only occasionally draw a high current. For example, garage doors spend a long time in standby and only operate twice a day. As part of an internship, I developed a way to better gauge the battery life of a microcontroller.

Introduction

Low-power microcontrollers generally have batteries in the mAh range, which last anywhere from 100 to 100,000 hours. The battery life depends on the application being run on the microcontroller and how often it is awake. The amount of current drawn in sleep and awake mode is different, so we need to know how long the application is in either mode.
Assume the application runs in alternating modes of standby and full operation, as an approximation of what it does in real life. We also call the awake time an "iteration". The following variables are then defined:

Calculations

First, we figure out how long the application is asleep, depending on the duty cycle. Define the amount of sleep time as t, and the total time for one cycle (which is an iteration and a period of sleep) as T.
Then we need an estimate of the amount of energy the battery can provide. This depends on the current being drawn (which is different between awake and sleep periods). We find a weighted average of the two.
Now calculate how much energy is used up per cycle.
Next, we calculate how many cycles can occur before the battery is drained. This depends on the previous result and the actual capacity of the battery.
Once we know how many cycles are possible and how long each cycle takes, we can find a good good estimate of how long the battery will last.
This is probably an underestimate of the true battery life, since applications don't cycle through sleep and awake periods that quickly. However, we did not take into consideration the battery's voltage. This actually decreases as the battery gets closer to the end of its lifetime. This would make the actual battery life shorter.