Build a Variable Bench Power Supply: LM317, Current Limiting, LED Drivers, and Upgrades
Prices and availability as of Nov 29, 10:28 PM ET and subject to change. The price shown on Amazon at the time of purchase applies.
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
| Component | Value | Price |
|---|---|---|
| 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 capacitor | 2200μF 35V electrolytic | $1.00 |
| R1 | 240Ω 1/4W | $0.01 |
| R2 (potentiometer) | 5kΩ linear | $1.00 |
| Cin | 0.1μF ceramic | $0.05 |
| Cout | 10μF 25V electrolytic | $0.10 |
| Protection diode D1 | 1N4007 | $0.05 |
| Protection diode D2 | 1N4007 | $0.05 |
| Heatsink | TO-220 compatible | $1.00 |
| Banana jacks or terminal blocks | Red + Black pair | $2.00 |
| Enclosure | Project box 100×60×40mm | $3.00 |
| Stage 1 Total | $14-24 |
Circuit 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 heatsink
The 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
| Parameter | Value |
|---|---|
| Input voltage range | 3V to 40V |
| Output voltage range | 1.25V to 37V |
| Maximum output current | 1.5A (with adequate heatsinking) |
| Line regulation | 0.01%/V typical |
| Load regulation | 0.1% typical |
| Reference voltage (Vref) | 1.25V (between OUT and ADJ) |
| Minimum load current | 3.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 resistor
This 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
| Component | Price |
|---|---|
| 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.50 |
Wiring 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 on
Good 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 compliance
Much 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:
| Component | Price |
|---|---|
| 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.30 |
Wiring
- 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 Output
Upgrades 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
Bill of Materials - Complete Build
| Item | Qty | Total |
|---|---|---|
| LM317T + heatsink | 1 | $1.30 |
| 12V 2A wall adapter (safer than transformer) | 1 | $8.00 |
| Bridge rectifier + filter cap | 1 | $1.50 |
| Resistors, caps, diodes, potentiometer | set | $2.00 |
| Digital voltmeter/ammeter | 1 | $6.00 |
| XL4015 buck module (USB 5V) | 1 | $3.00 |
| TP4056 charger + 18650 holder | 1 | $2.00 |
| Banana jacks, USB-A connector, switch, LED | set | $4.00 |
| Enclosure 120×80×50mm | 1 | $4.00 |
| Perfboard | 1 | $1.00 |
| Wire, solder, connectors | $2.00 | |
| Grand Total | $34.80 |
Troubleshooting
| Problem | Cause | Fix |
|---|---|---|
| No output | LM317 pinout wrong; no input voltage; blown fuse | Verify pinout (ADJ, Vout, Vin from front); check fuse; measure input |
| Output stuck at ~1.25V | R2 open circuit; potentiometer broken or miswired | Check R2 continuity; verify pot wired correctly |
| Output varies with load | Inadequate input capacitance; LM317 oscillating | Add 10μF tantalum at input; add 0.1μF ceramic close to pins |
| LM317 gets extremely hot | Excessive power dissipation | Reduce input voltage; add bigger heatsink; reduce load current |
| Output has AC ripple | Insufficient filter capacitance | Increase filter cap to 4700μF or more; add 100nF ceramic |
| Current limit not working | Sense resistor too large or small; transistor wrong type | Verify Rsc value; check PNP orientation; test transistor |
| Meter reads wrong | Meter powered from output being measured (loading effect) | Power meter separately or from pre-regulator voltage |
| USB output not charging phone | No D+/D- short; insufficient current; voltage too low | Short USB data pins (2-3); ensure 5V at load; check wiring |