Take Simple Steps to Optimize Battery Runtime

Blog Post created by BradJolly Employee on Apr 13, 2017

After you have selected your microcontroller unit (MCU), there are several simple steps you can take to optimize battery runtime. Correctly configuring and testing your hardware and firmware can help you to develop the optimal IoT device configuration.


Power budget

Begin by creating a theoretical power budget for your device. Using the MCU’s data sheet and manual, consider a complete cycle of events, such as waking, collecting data, processing data, turning on the radio, transmitting data, turning off the radio, and returning to sleep. Multiply the current by the duration of each step, and add the values to obtain a projected total for a typical operational cycle. Be sure to include the current consumed while the device is in its longest sleep mode; even nanoamps add up over long periods of time. Your MCU vendor should have software that helps you estimate current drain associated with various operational parameters, and you can use a DC power analyzer, digital multimeter (DMM), or device current waveform analyzer to fine tune the estimated values.


Hardware configuration

Begin by optimizing the clock speed at which the MCU runs. The current consumption for many MCUs is specified in units of µA / MHz, which means that a processor with a slow clock consumes less current than a processor with a faster clock. However, a processor working at 100% capacity will consume the same amount of energy at 10 MHz as at 20 MHz, because the 20-MHz processor will consume twice the current for half as long. The conclusion is that for code segments where the processor is largely idle, you can save current by running the MCU more slowly.


Next, optimize the settings associated with data sampling. These settings include the frequency with which the sensor wakes up to collect data, the number of samples taken, and the ADC sampling rate. There is often a tradeoff between measurement accuracy and these sampling parameters, so set the sampling parameters to minimize current drain while delivering acceptable accuracy. Similarly, you may be able to change the rate at which the MCU updates the device display, requests data from sensors, flashes LEDs, or turns on the radio.


Finally, carefully examine the various idle, snooze, sleep, and hibernation modes available on your MCU. For example, some MCUs have sleep modes that disable the real-time clock (RTC), and disabling the RTC may reduce your sleep current consumption by a factor of six or more. Of course, if you do this, you will likely need some mechanism to recover the date and time, perhaps through a base station.


Firmware options

Design your program to finish each task quickly and return the MCU to sleep. Cycle power on sensors and other peripherals so that they are on only when needed. When you cycle sensor power, remember power-on stabilization time to avoid affecting measurement accuracy. For ultra-low-power modes, consider using a precision source/measure unit (SMU) to make very accurate current measurements, especially when you have the option to power the MCU at different voltage levels.


Consider using relatively low-power integrated peripheral modules to replace software functions that would otherwise be executed by the MCU. For example, timer peripherals may be able to automatically generate pulse-width modulation (PWM) and receive external timing signals.


Use good programming practices, such as setting constants outside of loops, avoiding declaring unnecessary variables, unrolling small loops, and shifting bits to replace certain integer math operations. Also, use code analysis tools and turn on all compiler optimizations.


Test and learn

Finally, use your instruments’ software tools to analyze the actual current consumption frequently as you develop the MCU code. These tools may include a complementary cumulative distribution function (CCDF) or automatic current profile, and they will give you information to refine your power budget. Observe and document how your coding decisions affect current consumption to optimize the present program and give you a head start on subsequent projects.


Learn more about maximizing battery life of IoT smart devices by downloading helpful applications notes and webcasts from Keysight.


Follow our Next Generation Wireless Communications blog and connect with our industry and solution experts as they share their experiences, opinions and measurement tips on a number of cellular and wireless design and test topics that matter to you.