Optimizing for low power in embedded MCU designs
Low-power embedded design is motivated by the need to run applications for as long as possible while consuming minimum power. In a battery-powered system, this need is magnified. Furthermore, low power implies lower cost of operation and smaller battery size to make applications more mobile. When energy comes at a premium as it does with today’s green initiatives, ensuring that an embedded design consumes as little energy as possible is even important for wall-powered applications.
Designing power-efficient applications also ensures less overhead to manage thermal dissipation, and heat generation is controlled at the source by optimizing the power consumed. Given these advantages, embedded systems engineers can no longer ignore the problem of optimizing power. This article will focus on the major factors contributing to power consumption in an embedded system by analyzing the various power modes which most microcontrollers offer. Then we will analyze a real-life example of an embedded application in terms of power consumption and how its efficiency can be maximized.
MCU Power Consumption
There are several points to be aware of when selecting an MCU or external components. The overall power consumption of an MCU is defined by its power consumption in different modes, typically active and standby (which includes sleep, hibernate, etc.), and taking into account the power consumed to transition from one mode to another.
Active power consumption by an MCU is the power consumed when the MCU is running. As almost all controllers are based upon CMOS logic, power is consumed primarily during the switching of transistors. As a starting point, we will analyze the power consumption of a CMOS inverter (Figure 1), which is the basic building block of any CMOS design.
CMOS circuits dissipate power by charging the various load capacitances whenever they are switched. When considering internal architectures, this is mainly the gate capacitance but there are drain and source capacitances too. Power is dissipated across the PMOS transistor while the load capacitor is being charged and across the NMOS when the load capacitor is being discharged. Instantaneous power dissipation across the NMOS transistor of a CMOS inverter is given by this equation:
PPMOSi = iL(Vdd - Vo)After substituting the value of iL:
PPMOSi= CL (Vdd - Vo) dVo/dtTotal power dissipation across the PMOS to switch the output from low to high can be found by integrating power dissipation across the PMOS to the charge load capacitor from 0 V to Vdd:
PMOS power consumption, PPMOS = ½ CLVdd2Similarly, to switch the output from high to low, total power dissipation across the NMOS is:
NMOS power consumption, PNMOS = ½ CLVdd2For one switching cycle, then, power dissipation is:
PTotal = PNMOS + PPMOS = CLVdd2If we define the average power in terms of the switching frequency (f), we get:
P = fCLVdd2From this equation we can see that power consumption depends upon the switching frequency, load capacitance, and supply voltage. Load capacitance is determined by the technology parameters and the design layout, and is therefore beyond the control of the embedded system designer. However, the other two factors – switching frequency and supply voltage – are factors a system designer can modify to impact power efficiency for a given microcontroller. Of course, the value of these parameters is also heavily dependent on the application of the design.
However, modern controllers run at an internal regulated voltage irrespective of the input voltage on the supply pins. There are controllers available in market that can be operated from 0.5 V to 5.5 V, but the internal core runs at a fixed regulated voltage such as 1.8V, no matter what the supply voltage is. Therefore, this parameter is not as important in the case of modern controllers as it was in the past. However, it is good to keep the supply voltage to the minimum requirement for regulators or near the voltage where the regulator is bypassed.
This leaves system designers have just one parameter available for affecting power control: switching frequency. Hence, in the active mode the minimum required operating speed for the MCU should be calculated and higher clock speeds should be avoided.
The other major factor which determines battery life is the standby power consumption of an embedded system. Most applications can spend significant periods of time in standby mode. In these systems, the major contributor to total system power consumption is the standby current rather than the active current. Standby current is the sum of leakage current, current consumed by power management circuits, clocking systems, power regulators, RTC, IOs, interrupt controllers, and so on. It varies from controller to controller, based upon the particular features and peripherals supported in standby mode.
Finally, the power consumed while transitioning from low power mode to active mode should not be overlooked. Devices may end up wasting a significant amount of power while transitioning between these two modes.
Based on these power modes, an MCU’s average power consumption is:
MCU average power consumption = (Active Power + Sleep Power + Transition Power) / Total Time, where Active Power= Time for which MCU is active * Active Current
Sleep Power= Time for which MCU is in sleep * Sleep Current.
Transition Power= Power consumed while making transition from sleep to active mode
The amount of time the system remains in active and standby mode is application-dependent. Some applications may need to have the MCU running all the time while some may need to have it running only occasionally. There are MCUs available on the market that come with power-down modes other than sleep, such as hibernate, deep sleep, or shut down, in which power consumption can be on the order of 10s of nA. System designers need to look at the power consumption of the mode in which the system has to operate for the majority of time to ensure that the overall design is as power efficient as it can be.
If we look deeper, there are some vital tradeoffs that must be considered. For some applications, it could prove beneficial for the system to run at a higher speed so it can finish its job faster and return to a low power mode. Other systems may do better running at a slower speed to keep active power consumption low. Here, the system designer has to analyze the best case for the application considering the current at different operating speeds, the time it takes to come out of low power mode, the current consumption in low power mode, and the frequency with which the system needs to switch between active and sleep modes.
MCU power consumption is only one factor when considering system power consumption. Some engineers tend to concentrate too much on the MCU and ignore the power consumed by external peripherals. If the objective is to optimize the power consumption of the entire embedded system solution, one cannot afford to do this.
Consider a simple temperature measurement system for home use (Figure 2).
This system has one ADC to measure the sensor voltage, one DAC to generate a reference, one LCD module to display data, and one MCU to process the data. Power should be saved beginning at the individual block level. If the power consumption is calculated for this system, it will be given by:
Total power consumption = MCU power consumption + ADC power consumption + DAC power consumption + LCD power consumption
For this system, the sample rate need not be very high since temperature does not change rapidly. Power consumption can be kept to a minimum by switching on the ADC and DAC only when required and optimizing the time ratio of MCU active and standby modes. If this system is made up of discrete components, it can get quite challenging to coordinate. Power consumption for discrete component-based architectures will look similar to the system shown in Figure 3.
In Figure 3, standby current is contributed to by MCU standby current and the active current of the ADC, DAC and LCD. To save ADC power consumption, the ADC may have an option by which the MCU can stop ADC conversion before it goes to sleep. However, there will still be some standby current for ADC and similarly for the DAC. Alternatively, the system could be implemented using a system-on-chip (SoC) architecture where all of the peripherals are integrated onto a single chip along with the ability to control the power of each individual peripheral. Power consumption of such a system will look similar to that shown in Figure 4 and can lead to a dramatic reduction in power consumption compared to a discrete component-based implementation.
Click on image to enlarge.
When designing any system, we should use what is needed rather than simply using what is available. Choosing a faster or more sophisticated component than is needed results in higher cost and lower power efficiency. For example, a 20-bit ADC running at 1 Msps is clearly more than is needed for a temperature measurement application. In addition, the ADC needs a high-frequency operating clock to sample at this rate.
Advancements in SoC technology allow developers to access a wide range of on-chip peripherals such as filters, ADCs, DACs, Op-amps, and programmable analog and digital blocks. For example, PSoC devices from Cypress Semiconductors have a wide operating frequency range with programmable clock sources for different blocks, including the MCU, and support numerous power management modes. These modes range from active mode, where all the features on the device are available, to hibernate modes, where current can be as low as 100 nA while retaining the contents of configuration registers and RAM.
As complex as SoC architectures are, they represent almost the complete system, making it more straightforward to compute power consumption. For example, if the system is doing nothing, then the standby current of the whole system can be as low as 100 nA. Since peripherals and the MCU can be switched on or off individually, only the appropriate blocks need to resume operation after the next wake up event. This is one of the key benefits of an SoC can have from a system point of view.
In some systems, for some periods the only hardware functions needed do not require an MCU, such as when generating a waveform using a DAC. This task can be completed by the DMA (Direct Memory Access) and DAC without the MCU, and so the MCU can be switched off. SoCs enable developers to design ultra-low-power embedded systems that are also cost and space efficient, with the added advantage of fast time to market.
A system’s average power calculation in a SoC-based system becomes more complex since along with the average MCU current, we need to consider the operating state of each individual peripheral on the chip. Average system current is:
Battery life is a critical specification for any battery-powered application. Battery ratings are given in units of mA -Hr, meaning the battery can supply ‘X’ mA of current for one hour. If we know the average current, we can calculate battery life:
This equation gives the battery life in hours if Iavg is given in mA.
Most consumers care about power consumption in both wall-powered and battery-powered devices. In today’s competitive market, designing a product that consumes higher power or costs more than competitive products can result in reduced market success. When optimizing power consumption is a major criterion, designers should look at critical parameters such as choosing the appropriate components and making sure they are not overrated for the desired end application, as well as making sure the system does not operate at higher speeds than required. In addition, developers will want to seriously consider how long the system spends in active and standby modes and the relative power consumption in each.
Sachin Gupta is Product Marketing Engineer with Cypress Semiconductor. He holds a B.Tech in Electronics and Communication from Guru Gobind Singh Indraprastha University, Delhi. He has several years of experience in mixed signal applications development.