Building an LM317 Adjustable Power Supply: Circuit and Calculations

Projeler Beginner 10 min read Published:
LM317 ile ayarlı güç kaynağı yapımı kapak görseli, TO-220 kılıf çizimi

To build an adjustable power supply with the LM317, all you need to add to the IC is one fixed resistor (R1 = 240 Ω) and one potentiometer (R2 = 5 kΩ). The output voltage is set by the formula Vout = 1.25 V × (1 + R2 / R1) and rises from 1.25 V as the potentiometer is turned. Powered from a 24 V DC adapter, the circuit gives a bench supply adjustable from about 1.25 V to 21 V. In this article you will find the schematic, the bill of materials, the resistor calculation and, step by step, the most frequently skipped topic: the heatsink calculation.

All values in this article are taken from the LM317TG (onsemi, TO-220) datasheet. The 3 A LM350T, which works in the same circuit when more current is needed, is covered at the end of the article.

What is the LM317 and how does it work?

The LM317 is a three-terminal positive linear voltage regulator whose output voltage is set with two resistors. According to the datasheet, it can deliver an output from 1.2 V to 37 V and supply more than 1.5 A. It includes current limiting, thermal shutdown and safe operating area protection.

Its operation can be summed up in one sentence: the IC always holds the voltage between its output (Vout) pin and its Adjust pin at a typical 1.25 V. When R1 is connected between these two pins, a constant current flows through R1. Because the same current flows through R2 to ground, the output voltage rises as R2 increases. Unlike fixed regulators such as the 7805, it has no ground pin. The LM317 is a “floating” regulator and only sees the voltage difference between input and output.

LM317 pinout (TO-220)

LM317 TO-220 package pinout: 1 Adjust, 2 Vout, 3 Vin, metal tab connected to the Vout pin
LM317 TO-220 pin order, front view. The metal tab is connected to the output (Vout) pin.

With the marked face of the TO-220 package toward you and the leads pointing down, the order from left to right is:

Pin Name Function
1 Adjust Connects to the junction of R1 and R2
2 Vout (output) Regulated output. The metal tab is also connected to this pin
3 Vin (input) Unregulated DC input

The order differs from the 7805. The most common mistake made by those used to the 7805 is wiring the LM317 with the same pinout. The second important detail is the metal tab: because it is connected to the output, not to ground, the heatsink also carries the output voltage.

LM317 key specifications

Parameter Value Condition / note
Output voltage range 1.2 V – 37 V Set with two resistors
Reference voltage (Vref) min 1.2 V, typ 1.25 V, max 1.3 V Between Vout and Adjust
Input-output voltage differential max 40 V Absolute maximum rating
Output current min 1.5 A (typ 2.2 A) Input-output differential up to 15 V, power dissipation not exceeding 20 W, TO-220
Output current min 0.15 A (typ 0.4 A) Input-output differential of 40 V, 25 °C
Adjust pin current (IAdj) typ 50 µA, max 100 µA
Minimum load current typ 3.5 mA, max 10 mA Input-output differential of 40 V
Ripple rejection typ 65 dB; typ 80 dB with CAdj = 10 µF Vout = 10 V, 120 Hz
Thermal resistance, junction-to-ambient 65 °C/W TO-220, no heatsink
Thermal resistance, junction-to-case 5 °C/W TO-220
Thermal shutdown typ 180 °C

LM317 adjustable power supply schematic

LM317 adjustable power supply schematic: R1 240 Ω, R2 5 kΩ potentiometer, input, output and adjust capacitors, two 1N4007 protection diodes
1.25–21 V adjustable power supply circuit with the LM317. D1 and D2 are protection diodes.

The circuit is the datasheet’s standard application with protection diodes added. The connections are as follows:

  • R1 (240 Ω) connects between the output pin (2) and the Adjust pin (1). It should be placed as close to the IC as possible.
  • R2 (5 kΩ potentiometer) connects between the Adjust pin and ground. The potentiometer’s wiper and one of its end terminals are used.
  • Cin (0.1 µF) sits between input and ground. It is required if the regulator is far from the supply’s filter capacitor.
  • CO (47 µF electrolytic) sits between output and ground. The LM317 is stable without an output capacitor, but the datasheet recommends a 1 µF tantalum or 25 µF aluminum electrolytic to prevent oscillation and improve the response to sudden load changes.
  • CAdj (10 µF) sits between the Adjust pin and ground. It prevents ripple from growing as the output voltage is raised.
  • D1 connects from output to input (anode at the output, cathode at the input). If the input is shorted, it prevents CO from discharging through the IC.
  • D2 connects from the Adjust pin to the output (anode at the Adjust pin, cathode at the output). If the output is shorted, it prevents CAdj from discharging through the IC.

The datasheet recommends the protection diodes when the output exceeds 25 V or when large capacitors are used (CO larger than 25 µF, CAdj larger than 10 µF). In this circuit both diodes are kept, because CO is 47 µF and the output of a bench supply is frequently shorted. The datasheet schematic shows a 1N4002. The 1N4007, the 1000 V member of the same family, is also a 1 A rectifier diode and does the same job here. For the differences between diode families, see the 1N4007, UF4007 and 1N5819 comparison.

Bill of materials

  • 1 × LM317TG (TO-220)
  • 1 × 240 Ω resistor (1% tolerance improves output accuracy)
  • 1 × 5 kΩ linear potentiometer (0.25 W or higher)
  • 1 × 0.1 µF ceramic capacitor
  • 1 × 47 µF and 1 × 10 µF electrolytic capacitor (35 V or higher)
  • 2 × 1N4007 diodes
  • TO-220 heatsink, insulating pad, insulating washer for the screw and thermal paste
  • 24 V regulated DC adapter, terminal block or banana jacks for the output
LM317TGonsemi · EE02485-3$0.6310 In StockView

LM317 resistor calculation: what value should R2 be?

The full formula from the datasheet is:

Vout = 1.25 V × (1 + R2 / R1) + IAdj × R2

Because IAdj is at most 100 µA, the second term is neglected in most applications. R2 for the desired voltage is then found as:

R2 = R1 × (Vout / 1.25 − 1)

With R1 = 240 Ω, common voltages correspond to:

Desired output Calculated R2
3.3 V 394 Ω
5 V 720 Ω
9 V 1488 Ω
12 V 2064 Ω
15 V 2640 Ω

With the 5 kΩ potentiometer turned fully up, the formula gives 1.25 × (1 + 5000 / 240) ≈ 27.3 V. The typical 50 µA adjust current adds about 0.25 V to this. However, the circuit cannot produce a voltage higher than its input: the datasheet values apply with an input-output differential of at least 3 V. With a 24 V adapter, the upper limit of the regulated output is therefore about 21 V, and the last part of the potentiometer’s travel does nothing.

The reference voltage can vary from one IC to another between 1.2 V and 1.3 V. For this reason alone, with fixed resistors calculated for 12 V, the actual output will be somewhere between about 11.5 V and 12.5 V. This is not a problem in an adjustable supply, because the voltage is set with the potentiometer while watching a voltmeter connected to the output.

Heatsink calculation: why does the LM317 get hot?

A linear regulator turns the voltage difference between input and output into heat. The dissipated power is calculated as:

P = (Vin − Vout) × I

The junction temperature is found with Tj = Ta + P × θJA. Because the LM317TG’s electrical characteristics are specified up to a junction temperature of 125 °C, it is safe to use this limit in calculations.

How much power can be dissipated without a heatsink?

The thermal resistance of the TO-220 package without a heatsink is 65 °C/W. At an ambient temperature of 40 °C, the allowed power is (125 − 40) / 65 ≈ 1.3 W. With a 5 V output from a 12 V input, that means about 185 mA. Expecting 1 A from an LM317 without a heatsink is not realistic.

Example 1: 12 V input, 5 V output, 0.5 A

P = (12 − 5) × 0.5 = 3.5 W. At 40 °C ambient, the required total thermal resistance is (125 − 40) / 3.5 ≈ 24.3 °C/W. Of this, 5 °C/W is the IC’s own junction-to-case resistance. The remaining approximately 19 °C/W is the upper limit for the insulating pad and the heatsink combined. Check the thermal resistance of the heatsink you choose in its own datasheet.

Example 2: 24 V input, 5 V output, 1 A

P = (24 − 5) × 1 = 19 W. The required total thermal resistance comes out to (125 − 40) / 19 ≈ 4.5 °C/W. This is smaller than even the IC’s 5 °C/W junction-to-case resistance, meaning no heatsink can save this operating point. The datasheet’s electrical characteristics are also given for a maximum power dissipation of 20 W. If you need high current at a low output voltage, lower the input voltage or use a switching step-down circuit.

Common mistakes

  • Wiring the pins like a 7805. On the LM317 the order is Adjust, Vout, Vin.
  • Letting the heatsink touch the chassis. The metal tab is connected to the output. If the heatsink touches a metal enclosure or the chassis, the output is shorted. Use an insulating pad and an insulating washer.
  • Misreading the 40 V limit. The limit applies to the difference between input and output. However, when the output is shorted or set to the lowest voltage, this difference is almost equal to the full input voltage. In an adjustable supply, keep the input voltage below 40 V for this reason as well.
  • Expecting 1.5 A at every voltage. 1.5 A is guaranteed with an input-output differential up to 15 V and power dissipation not exceeding 20 W. With a 24 V input and the output set below 9 V, the difference exceeds 15 V and the current limit starts to drop. In most cases, heat is still the real limit.
  • Mistaking a rising no-load output for a fault. The LM317 needs a minimum load current of up to 10 mA to regulate properly. A 240 Ω R1 draws about 5.2 mA (1.25 V / 240 Ω). This meets the typical 3.5 mA but not the worst case. If your output voltage rises with no load, use 120 Ω for R1 and 2.5 kΩ for the potentiometer. The adjustment range stays the same and the R1 current rises to 10.4 mA. Because this current also flows through the potentiometer, choose a potentiometer rated at least 0.5 W.
  • Choosing capacitors with too low a voltage rating. The voltage rating of the output and adjust capacitors must be above the highest voltage the supply can deliver.

Building and measuring the circuit step by step

  1. Screw the IC to the heatsink with an insulating pad and thermal paste. Using the multimeter’s continuity setting, verify that there is no connection between the heatsink and the middle pin.
  2. Connect R1 between pin 2 and pin 1, and the potentiometer between pin 1 and ground.
  3. Add the capacitors and diodes, paying attention to their orientation in the schematic. The negative lead of the electrolytic capacitors goes to ground.
  4. Plug in the adapter without a load on the output and measure the output voltage. With the potentiometer at its lowest setting, you should see about 1.25 V.
  5. Turn the potentiometer and watch the voltage rise smoothly. To maintain regulation under load, leave a margin of about 3 V between input and output. With no load, the output can be set a little higher than this.
  6. Set the voltage you want and connect the load. Check the heatsink temperature during the first few minutes. If it gets too hot to touch, reduce the current or move to a larger heatsink.

The mains-powered transformer and rectifier section is outside the scope of this article. For a first attempt, using a ready-made regulated DC adapter is both safer and easier.

If you need more current: LM350T

The LM350T is a 3 A adjustable regulator that works in the same circuit. Its reference voltage is again a typical 1.25 V, and the formula and pin order (Adjust, Vout, Vin from the front) do not change. The differences between the two ICs are:

Feature LM317TG LM350T
Output current 1.5 A 3 A
Output voltage range 1.2 V – 37 V 1.2 V – 33 V
Input-output differential (max) 40 V 35 V
Current limit (min) 1.5 A (differential up to 15 V) 3 A (differential up to 10 V)
Thermal resistance, junction-to-case (TO-220) 5 °C/W typ 3 °C/W, max 4 °C/W
Thermal resistance, junction-to-ambient (TO-220) 65 °C/W 50 °C/W

3 A makes the thermal calculation even more critical: drawing 3 A at a 5 V output from a 12 V input, the IC dissipates 21 W. At 40 °C ambient, the total thermal resistance required for this is (125 − 40) / 21 ≈ 4 °C/W. Because the IC’s own junction-to-case resistance can be as high as 4 °C/W, this operating point cannot be cooled in practice. 3 A can only be drawn continuously when the input-output differential is small: at a 3 V differential, the dissipated power drops to 9 W. When you choose the LM350T, also size up the heatsink, the adapter and the wire gauges for this current.

LM350TTexas Instruments · EE01894$0.755 In StockView

Frequently asked questions

What are the lowest and highest voltages you can get from an LM317?

The LM317’s output can be adjusted from 1.2 V to 37 V. The lower limit comes from the IC’s typical 1.25 V reference voltage, so the standard circuit cannot go down to 0 V. In practice, the upper limit is set by the input voltage: a margin of about 3 V is left between input and output to maintain regulation.

Why is R1 chosen as 240 Ω on the LM317?

240 Ω is the value in the datasheet’s standard application circuit, and with the 1.25 V reference it produces a current of about 5.2 mA. This current meets the IC’s typical minimum load current (3.5 mA). For the worst-case value of 10 mA, 120 Ω can be used.

How many amps does the LM317 deliver?

It delivers at least 1.5 A when the input-output differential does not exceed 15 V, the dissipated power does not exceed 20 W and the IC is adequately cooled. As the differential grows, the internal protection reduces the current: at a 40 V differential, the guaranteed value is 0.15 A. The current that can be drawn continuously is usually determined by the size of the heatsink.

Can a 7805 be used instead of an LM317?

If you only need a fixed 5 V, the 7805 does the same job with fewer parts. If you need a different or adjustable voltage, the LM317 is the right choice. The two ICs have different pin orders, so one cannot be dropped directly in place of the other. For a comparison of fixed regulators, see the article on the difference between the 7805 and AMS1117.

Conclusion

An adjustable power supply with the LM317 is built with one IC, one resistor, one potentiometer, three capacitors and two diodes. The output voltage is set by the formula 1.25 V × (1 + R2 / R1), while the current that can be drawn is largely determined by the heatsink. Before building the circuit, calculate the product (Vin − Vout) × I and choose the heatsink accordingly. For other adjustable and fixed regulators, browse the Linear Voltage Regulators category.

References

Products in this article

More from Projeler