MJLorton Solar Power and Electronic Measurement Equipment Forum

New proof of concept ideas, projects, inventions => New proof of concept ideas, projects, inventions => Topic started by: ttyz on August 19, 2013, 04:50:39 PM

Title: My Simple bench power supply
Post by: ttyz on August 19, 2013, 04:50:39 PM
Hello everybody,

I'm just starting in electronics, and there is a bunch of stuff I need to learn. But I don't have a power supply, so I've decided to build one. First I thought the best way is to make a variable power supply form an ATX power supply, as it would keep things as simple as possible. But then I've found this schematic on MAKE:

(https://dl.dropboxusercontent.com/u/4269740/output.png)

It uses LM317, and looks simple to me. I've already bought all components and put them together on a breadboard, but I am actually using a constant 12V/1.5A notebook power supply instead of transformer and a bridge rectifier to check the circuit before switching to mains.

It would like to add some features to this device: some meter to monitor voltage and current would be useful. And I am thinking of current limiting, but did not find a way to implement this.

I am still waiting for some parts for this project, and I need to find a 10-turn pot, that seems difficult. But I will share my progress and waiting for support and help if I am doing anything wrong.

Thank you all and thanks Martin for this forum and great vblog, I've learnt a lot
Title: Re: My Simple bench power supply
Post by: mariush on August 19, 2013, 10:04:10 PM
If you're eventually going to buy a transformer, replace the 2 capacitors with a single 2200-3300 uF capacitor with suitable voltage rating (transformer output rectified + 25%+). 
So for example if you find a 12v transformer,  rectified output would be 12 x 1.414, minus about 1-1.5v would give you about 15.5-16v, +25% = 20v, so use at least a 25v rated capacitor.
If you're going to power it from a notebook power supply, even a 330-470uF capacitor would be more than enough.

With a notebook power supply, you're kinda missing the point of such power supplies.. they're supposed to be as little noisy as possible. The LM317 would not be able to filter all the high frequency noise from the notebook power supply so such "adjustable power supply" won't be quite optimum for use with opamps, audio stuff.. etc.

Check the lm117/lm317 datasheet... depending on how you plan to use it, you might want to add a 10uF capacitor in parallel with the trim pot and an additional diode to protect the adjust pin ...

See http://www.ti.com/lit/ds/symlink/lm117.pdf , page 11 ..  the datasheet is for lm117 AND lm317 but most examples are with lm117, hence why the R1 resistor is 240 ohm in that example ... in your circuit, it's ok to be 100 ohm, LM317 needs a bit lower resistor there (100-120 ohm is good)
Title: Re: My Simple bench power supply
Post by: ttyz on August 20, 2013, 01:46:30 AM
Thanks for your reply mariush,

Yes, of course I am going to use transformer eventually. I already have one - it is 24V/0.8A transformer. And I use 50V capacitors.

I have some questions now:


Now I need to decide if it is necessary to rearrange the capacitors, as I need more of a universal application.

Thanks for support once again.
Title: Re: My Simple bench power supply
Post by: Mr Eastwood on August 20, 2013, 05:50:53 AM
in your circuit, it's ok to be 100 ohm, LM317 needs a bit lower resistor there (100-120 ohm is good)

Hi,  is the value for R1 correct?   surely a 170 ohm with the 5K POT would be a better choice to give nice spread across the maximum voltage range of the regulator?   But if you used the maximum voltage range of the regulator and used the 100 ohm for R1,  according to the online LM317 calculators R2 wouldn't effect the voltage until it was set less than ~2.9K;  so ~5 turns of 10 turn 5K POT would be wasted?   But, I could be wrong :-) as I'm only a beginner in electronics.
Title: Re: My Simple bench power supply
Post by: iloveelectronics on August 20, 2013, 06:13:53 AM
Why is transformer output x 1.414? I thought that 24V in my case is the transformer output voltage. [/li][/list]

Because the spec'ed voltage is the RMS (Root Mean Square) voltage. For sine wave you need to multiply that by the square root of 2, which is 1.414 to find out the peak voltage.
Title: Re: My Simple bench power supply
Post by: ttyz on August 20, 2013, 06:21:03 AM
jucole, Thanks for the calculators advise. I have to play with those.


UPD: I've used this calc: http://www.reuk.co.uk/LM317-Voltage-Calculator.htm
I got these results:
If i need Vout = 20V and R2 = 5K (Max of the pot) then R1 should be 330 Ohms.
And I can get Vout = 30V using 220 Ohms resistor, as my Vin = 24V x 1.414 - 1.5V = 32.4V
Am I wrong with my calculations?

 
iloveelectronics, Thank you, yes now this all makes sense.
Title: Re: My Simple bench power supply
Post by: MJLorton on August 20, 2013, 10:47:21 AM
Hello Evgeny and welcome aboard!

Great to see you are getting stuck into your power supply project and learning along the way.

Thanks to everyone for giving a helping hand...makes me realise all the hard work is worth it if the forum works this way.

I'm off  for the next couple of weeks and will continue my power supply project early in September on my return.

Cheers,
Martin.
Title: Re: My Simple bench power supply
Post by: mariush on August 20, 2013, 11:49:28 AM
ttyz, the regulator needs a minimum amount of current coming from the output pin to the adjust pin through that R1 resistor. If you increase the resistor more than - let's say probably 150-180 ohm - the current may be too low in some cases and the regulator may not regulate properly.  People have had problems with a 240 ohm resistor, which was fine for LM117 but not good enough for LM317 in all situations.

It's recommended to leave that resistor to 100-120 ohm.

Your voltage will be 24v AC rms x 1.414 = 34v +/- about 5-10% (more at low loads/ less at high loads).  The bridge rectifier will waste about 1.5-2v so you are left with about 32v.
But that's with the rectifier producing a perfect DC, which is not the case.  The capacitors after the bridge rectifier smooth out the output and try to get the DC voltage as ripple free as possible.
The formula to calculate how much capacitance you need there is something like  C =  0.75x current / (2 x f x Vripple)  where Vripple is how much you're willing to let the input voltage vary, f is the ac frequency, current is the maximum current.

So assuming after the bridge rectifier you have a peak voltage of 32v, if you want the voltage to not go down more than 1v at 1A, then you have C = 0.75 x 1A / 2x50Hz x 1v = 0.75 / 100 = 0.0075F = 7500uF 

So at 1A, with 32v peak from bridge rectifier, with about 3300uF capacitance you'll have 30-32v DC. It's not a great idea to put A LOT of capacitance, you'd be "stressing" the transformer. It's common to just accept a small voltage drop of 1-2 volts and use at most about 4700uF  for 1A.

Now, LM317 needs about 1.5-2v ABOVE the output voltage to regulate properly, so the best you're looking at when it comes to output voltage is 1.25v - 28v, maybe a bit more if you add a lot of capacitance.

So I suggest aiming for a maximum of 28v on the potentiometer.... 

The output voltage is calculated with formula  Vout = Vref ( 1 + R2/R1)  = 1.25(1 + ? / 100)  so for 28v = 1.25 (1+ ? / 100)   => ? = (28/1.25 - 1 )  * 100 = 2140 ohm.

So now you can do a trick ...  you can put a resistor in paralel with the potentiometer to reduce the maximum resistance.

1/Rtotal = 1/R1 + 1 / R2 =>Rtotal = r1xr2 / (r1+r2)

So for example, you can put a 3900 ohm resistor in paralel, so the maximum will be 3900x5000 / 8900   = 2191 ohm.

Last... keep in mind that the lm317 can dissipate about 15 watts with a good heatsink.  The power dissipated is calculated with formula  P  = (Vin - Vout) x Current.

With 30v in (after rectification, capacitors etc), if you want 3.3v out ... P  = (30-3.3) x current, so the maximum current you'd be able to get out would be 15/ 26.7 = 0.56A.  For 0.8-1A out, you're looking at a maximum of about 15v difference between input and output, and that's with a BIG heatsink (or a smaller one but with fan blowing on it).

A possible solution would be if the transformer has two secondary windings ( 0 - 12 - 24  or  0 - 12   0 - 12) so that if you want your power supply to output  1.25-12v, you switch to the first winding, and if you want more you join the two windings so that you have higher input voltage.
Title: Re: My Simple bench power supply
Post by: Adrian on August 20, 2013, 02:19:01 PM
This is a very good bench power supply for a beginner in electronics because is having an output voltage/current perfect for a op amp(+/GND/-)! 8)
Title: Re: My Simple bench power supply
Post by: ttyz on August 20, 2013, 03:31:06 PM
mariush, wow, thanks for this reply, all this calculations are really great help, now i think I have some understanding of what is going on here.
So now I've changed the schematics to this:
(https://dl.dropboxusercontent.com/u/4269740/PSU/Schematic1.png)

I am still not sure about C2 and C4 values and I need to find a new transformer.

And one more question: will the input ripple affect the output voltage or it all would be regulated?

Adrian, Yes, I am thinking of adding a negative output eventually, thanks for the diagram.

P.S.

Here the enclosure I've got for this project:
(https://dl.dropboxusercontent.com/u/4269740/PSU/enclosure1.jpg)

Martin, And there is a postcard, that I am going to send. I realize that it is already late for the giveaway, but I hope there is some space left on the wall for it ;)
Title: Re: My Simple bench power supply
Post by: mariush on August 20, 2013, 04:31:20 PM
C2 should be 0.1uF usually, but up to 0.47uF would probably be OK. 
Pretty much all ICs should have a 0.1uF or thereabouts capacitor for decoupling purposes.

The capacitor should be ceramic (which means it has no polarity so you can put it either way). It should be X7R or X5R... maybe NPO but those are usually too expensive. don't get anything else or something that doesn't specify which type is.

Should be rated for 50v or more, ideally 100v or more... unlike with electrolytic and tantalum capacitors,  capacitance of ceramic capacitors drops as the voltage on capacitor gets close to maximum voltage rating... so for example a 10uF 50v ceramic capacitor may only be able to hold 1uF when you have 20-30v going through it.   

C4 should be a regular electrolytic capacitor, 10-22uF 50-100v rated should be enough. You can go with more but it wouldn't give you any extra benefit.
If you want, you can use tantalum, but it's pointless and they're expensive (1-2$ a piece for 10-22uF/50v)
Title: Re: My Simple bench power supply
Post by: ttyz on August 21, 2013, 05:08:02 AM
Now the capacitors are in place and I've added some switches. I was thinking of some kind of automatic switching to higher voltage but I think it is not possible without a microcontroller. This might be the next step in the project :)

(https://dl.dropboxusercontent.com/u/4269740/PSU/Schematic2.png)

The only question left is input voltage ripple. How critical 2V ripple is for the output?

I am just waiting for a new transformer now and a 10-turn pot before I can test it on a breadboard.
Title: Re: My Simple bench power supply
Post by: dr_p on August 21, 2013, 08:15:02 AM
The only question left is input voltage ripple. How critical 2V ripple is for the output?

The LM317 Datasheet says this about line regulation:

(https://lh4.googleusercontent.com/-gt8HRq88pDU/UhSsut61j_I/AAAAAAAAC6g/0zTOGjsKsFA/w958-h193-no/Clipboard01.jpg)

So at above 25C (it's obviously going to run hot), with an input-output differential of at least 3V, line regulation is maximum 0.07%/V which is decent I think.

So 12V RMS is 12 x 1.41 = 16.92 peak, minus 2 V ripple = 14.92, minus 3V input-output differential = 11.92V, so it's only decent for up to 12V regulated output.

IMHO, you can add some input capacitance to keep the input ripple lower and raise the max output voltage. I generally go 2200-3300 per each amp, if space is not a problem.

Title: Re: My Simple bench power supply
Post by: mariush on August 21, 2013, 11:07:48 AM
The windings are usually switched using opamps and relays.
For the simple case of a single flip between two windings, it's possible to just use a relay and some passives (resistors,capacitors, npn).

Have a look at the picture below :

(http://mjlorton.com/forum/index.php?action=dlattach;topic=396.0;attach=2082;image)

Basically, the output of the power supply above goes through a voltage divider formed by those R6, R7, and C4.  When voltage goes high enough (this is from a 18v power supply so I think about 7v) the npn transistor starts passing current through it and relay gets energized, switching from 8 to 9.
The C4 I think it's there as a sort of prevention against having the relay flip constantly between windings when user selects a voltage right at the threshold.

Relays are usually running at 12v, so in this design the input is separate (about 15v in after it goes through the db107 rectifier) and then the 78L12 (12v reg, max 100mA) takes it down to 12v for the relay, but if you can get a 5v relay capable of about 10-16A then you should be able to power it from the winding that's always connected, through a 7805 regulator. 
But the relay will use about 50-100mA when it's energized so you have to keep that in mind.

K1A is the primary winding of the relay, K1B is the secondary, it's a relay that always connects something so it has three terminals at the other end ... i forget now the exact term for it.
Title: Re: My Simple bench power supply
Post by: ttyz on August 21, 2013, 02:50:28 PM
dr_p, Thank you, no questions left then :)

mariush Thanks a lot. I think this will be the first improvement after I finish with the simple version with the switch.
Title: Re: My Simple bench power supply
Post by: mariush on August 21, 2013, 04:02:50 PM
One minor observation I would like to add.

I only now noticed that you've added a switch to the output.  That's OK but now you can have the following scenario:

Set psu to 12v
Turn off power supply from output switch
Set psu to 5v
Turn on power supply from output switch.

When you turn off the power supply from the output switch, for a few ms, you'll still have 12v... if the 10uF cap. doesn't discharge through the D2 diode.. I'm not sure.
By itself, the capacitor would probably self discharge within minutes, if not less than a minute.
Still, it wouldn't be a bad idea to put a high value resistor in parallel with it to have it discharge within a few of seconds... try for example with a 4.7k-10k resistor... put the multimeter on the output, flip the switch to power off and see how fast the voltage goes down. If the voltage goes down too fast or you notice the output voltage wobble during operation, increase the resistor value.

I would say if you're worried about the charge on the large 3300uF capacitor, you should put a discharge resistor on that as well - but if you don't plan to touch the bottom of the pcb then just leave it be.  Same values, around 4-10k should be high enough to slowly discharge.




Title: Re: My Simple bench power supply
Post by: ttyz on August 22, 2013, 12:57:57 PM
mariush, Thanks for mentioning this, I will check if this will be an issue when I get all parts I need.
Title: Re: My Simple bench power supply
Post by: ttyz on August 29, 2013, 02:29:18 PM
Hello again,

I am a bit stuck now with the transformer selection:

There is an ordinary one (don't know how this type is called) that is rated for 2A.
(http://lib.chipdip.ru/107/DOC000107288.jpg)

And a toroidal that is rated for 1.5A.
(http://lib.chipdip.ru/109/DOC000109839.jpg)

Both of them have double 12V output.

I assume the toroidal should be better. But this leads me to some current control circuit, because the regulator might be overloaded with even 12V input voltage and 1.5A maximum current.
Title: Re: My Simple bench power supply
Post by: mariush on August 29, 2013, 08:19:50 PM
Use whichever you want.
If you think you're going to need more than 1A of current, use the first type.

The toroidal is better mostly if you use it in audio applications. They're also preferred for other purposes, including adjustable linear power supplies, but for a simple power supply like yours, it won't make a difference. 
The main benefit is smaller size and the fact that magnetic field is contained better inside the transformer which helps with some things.

see http://www.raftabtronics.com/TECHNOLOGY/ElectromagneticBasics/ToroidalTransformerBasics/tabid/112/Default.aspx for more detail...
Title: Re: My Simple bench power supply
Post by: dr_p on August 30, 2013, 03:35:34 AM
Hello again,

I am a bit stuck now with the transformer selection:
...
But this leads me to some current control circuit, because the regulator might be overloaded with even 12V input voltage and 1.5A maximum current.

LM78XX and LM317 both have Internal Thermal Overload Protection and Internal Short-Circuit Current Limiting. So basically it's a lot harder to kill them. However, the project that you are powering will possibly be damaged if something in that project goes wrong and tries to pull 1.5A out of your power supply. Having a adjustable current limit can save your precious electronics if used properly.

But it's a bit more complex for a beginner, so I say go for a simple, non limited supply at first. You are on a learning curve, so you'll inevitably make some other mistakes. You can then use your experience from this build and other projects to build a better power supply, or maybe buy one ready built.

IMHO, it's better to have a DIY cheap ass LM317 power supply than no power supply because you're trying to build a better one but it doesn't work.

Any type of 12V transformer will do, go for the cheaper, smaller one.

Also, as a side note, I think it's worth noting that you will not always get the full 1.5A from the LM317.
The LM317 Datasheet (http://www.fairchildsemi.com/ds/LM/LM317.pdf) says on page 3:

(https://lh3.googleusercontent.com/-sRndLioevpY/UiBFDWEEQXI/AAAAAAAAC68/zjMSu0PFJSM/w1067-h134-no/Clipboard01.jpg)

So this means you typically get 2.2A (minimum 1.5A) when input-output voltage differential is less than 15V and the maximum power dissipation is not reached and at 25 degrees C. That's not gonna happen too often...
From my experience, using a small heatsink, you get about 200-300mA at 1.25V, around 1A at 5V and 2A at 12V. So just be aware that this will most likely happen.
Title: Re: My Simple bench power supply
Post by: ttyz on August 30, 2013, 05:15:44 AM
Thank you marius, dr_p

I think then I will use the toroidal one, as it seems to be smaller.

Do I need any kind of protection for the transformer as it is rated for 1.5A? Can I overload it somehow?
Title: Re: My Simple bench power supply
Post by: dr_p on August 30, 2013, 06:57:10 AM
To be safe, I would add a 3A fuse right after the secondary of the transformer and a 1A fuse on the mains primary. Some people only fuse the primary, considering that a short-circuit on the secondary would increase primary current, thus pop the fuse. I don't know... I'm not trusting that, so I prefer to add a fuse on each winding of the transformer.
Title: Re: My Simple bench power supply
Post by: ttyz on August 30, 2013, 08:45:19 AM
Yes, it can never be over protected I think. Especially for such a beginner like me.

Just wanted to ask if it is ok to use self-ressetable fuses or better to use normal ones?
Title: Re: My Simple bench power supply
Post by: ttyz on October 31, 2013, 02:37:06 PM
Hello everybody,
 
I have been collecting all the bits and pieces for my project, and ran into a problem, while searching for LM7812 (Did not expect this to be a problem, but you never know when russian stores get you  :) ), but I've found an alternative LM2576, and I really liked it, especially the adjustable version, it seems to be much better than LM317 in terms of efficiency and heat dissipation, so I might even do not need this complicated windings switching circuit and have 30V/3A power supply, so for me it sounds like a win  :)
 
The only problem I now have is an inductor. It seems impossible to get the right inductance and current rating at once. I noticed that it seems not very hard to make one, there are plenty of online calculators, but I did not find any good tutorial on this. So if somebody knows a good one,  I would really appreciate the help. I understand the theory, but I need some practical information. The only other option is to get it on eBay, but then it take up to 2 month to get it here, and I might be quite late for the competition.
 
After this I will still need a decent transformer. Guy in the store ensured me that they will have some good toroidal ones in two weeks, so I really hope on that :)
Title: Re: My Simple bench power supply
Post by: dr_p on November 01, 2013, 10:33:59 AM
You must be joking! Surely you can source a 7812 somewhere in Russia. Actually, you must have like 10-20 shops that deliver stuff(tme.eu, ru.farnell.com etc). And they have inductors too. I understand that paying 20$ to ship a 0.30$ regulator is hard, but bulk up the order and get a lot of the stuff you need. Or you can ask the guy at the shop to order some for you. Then 3-4-5 days later you go get them.

Switch mode is great, but maybe it's easier to build a linear one, first. I mean there are a little more complicated. You try to run away from switching the windings and then you choose a switch-mode regulator that you know nothing about, lack the inductor and want to buid it yourself...
It may work and it will be awesome if it does, but I strongly doubt that you can pull it off, since you well... lack the experience.

IMHO, it's better to have a lesser perfect PSU, but a working one. I would advise beginers to build a simple 15V @1A, linear, maybe current limited PSU. When you're done, you not only have a PSU, you have experience in PCB making, fiting parts inside a box, making a front panel, making knobs not stick out too much as to show the nut holding them. Little thing like that, that will serve you very well in the future.

NOW, this is for the contest, so maybe you're better off in sticking to the hard route, give all your best and hope for success, but consider that you might bite more than you can chew.
Title: Re: My Simple bench power supply
Post by: ttyz on November 01, 2013, 01:30:40 PM
Not joking, I was shoked myself. I suppose there are places where I can get those, but I don't know much yet :) Thanks for the links, shipping does cost quite a lot but they promise a 8-day delivery, so I should give it a try sometime. I asked at the shop and they said that they can get any part on demand in 4-7 weeks if I order 10 or more of each. This does not sound like a great deal to me :)

I thoght that switch mode it might be not as easy as it seemed :) It was not really an attempt to build a petter PSU but to build any PSU without having to wait month doing nothing :) But I guess you are right.

Thank you for the advice.
Title: Re: My Simple bench power supply
Post by: mariush on November 01, 2013, 02:55:51 PM
Go to the store and ask for an ADJUSTABLE linear regulator, whatever they have. You only need two resistors to set the output voltage on most such linear regulators.

If you still have no luck... PM me with your address and I'll mail you something on Monday which should get to you within a week... .
I don't know if i have 7812 but I should have an adjustable LM317 (1-2A) or at least a LM1117 (0.8-1A max).  Maybe not LM, but 1117 made by other company (it's a generic part like a 7805 or 7812)


Switching regulators are more complex and don't have the good thing about linear regulators, low ripple and simplicity.
Title: Re: My Simple bench power supply
Post by: ttyz on November 01, 2013, 03:00:45 PM
mariush That's so stupid of me, I already have a spare LM317 so I can use it as a 12V or 5V reference, did not realize that. Thank you very much, I think that solves all my problems :)