Introduction: LM317 Based DIY Variable Benchtop Power Supply
A power supply is unquestionably an absolutely necessary equipment for any electronics lab or anyone who wants to do electronics projects, especially a variable power supply. In this tutorial I'll show you how I built an LM317 linear positive regulator based variable 1.2-30V (1.2V to input voltage-2.7V actually) power supply.
These are the features I wanted my PSU to have.
- One variable output with minimum current 2 A.
- Fixed 12 V output with 2A.
- Fixed 5 V output with 2 A.
- Fixed 3.3 V output with 1A.
- Two USB ports for charging phones at 1A.
The power supply doesn't use any transformer instead it reduces constant input voltage in the range of 15-35V to many different voltages at the output. So you can power this unit by any SMPS with a rated voltage 15-35V and current 2-5A OR a transformer supply with the same specs.
Step 1: Getting Ready
- Go to https://www.autodesk.com/products/eagle/free-download and download Eagle schematic capture software for your operating system.
- Go to https://www.sketchup.com/download and download latest version of SketchUp and install it.
- Find a good SMPS with a voltage rating between 15-36V OR make a transformer based supply with 15-36V DC output voltage.
Step 2: Schematic
The schematic will give you an insight on my plan. But it was not designed to generate a PCB file as I usually perfboard for my one off designs. So I didn't care about the component packages. You have to select proper packages if you want to create a PCB layout. There are three LM317s and three TIP2955 PNP pass transistors for each. Each of those LM317s will reduce the 36V input to programmed voltages. U2 will output a constant 12V, U3 will output a variable voltage and U1 will produce an auxiliary 12V for other 5V and 3.3 regulators so as to reduce the heat dissipated by them.
LM317 can provide output current in excess of 1.5A. But in this case, with large difference in input and output voltages, LM317 will have to dissipate the excess power as heat; so much heat. So we use pass elements. Here I've used TIP2955 power transistor as pass element on the positive side. You could use TIP3055 or 2N3055 as pass element on the negative side or the output side. But the reason I chose PNP ones is because they do not alter the output voltage as NPN transistors would do (output will be +0.7V higher when NPN is used). PNP transistors are used as pass elements in low dropout and ultra-low dropout regulators. But they exhibit some output stability issues which can be mitigated by adding capacitors at the output.
The 2W resistors R5, R7 and R9 will produce enough voltage to bias the pass transistors at low currents. The auxiliary 12V output is connected to inputs of three LM2940 ultra-low dropout 5V 1A regulators of which two are used for USB outputs and the other is for front panel output. One of the 5V output is connected to a AMS1117 regulator for 3.3V output. So it's a series network of different regulators.
The variable output is taken from U3 as shown in the schematic. I used a 5K potentiometer in series with a 1K pot to have coarse and fine adjustment of output voltage. A DSN DVM-368 (tutorial on my website) voltmeter module is connected to the variable output to display the voltage at front panel. See the "Wiring" section to see the modifications to be made to the voltmeter module. You can use any other V or A modules without much modifications.
Download high resolution PNG image of the schematic here.
Or download different sizes from Instructables : https://www.instructables.com/file/F278MX2J4IQ00GW/
Step 3: SketchUp 3D Model
To plan the placement of connectors, switches etc and to get correct dimensions to cut MDF board, aluminium channel etc, I first designed a 3D model of the PSU box in SketchUp. I already had all the components with me. So designing the model was easy. I used MDF board of thickness 6 mm and aluminium extrusions (angle) of size 25 mm and thickness 2 mm. You can download the SketchUp model file using the link below.
LM317 PSU SketchUp 2014 file : Download the file below. You're free to download, modify and redistribute this material.
Step 4: Gather Tools and Parts
These are the material, tools and components required.
For PSU box,
- MDF board of thickness 6 mm.
- Aluminium Angled Extrusions - size 25 mm, thickness 2mm.
- 25 mm machine screws with slotted, round head and compatible nuts and washers.
- Acrylic or ABS sheet of thickness 3-4 mm.
- Old CPU Aluminium heatsink and fan.
- PVC feet of size 1.5 cm.
- Matte black spray paint.
- MDF primer.
For circuit board,
- 3x TIP2955 (TO-247 package)
- Mica insulators for TO-247 transistors
- 3x LM317T
- 3x LM2940
- 1x AMS1117-3.3
- 3x 2W, 100 Ohm resistors
- 10x 100 nF ceramic capacitors
- 6x 1N4007 diodes
- 470 uF, 40V electrolytic caps
- 1x 6A4 diode
- 3x 1K resistors
- 3x 200 Ohm resistors
- 1x 3-4A fuses and fuse holders
- 100 uF, 10V electrolytic caps
- 1x 1K linear potentiometer
- 1x 5K linear potentiometer
- 2x Potentiometer knobs
- 2 pin terminal blocks
- Heatsinks for TO220 packages
- Heat sink paste
- 4x SPST Toggle/Lever switches
- Cables and wires from old PC power supplies
- Heat shrink tubes of 3mm and 5mm
- Perforated matrix PCB
- Male pin headers
- 2x Female USB type A receptors
- 4x Speaker connectors OR 8x binding posts
- 1x SPST/DPDT rocker switch
- 4x 3mm/5mm LEDs
- 1x DSN-DVM-368 voltmeter
- 5x Female DC barrel connectors (screwable)
- Plastic standoffs
- Hacksaw blades
- Drilling machine
- Nose player
- Different types of files
- Different types of spanners
- Measuring tape
- Black permanent CD marker
- Many types of Philips and slotted screw drivers (buy a kit)
- Retractable knife and blades
- Rotary tool (not necessary if you have skill)
- 300 and 400 grit size sand papers
- Nipper (for copper wires)
- Soldering iron
- Solder wire and flux
- Wire strippers
- And any tool you can find.
- Pollution/Dust mask to protect from paint.
Step 5: Building the Circuit Board
Cut the perfboard as per your requirement. Then place and solder components as per the schematic. I didn't make a PCB file for etching. But you can use the Eagle schematic file below to make a PCB on your own. Otherwise use your ingenuity to plan the placements and routing and solder everything nicely. Wash the PCB with IPA (Isopropyl Alcohol) solution to clean any solder residue.
Step 6: Building the Box
All the dimensions with which the MDF board, aluminium channels are to be cut, hole dimensions, hole placements and all are in the SketchUp model. Just open the file in SketchUp. I've grouped parts together, so you can easily hide parts of the model and use the Measure tool to measure the dimensions. All dimensions are in mm or cm. Use 5mm bits for drilling holes. Always check for alignment of holes and other parts to make sure everything will easily match together. Use sand papers to smooth out the surface of MDF and Aluminium channels.
You'll get the idea to how to build the box once you examine the 3D model. You can modify it as per your needs. This is a place where you can put your creativity and imagination to maximum use.
For the front panel, use acrylic or ABS sheet and cut holes in it using a laser cutter if you can access one. But unfortunately I didn't have a laser machine and finding one would be a tedious task. So I decided to stick with the traditional approach. I found plastic frames and boxes from old fridges from a scrap shop. Actually I bought them for an unreasonable price. One of that frame was thick and flat enough to be used as front panel; it was not too thick nor too thin. I cut it with correct measurements and drilled and cut holes in it, to accommodate all the switches and output connectors. A hacksaw and a drilling machine was my main tools.
Due to the specific design of the box, you may face some problem attaching the front panel to the rest of the box. I glued plastic pieces of ABS plastic behind the front facing angles and screwed to them directly without needing nuts. You will need to do something like this or something better.
For the heatsink, I used one from an old CPU cooler. I drilled holes in it and attached all three pass transistors with mica insulators (THIS IS IMPORTANT!) between them for electrical isolation. Realizing the heatsink alone wouldn't do the job, I later added a cooling fan from the outside of the heatsink and connected it to the auxiliary 12V.
Step 7: Painting the Box
First you have to sand the MDF with 300 or 400 grit size sandpaper. Then apply thin, uniform layer of wood primer or MDF primer. Apply another layer after the first layer is dried enough. Repeat this as per your requirement and let it dry for 1 or 2 days. You have to sand the primer layer before you can spray the paint. Painting is easy using compressed paint cans.
Step 8: Wiring
Fix the board you soldered in the center of the bottom sheet and screw it using small machine screws and standoffs between them. I used wires from old computer power supplies as they are of good quality. You can either solder wires directly to the board or use connectors or pin headers. I made the PSU in a hurry so I didn't use any connectors. But it's recommended to use connectors whenever and wherever possible, to make everything modular and easy to assemble and disassemble.
I had come across some rather strange problems while wiring and the initial testing. First one was the instability of the output. As we're using PNP pass elements, the output would oscillate giving reduced effective DC voltage on the meter. I had to connect high value electrolytic capacitors to rectify this problem. Next problem was the difference in output voltage in the board and at the output connectors ! I still don't know what exactly the problem is, but I solved this by soldering some high value resistors, 1K, 4.7K etc, at the output terminals directly. I used 2K (1K+1K) resistor value to program the Aux 12V and main 12V outputs.
We only need the DSN-DVM-368 voltmeter for the variable output as all other outputs are fixed. First you have to disconnect (IMPORTANT!) the jumper (Jumper 1) as shown in the figure then use the three wires as in the schematic. The voltmeter has already a 5V regulator inside. Feeding 12V directly to it will cause undesired heating. So we use a 7809, 9V regulator between the AUX 12V and the Vcc input of the voltmeter. I had to make the 7809 a "floating" component as it was added after I soldered the board.
Step 9: Testing
Connect an SMPS with a voltage rating between 15-35V and current of minimum 2A, to input of the board though a DC barrel jack. I used 36V 2A SMPS with over-current protection (shutdown) built-in. See above the table of measurements from the load test.
Load regulation in here is not that good due to the output power limitation of the SMPS I'm using. It'll limit the current and shutdown at high currents. So I couldn't conduct surge current tests. Upto 14V, the load regulation seemed good. But above 15V set voltage (#8, #9, #10), when I connect the load, the output voltage will diminish to around 15V with a constant current of 3.24A. At #10, the loaded voltage is half of the set voltage at 3.24A current ! So it looked like my SMPS was not providing enough current to keep the voltage at what is set. The maximum power I was able to get was at #11, of 58W. So, as long as you keep the output current low, the output voltage will stay where it is supposed to. Always keep an eye on the voltage, current and the temperature of the heatsink as a significant amount of power will be dissipated there.
Step 10: Finishing
Once you finish the tests, assemble everything and label the front panel the way you like. I painted the front panel with silver paint and used a permanent marker to label things (not a nice way to do). I put a DIY sticker I got with my first Arduino, on the front.
Step 11: Pros and Cons
There are many advantages and as well as disadvantages with this power supply design. It's always worth studying them.
- Easy to design, build and modify as it's a linear regulated power supply.
- Less undesired ripples at the output compared to ordinary SMPS units.
- Less EM/RF interference produced.
- Poor efficiency - most of the power is wasted as heat at the heatsinks.
- Poor load regulation compared to SMPS power supply design.
- Large in size compared to similar power SMPSs.
- No current measurement or limiting.
Step 12: Troubleshooting
A digital multimeter is the best tool to troubleshoot power supply problems. Check all the regulators before soldering using a breadboard. If you have two DMMs, then it's possible to measure the current and voltage simultaneously.
- If there's no power at the output, check voltages from the input pin, at regulator input pins and double check if PCB connections are correct.
- If you find the output is oscillating, add an electrolytic capacitor of value not less than 47uF near the output terminals. You can solder them directly to the output terminals.
- Do not short the outputs or connect low impedance load at the outputs. It could cause the regulators to fail as there's no current limiting in our design. Use an appropriate value fuse at the main input.
Step 13: Improvements
This is a basic linear power supply. So there's a lot you can improve. I built this in a hurry becasue I needed some kind of variable power supply so badly. With the help of this, I can build a better "Precision Digital Power Supply" in future. Now here are some ways you can improve the current design,
- We used linear regulators like LM317, LM2940 etc. As I said before these are so inefficient and can't be used for a battery powered setup. So what you can do is, find one of those cheap DC-DC buck modules from any online shops and replace the linear regulators with them. They're more efficient (>90%), has better load regulation, more current capability, current limiting, short circuit protection and all. LM2596 is one of that kind. The buck (step down) modules will have a precision potentiometer on top. You can replace it with a "multi-turn potentiometer" and use it at the front panel instead of normal linear pots. That'll give you more control over the output voltage.
- We only have used a voltmeter here, so we're blind about the current our PSU is supplying. There are available cheap "Voltage and Current" measuring modules. Buy one and add to the output, may be one for each output.
- There are no current limiting feature in our design. So try improving it by adding a current limiting function.
- If your heatsink fan is noisy, try adding a temperature sensitive fan controller may be with speed control.
- A battery charging function can be easily added.
- Separate outputs for LED testing.