Build a Variable Bench Power Supply: LM317, Current Limiting, LED Drivers, and Upgrades
Project Overview
Every electronics workbench needs a variable power supply. This project starts with a simple but capable LM317-based adjustable supply and builds up through multiple upgrade stages — adding digital voltage/current display, constant-current LED driving, USB output, and lithium battery charging. By the end you'll have a versatile bench tool that can power circuits from 1.25V to 30V, drive LED strips, charge batteries, and provide clean 5V USB power — all built from widely available components for under $40.
Stage 1: Basic LM317 Adjustable Supply
The LM317 is the classic adjustable voltage regulator — three pins, two resistors, and you have a stable adjustable output from 1.25V up to about 2V below your input voltage.
How the LM317 Works
The LM317 maintains exactly 1.25V between its OUTPUT and ADJ pins. By connecting a resistor divider from OUTPUT to ADJ to GND, you set the output voltage:
Vout = 1.25V × (1 + (R2 / R1))Where R1 is between 100Ω and 240Ω (typically 240Ω) and R2 is your adjustment resistor. A potentiometer for R2 lets you vary the output voltage.
Parts List - Stage 1
ComponentValuePrice LM317T (TO-220)1.5A adjustable regulator$0.30 Transformer (or wall adapter)12-24V AC or DC, 1-2A$5-15 Bridge rectifier (if using AC input)2A, 50V$0.50 Filter capacitor2200μF 35V electrolytic$1.00 R1240Ω 1/4W$0.01 R2 (potentiometer)5kΩ linear$1.00 Cin0.1μF ceramic$0.05 Cout10μF 25V electrolytic$0.10 Protection diode D11N4007$0.05 Protection diode D21N4007$0.05 HeatsinkTO-220 compatible$1.00 Banana jacks or terminal blocksRed + Black pair$2.00 EnclosureProject box 100×60×40mm$3.00 Stage 1 Total$14-24Circuit Diagram - Stage 1
Input (+) → Bridge Rectifier → 2200μF Cap (+) → LM317 Vin | 2200μF Cap (-) → GND LM317 Vout → R1 (240Ω) → ADJ pin (feedback loop) | → R2 (5k pot) → GND | → Cout (10μF) → GND | → Output (+) GND → Output (-) Protection diodes: D1: Vin → Vout (reverse protection if input shorted) D2: ADJ → Vout (protects if ADJ pin current exceeds safe limit)Assembly Steps
- Mount the LM317 on the heatsink with thermal compound and insulating washer (if heatsink is not isolated)
- Install the bridge rectifier and filter capacitor on a perfboard or breadboard
- Wire R1 (240Ω) between LM317 Vout and ADJ pins — solder directly or use short wires
- Wire the 5kΩ potentiometer: one end to ADJ, wiper to the other end to GND
- Install Cout (10μF) close to the LM317 output pins
- Install protection diodes D1 (anode to Vout, cathode to Vin) and D2 (anode to ADJ, cathode to Vout)
- Connect Cin (0.1μF) between Vin and GND, close to LM317
- Mount banana jacks or terminal blocks for output
- Test: power on, adjust potentiometer, verify output varies from ~1.25V to ~Vinput - 2V
Heat Dissipation
Power dissipated in LM317 = (Vin - Vout) × Iload Example: Vin = 15V, Vout = 5V, Iload = 0.5A P = (15-5) × 0.5 = 5W — requires substantial heatsinkThe LM317 has thermal shutdown at ~125°C junction, but sustained high dissipation reduces lifespan. For loads over 500mA with large Vin-Vout differentials, use a larger heatsink or consider a switching regulator.
LM317 Specifications
ParameterValue Input voltage range3V to 40V Output voltage range1.25V to 37V Maximum output current1.5A (with adequate heatsinking) Line regulation0.01%/V typical Load regulation0.1% typical Reference voltage (Vref)1.25V (between OUT and ADJ) Minimum load current3.5mA (R1 = 240Ω gives 5.2mA, which is sufficient)Stage 2: Add Current Limiting
A basic LM317 supply has no current limiting beyond its internal protection. Adding an external current limit prevents damage to circuits under test.
Simple Current Limiter (BJT + Resistor)
Add a PNP transistor (2N2907) and sense resistor: Sense resistor (Rsc): 0.68Ω 2W between LM317 output and actual output terminal PNP emitter → actual output terminal PNP base → LM317 output (before sense resistor) PNP collector → GND (or ADJ pin for foldback limiting) When current × Rsc exceeds ~0.6V, the PNP turns on and shunts current away, limiting output current to approximately: Ilimit = 0.6V / Rsc With Rsc = 0.68Ω: Ilimit = 0.6/0.68 = 0.88A (practical limit)LM317 as Constant-Current Source
Interestingly, the LM317 can also work as a constant-current driver — perfect for LEDs:
Connect LM317: Vin → Vin pin, Vout pin → LED anode, ADJ pin → LED cathode → Rset → GND The LM317 maintains 1.25V across Rset, so: Iout = 1.25V / Rset For 350mA LED drive: Rset = 1.25/0.35 = 3.57Ω → use 3.3Ω (gives ~380mA) Power in resistor: P = 1.25 × 0.35 = 0.44W → use 1W resistorThis configuration drives any number of series LEDs (up to Vin - 3V) at a constant current, regardless of input voltage variations or LED forward voltage differences.
Stage 3: Digital Voltmeter/Ammeter Display
Add a cheap digital panel meter to monitor voltage and current in real-time.
Parts
ComponentPrice 0-100V 0-10A digital voltmeter/ammeter (panel mount)$4-8 Shunt resistor (included with meter, usually 0.01Ω 10W)included Small switch for meter power (optional)$0.50Wiring the Meter
- Voltage sense: Thin red wire to supply positive (or output after current shunt), thin black wire to ground
- Current sense: Thick red wire to supply positive input, thick black wire to load — the shunt sits in series with the load
- Meter power: Connect to 5-30V DC (can tap from your input or use a separate 78L05 regulator)
- Calibrate by comparing with a known-good multimeter
Stage 4: Add USB 5V Output
A dedicated 5V USB port lets you power and charge phones, Arduino boards, and Raspberry Pis directly.
Option A: Linear (7805-based, simple, runs warm)
LM317/rectifier output → 7805 Vin 7805 Vout → USB-A female connector (VCC = pin 1, GND = pin 4) Add 0.1μF and 10μF caps on both input and output of 7805 Add LED with 1kΩ resistor to show USB power onGood for low-current USB devices (under 500mA). The 7805 burns excess voltage as heat.
Option B: Switching Buck Module (efficient, cooler)
LM317/rectifier output → XL4015 or LM2596 buck module set to 5.2V Buck output → USB-A connector with data lines shorted (2-3) for 1A charge signaling Add 1000μF cap on output for USB spec complianceMuch more efficient — 90%+ vs 30-50% for linear. Can deliver 2-3A continuously without excessive heat. Buck modules cost $2-3 on Amazon/eBay.
Stage 5: Lithium Battery Charger
Add a TP4056 module for charging 18650 lithium cells safely:
ComponentPrice TP4056 charging module (micro-USB input)$0.50-1.00 18650 battery holder$0.50 18650 cell (LG HG2, Samsung 30Q, or similar)$4-8 Protection module (DW01A + FS8205A)$0.30Wiring
- TP4056 input (micro-USB or pads): connect to your rectified DC input (5-8V optimal)
- TP4056 B+/B- outputs: connect through protection module to 18650 holder
- Protection module output: becomes your battery terminals
- Add a boost converter (XL6009 or MT3608) to step battery voltage up to 5V or 12V as needed
Stage 6: Putting It All Together
Suggested Front Panel Layout
[USB 5V] [Banana Jacks: Red + / Black -] [5mm Binding Posts] | | | [USB LED] [Digital Meter: XX.XXV X.XXXA] [On/Off Switch] | | | [USB Current] [Voltage Adjustment Knob] [Current Limit Knob] | | | [Charge LED] [Fine/Coarse Switch (optional)] [Mode: CV/CC LED]Wiring Diagram - Complete System
AC Input / Wall Adapter → Fuse → Power Switch → Bridge Rectifier | 2200μF Filter Cap | +---------+---------+ | | LM317 Supply XL4015 Buck Module (1.25V-Vin-2V) | | 5.2V USB Output Current Shunt | | TP4056 Charger Output Terminals | | 18650 Battery Digital Meter | | MT3608 Boost (optional) | | Load/Work circuit 5V/12V Aux OutputUpgrades and Variations
LM338 (5A Version)
Drop-in replacement for LM317 with 5A output capability. Same pinout, same circuit, just more current. Requires much larger heatsink ($5-10).
LT3080 (Low Dropout, Parallelable)
1.1A LDO with 350mV dropout. Can be paralleled for more current. Excellent line and load regulation. $3-5.
Switching Buck Module as Main Supply (High Efficiency)
For higher current with less heat, replace the LM317 with an adjustable buck module:
- XL4015 module: 5A, 1.25-36V output, adjustable with pot — $3
- RD DPH5005: 50V 5A programmable buck-boost with display — $35
- Ruideng DPS5015: 50V 15A with color display and Bluetooth — $45
Dual Tracking Supply (+/- voltage)
For op-amp circuits and audio:
- Use LM317 for positive rail, LM337 (negative version) for negative rail
- Center-tapped transformer required
- Gang the potentiometers for tracking adjustment
Safety Considerations
- Always use a fuse: 2A slow-blow fuse on the AC input or between rectifier and regulator
- Heat dissipation is real: A LM317 dropping 20V at 1A dissipates 20W — that's enough to cause burns and start fires
- Use an enclosure: Mains voltage (if using transformer) must be enclosed
- Add indicator LED: Shows when unit is powered — prevents accidental contact
- Insulate all mains connections: Use heat shrink, terminal covers, and proper strain relief
- Ground the enclosure: If using a metal case, connect earth ground to the case