Power Supply Design

Converting raw input power (wall adapter, battery, USB) into the clean, stable voltage rails your circuit needs. Get this wrong and everything downstream misbehaves — brownouts, noise, resets, or released magic smoke.

Why It Matters

Every embedded system needs at least one regulated supply (often 3.3V and 5V). Choosing between linear and switching regulators, sizing capacitors, and adding protection determines whether a design is reliable or fragile. A bad power supply is the #1 cause of mysterious intermittent failures.

How It Works

Linear vs Switching Regulators

Linear (LDO)Switching (Buck)
EfficiencyVout/Vin (poor for large drop)85-95% typical
NoiseVery low output rippleSwitching noise on output
Complexity3 components (IC + 2 caps)6+ components (IC, inductor, diodes, caps)
HeatHigh at large Vin-Vout or high currentLow
CostCheapModerate
Best forLow current, small Vin-Vout drop, noise-sensitive analogHigh current, large Vin-Vout drop, battery-powered

LDO Design (Linear)

An LDO (Low Drop-Out regulator) is the simplest voltage regulator.

         Vin           Vout
    ──────┤ LM7805 ├──────
          |         |
    [Cin] |         | [Cout]
    100nF |         | 100nF
          |         |
         GND       GND

Key parameter: dropout voltage. The minimum Vin - Vout the regulator needs to function. The LM7805 needs ~2V dropout. True LDOs (like AMS1117-3.3) need only 1V or less.

Power dissipation: P = (Vin - Vout) x I_load

Example: 12V in, 3.3V out, 500mA: (12 - 3.3) x 0.5 = 4.35W. That is a lot of heat — use a switching regulator instead.

Common LDO ICs:

PartVoutMax IDropoutNotes
LM78055V fixed1.5A2VClassic, needs heatsink
AMS1117-3.33.3V fixed1A1.1VCommon on dev boards
MCP1700-3.33.3V fixed250mA178mVUltra-low dropout, battery
LM317Adjustable1.5A3VSet with 2 resistors

Buck Converter (Switching Step-Down)

Chops the input at high frequency (100kHz - 2MHz), stores energy in an inductor during on-time, releases it during off-time. The output is a smoothed average.

    Vin ──[SW]──┐
                |
               [L]  inductor
                |
                +──── Vout
                |
              [Cout]
                |
               GND

SW closes: current ramps up through L, energy stored in L
SW opens:  inductor current continues through freewheeling diode,
           energy transferred to Cout and load

Duty cycle: D = Vout / Vin (ideal). 12V to 5V: D = 42%.

The inductor and output capacitor form an LC filter that smooths the chopped waveform into DC. Inductor size, switching frequency, and capacitor ESR all affect output ripple.

Capacitor Selection (ESR Matters)

Output capacitors are not just about capacitance — their ESR (Equivalent Series Resistance) directly affects output voltage ripple.

V_ripple = I_load x ESR + delta_Q / C

Low-ESR ceramic capacitors (MLCC) are best for switching regulators. Electrolytic caps have higher ESR but provide bulk energy storage. The common pattern:

  • 10-22uF ceramic close to the regulator output (low ripple)
  • 100-470uF electrolytic for bulk storage (handles load transients)

See Capacitors and Inductors for details on cap types and ESR.

Power Budget Example

System: battery-powered sensor node
Battery: 3.7V LiPo, 2000mAh

Component          | Voltage | Current | Power
MCU (ESP32 active) | 3.3V    | 160mA   | 528mW
Sensor (I2C)       | 3.3V    | 5mA     | 16.5mW
LoRa radio (TX)    | 3.3V    | 120mA   | 396mW
LED indicator      | 3.3V    | 10mA    | 33mW
─────────────────────────────────────────────────
Total 3.3V rail             | 295mA   | 973.5mW

Regulator: MCP1700-3.3 (dropout 178mV, 250mA max)
Problem: 295mA > 250mA max. Need a bigger LDO or a buck converter.

Using buck (90% efficient): Pin = 973.5 / 0.9 = 1082mW
Battery current: 1082 / 3.7 = 292mA
Battery life: 2000mAh / 292mA = 6.8 hours (continuous TX)

Protection Circuits

Reverse polarity protection (simplest: P-MOSFET in series):

    Vin ──┤S  G├──┐
          P-FET   |
          ├D      [R] 100k
          |       |
          +───────+──── Vout (protected)
                  |
                 GND

If Vin is reversed, Vgs > 0 and P-FET stays off. Circuit protected.

Overcurrent protection: use a polyfuse (resettable PTC fuse) in series with Vin. Trips at rated current, resets when cooled. Example: MF-R050 (500mA hold, 1A trip).

Overvoltage protection: TVS diode (transient voltage suppressor) clamps voltage spikes. Place across the input after the fuse.

Calculation Example

# LDO thermal check: can we use AMS1117-3.3 with 5V USB input?
vin, vout, i_load = 5.0, 3.3, 0.8  # 800mA load
dropout = 1.1  # AMS1117 dropout
headroom = vin - vout  # 1.7V (> dropout, OK)
 
p_dissipated = (vin - vout) * i_load  # 1.36W
# AMS1117 in SOT-223: thermal resistance ~90 C/W (junction to ambient)
theta_ja = 90  # C/W
t_ambient = 25
t_junction = t_ambient + p_dissipated * theta_ja  # 147C (max is 125C!)
# FAIL: need a heatsink, a bigger package, or a buck converter
 
# Buck converter duty cycle
vin_buck, vout_buck = 12.0, 5.0
duty = vout_buck / vin_buck       # 0.417 (41.7%)
f_sw = 500e3  # 500kHz switching frequency
# Inductor sizing (rule of thumb: 30% ripple current)
i_out = 2.0
delta_i = 0.3 * i_out             # 0.6A ripple
L_min = (vin_buck - vout_buck) * duty / (f_sw * delta_i)
# L_min = 16.3 uH -> use 22uH standard value