Anth's Computer Cave Tutorials

Build an Adjustable Power Supply Using LM317 Regulators

I am waiting for parts for my big multi-channel power supply project, The PowerStation2, so I thought I'd build a single channel unit to use now.

I need something to provide fully adjustable power, both current and voltage. It needs to range from about 3.3v @ 30ma for creating signal pulses and up to 24v @ 800ma for powering motors and servos.

As always, I wanted to use salvaged parts so the unit will get its power from an old HP printer power brick, which has 16v @ 625ma on one channel and 32v @ 940ma on the other.

The power brick for the project, Picture: Anthony Hartup

The LM317 voltage and current regulator

I won't go into much detail about setting the LM317s up, I'll instead direct you to a handy site where I found the information I needed. Click here for an excellent guide to using the LM317 as a current regulator. They have a great online calculator to determine which resistors you need to get your preferred current. They have another page for using the LM317 as a voltage regulator. This page also has a calculator for resistor values to regulate voltage. These two pages have helped me immensely.

A pair of LM317 chips.

Please note that most of the circuit diagrams for the LM317 do not show the pins in their actual order. Refer to the image above for the actual pin positions.

I'll give you a brief rundown on what these chips are and what they do. They are a small, three-legged IC. They have one pin for voltage in (Vin), one for votage out (Vout) and one pin called "adjust". You wire these pins differently depending on whether you wish to regulate voltage or current. You then use different resistor values in the circuit to adjust the output.

One consideration, I was lead to believe with these chips, is they have an automatic initial voltage drop regardless of which resistor values you use. The current regulator will drop about 3v and the voltage regulator will drop 1.5v. This means to use both a current and voltage regulator together your input voltage must be 4.5v higher than the maximum voltage you hope to get out.

However, I am not noticing any where near the voltage drop I was expecting. The current regulator used on its own is dropping my 16.1v input down to 15.1v. That is only a 1v drop as opposed to the 3v drop I was lead to expect. The voltage regulator also seems to drop less than the 1.5v specified, closer to 1.2V. These figures must be based on using the the LM317 chips at higher Amps or voltages than my testing entailed.

Test Rig

Below is my test setup I am using until I am ready to mount everything in a case.

The test rig for the project, Picture: Anthony Hartup

As usual, a lot of it is recycled from other devices. The base is a paper tray from a printer and the heat-sinks are out of a TV we tore down last week.

Below is the diagram for my circuit.

The circuit diagram for a dual LM317 power supply, Picture: Anthony Hartup
The circuit diagram for my dual LM317 adjustable current amd voltage power supply. Picture: Anthony Hartup

In the top-right corner I have a small volt-meter to measure the input voltage from the power brick. The positive wire from this goes to Vin pin on the first LM317 chip, the current regulator (top-left). The Vout pin runs through a resistor (R1) before joining with the adjust pin and attaching to the Vin pin of the second LM317 chip, the voltage regulator (bottom-left).

The Vout pin on the voltage regulator becomes the positive output wire with a juction inline that diverts through a resistor (VR1) before joining with the adjust pin. The adjust pin connects to ground via a second resistor (VR2).

For my first test I used a 4.7ohm 1watt resistor for R1 the current regulator. I used a 220ohm 5 watt resistor for VR1 on the voltage regulator and a 1kohm 5 watt resistor for VR2. The wattage on these resistors was a bit of overkill, but that was just what I had in my kit. One watt resistors would have been sufficient.

Using the online calculator I mentioned earlier I was expecting an output of 7.2v @ 260ma, and that was almost exactly what I got.

Volt meters showing 12v input voltage and 7.2v output voltage, Picture: Anthony Hartup

You can hopefully see the small volt-meter in the image above reading 12v input power. The yellow multimeter shows an out put voltage of 7.18v. That is a pretty good first effort!

Volt meters showing 12v input voltage and 7.2v output voltage, Picture: Anthony Hartup

Switching the multimeter to display current I was even more impressed. 260ma, just what I had hoped for. This was exactly the setup I have been looking for.

Volt meters showing 12v input voltage and 7.2v output voltage, Picture: Anthony Hartup

The output voltage remained exactly the same. I now had a lot more confidence in these tiny little magic chips, but I was not quite convinced. After all, this setup was not actually powering anything yet.

I removed the multimeter and connected a motor controller to my output power. To this I connected a scanner assembly from a printer we tore down recently. I hooked an Arduino Uno micro controller to the motor controller and powered it up. The scanner head travelled across to the left, but stalled when it attempted to change direction.

I had ran this unit from a 7.5v wall cable off a router before so I knew the stepper could run at that voltage. That wall cable was more like 700ma than the 260ma my new supply was regulated to. Current was obviously the issue.

I went back to the calculator and replaced the 4.7ohm resistor on the current regulator with a 2.7ohm resistor I had at hand. I expected 460ma this time.

A multimeter displaying 460ma of current, Picture: Anthony Hartup

The multimeter displayed exactly 460ma. I tested the scanner assembly again and this time the stepper motor drove the scanner head effortlessly left, all the way to the right, and back to the centre. Just as I had programmed it to do.

I have since changed the resistor value for R2 on the voltage regulator and acheived a fairly close 9v output, and again to get 5v.

I am extremely happy with this setup.

Next I need to add two capacitors, one before and one after the second LM317, the voltage regulator. Everything seems to be working fine, but it seems these capacitors are a recommended addition.They are said to smooth out the power the system produces. As I may run sensitive devices like the Raspberry Pi in future, I think I will play it safe. The first capacitor is a .1uf and the second is a 1uf. I plan to increase that to a 1uf and a 4.7uf, partly because I like overkill, and also because I just happen to have those size capacitors in my kit. I love to recycle.

The final test is to switch from the 16v channel on the power brick to the 32v channel. I think it will be fine, but I may wait till I can order a spare pair of LM317s just in case. I would hate to fry it and have to wait for replacement chips.

After that I will replace a couple of resistors with turnpots for easy adjustment. I am a little worried about their wattage rating for this task. I cant seem to find any turnpots over .5 watts, and some of the voltage and current combinations I plan to use may be too heavy for these ratings. The resistor for the current regulator, in particular, needs to be at least 1.25 watt to use current over 1000ma going by the calculator I mentioned earlier. Even 500ma of current requires a .65 watt resistor.

I'll keep searching for an answer to this.

When the technical details are sorted I will put the entire unit into a set-top box case I have salvaged. Once my other big power supply, the PowerStation2 is finished, this compact unit will live permanently on my desk.

My unfinished power supply, Picture: Anthony Hartup

Stay tuned for an update soon.





Leave a comment.

There are currently no comments for this article.

Leave a comment on this article