Energy monitoring and management is critical for battery-operated gadgets, but it’s useful in many other applications, like software-defined wide area networks. Shunt resistors can be combined with microprocessors to do it efficiently.
Energy monitoring and management are critical for portable, battery operated devices, but the process is becoming increasingly important in more and more applications. There are multiple ways to monitor energy, but shunt resistors tend to be less expensive than other implementations, and more efficient energy management can be achieved by combining shunt resistors with microprocessors.
Systems as vast as data centers can be made significantly more energy-efficient and less costly by careful energy monitoring and management, but the focus understandably remains on battery operated devices. Since the introduction of cell phones two decades ago, the number of rechargeable battery powered devices has increased exponentially. Techniques pioneered in cell phones are currently being adopted by laptop manufacturers; we will review some of those efforts below.
Hardware developers tend to focus more and more on low-power implementations, while increasing capabilities and decreasing size and cost. Software developers also aim to lower power consumption by researching and developing new, power-aware approaches to older algorithms. That includes both operating systems (energy-aware scheduling, for example) and applications, including newer apps such as machine learning.
Energy versus power
Power is the instantaneous consumption of energy. In electronics, power is the product between instantaneous voltage and current (EDN readers should find the following equation familiar). The basic measure, the watt, is also a Joule per second.
Energy is the product between power and time. It is what circuits consume and what batteries store. Managing power usually means managing instantaneous currents and voltages to satisfy power transport capabilities and loading conditions. Energy monitoring generally gives information on energy consumption to help developers with battery management and overall power benchmarking. Active energy management occurs when energy is monitored by software specifically designed to take actions based on certain loads.
Active energy management can be done either automatically, based on predefined settings, or manually when the software starts, to give certain recommendations and suggestions to the user. For example, when most laptops run on battery instead of AC power, the processor performance may be automatically reduced and graphics may be switched to the integrated graphics processor, which is lower power with less performance compared to the dedicated processor. Some of the laptop peripherals can be switched off to achieve better battery life, or the user can receive notifications to reduce screen brightness or keyboard backlight.
Most smartphones have energy-saving options which are suggested by the active energy management software when the battery drops below a certain level. This includes turning off some active internet connections, reducing screen brightness, and others.
The examples don’t stop with battery-powered devices, however. Servers carefully monitor power consumption and load level to decide if certain services can be stopped or suspended. In the case of virtual servers where an application can scale up and down depending on the total current usage and usage predictions based on statistics, hypervisors can fully shutdown some of the virtual machines.
Another application where active energy management can be beneficial is in debugging. Monitoring energy can provide powerful information to whether overall systems, or parts of them, perform within boundaries.
Circuits for measuring DC power and energy
Measuring precise power requires measuring both voltages and currents with high accuracy. Power measured and accumulated over a period of time results in energy. Because power consumption isn’t constant in most cases, voltage and current measurements must be done with a selected bandwidth. Some typical examples of DC voltage measuring circuits include the simple voltage divider on the left in Figure 1 and the buffered voltage divider depicted next to it.
While both circuits can offer high accuracy with proper calibration, the buffered voltage divider, while being more expensive than its unbuffered twin, usually consumes less power and is used especially when measuring very low DC signals.
While current (including DC) can also be measured with the help of the Hall effect, this article focuses on measuring DC current with shunt resistors, because they are more commonly used and less expensive. The shunt resistor is a low-valued resistor that is connected in series with the circuit. When current flows through it, a small voltage drops across the shunt. The voltage drop is proportional to the current, as in the following equation, and is usually amplified with an op-amp.
As the shunt resistor is in series with the rest of the circuit, it can be placed in either of two positions: high-side, where one of the shunt’s terminals is directly connected to the bus voltage, or low-side, where it is connected to the ground, as depicted in Figure 2. In both cases, the small shunt voltage drop will be present, and the overall voltage applied to the circuit will be lower. Be aware the position of the shunt has implications.
If the shunt is placed on the low-side (Figure 2, right), the voltage across it is directly linked to ground. Since shunt resistors are usually small, voltage drops across them are small as well, making it very easy for the current measurement circuit to use a cheap, low-voltage op-amp to amplify the voltage drop. This is highly desired for cost reasons. The main downside of low-side shunts is that the overall circuit is not connected directly to ground anymore, but to something higher than ground. Shunt voltage drops are usually in the range of millivolts.
On the other hand, if the shunt is placed on the high-side (Figure 2, left), then the circuit is directly connected to ground, removing any ground bouncing effects. This is highly desired when the circuit does precise measurement or must provide precise outputs. The only downside of this method is that a higher-voltage differential op-amp circuit needs to be used, and, depending on the bandwidth of the op-amp, the price can increase.
While voltage, current, and even power itself can be measured with analog circuits quite easily and at a low cost, energy requires more complex circuitry. The classic approach to measuring energy is to measure voltage and current using analog circuitry then convert the signals to digital using an analog to digital converter (ADC), which outputs the data to a microcontroller. The microcontroller’s responsibility is to sample the signal’s accumulated power over time, which results in energy measurements. The typical circuit for measuring energy is illustrated in Figure 3.
Adding a microcontroller to the measuring circuit has advantages and disadvantages. On one hand, it can offer lots of flexibility in computation algorithms, monitoring different behaviors, and doing more detailed reports – for example, hourly, daily, etc. One other advantage is that a microcontroller can do more than energy measurements. It can trigger events, run custom state machines or virtually anything the engineer needs it to do. The cost and bill of materials (BOM) increase aren’t a problem if the system already needed a microcontroller.
On the other hand, the disadvantages of monitoring energy with the microcontroller includes the increase in total power consumption of the measurement system, more code development and overhead, and, depending on the accuracy desired, sometimes external ADCs may be needed.
As the demand for DC energy monitoring features has grown over the course of years, several integrated circuits were developed for such applications. An example of such an IC is the PAC1934 from Microchip. Such an IC can easily sample up to 4 channels simultaneously, the only required external component being the shunt resistor.
The basic circuit diagram is presented in Figure 4. It integrates op-amps, ADCs, arithmetic calculation logic, memory and a standard interface in order to connect it to the system (usually I2C or SPI). The advantages of using an integrated circuit vs. the classic approach is immediately observed in cost, as the BOM reduces significantly, and of course in PCB size, as everything needed for energy measurement is already integrated into one IC.
Benefits of active energy monitoring
With a flexible configuration to fit most use cases, a specialized IC can accumulate power over large periods of time with very little power consumption. Usually, the power sampling rate varies from 8 samples per second (sps) up to more than 1 ksps. PAC1934, for example, when running at 8 sps, can accumulate power over more than 36 hours, with a current of less than 16 microamps while all 4 channels are fully active and running at 16-bit resolution, without any intervention from the software.
By allowing sampling rate changes on the fly, the use cases extend. An example use case is when the IC is used in a standard laptop to monitor power rails. The monitoring can be done at 1024 sps while the laptop is running and active, and then the monitoring speed can drop to 8 sps when the laptop is running in suspended state because the power usages won’t fluctuate too much in the suspended state. Additionally, lowering the sampling rate reduces energy monitoring power consumption, without compromising performance.
One of the most popular use case of active energy monitoring is battery fuel gauging. A specialized IC monitors battery voltage and current and always knows how much energy the battery currently has. More advanced fuel gauges can also detect when the battery encounters certain issues. For example, it can track battery voltage versus energy, and when they don’t correspond anymore, it means that the battery’s overall capacity is shrinking due to age and other factors.
Active energy monitoring is also the core of a standard battery management system (BMS). The BMS is a circuit used in multi-cell battery packs, and it is responsible for safely charging and discharging the pack, where it actively measures voltage and current to ensure each battery cell has the same parameters. BMS features also include detecting faulty cells, and disconnecting the pack when the voltage is either too high or too low.
Another popular use case of active energy monitoring is using it together with an operating system on smartphones and tables, and Linux or Microsoft Windows on laptops, computers and servers. In the case of smartphones and tablets, the operating system monitors energy used by different services and applications through various methods. In its early stages, the energy was not directly measured, and the system estimated it based on CPU, GPU and screen usage, through the use of table data for power consumption in various operating points. The estimated power usage data was reported in a form of statistics for the user to decide on how they wanted to operate the device further.
Laptop energy efforts
On laptops and personal computers, Microsoft introduced the Energy Estimation Engine (E3) in Windows 8. In its early stages, E3 worked similar to the estimation algorithms in smartphones, with the ability to track every tasks’ power consumption by estimating it based on the usage of various resources (processor, graphics, disk, memory, network, display and others).
E3 also introduced the energy metering interface (EMI), which allows for system manufacturers to add and declare energy measurement sensors physically available to the system. When they are present, the E3 makes use of such sensors to accurately measure power and energy, instead of only doing estimations. Certain laptop manufacturers are already implementing these features into their laptops.
There were past initiatives as well (i.e. Sony monitoring power in the Vaio laptops), but there was no operating system support for it, and only proprietary applications could access the data.
Linux does not have an equivalent for Microsoft’s E3, but Linux developers are reportedly working on it. The Industrial I/O subsystem supports adding various sensors to the operating system, providing a very simple and powerful interface to the user space application (file-based interface). However, at the time when this article was written, the Industrial I/O subsystem is currently a Kernel extension, which is not part of the default Linux build. Linux also supports energy aware scheduling and intelligent power allocation, an algorithm designed to be used more in the embedded Linux area, allowing the system to decide how to schedule different tasks, while also having thermal considerations (power consumption results in CPU/GPU heating).
Another example of using energy measurement ICs worth noting is monitoring USB power and energy for various reasons and usage in server applications, as described in the first part of the article. Because servers are machines designed to continuously run without interruption, monitoring power consumption offers many benefits, from increasing overall power efficiency through active service control and meeting higher and higher power efficiency standards to allowing system administrators to perform predictive maintenance when certain parts of the server starts behaving differently in terms of power consumption (this might indicate future failure).
Summary
Depending on the need for energy monitoring, as well as other functions the system needs to perform, some approaches may be more suitable than others. The classic approach might be the winner in cases where an embedded system is built with its own purpose and it also needs to know its power consumption or have an energy estimation. It would also be recommended that the microcontroller has an internal ADC, so that the costs for energy monitoring features would be minimal. In this approach, only the external analog circuitry used for voltage and current sensing is needed. Other cases where the classic approach is more suitable than the integrated one is when very high accuracy is needed and BOM cost and power consumption are not an issue.
The integrated approach is more suitable when energy measurement is integrated along with an operating system because the integrated solution is already built for this. With proper drivers, the system knows what to do. This is an advantage in instances where, for example, a lot of buses need to be monitored, because energy measurement ICs can usually measure more than one channel (thus, more than one bus). Additionally, multiple ICs can be used on the same communication bus (such as I2C or SPI).
Another case where the integrated solution wins is when measuring energy over longer periods of time while having the system in a very low power sleep mode or completely shut down. This relies on the fact that the integrated energy monitoring chips draw very little power and can make calculations and energy accumulations over certain periods of time by themselves, without any system intervention whatsoever.
And of course, when size matters in highly integrated and dense PCBs, such as the mainboards of phones, tablets or laptops, an integrated circuit always occupies less area than its equivalent discrete components.
Adrian Lita is an applications engineer in Microchip’s Mixed Signal and Linear Division.