LM317 voltage regulator: choosing the resistors and keeping it cool
The LM317 is the adjustable linear regulator everybody starts with: three pins, 1.25 to 37 V out, 1.5 A, and it protects itself. Two resistors set the output, Vout = 1.25 (1 + R2/R1) + Iadj R2, and the only things that go wrong are forgetting the 3 V it needs across it and forgetting that every volt it drops at every amp it passes is heat. This calculator designs R2 for the output you want (or checks the pair you have), and works out the headroom, the heat and the junction temperature for your load and heatsink.
How to use the LM317 calculator
- Type the input voltage and the load current; the load is what decides the heat.
- Type the output you want (or pick a common rail) and leave R2 blank: it is designed for your R1 with the nearest E24 and E96 values and the output each really gives. Or type R2 to check a pair you have.
- Pick the package and cooling in the menu row: a bare TO-220, a heatsink size, the TO-92 LM317L or SOT-223. Set the ambient (25 °C bench, 50 °C in a box) and, if you like, the adjust current.
- The drawing shows the regulator with its resistors and capacitors and the output; the panel shows the headroom against the 3 V dropout and the heat against what the cooling can shed. Click R1, R2 or the chip for its own notes; the Common outputs tab tabulates R2 for the usual rails.
The formula
Vout = 1.25 (1 + R2/R1) + Iadj R2
The regulator holds a 1.25 V reference between its OUT and ADJ pins. Across R1 that makes a current of 1.25/R1, which flows on through R2 to ground; the ADJ pin sits at I × R2 above ground, and the output 1.25 V above that. The ADJ pin itself leaks about 50 µA (100 µA worst case), which also flows through R2: the second term, usually a few tens of millivolts. Turned round, R2 = (Vout − 1.25) / (1.25/R1 + Iadj).
Choosing R1 and R2
R1 is almost always 240 Ω: its 5.2 mA satisfies the regulator's minimum load (3.5 mA typical, up to 10 mA for some parts), so the output stays put with nothing connected; use 120 Ω if the data sheet asks for 10 mA. R2 then follows from the target. Use 1% resistors for a fixed rail, or a potentiometer with a series resistor for an adjustable one; mount R1 right at the pins so the output's own wiring drop does not get regulated out.
| Output | R2 exact | E24 | E96 |
|---|---|---|---|
| 1.8 V | 104.6 Ω | 100 Ω | 105 Ω |
| 2.5 V | 237.7 Ω | 240 Ω | 237 Ω |
| 3.3 V | 389.9 Ω | 390 Ω | 392 Ω |
| 5 V | 713.2 Ω | 680 Ω | 715 Ω |
| 6 V | 903.3 Ω | 910 Ω | 909 Ω |
| 9 V | 1.474 kΩ | 1.5 kΩ | 1.47 kΩ |
| 12 V | 2.044 kΩ | 2 kΩ | 2.05 kΩ |
| 15 V | 2.615 kΩ | 2.7 kΩ | 2.61 kΩ |
| 24 V | 4.326 kΩ | 4.3 kΩ | 4.32 kΩ |
Dropout and the input
The LM317 needs about 3 V across it at 1.5 A (less at light load) or it stops regulating and the output follows the input downwards, ripple and all. So the input must be at least Vout + 3 V at the bottom of its ripple: 8 V minimum for a 5 V rail, which from a transformer and rectifier means a 9 V secondary and a big enough capacitor. For 3.3 V from 5 V, or anything within 1 V, use a low-dropout regulator instead. The maximum input-to-output difference is 40 V.
Heat and heatsinks
P = (Vin − Vout) × I Tj = Ta + P × θja
A linear regulator is a variable resistor: the voltage it drops times the current is heat, all of it. 12 V to 5 V at 500 mA is 3.5 W. A bare TO-220 in free air has about 50 °C/W junction-to-air, so 3.5 W would put the junction 175 °C above ambient: it shuts down. A small clip-on heatsink is about 20 °C/W, a medium finned one 10, a large one or a chassis 4; with thermal compound and the tab insulated (the tab is the OUT pin). The junction limit is 125 °C. If the sums say more than a few watts, a buck converter in front of the regulator, or instead of it, is the better answer.
Capacitors and diodes
0.1 µF at the input if the regulator is more than a few centimetres from the supply capacitor; 1 µF (tantalum) or 10 µF (electrolytic) at the output for stability and transient response. An optional 10 µF from ADJ to ground improves ripple rejection by about 15 dB, and then a diode from OUT to ADJ (1N4002) is needed so that capacitor cannot discharge into the pin. A diode from OUT to IN protects the regulator if the input is shorted while the output capacitor is charged. All of this is in the data sheet's "typical application".
Your regulator, step by step
- Reference current: 1.25 V / 240 Ω = 5.21 mA, minimum load covered.
- Output: 1.25 × (1 + 715 Ω / 240 Ω) + 50 µA × 715 Ω = 5.01 V.
- Headroom: 12 V − 5.01 V = 6.99 V against 3 V: regulating.
- Heat: 6.99 V × 505 mA = 3.53 W; junction 25 °C + 3.53 W × 20 °C/W = 96 °C.
Worked example: 5 V at 500 mA from 12 V
With R1 = 240 Ω the reference current is 5.21 mA. R2 = (5 − 1.25) / (5.21 mA + 50 µA) = 713.2 Ω; the nearest 1% (E96) value is 715 Ω, giving 5.01 V (the nearest 5% value, 680 Ω, would give 4.826 V). The headroom is 12 − 5 = 7 V, well above the 3 V dropout. At 500 mA (plus the 5 mA reference current) the regulator dissipates 7 V × 0.505 A = 3.53 W: on a bare TO-220 at 50 °C/W the junction would reach 202 °C, far over the 125 °C limit, while a small 20 °C/W clip-on heatsink holds it at 96 °C. The efficiency is 41%: more than half the power is heat, which is why a buck converter is the better choice above a few hundred milliamps at this ratio.
Questions
Why is my output higher than calculated with no load?
R1 is too large: below the minimum load the regulator cannot sink its own quiescent current and the output drifts up. Use 240 Ω or less.
Can the LM317 make 3.3 V from 5 V?
Only at very light load: it needs up to 3 V across it. Use an LDO such as the AMS1117-3.3 or MCP1700 for that.
Can I use it as a current source?
Yes: one resistor from OUT to ADJ, load from ADJ to ground, I = 1.25 V / R. 12 Ω gives about 100 mA for LED strings; the heat sums are the same.
Which pin is which?
TO-220, looking at the printed face with the pins down: ADJ, OUT, IN from left to right. The tab is OUT. The 78xx fixed regulators are IN, GND, OUT, so do not swap them by habit.