The LM317 regulator
The LM317 is a classic three-terminal adjustable linear regulator. It keeps 1.25 V between its output and adjust (ADJ) pins, and two resistors scale that reference to any output from 1.25 V to about 37 V, at up to 1.5 A.
The formula
With R1 between OUT and ADJ, and R2 between ADJ and ground:
Vout = 1.25 × (1 + R2 ÷ R1) + Iadj × R2
Iadj is about 50 µA and usually adds only a few tens of millivolts. To find R2 for a target voltage: R2 = (Vout ÷ 1.25 − 1) × R1.
Example
R1 = 240 Ω and R2 = 720 Ω:
- Vout = 1.25 × (1 + 3) + 0.00005 × 720 ≈ 5.04 V.
For 9 V with the same R1: R2 = (9 ÷ 1.25 − 1) × 240 = 1,488 Ω, so use 1.5 kΩ, or a 1.2 kΩ resistor plus a 500 Ω trimmer.
Why R1 is usually 240 Ω
The LM317 needs a minimum load current, about 3.5 to 10 mA, to regulate. With R1 = 240 Ω, the divider itself draws 1.25 ÷ 240 ≈ 5.2 mA. Newer designs often use 120 Ω for a guaranteed 10 mA.
Headroom (dropout)
The input must be about 3 V above the output at full current for the LM317 to regulate. For lower headroom, use a low-dropout (LDO) regulator.
Heat
A linear regulator burns the excess voltage as heat:
P = (Vin − Vout) × Iload
From 12 V to 5 V at 0.5 A, the LM317 dissipates about 3.5 W. A TO-220 package without a heat sink handles only about 1 to 2 W, so this design needs a heat sink. Efficiency is only Vout ÷ Vin, about 42% here; for large drops or currents, a switching (buck) converter wastes far less.
Good practice
- Add a 0.1 µF ceramic capacitor at the input and 1 µF or more at the output.
- A 10 µF capacitor from ADJ to ground improves ripple rejection; add a protection diode if you do.
- Place R1 close to the regulator so the reference is not affected by voltage drops in the wiring.
- The LM317 also makes a simple constant-current source: a single resistor R between OUT and ADJ sets I = 1.25 ÷ R.