EEVblog #221 – Lab Power Supply Design – Part 1

hi one of the most popular art projects in electronics especially for beginners is to build your own power supply your own lab power supply and I highly recommend it as I’ve done on many occasions you should build your own and a good LED power supply is one that has constant voltage and constant current as you might know if you don’t know you do now and how do you go about building one of those well it’s pretty simple as hundreds of designs out there using basic lm317 s or whatever you know a voltage control knob a current control knob for the constant current pretty simple but a lot of people ask how do you do it with software control or at least have the capability to add software control beer from a pig from an atmel on arduino or a pc or whatever our processor or intelligent thing you may not want to use a an expensive 10 turn pot which I’ve recommended you should have on a good lab power supply you may want to use an optical rotary encoder knob and hook it up to a microcontroller and then control the voltage and current that way how do you do it it’s a good question it’s a bit more complicated than your more traditional design that just uses the knobs for the voltage and current they’re very simple designs there’s hundreds of them out there choose your own flavor for your own voltage and current requirements and stuff like that but when you add that software capability to be more complex and also I thought I’d throw in an extra thing is ia supply which goes down to zero volts as well so let’s go through the process of designing building breadboard in and test in a lab power supply that has that sort of capability let’s go and of course the first thing we’re going to start with the specs because if you don’t have specs to work from well it’s going to be a dog’s breakfast so let’s have a look we want a very modest low range supply today just for the sake of argument zero to six volts now that’s important zero volts output R is not always easy to obtain in a lab supply if you’re using a basic lm317 especially when we get down the last one here I’ll go into it anyway it’s not as easy a lot of power applies traditional ones we’ll only go down to 1.2 or 1.25 volts and the reason for that is the reference voltage used in say an lm317 using the design anyway we’ll go into that but we want a complete from 0 to 6 volt range we want a modest 0 to 1 app constant current adjustment on it because a good lab power supply it’s got to have constant current and just know about it we want at and this is a key point we want a optional it’s not mandatory we can use knobs or we can replace those knobs with our microcontroller software control of both the voltage and the constant current value usually using a pulse width modulation scheme because that’s how you generate a voltage and voltage output easily from microcontroller like a pic you use a PWM or pulse width modulator you can use a DAC but most micros don’t have a deck built in so they have pulse width modulator and we want a low noise which basically means we’re going to use a linear power supply we’re going to design a linear power supply today not a switching one and we want a single supply input and you’ll find as we go through you’ll find why that’s are actually important because it’s a heart harder to get a zero a true zero volt output range with only a single supply input so there’s our specs remember them that’s what we’re designed around so let’s get into the design and of course when you’re building a LED power supply like this one of the first devices you’re going to consider is the classic lm317 and you’ve probably seen this before and both of these are configurations it’s a classic device it’s robust it’s low noise it works it’s relatively stable it works in constant current and constant voltage configurations which will cascade to the dunny very versatile device and let’s take a look at what how you can build a a basic LED power supply with an lm317 based our system now we’ve got our voltage input here and we’ve cascaded to lm317 in series now what we’ve done is we’ve used the classic constant current configuration where we use a single in this case adjustable resistor you’d have to use a wire round pot in there to set your constant current or in this case a maximum constant current which it won’t exceed and it to the spoilers are very simple to calculate the maximum current is the reference voltage 1.25 volts as we’ve seen divided by I 1 up here and that gives you you your maximum constant current and because basically very little current flows through these resistors and it’s basically in series with your load your output here then your output load will not exceed that maximum value you’ve set but it can draw less no problems at all and it passes it straight through so if you put a constant current lm317 first before a voltage a standard voltage mode lm317 bingo you’ve got your constant current and constant voltage lab power supply and of course the output is just the classic voltage configuration with the divider resistors and adjustable pot here you can adjust your voltage beautiful so what’s wrong with it for our design today well turns out there’s quite a few things wrong with it actually the first one is you remember a spec from 0 volts up to whatever voltage we need to go down to 0 volts but the lm317 doesn’t allow you to go down to 0 volts it only allows you to go down to a minimum of 1.25 volts and that is because of the internal our voltage reference in side of it and the second one is is that this adjustment pot here and you can’t it’s not terribly good down at the very low level so if you wanted to set an output current of 1 milliamp you know it’s not that great down there third how do you adjust these with a you know a microcontroller or a software function it’s quite difficult well it turns out it’s not that hard for the voltage you can actually what you can do is get these out of the circuit completely and just drive this directly with a buffer from a pulse width modulated what filtered of course to turn it into a voltage but you can feed that directly from a voltage and that can come from your microcontroller or come from another pot or whatever can drive it directly you can effectively override the internal reference and circuitry and actually drive a direct problem with that though is that whatever fault if you feed in one volt here you don’t get 1 volt out you actually get 1 volt plus the reference voltage of 1.25 volts you get out 2.25 volts here and well you can take care of that in software it’s not too hard so the voltage configuration you can actually drive it with software so let’s actually build up this lm317 circuit and verify that it actually does what we think it does now here it is got my lm317 I got bypass caps on the input now put the inputs the top rail up here coming from my lab power supply grounders down the bottom here the right hand pen over here is the input there it is there the output is the center pin or the tab the center pin is electrically connected through to the tab up there I’ve got a load here I’ve got a 1k load just to because these devices if you check the datasheet do actually need a minimum load and we’ll take a look at that in sec and this orange wire over here is our adjust pin which with a typical lm317 as you would know it’s a basic building block circuit you would have a voltage divider on the output and then you’d feed it back to the adjust pin to get your output voltage but in this case we’re going to actually ground it like this and see what we get and or so then drive that from our low-impedance second LED power supply actually drive a voltage into that adjust pin and see what we get out alright let’s check it out see what we’ve got now input voltage is just over seven volts and our input pin is grounded let’s measure our output here bingo there it is one point two five three volts and that is the reference voltage the internal reference voltage used in the lm317 and if you’ve only got a single supply input like we’ve got here from zero two zero two seven or whatever voltage it is then you can’t get any lower than that 1.25 volts output because we’ve grounded our input here we can’t get any lower than that so that’s why a lot of traditional LED power supplies will only go down to 1.25 volts because it’s the reference voltage used in there now I mentioned that loads important well let’s actually check what happens to the output if we disconnect the load like that so all we’ve met all we’ve got now is the bypass cap well let’s check it out remember it was uh there we go it’s jumped up to six point four volts it is not 1.25 anymore and if we plug it back in bingo we’ll get one point two five there you go now ordinarily you don’t really have to worry about this with a traditional lm317 circuit with the voltage divider on the input because the voltage divider if you read the datasheet is designed to and the values are low enough to actually present the minimum load requirement of the lm317 but because we don’t have that voltage divider and we’re just driving the input pin like this then there’s no minimum load and we’re going to need a minimum load on there to make them to actually make this thing stable now I’ve got the adjustment of the lm317 connected through to my external another second external variable lab supply which we can adjust here and I’ve got the meter I just hooked up with some alligator clips out of the airport and I’m feeding in 1.25 volts from my lab power supply and look what we’re getting out 2.5 1 bingo it adds up so any voltage you feed in to this adjust pin on the lm317 you’ve got to add one point to 5 volts and there it is there and if we adjust that set pin to 5 volts what do we get you guessed it six point two five or six point two seven bit of error there but there you go we whatever voltage you feed into that set pin you’ve got to add one point two five volts and that’s really quite annoying from a well at from a software point of view it’s probably not that bad because you can do the math and do the adjustment in software whatever value you set on your part you know you’ve got an output Y at one point two five volts higher than that but it’s it’s not nice it’s not elegant and of course the lm317 doesn’t go down to zero volts so that’s hopeless and of course our I had to turn just in case for those who are wondering out there yes I did have to turn my input voltage up from the suburb alts because we were too close to the dropout voltage that regulator remember there’s a couple of volts drop out voltage on an lm317 now you can actually get the output of the lm317 to go down to a closer to zero volts if you are feeding a negative voltage into the set pin and you offset it by that 1.25 volts now in this case I am actually feeding in – 1.25 volts because I’ve swapped the leads look I’ve got my negative lead going into the adjust pin and so I’m effectively feeding in minus 1.25 from my supply instead of plus 1.25 and I can do that because my power supply is floating the outputs are floating remember that that’s important now um I’m feeding in minus 1.25 and we’re getting out naught point 1 to 5 volts it’s not quite the zero as you’d expect that’s because what turned itself off there we’re falling victim to the minimum load requirement you’ll notice that this isn’t the one a value resistor anymore we were using before to get our minimum load this is a this is a hundred ohm resistor so it’s only going to let us go down to 0.125 volts if we lower that value resistor again we’ll able to be get closer to zero volts and just to prove that I change the resistor value to 22 ohms and there you go we’re getting pretty darn close to zero about 28 millivolts so that’s an example of something you’ve got to be careful of when you’re designing these sort of power supplies with these voltage regulators that minimum load requirement is actually quite important and you’ll find that we’ll have to I’d take that into account later on in our final design but it doesn’t satisfy our requirement of a zero volt output not unless you start using split supplies and driving things negative and doing fancy stuff like that but yeah it’s just it doesn’t meet our spec there another thing it doesn’t meet is how do you adjust this pot here how do you convert this pot into digital control well it actually turns out that it’s a reasonably difficult you can’t just well you could get it like an e squared pot or something like that but you got to watch your maximum voltages a lot of those alone they go up to six or alright you know getting once it got to 12 volts are quite rare any higher than that rare again you’ve got that big dropout voltages your voltage here has to be several volts greater than your output and you’ve got another drop on here it’s just it’s not pretty at all and it’s not going to meet our requirements we’re going to need something different but although we might end up using something different today for our final design the configuration is going to be quite similar or can be quite similar you can actually design some circuitry around here to replace an lm317 type a constant current configuration and we will actually use the technique of overriding a pin on a voltage regulator so standby so how exactly do we start designing a circuit to overcome some of the limitations well I think the first thing you should do is take a look at how these lm317 actually work because you might be able to you maybe duplicate them with some similar circuitry now if you have a look inside a typical lm317 broken down you’ve seen this before it’s just an error amplifier with a series pass transistor in this case it’s a Darlington usually a Darlington transistor pair like that your input terminal your output terminal usually there’s some like little protection small amount of protection resistance in there and there’s overload protection circuitry in there and thermal overload and there’s some extra stuff but the basic operation is just that series pass error amplifier and the voltage reference here and whatever and of course you’ve seen how this works before the op amp controls the series pass transistor to make sure that the output voltage matches the input voltage because that’s what not amp does it makes it does whatever it needs to on the output here to make sure that these two inputs are the same value and in this very simplified block diagram here you can actually see why we have to add on the reference voltage onto our adjustment but you see that we can actually for y we can force the adjust pin because it’s effectively just setting the value on that op amp there so really I’m in theory as possible we can use a discrete transistor a Darlington transistor on the output like that we can have an op amp like that and we can feed it back and we can just feed our voltage directly into this pin and that’s why you can actually design a constant voltage power supply using a will a linear regulator like this using a software control or something like that because this value can come from a pulse width modulator / dark it could come from a pot could come from whatever so as a first step let’s replace our lm317 voltage circuit with effectively what’s inside there if we use a discrete our Darlington transistor on the output can be a standard transients or it can be a MOSFET and I edited let’s not get into the details of that but we use a series pass transistor and op amp just can be a regular op amp and we put it in the error configuration like this needs some output capacitance to keep it stable but there we get rid of the voltage reference which is inside and our V set pin whatever voltage we put on the non-inverting input of the op-amp like this should be on the output like that bingo but you’ll find that in practice this is not an inherently stable stable configuration it’s very tricky to get this stable in LED power supply like this over a whole bunch of output load capacitances and configurations and and currents and all sorts of things so by all means build this up try it yourself experiment with it you will be able to get it to work but I think you’ll find be a little bit unstable but anyway that is a way that we can do the constant voltage our aspect and this V set of course can go right down to zero and the output will go down to zero – in theory subject to minimum load and other things to keep it stable so we can drive this V set directly from either a pot multi turn pot single turn pot or from a DAC or pulse width modulator micro output so just like using an lm317 I don’t want to muck around with trying to make it you know stabilize this and worry about all that only using off-the-shelf solution aha I remember the LT 30 80 / 30 85 from my first blog and I mentioned it a couple of times it’s one of my favorite little linear regulators because it has if you look inside of it exactly this circuitry and it’s designed to be stable bingo or use the LT 30 80 so I think we might have constant voltage part sort it out what about constant current it’s a bit harder to try and adjust this value in here but anyway let’s try it using the same technique of replacing it with this kind of circuitry and to do that I think I’m going to need a little bit more room so I’ll erase all this and we’ll concentrate on the constant current part so what have I come up with to replace the lm317 constant current circuit well tada here it is it it’s rather neat I think I like it now it looks a little bit complicated but stick with me it’s not trust me now we’ve replaced where we’ve got the lm317 constant current equivalent circuit in this red box here remember we’ve just replaced it Ferro amplifier the series pass transistor and we’ve got a 1 ohm current sense resistor here it’s 1 ohm because 1 ohm makes the math really easy because what we’re after here is what we want to do is we want to because we want this PC controlled remember on software micro controlled we want to convert say 0 to 1 volts from a microcontroller or from a pot or whatever source it is into a 0 to 1 amp a constant current limiter circuit like this so we want to feed in 0 to 1 volt and get zero to one amp out ok let’s try and explain this circuit shall we now hopefully we won’t get lost now here’s our voltage control input we’ll call it V set and we want zero to one volt to represent zero to one amp are currently meeting around this circuit so we’ve got a buffer here because you need a buffer if this comes from a pulse width modulated output with an RC filter you want that’s not good enough to drive this circuit so you need a buffer there so this is our 0 to 1 volt control our input now it goes into this adder or summer circuit here and then that is fed into a times to amplify here into the non-inverting input of this constant current equivalent circuit now if you remember how the lm317 worked because it had a voltage reference in here of 1.25 volts and it fed directly around to this pin here with no additional circuitry like that then the current eagled 1.25 volts divided by 1 ohm or 1.25 amps in this case and we’re basically replacing that direct feedback with the circuit that allows us to inject the 0 to 1 volt heart signal and raise it up so that it can trol this higher voltage circuit up here and this is what this little part of the circuit does now the reason we’ve got a gain of times two here is because this divider here is effectively dividing that this voltage by half so we need to compensate for that by having a gain of two here and you can muck around with these ratios or you want but they’ve got to basically match each other so that they’re equivalent but we need but because we have to feed in this voltage down here and it’s got to go into this adder we have to compensate with this game of times to here now I could try and explain it but let’s just go through a worth example I think that’s probably the best way to illustrate it let’s start with the example at the extreme bottom where we’ve got zero volts here so this is effectively grounded and let’s say our output here is at 10 volts so this mode here is going to be exactly half of that half of 10 minus zero so it’s going to be 5 volts here on this node and of course this has got a gain of 2 so going to have 10 volts here so this voltage here at this point is going to be 10 volts as well and if you’ve got 10 volts on either side of a resistor like that what’s the current flowing through it 0 Ohm’s law so when we’ve got 0 volts input here we have zero current flowing through that resistor regardless of what the load is trying to do the loads till I want more current or more current I’m shorter down on you know right give me current it’s not going to because there’s zero volts across that resistor can’t beat Ohm’s law and just as a reminder that works because of op-amp action this op-amp tries to do whatever it can on its output to make sure that these two inputs are the same so if this voltage here is 10 volts and we’re feet well 10 volts here on this pin because it’s being fed back and raised by 2 there’s 10 volts here it makes this pin here 10 volts as well it drives all this circuitry to make it 10 volts and that’s why this input there’s a dropout voltage it needs to be higher than that 10 volts significantly higher so that it can so that the actual circuit itself can function and if you’re wondering about the power supply for these op amps it all this by the way it works from our single supply because that’s part of our spec so this would be grounded here like this and this actually would be connected to the input like that so the input voltage must be significantly higher then then the voltage that we’re actually trying to control so there will be some dropout voltage there but all of this all these op amps can be powered from this one supply alright we’ve done the minimum case of zero volts control signal what if we do our maximum case of one volt so our control voltage here is one volt and once again we’re going to assume 10 volts there just for the sake of this calculation now forgot 1 volt here and 10 volts there it’s actually 9 volts drop across these so it’s 4.5 volts per resistor and 4.5 volts down from 10 volts our node here is going to be 5 point 5 volts and you see how it’s added that it’s a it’s added that 1 volt above it because if this was ground it was only 9 volts drop into before and a half volts here but it’s not we’ve added on that 1 volt because our reference point is up the top here so this node here is 5 point 5 volts a gain of 2 bingo we get 11 volts out here VR our reference voltage is 11 volts and that juda op amp action we’re going to get 11 volts here and what’s 11 volts minus 10 volts over 1 ohm it’s 1 volt over 100 is 1 and so regardless of what the load is trying to do it screaming it shorted out it’s doing whatever you can short this puppy out to ground like this and it will it will generate 1 volt across that resistor and limit the current to 1 amp magic and it’s pretty obvious that it’s going to be linear within that range we have tested the two extremes and it works so you just because this yellow there’s nothing nonlinear going on here you know that it’s going to work those Rangers and if you want you can go through and you can actually test out different cases and half a volt or ten you know a naught point one volts or something like that for a hundred milliamps do whatever one thing to remember though is that with the 1 ohm resistor here at 1 amp you can add one volt drop across there and that’s an additional drop so you’ve just got to take that into account in your design it may be fine for you you because your input voltage may be quite high you know one volt here plus your additional drop further on on your next stage for your voltage side of the voltage regulation you’ve got an additional minimum dropout voltage there then it all adds up just make sure and if you wanted to lower their value of that resistor say 2.1 ohms then you can compensate with the gain of this circuit no problems whatsoever to lower your voltage drop but yeah you can’t go arbitrarily low because then you get down in noise problems and things like that now I encourage you to go and build the circuit up and try it for yourself and maybe even simulate it and do stuff like that but don’t ultimately as with all these type of configurations they can be quite hard to stabilize especially when you’ve got a variant load in lab power supply so ultimately you might want to replace this with an already are stabilized solution like the LT 30 80 now as it turns out this circuit is quite inefficient in terms of parts utilization we can actually eliminate and in an op amp entirely from this circuit how do we do that if you had your thinking cap on you could see that the gain of two can be actually put in this feedback path instead of the gain of two here you can actually divide by two in this path so if we get rid of this and feed that directly into there like that and then we break into here like this we can add our 10k there and we can have a 10k going to ground like that and that is exactly the same configuration if you I believe it go through the example and try it again so hey now we’re getting somewhere here is our lab power supply so far it’s got 2 LT 30 ATS one for constant current one for constant voltage and we’ve got two voltage set pins from the current set pin goes from 0 to 1 volts which represents 0 to 1 amps we’ve got our voltage set pin from 0 to 10 volts or whatever your maximum output voltage you want consistent with the maximum specs of your components and you know it’s getting there and of course you probably want a few extras you probably want to be beefy protection diode on the output like that and you remember that thing we said about minimum current load as well the output of this sucker fits drawing no current not that great doesn’t go down to that lower voltage and can cause issues we could have some major issues there so we may have to add some some sort of load on there to get our minimum current out of there and oh that’s ok but jeez gosh darn it I don’t know the LT 3080 it runs to about 3 or 4 bucks each or something geez your shave that cost off simplicity and if you’ve got two devices like this remember they will be sharing the heat as well so not only do you have to have a heatsink that actually yeah you can mount both of both devices on there in constant current mode you’re going to be dissipating most of your heat in the constant current regulator in constant voltage mode you’re going to be dissipating most of the heat in this regulator and so on but I reckon we can eliminate one of these regulators let’s give it a go so just how do we plan to eliminate one of these regulators are here you are squirrel you’ve obviously got to have your voltage regulator it’s got to be there but maybe we can do something with this adjust pin here to regulate the current instead of having a whole nother you know instead of having a limiting it back here actually limit limit the current inside this device get this device to do both jobs voltage and current limiting how do we do that well we’ll find out now if we want to get rid of this we still need a current sense resistor we’re still all of us sense the current so let’s keep our 1 ohm resistor and let’s tap off the voltage on there and see what we can do with it ok here’s what I’ve come up with now once again may look a bit complicated but it’s not stick with me it’s all basic building block stuff now what we’ve done is we’ve got rid of the current LT 30 80 up here the current regulator up here and we’ve replaced it we’ve still got the 1 ohm current shunt resistor you got to have that got to have something to measure the current actually flowing in the input and you can do this by the way even all this you can put this before the regulator because there basically is very little current flowing out of the control pins of most voltage regulators so all the current in is going to be basically equal to the current out you may have to take it into account as you might see but basically that’s how you can get a way of doing it here instead of on the output something like that where you end up dropping the voltage because if you put in the output either the high side or in the return ground path which is called the low side current shunt then that will drop some voltage and your output voltage isn’t going to be as well it’s going to have a voltage drop it’s not exactly what you said it so not ideal so it’s better to have it on the input side of the voltage regulator and let it handle it anyway we’ve replaced it with a differential amplifier and if you know your basic building block or camp configurations this is a single op-amp differential amplifier it’s not that great but it’s probably good enough for our purposes you could actually replace all that with a a proper off-the-shelf differential amplifier like an 86 20 or something like that they’re quite expensive and you know yeah you don’t need that sort of precision anyway what the differential amplifier does is the output voltage here at this point here will be equal to the difference in voltage across that resistor so if there’s one amp flowing through there will be a 1 volt voltage drop and you get 1 volt out of here simple now one of the key parts to this is this little bit here and this is the current limiter and how this works it’s using you’ll notice there’s no feedback on this op-amp it’s using it as a comparator and once again you can replace this with a comparator but we’ll use and our op-amp in this particular circuit now you’ll notice that because this input to this op-amp is high impedance you don’t need this driver anymore you can eliminate that entirely and just connect your I set so it’s still got out three op-amp configuration we haven’t increased our number of op amps but we have dropped one current regulator device over here so that’s a parts count and possibly cost advantage now obviously if this is working as a comparator if this voltage here let’s say we’ve got one amp flowing through here one volt I’ve got one volt here if that is greater than the current we’ve set on our pot remember from zero to one volt zero to one amp we set it to you know not 0.99 volts or not point nine nine nine volts then this one volt will be greater than that and it will switch on this transistor here which is the same we’ve got the same circuit here before remember this is exactly the same just ignore these resistors for a second and before we had this connected directly to the adjust pin to control our output voltage simple but we can’t just short out we can’t just add this transistor which will short out the output of this op amp it’s not very nice for the op amp and it’s not going to work too well so we need a series current limiter resistor in there let’s make it 1k and let’s make another 1k resistor there and bingo when this input sorry when this is one volt when it goes into current limiting mode ie the volt the current flowing through this resistor has exceeded the value exceeded the value set by your adjustment total your microcontroller whatever it is then we’ll turn on this transistor and pull this pin adjust pin low which will then drag your output voltage low with it but of course because you’ve got output capacitance here it’s not going to instantly drop to zero it’s actually going to slowly go down or go to it’ll go now reasonably quickly but it’ll drop and then it will sort of survey so the current so the output voltage will drop so therefore your load the current in your load will drop so therefore it will kind of like oscillate in servo and control that and keep it at an average value of one amp and also I think we’re probably going to water add in some capacitance in there as well not only to know it lower the noise of the regulator if you look at the data sheet which we will later for the LTE 3080 to put a cap there you can actually lower the output noise but that will also just help stabilize things and you know slow down the operation of the current adjustment and stuff like that but that’s the whole mechanism behind this thing is that it basically switches the output off and on off and on so that it gets that average value only in current limiting mode though does that happen when if you’ve got one volt set for your current limit one amp set up here and your output current is less than one out then none of this turns on this transistor stays permanently switched off and this acts just like a the standard of voltage regulator by setting this pin if you’ve got one volt set in one volt output you’ll have one volt here and bingo this transistor is turned off so that’s not there is effectively no current dropped through these resistors and you have one volt here and you have one volt there easy but as always I simplified things and lied to you a little bit by saying that there was no current drop in these resistors but if we check out the data sheet for the LT 30 80 might be a couple of traps for young players so let’s go have a look at the data sheet but hey is our circuit I think we’ll build this one up you

Leave a Reply

Your email address will not be published. Required fields are marked *