Power Supplies, Regulators and Decoupling
Every circuit needs a steady supply. This volume works out how long a battery lasts and why its voltage sags, how a linear regulator holds 3.3 V and what heat it pays for that, how a buck converter does the same job far more efficiently by switching, why a small capacitor belongs beside every chip, and how a shared ground wire can quietly move a circuit's 0 V.
- How to estimate battery life from capacity and average current
- How a linear regulator works, what dropout means, and how hot it will get
- How a buck converter switches and filters its way to high efficiency
- Why decoupling capacitors are needed, and where they go
- How ground wires shift a circuit's 0 V, and how star grounding fixes it
- Volume 06 and the earlier volumes: Ohm's law, capacitors and inductors, diodes and transistors.
7.1 Batteries and capacity
A battery's capacity, in milliamp hours, says how long it can supply a current. Its internal resistance means its voltage sags as the current grows. Both decide how long a battery-powered circuit lasts.
Capacity
A battery is marked with its capacity in milliamp hours (mAh). It is the current it can give, multiplied by the hours it can give it for:
a 2000 mAh battery at 50 mA lasts 2000 mAh / 50 mA = 40 hours
energy stored: 3.7 V x 2 Ah = 7.4 Wh
That is a rough guide. Real batteries give less at high currents and in the cold.
Sleeping to save power
Battery gadgets, such as a sensor that reports once a minute, spend most of their time asleep. What matters is the average current:
asleep at 10 µA, awake at 20 mA for 1 percent of the time: average 210 µA
on 2000 mAh that lasts about 9528 hours - about 397 days
Awake all the time, the same battery would last 100 hours. Sleep is the biggest power saving in embedded design, and Embedded C from Zero shows how a program uses it.
Voltage sag
Volume 00 showed that every battery has an internal resistance. The more current it gives, the more voltage it loses inside itself:
circuit battery-sag: with a 1 kΩ load: 8.98 mA flows and V1 reads 8.98 V
circuit battery-sag: with a 88 Ω load: 100 mA flows and V1 reads 8.8 V
circuit battery-sag: with a 10 Ω load: 750 mA flows and V1 reads 7.5 V
A circuit that needs a steady voltage cannot rely on a battery alone. That is the job of a regulator.
Packs of cells
two 3.7 V 2000 mAh cells in series: 7.4 V and 2000 mAh; in parallel: 3.7 V and 4000 mAh
Cells in series add their voltages, as Volume 01 showed. Cells in parallel add their capacities.
A circuit draws 25 mA from a 1000 mAh battery. Roughly how long will it last?
Show the answer
Answer: B. Hours = capacity / current = 1000 mAh / 25 mA = 40 hours.
7.2 Linear regulators
A linear regulator holds its output at a fixed voltage by burning off the difference between its input and output as heat. It is simple and quiet, but wasteful when the difference is large.
Holding a voltage steady
A regulator has three pins: IN, OUT and GND. Whatever its input does, it keeps its output steady - as long as the input stays high enough. A low-dropout regulator, or LDO, needs its input only a little above its output:
circuit ldo: from 9 V: output 3.3 V; the load and the input both take 100 mA; U1 turns 570 mW into heat; efficiency 36.7%
circuit ldo: from 12 V: output 3.3 V; the load and the input both take 100 mA; U1 turns 870 mW into heat; efficiency 27.5%
circuit ldo: from 5 V: output 3.3 V; the load and the input both take 100 mA; U1 turns 170 mW into heat; efficiency 66.0%
Notice that the input current equals the output current. Inside, a linear regulator is a transistor that is deliberately only part on, like Volume 05's warm transistor. It drops whatever voltage it must, and the current flows straight through. So the heat is the voltage dropped times the current.
Dropout
Below its dropout voltage, the regulator has nothing left to drop, and its output simply follows the input:
from 3.5 V: U1 is in dropout: the output falls to 3.2 V
This regulator's dropout voltage is 0.3 V, so it needs at least 3.6 V in. Older regulators need 2 V or more.
Heat
The heat must go somewhere. A datasheet gives a package's thermal resistance: how many degrees it warms above the air for each watt:
temperature rise = heat x thermal resistance
570 mW in a package that rises 60 °C per watt: 34.2 °C above the air
870 mW in a small package that rises 200 °C per watt: 174 °C above the air - far too hot
Most chips must stay below about 125 °C inside. A regulator dropping a large voltage at a large current needs a big package, a heatsink - or a switching regulator instead.
A linear regulator gives 5 V at 200 mA from a 12 V input. How much heat does it make?
Show the answer
Answer: C. Heat = (12 V - 5 V) × 200 mA = 7 V × 0.2 A = 1.4 W.
7.3 Switching regulators
A switching regulator switches its input fully on and off very fast, and smooths the result with an inductor and a capacitor. Its switch is never part on, so it wastes far less than a linear regulator - often only a tenth of the power.
The buck converter
A buck converter steps a voltage down. It needs just a switch, a diode, an inductor and a capacitor:
The switch is on for part of each cycle. That share is the duty cycle. To get 3.3 V from 12 V, allowing for the diode's 0.7 V:
duty cycle = (Vout + 0.7 V) / (Vin + 0.7 V) = 4 V / 12.7 V = 31.5%
The whole circuit was simulated from the moment it was switched on, in tiny steps of time:
circuit buck: simulated for 5 ms from switch-on, in steps of 10 ns
the output settles at 3.30 V, with a ripple of 7.3 mV
the inductor current rises and falls between 0.71 A and 1.29 A
The inductor and capacitor form a low-pass filter, like Volume 03's RC filter. The square wave at the switch node averages 3.3 V, and the filter passes the average while blocking the fast switching.
Why it wastes so little
input power 3.79 W; output power 3.30 W; efficiency 87%
| Regulator | Input power | Heat | Efficiency |
|---|---|---|---|
| Linear (solved) | 12 W | 8.7 W | 27.5% |
| Buck (simulated) | 3.79 W | 0.49 W | 87% |
Almost all the buck converter's loss is the diode's 0.7 V while it carries the current. Real converters often replace the diode with a second transistor switch to do better still. The price is complexity, and electrical noise from the fast switching, which sensitive circuits sometimes cannot accept.
Why does a switching regulator waste so much less power than a linear one?
Show the answer
Answer: A. A fully-on switch has almost no voltage across it, and a fully-off switch carries no current, so neither wastes much. A linear regulator's transistor is always part on, with a large voltage and a large current at the same time.
7.4 Decoupling capacitors
Chips draw their current in short, sharp bursts every time they switch. A decoupling capacitor right beside each power pin supplies those bursts, so the chip's supply voltage stays steady.
Supply wiring is not perfect
The supply reaches a chip through wires or circuit-board tracks, and they have a little resistance and a little inductance. For a steady current, that hardly matters:
circuit decoupling: steady, the chip gets 3.29 V; Rw drops 10 mV
Bursts of current
When a chip's outputs switch, it draws a burst of current for a few nanoseconds. Volume 03 showed that an inductor fights any sudden change of current. So the wiring's inductance cannot deliver the burst:
a burst of 100 mA for 10 ns: charge = 100 mA x 10 ns = 1 nC
from C1: the supply dips by 1 nC / 100 nF = 10 mV
without C1, the current rising through Lw in 1 ns: V = 20 nH x 100 mA / 1 ns = 2 V
Without C1, the chip's supply could collapse by volts - enough to make it misbehave. With C1, the burst comes from charge stored right at the pins, and the supply barely moves. The wiring then refills C1 slowly between bursts.
Put a 100 nF ceramic capacitor beside every power pin of every chip, as close as possible, with a short path to ground. Add a bigger one, such as 10 µF, where the supply enters the board.
Placing the decoupling capacitor far from the chip. The track between them has its own inductance, which puts back the very problem the capacitor was there to solve.
What does a decoupling capacitor next to a chip do?
Show the answer
Answer: D. The supply wiring's inductance cannot deliver sudden bursts of current. The capacitor, right at the chip's pins, supplies them from its stored charge, so the supply voltage stays steady.
7.5 Ground and return paths
Every current flows back to its source through ground. If a large current shares a ground wire with a sensitive circuit, the wire's resistance shifts that circuit's ground. Give heavy loads their own return path.
Ground is a wire too
Schematics draw ground as one perfect 0 V point, but real ground wires have resistance. Here a motor and a microcontroller share one ground wire back to the battery:
circuit shared-ground: the motor takes 1.96 A and the microcontroller 9.8 mA; both return through Rg, so the microcontroller's ground sits 98.5 mV above the battery
The microcontroller's "0 V" is really almost 0.1 V. When the motor starts and stops, it jumps around - and every signal the microcontroller measures or sends jumps with it.
Star grounding
circuit star-ground: the microcontroller's ground now sits only 500 µV above the battery
Each part returns its current on its own wire, and the wires meet at one point: a star ground. The motor's big current no longer passes through the microcontroller's ground. On circuit boards, a whole layer of copper called a ground plane does the same job, with almost no resistance anywhere.
Why does a motor sharing a ground wire with a microcontroller cause trouble?
Show the answer
Answer: B. Current times resistance gives a voltage. The motor's amps through even 0.05 Ω of shared wire lift the microcontroller's ground by about 0.1 V, and it moves every time the motor current changes.
What you learned
- Battery life is capacity divided by the average current; sleeping saves the most.
- A battery's voltage sags under load because of its internal resistance.
- A linear regulator burns (Vin - Vout) × I as heat, and drops out when its input gets too low.
- A buck converter switches fully on and off and filters the result, reaching around 90% efficiency.
- A 100 nF decoupling capacitor beside each power pin supplies the chip's bursts of current.
- Shared ground wires shift grounds; star grounding and ground planes keep return currents apart.
Key words from this volume
Every word below has a plain-English entry in the glossary.
- Battery capacity
- Linear regulator
- Dropout voltage
- Switching regulator
- Buck converter
- Duty cycle
- Decoupling capacitor
- Return path
- Star ground
Practice
Battery life
A 1200 mAh battery powers a circuit that draws 80 mA. Roughly how long does it last?
Show the solution
a 1200 mAh battery at 80 mA lasts 15 hours
A regulator's heat
The LDO circuit runs from 5 V with a 16.5 Ω load. How much current flows, and how much heat does U1 make?
Show the solution
5 V to 3.3 V at 200 mA: U1 turns 340 mW into heat
A smaller capacitor
In the decoupling example, C1 is replaced by 10 nF. How far does the supply dip during the burst?
Show the solution
10 nF instead of 100 nF: the supply dips by 1 nC / 10 nF = 100 mV
Interview corner
Linear or switching
"When would you choose a linear regulator over a switching regulator?"
Show the solution
"When the voltage difference or the current is small, so the heat is acceptable, or when noise matters - for an analogue sensor, a radio or an audio circuit. A linear regulator is simple, cheap and quiet, and it also filters noise coming in on its input. A switching regulator is the choice when efficiency matters - battery power, a large drop, or a large current - accepting the switching noise and the extra parts. A common compromise is a switcher to get close, followed by an LDO for the sensitive parts."
Volume 08 reads real datasheets and schematics, and puts the bench tools to work on a first real build.