Feature

Tips for designing ultra-low power systems

Follow these tips to save power in battery-powered, microprocessor-based systems: Some involve simple coding techniques and others are hardware or system architecture related.

By Kevin Belnap, MSP430 MCU Product Marketing Manager, Texas Instruments -- EDN, 11/25/2008

Designing systems for low power operation is becoming more and more common. Some of the drivers for this trend include: consumer demand and/or product requirements for longer times between battery charges or swapping out batteries; environmental and regulatory requirements that make battery disposal more difficult; and the general public's desire to reduce energy use in order to achieve a more energy efficient lifestyle. Some product designs today require battery lifetimes of 20 years or more or are powered by harvesting energy from vibrations or other ambient energy, meaning virtually no energy can be wasted.

Selecting the right microcontroller (MCU) for a low power, portable application has become an increasingly complex task as variations among MCUs have grown in terms of cost, peripheral design and mix, CPU architecture and the level of on-board integration. However, making designs as energy efficient as possible and maximizing battery life involves more than just selecting a microcontroller with low power specs.

Hardware

Most engineers are familiar with the recommendation to tie any unused input pins high or low. This is because a floating input can either couple noise and continuously switch between high and low or the input transistors will be partially conducting. In either case unnecessary power loss will occur. In addition, unused input/output (I/O) pins should either be left open and configured as outputs or tied high or low externally or internally. Both methods will prevent the input portion of the I/O to float.

Another way to conserve power and lengthen battery life is to use a highly integrated microcontroller (MCU). In general, more integration saves power because on-chip peripherals will be designed for low power operation, will reduce leakage current and can be easily turned on or off so that they are active only when needed.

Battery selection is another hardware issue that is sometimes not just an engineering decision. One of the best batteries available for ultra-low power systems engineers today is a lithium battery due to its low leakage and a very gradual voltage decline over time and usage. Although alkaline batteries are more common, lithium batteries are generally the better choice to ensure long battery life.

One recent innovation in low power microcontrollers is the ability to adjust core voltages and clock speed dynamically according to the processing load. This allows the user to optimize clock speeds and even adjust core voltage and clocks on the fly according to the processing load. This is because the power in the core is proportional to voltage squared and will draw less power at lower voltages.

System architecture

Since low power microcontrollers consume less power during standby than when active, the best way to minimize microcontroller power in a system is to keep it in standby mode as long as possible, allow it to come out of standby only when necessary, and then send it back into standby immediately. Most ultra-low power products such as smoke detectors, thermostats, humidity or temperature data loggers, or medical equipment spend the majority of time in standby mode, so the MCU standby current is often the dominant factor in determining battery life. In these systems, the signals or environment are changing slowly relative to the microcontroller speed or, in the case of medical equipment, measurements such as blood pressure are done infrequently and can spend 99.9% of the time or more in standby.

Other systems such as electric meters spend nearly 100% of the time measuring and calculating energy, and low power is used to both save energy and load on the grid and for blackouts or brownouts. In these systems, the active current can be the dominant determinant of battery life.  In either standby or continuously active system the same basic principles apply: the system should spend as much time in standby as possible and designed to be interrupt driven - both to wake up the MCU as well as to control program flow. The interrupt service routine (ISR) should be written efficiently with the goal to get back into standby as quickly as possible.

In general the following rule of thumb can be used to determine which is the dominant factor—active current or standby current—and will give a guideline for which parameter designers should focus on when selecting an MCU.

The time that the MCU needs to come out of standby is also a critical spec, not only for near real-time response to inputs, but also for long battery life. The time that it takes the processor to wake up is essentially at full power, but because no useful processing is taking place during wake up, this power used to come out of standby is essentially wasted. Therefore, the shorter the wake-up time, the longer your battery life.

Coding techniques

Although it may seem obvious, every instruction that is executed takes energy from the battery that will never be returned so the goal in low-power coding should be to make sure every instruction executed is necessary and completed the most efficient way. There are several techniques that help ensure your code achieves maximum efficiency.

  • Know the compiler: First and foremost, an engineer must know the compiler and how it treats different code. For example, setting a compiler optimization for code size may reduce the number or instructions but increase the number of memory accesses. Optimizing for execution speed is generally the best way to lower the power, but this tactic could also increase the non-volatile memory requirements
  • Minimize memory accesses: One aspect of this is to use DMA to move data around and will be discussed in more detail shortly. The other aspect is to use CPU registers as much as possible When variables are in CPU registers, designers can execute a compare or other operations without a memory fetch, thus saving precious CPU cycles. The MSP430 microcontroller has 12 CPU working registers specifically for this purpose
  • Decrement v. increment: This simple way to save memory cycles can be used to control branching. Use a decrement instead of increment in while(); for(;;) or if() statements and branch or exit the loop when the variable is zero. If the variable is in a register and is then decremented, the MCU will set a bit when the register value is zero and the MCU will branch off of that bit. This saves both a memory fetch and a compare statement. The below code examples show an inefficient and more efficient way to compare and branch.

// Inefficient code example
int x;
while(x++<100);

// A better (and lower power) way to do it;
int x=100;
while(x--);

While the second example is more efficient than the previous example, there is an even more efficient way to do the same loop. If the loop is merely waiting for time to pass like in the example above, the most efficient way to do the loop is to load an interruptible timer and let it decrement while the MCU is in standby.

  • Integrated DMA: As mentioned previously, another example of wasted energy is the time spent when the processor is merely collecting ADC samples or transmitting or moving data and not doing processing. Many low power MCUs integrate direct memory access (DMA) that allows an analog-to-digital converter (ADC), for example, to put data samples directly into memory, bypassing the MCU. The MCU can then go into standby until the required number of samples are taken, wake up to process the samples, and then get back to standby as quickly as possible.

Some additional coding techniques to help reduce memory fetches and MCU cycles are the following:

  • Use low-power integrated peripheral modules in place of software driven functions. For example, internal timers can automatically generate PWM and capture external timing, with no CPU resources.
  • Implement calculated branching and fast table look-ups in place of flag polling and long software calculations.
  • Avoid frequent subroutines and function calls due to the associated overhead. Instead, use inline code or macros. When a function is called at a minimum the program counter is pushed onto the stack and if parameters are passed to the function these are usually pushed onto the stack as well. These use MCU cycles that can be avoided. Although programming in this manner reduces modularity and increases memory requirements, the typical gains will outweigh the costs.
  • Use local variables instead of global variables. Local variables are usually put in registers while global variables are generally put in RAM memory. (Again, check the compiler assembly code to ensure this is correct.)

Modern, low power MCUs have come a long way in becoming better optimized for low power operation. A significant portion of the complexity engineers face when designing for ultra-low power can be addressed by a MCUs integration of modules and advanced functionality.  In many systems, the standby power will be the determining factor in battery lifetime, but an analysis should be done to determine if active or standby current is the dominant factor. This means that the processing should be optimized, memory fetches should be minimized, and the system scrutinized for ways to save MCU cycles. This will in turn lengthen battery life.

Author Information
Kevin Belnap is the MSP430 product-marketing manager at Texas Instruments. He is responsible for managing worldwide marketing activities, including revenue, customer engagements, business development, and communications. Belnap received a bachelor's degree in electrical engineering and a master's degree in business administration from Brigham Young University (Provo, UT). You may reach him at k-belnap@ti.com.


EDN Resource Center

EDN Featured Vendor

Screaming Circuits

Screaming Circuits is an industry pioneer in the online quick-turn prototype pc board assembly market. Located in Canby, OR, the company offers assembly, prototype, pilot production and short-run production pc boards in as little as 24 hours for short runs. Screaming Circuits is a subsidiary of the Milwaukee Electronics Corporation, which offers full service contract manufacturing.
View More
View All Resources
ADVERTISEMENT

ADVERTISEMENT

Feedback Loop


Post a CommentPost a Comment

There are no comments posted for this article.

Related Content

 

By This Author

There are no additional articles written by this author.


ADVERTISEMENT

Knowledge Center


Events

Fairchild Semiconductor Power Seminar Tour
Dates: 2/23/2009 - 5/7/2009
Location: Eastern Europe, Israel, & Turkey

Fairchild Semiconductor Power Seminar Tour
Dates: 2/25/2009 - 4/22/2009
Location: 14 Western Europe dates (Spain, France, Belgium, Netherlands, Germany, Switzerland, United Kingdom, Denmark, Finland, Italy)

Transmission & Distribution Europe 2009
Dates: 3/17/2009 - 3/19/2009
Location: Barcelona, Spain

Fairchild Semiconductor Power Seminar Tour
Dates: 4/28/2009 - 4/30/2009
Location: Russia

Submit an EventSubmit an Event




Technology Quick Links

EDN Marketplace


©1997-2009 Reed Business Information, a division of Reed Elsevier Inc. All rights reserved.
Use of this Web site is subject to its Terms of Use | Privacy Policy

Please visit these other Reed Business sites

ADVERTISEMENT
You will be redirected to your destination in few seconds.