What Every Programmer Should Know About Memory
Introduction to Embedded Systems
Embedded Systems - Theory and Design Methodology
Microcontroller Programming and Interfacing
Introduction to Microcontrollers
1 - Beginnings
3 - Hello World
4 - More On GPIO
5 - Interrupts
7 - Timers
8 - Adding Some Real-World Hardware
10 - Buttons and Bouncing
Would you like to be notified by email when Jason Sachs publishes a new blog?
If you've ever designed or purchased a power supply, chances are you have had to work with efficiency calculations. I can remember in my beginning electronic circuits course in college, in the last lecture when the professor was talking about switching power converters, and saying how all of a sudden you could take a linear regulator that was 40% efficient and turn it into a switching regulator that was 80% efficient. I think that was the nail in the coffin for any plans I had to pursue a different major. It was kind of like saying to treasure hunters, "Yeah, those pirate's chests full of gold coins are nice, but look what's in this cave back here...."
Well, efficiency has a double-edged sword. Twenty years ago, switching converters were a lot harder to justify (except in PC power supplies, where there really wasn't any choice anymore, and the sales volumes made it the norm rather than the exception), and in many cases just going from a linear regulator to a switching converter was enough to keep people satisfied for power consumption. Now it's a lot less expensive, and there are demands to achieve certain efficiency standards: where power supplies were 80% efficient, now people want them to be 90% efficient or 95% efficient; where some high-power converters were 95% efficient, people want them to be 97% efficient.
A former coworker of mine, who's a systems engineer working on batteries and motors, used to harp on the fact that efficiency was a misleading statistic; people should really focus on power losses instead. This article is dedicated to his philosophy and to spreading the word.
First of all, what is efficiency? It's the ratio of delivered power to consumed power: if you draw 100 watts from the AC mains, and you deliver 90 watts of mechanical power with a motor, then that motor is 90% efficient.
But really this is backwards: nobody goes to a store and says "I have an electric outlet that supplies 100W, what's the most efficient motor you have? Ooh, that's 90% efficient, that means I get 90W of mechanical power out!" In reality it's demand driven: you need that 90W of mechanical power no matter how efficient or inefficient the motor is. If the motor's 50% efficient, you draw 180W from the AC mains. If the motor's 95% efficient, you draw 94.7W from the AC mains.
Mathematically, we have this equation for the efficiency η:
$$ \eta = \frac{P _ {out}}{P _ {in}} = \frac{P _ {out}}{P _ {out} + P _ {loss}} $$
Let's invert the equation:
$$ \frac{1}{\eta} = \frac{P _ {in}}{P _ {out}} = \frac{P _ {out} + P _ {loss}}{P _ {out} } = 1 + \frac{ P _ {loss}}{P _ {out}}$$
If something is 50% efficient, the losses are equal to P_{out}. If something is 80% efficient, the losses are equal to 25% of P_{out}. If something is 95% efficient, the losses are equal to 1/19 of P_{out}. You get the picture. In fact, I would call this the relative inefficiency, a backwards epsilon: ∍
$$ \ni \, = \frac{ P _ {loss}}{P _ {out}} = \frac{1}{\eta} - 1 $$
Inefficiency in power calculations is just like a sales tax. In most cases you're going to spend the energy you need to, in order to deliver the output power, and this extra energy is an unwanted but necessary cost of power transfer. (In a few cases, like battery-powered devices, the amount of energy you can spend is a fixed constraint, and here efficiency tells you how much of it you have available to use.)
But a lot of times it's not even relative inefficiency that makes sense to calculate; the losses themselves are the most important thing. Here's a graph of efficiency vs. output current for a small 2W power supply (Recom RS series):
We'll do one of my favorite activities (don't miss the sarcasm), called Read the Data Off the Datasheet Graph. Let's see, at 5% load the efficiency's about 20%; at 10% load it's about 33% efficient, at 20% load it's about 50% efficient, at 40% load it's about 66% efficient, at 60% load it's about 75% efficient, at 80% load it's about 79% efficient, and at 100% load it's about 81% efficient. Let's graph power loss (as a fraction of maximum load) as a function of load power:
import numpy as np import matplotlib.pyplot as plt Pout = np.array([0.05, 0.1, 0.2, 0.4, 0.6, 0.8, 1.0]) eff = np.array([0.2, 0.33, 0.5, 0.66, 0.75, 0.79, 0.81]) Ploss = (1/eff - 1)*Pout plt.plot(Pout,Ploss) plt.xlabel('output power (fraction of max load)') plt.ylabel('power loss');
Huh, that's kind of interesting; the power loss is relatively constant, about 20% of max load (20% of 2W = 0.4W in this case), until you get to higher loads where the power loss goes up a little bit, maybe 10% of the increase in load power above 60% of maximum load: incrementally this power supply is about 90% efficient; for every 100mW of extra output power, it uses up 10mW of extra input power. At low load levels it takes a certain amount of power (again, 0.4W in this case) just to operate.
And this kind of information is more directly useful.
If you're careful, and you have access to a well-insulated thermal chamber (aka "styrofoam beer cooler") you can actually measure power loss directly:
Put your power conversion system inside a thermal chamber, aside from the wires leading into and out of it, along with a thermocouple tied to a small block of metal (I like aluminum) for stability.
Put the block of metal in close thermal proximity to your power conversion system. That usually means to attach the two directly together; if the power conversion system has a flat heat plate, place it directly against the block of metal, so the surfaces are next to each other. Thermally conductive grease is an option, but not really necessary as long as the thermal chamber is well-insulated.
Run it for a specific amount of time T, while taking temperature readings. You will want to do this for a time that is long enough so see a measurable temperature rise, but not long enough that the power conversion system overheats or the rate of increase in temperature drops off and the temperature begins to stabilize.
Calculate energy loss = temperature rise (in degrees C = degrees K) * thermal capacity in joules per kelvin.
What's the thermal capacity? Well, if your block of metal is a common type of metal, you can calculate it by knowing the specific heat capacity, and multiplying by the metal mass; aluminum's is 0.897 joules / kelvin per gram. But it may be better to just figure out the heat capacity empirically, by doing the same experiment with a known amount of power loss, e.g. a power resistor tied to the block of metal, where you run a fixed current through it. If the power conversion system has an appreciable amount of metal itself, either make sure the block of metal is much larger, or you'll have to estimate the thermal capacity of the power conversion system.
Then compute power loss by taking the energy loss and dividing by the time T. It's even better if you graph the temperature readings vs. time and compute the initial slope once it starts heating up:
from scipy.signal import lfilter t = np.linspace(0,720,120) dt = t[1]-t[0] P = np.ones_like(t)*100 plt.figure(figsize=(10,5),dpi=80) plt.plot(t,P) a1 = 0.08*(dt/60) a2 = 4*(dt/60) lpf1 = lambda x, alpha: lfilter([alpha],[1,alpha-1],x) def frepeat(f,n,*args): def h(x): y = x for i in xrange(n): y = f(y, *args) return y return h temperature = lpf1(frepeat(lpf1,4,a2)(P),a1) plt.plot(t,temperature,'.') tfit = [0.42*60,5*60]; tempfit=[0,32] plt.plot(tfit,tempfit,'-') plt.ylim(0,60); plt.xlim(0,720); plt.xticks(np.arange(13)*60) plt.xlabel('time (sec)') plt.ylabel('temperature rise (C)') m = (tempfit[1]-tempfit[0])/(tfit[1]-tfit[0]) plt.legend(('raw data','max slope = %.3f' % m),'best')
This gives you the temperature rise rate (kelvins per second), and you can multiply by thermal capacity to get joules per second = power in watts.
Empirical measurements are fun! They take a while to setup correctly, and although it's tough to estimate exactly how accurate they are, often they are more accurate than theoretical calculations where you make an incorrect assumption.
Empirical measurements of power losses using this technique are also usually more accurate than subtracting input and output power measurements. If you're measuring a 95% efficient power supply running at 100W input and 95W output, and you have voltage and current measurements that each have 0.2% error, you could be off by 0.4W in input power, and 0.4W in output power, meaning up to 0.8W worst-case error in power loss when you subtract the two (100.4W - 94.6W = 5.8W, or 99.6W - 95.4W = 4.2W, vs. the exact amount of 5.0W). That's 16% error in a 5W power loss measurement, from 0.2% accuracy test equipment! It's not too difficult to do better if you measure power loss directly via temperature rise measurements.
The reason to talk about losses comes into play when the efficiency gets closer to 100%. When we talk about systems that are 94% efficient and 97% efficient, they sound about the same, whereas in reality the 97% efficient system has only half the power losses of the 94% efficient system. What's the impact on your power budget between these two systems? Probably not too much; you'd pay a little more for the extra energy used in a 94% efficient system. It may or may not be worth the extra cost of a 97% efficient system. But from a system design standpoint, the 97% efficient system is only allowed to waste half as much power as its 94% efficient competitor! That's a huge change in design requirements, and not very easy to achieve even with modern power supply design techniques.
In fact, the only real driver of high-efficiency in the above-90% market (aside from marketing power, or meeting a high-efficiency standard) is keeping power losses low for thermal reasons: If I have a 10kW power converter that is 94% efficient, it has to dissipate 640W of heat. If I have a 10kW power converter that is 97% efficient, it only has to dissipate 310W of heat. That means less expensive fans or heat sinks, or no fans (natural convection cooling), or components that don't get as hot. But as far as the cost of the power goes, we're talking 10.64kW vs. 10.31kW; not a very big change.
Think about these issues the next time you work on a system that has power efficiency specifications.
May your power electronics always stay cool!
© 2013 Jason M. Sachs, all rights reserved.
import numpy as np
import matplotlib.pyplot as plt
Unsure why it doesn't want to plot on my system.