Volume 07 Beginner 5 sub-modules ~15 min read

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.

You will learn
  • 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
You need
  • 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:

A 9 V battery, with its internal resistance, driving a load + V Rint 2 Ω B1 9 V RL 88 Ω V1
Figure 7.1 - The battery is drawn as a perfect 9 V cell B1 with its internal resistance Rint. The voltmeter reads what the load really gets: the terminal voltage.

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.

Quick check

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:

A 3.3 V low-dropout regulator fed from a 9 V battery + U1 IN OUT GND B1 9 V C1 10 µF C2 10 µF RL 33 Ω 3.3 V regulator
Figure 7.2 - U1 holds its output at 3.3 V whatever its input does, as long as the input stays at least 0.3 V higher. C1 and C2 are the small capacitors its datasheet asks for. RL is the circuit being powered.

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.

Quick check

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:

A buck converter: a switch, a diode, an inductor and a capacitor + B1 12 V S1 D1 L1 47 µH C1 100 µF RL 3.3 Ω Vsw
Figure 7.3 - S1 is a transistor switched on and off 100 000 times a second; it is drawn open. Vsw marks the switch node. While it is on, the 12 V drives current through L1. While it is off, L1 keeps the current flowing round through D1. C1 smooths the result for the load RL.

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 switch node and the output of the buck converter over three cycles 0 5 10 15 20 25 30 -2 0 2 4 6 8 10 12 14 time (µs) voltage (V) switch node output
Figure 7.4 - The switch node jumps between 12 V while S1 is on and -0.7 V while D1 carries the current. The inductor and capacitor average this into a steady 3.3 V.
The inductor current over the same three cycles 0 5 10 15 20 25 30 0 0.25 0.5 0.75 1 1.25 1.5 time (µs) inductor current (A)
Figure 7.5 - While S1 is on, the current climbs; while it is off, the current keeps flowing through D1 and falls. It averages the 1 A the load takes.

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.

Quick check

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:

A chip's supply, with the wiring's resistance and inductance, and a decoupling capacitor + B1 3.3 V Rw 0.1 Ω Lw 20 nH C1 100 nF ICHIP 100 mA chip VDD
Figure 7.6 - The chip is drawn as the current it draws, ICHIP. The supply reaches it through wiring with resistance Rw and inductance Lw. C1 is the decoupling capacitor, right at the chip's power pins.

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.

Remember

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.

Common mistake

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.

Quick check

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:

A motor and a microcontroller sharing one ground wire + B1 5 V RM 2.5 Ω RMCU 500 Ω Rg 0.05 Ω MCU ground
Figure 7.7 - The motor is drawn as the 2.5 ohms it looks like while running, and the microcontroller as a 500 ohm load. Both return their current through the same 0.05 ohm ground wire Rg.

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

The same circuit with star grounding + B1 5 V RM 2.5 Ω RMCU 500 Ω Rg 0.05 Ω Rg2 0.05 Ω MCU ground
Figure 7.8 - Now the microcontroller has its own ground wire, Rg2, back to the battery. The motor's large current no longer flows through the microcontroller's ground.

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.

Quick check

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

Key words from this volume

Every word below has a plain-English entry in the glossary.

Practice

Practice 1

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
Practice 2

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
Practice 3

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

Interview question 1

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.