The formula
The LM317 keeps 1.25 V (VREF) between its output and ADJ pins. R1 sets a current of 1.25 V ÷ R1, which also flows through R2, along with a small current from the ADJ pin (IADJ, typically 50 µA). From the Texas Instruments datasheet:
VOUT = 1.25 × (1 + R2 / R1) + IADJ × R2
Worked example. R1 = 240 Ω and R2 = 720 Ω: 1.25 × (1 + 3) + 0.00005 × 720 = 5.04 V. For 12 V with R1 = 240 Ω, R2 = (12 − 1.25) ÷ (1.25/240 + 0.00005) = 2,044 Ω, so 2 kΩ (E24) gives 11.8 V, or 2.05 kΩ (E96) gives 12.0 V.
Design checks
- Headroom. The datasheet specifies operation with 3 V to 40 V between input and output, and says it may need up to 3 V to stay in regulation. Keep the input at least 3 V above the output at your lowest supply voltage.
- Tolerance. VREF can be 1.2 V to 1.3 V, so the output can be about ±4 % from the calculated value before resistor tolerance. Use 1 % resistors, or a trimmer for R2, if it matters.
- Minimum load. The regulator needs at least 3.5 mA (typical, 10 mA worst case) flowing out of it. With R1 = 240 Ω, R1 itself draws 5.2 mA, which is why that value is common.
- Heat. The regulator dissipates (VIN − VOUT) × ILOAD. Above about 1 W it needs a heatsink. Use the heatsink calculator to size one.
- A 0.1 µF input capacitor and a 1 µF output capacitor are recommended. Check the datasheet for your version.