Dave goes through the final base schematic for his Open Hardware lab power supply design.
Schematic is here:
http://eevblog.com/uploads/uSupplyBenchRevA.pdf
Schematic is here:
http://eevblog.com/uploads/uSupplyBenchRevA.pdf
Hi, it's time for the next part in the power supply series. I've been designing this cute little power supply and I thought we'd take a look at the final schematic. Let's go. And if you remember the previous videos, here's the existing circuit we already had, which I breadboard it up.
We pretty much developed this uh, from scratch. Now the uh, the final Uh schematic we're going to go through today is essentially exactly the same configuration as this, but I've gilded the lily a bit, added a few niceties, and uh, put some uh system engineering into it I guess you could say and taada here it is. Here's the final schematic. Now it might look a bit complicated.
that's cuz I've put it all sort of crammed it all onto an A4 uh sheet here. It's not terribly modular, but stick with me. we'll go through it and you'll see that it's not that hard at all. It's very simple.
First of all, if you take away all the other circuitry there, you'll find that this circuitry in here is pretty much identical to our existing circuit here. So let's take a look at that part of it first. and the current shunt. that uh, current shunt, amplifier and resistor which I've changed up here.
But before we do that, let's just take a look at uh, the thing from a block diagram level, shall we? This is exactly the same circuit we had before I've added a microcontroller down here. it's an At Mega 168. It could be an At Mega 328 or whatever. Any of those 28 pin at megas it's going to be Arduino compatible because the software will be written in the Arduino software environment.
I've added external ADC an external ADC here around here with some voltage follows and an external deck as well. Now you know how I did the video on the pulse width modulation output and how you can control the output voltage of current with Pwm I was originally going to do that cuz most microcontrollers are only 10bit resolution. uh adcs. so I I don't know I decided to Guild the lily a bit I wanted a bit more resolution so I'm using external 12-bit Dack and an external 12bit ADC which we'll go into later.
Uh, up here we've got the LCD because we've got to have an LCD display to display the voltage and carrent and all sorts of other stuff. It's a Ice Squ C one. we'll go into that. some push button switches, rotary encoders down here, two of them, one for voltage, one for current.
Decided not to use the more expensive Uh 10 turn pots. um up here I've added a 5volt uh USB um output connector on the front panel with some um iPod kind of compatible uh things in there so it can, uh, tell an iPod that it's a genuine charger just so that you can power 5V USB devices directly. There's a couple of voltage Regulators up here and here. I've added I've really gilded the Lily here.
I've added what is essentially one of my microcurrent devices into the design here. So I I think this is probably one of the first uh Power Supplies bench power supplies on the market that I'm aware of anyway that can measure down to microamps Output current so it can do a massive range uh, from anywhere from a couple of micro amps all the way up to a couple of amps with full resolution and full accuracy. So that's a little nicety. I've gone to the trouble to add there. we'll take a look at that, but that's the basic block diagram in the previous design. We used a a very uh, crude uh differential amplifier here for the current shun and that's not very accurate at high resolution stuff 10 or 12 bits which we're trying to do here. it' be okay for 8 bit or something like that. but so I've decided to add a uh maximum uh Max 480f uh highs side Uh current Sense amplifier It's specifically uh designed for the task and it does a really nice job.
It's only a doar or $150 or something like that, so it's You know it's reasonable price, but it's very accurate and does a really good job. The current shunt resistor here I've actually made up um I've Well, when I've laid out my board, I've put in uh 10 half W half WT resistor um Footprints in there so that uh, you can uh, basically get better than your uh 1% uh, typical tolerance because it's quite difficult to get an accurate Precision current shunt resistor like half a% or 0.1% or02 or something. It's very difficult to actually get those. They're very difficult and expensive to source.
so I've put 10 resistors uh, in parallel. so hopefully if you seen my previous videos on the Gyan resistor response, we should get better than the typical 1% resistors. We're using the tolerance there now because we've got an intelligent controller over here. we don't really need technically need um, a high Precision accurate resistors in all of this power supply design because we can all we can calibrate the thing and compensate for that in software.
But I that's just not nice I didn't want to have to do that so I've made this overall design fairly. High Precision So I've used a 0.1% um, high side current sense amplifier here I've used .1% resistors elsewhere in the circuit down here as we'll see Um and the current sensor resistor. Well, we'll see what we can get when we actually build the thing up, but I'm going to try and get it as accurate as possible. Now you'll notice on my schematics I've added these uh notes in various uh places here and I love doing that sort of thing cuz it just uh put formulas and things like that in little uh boxes next to, uh, the next to the actual pin that you're actually uh, talking about and it just helps explain the schematic.
and when you come and look at it later, all the formulas are there and you don't have to do the calculations. It's all done and little notes and things you know you might add a star ground over here. So you put little notes and current values and things like that. That's just a nice touch to add to any schematic that you're actually doing.
So we're using a maximum 480f high side current sense amplifier and that's got a fixed gain of five. It's basically a differential amplifier so it measures the differential voltage across a highs side current shunt resistor we've got here and it multiplies by five and it gives you a direct voltage uh, output referenced to ground and that's all It is. Very simple device and this is a quite uh, a precise PR one and it's 0.1% So with a gain of five, we can do various calculations up here for various current shunt resistor values. Now I'll just mention that I'm actually using a 2.04 voltage reference here. It happens to be an ISL 21070, but it can be any one on the market. really. Um, it's You know, it's not too bad. It's 30 PPM plusus .25 Uh, .25% Now, why I'm using 2 048 Vols instead of the more traditional Uh 2.5 volt voltage reference is because then the values that we're going to get out of our analog to digital converter are going to be spot on.
We don't have to fudge them or do anything like that Now I'll give you an example of that. Let's say we use a 2.5 volt voltage reference. Okay, and we're using a 12-bit analog to digital converter. There's going to be 2 to ^ of 12 or 4,096 um, different steps in that analog to digital converter.
Now if we divide our 2.5 Vols maximum input to our analog to digital converter cuz we're using a 2.5 volt voltage reference, Divide that by 4,096 steps, You end up with some weird ass value here of 610 or thereabouts. Uh, microvolts per bit resolution on your analog to digital uh converter and that's well, that's hopeless. You know, if you H feed in 100, you know if you're measuring 100 bits out or something that represents a voltage of you know 61.0 35 mols. It's not a nice round number.
It sucks. So and you have to compensate for that in software, you've got to uh, actually do some math in software. It's not that bad. But there's a reason they make these voltage references which correspond to uh the uh like a power of two uh to match your analog to digital converter.
In this case, 2.04 Vol But you can get uh 4096 Vol uh voltage reference. But uh, 2.04 volts is more common so we're going to use that. So look what happens if you're using 2.04 volts. Okay, on maximum ADC value and you divide that by your 4,096 bits.
Bingo you've got a nice round number of 500 microvolts uh, per bit. And if you have a look at up here of when you translate this into your current shunt values, you end up with a very nice round. 500 microamps per bit resolution. Or if you use different values, you can have 1 milliamp per bit resolution precisely from the output of your analog to digital converter and that works out really nice in your software I Love it and that's why I've used it.
Now if we take a look at our current shunt resistor R Here let's take a value of Uh 2 Ohms. If you put 10 in parallel, you're going to get. 2 Ohms current shun resistant Now I've put up here for a gain of five in this Max 480 Remember it's built in gain of five. You can get different versions in a gain of 20 or I think a gain of 60 but we're going to use a gain of five and I'll tell you why in a minute. and uh, that for a that will give us because it's a gain of five. Okay, 0.2 Ohms Let's say an amp uh through it is 0.2 Vols multiplied by a gain of 5 is 1 vol. So you're going to get out of your uh current, shun your uh current sense amplifier. Here you're going to get out 1 V per amp output.
and of course, that will give you a range because you're using a reference voltage on your analog to digital converter. It's going to give you a range a usable measurable range of 0 to 2.04 amps and that translates to 500 microamps per bit resolution and you can go through. Let's say you wanted to use a 3 amp version of this LT 380 the LT 383. Then uh, you could say set it for a 4 amp current range and you get what still get an excellent resolution of 1 molt per bit.
Awesome! And because you've used 10 resistors in parallel like this, say at half a wat each, or you might have a 1 wat resistor in there, then you might have 5 wats or 10 wats dissipation capability in your current shunt resistor there. And that's plenty. So this current shun resistor isn't going to heat up at all. So you can use um, you know, fairly low grade ones and they're going to work quite well.
They're not going to change much with temperature because they don't heat up much. Let's take the example of the 2 Ohm resistor here. If we've got 2 amps flowing through it, I^ 2 R 2^ 2 is four and times2 ohms. We're only going to dissipate 0.8 watts in all of those resistors.
and we've got if we' Got 5 wats total capability or 10 wats not a problem whatsoever. it's not going to heat up much at all now. of course, the value of your current shunt resistor is going to determine how much voltage drop you get across there and depending on your input voltage over here, depending on what you power it from, that may be an issue in this case. If we use Uh 0.1 ohms Um, then we're only well in either of these two cases.
up here, we're only talking about a 0.4 Vols maximum drop which really isn't that bad at all. and you don't want to make it too low and use like a gain of 20 here or gain of 60 because then you can start getting right down into the noise and you can get errors and issues like that. So you really don't want to go there. you want to.
Uh Toler It You want to get as maximum voltage drop across your current shut resistor as you can tolerate and the lowest gain here so you minimize your errors. So how much error can you tolerate in this amplifier here? What's the Uh minimum? Well, it depends on your specs and what you're willing to, whether or not you're willing to compensate for it in software which I don't really want to do I Want to try and get the maximum um, uh, possible, uh, absolute accuracy out of this thing. So the input offset error of this amplifier is going to matter so you can't make this resistor shut resistor arbitrarily small because then, uh, the voltage drop's going to be so small, it's going to be swamped by the input offset voltage of this uh Op amp of this amplifier here. So what's the minimum that we can tolerate? Well, it's a basic rule of thumb is that Well, you don't want it to be any more than one bit resol. Solution On your analog to digital converter, you want to be able to measure accurately down to your last bit. Why not? So in this case, we've got 500 microamps per bit. So 500 microamps is the minimum we can measure. So if we do 500 microamps here, uh, times our Uh 2 ohm resistor there, we're basically going to get 100 microvolts drop across this resistor here.
So that's the minimum that we're going to get 100 uh microv volt. So let's go over to our data sheet here for our Max uh uh, 4080 device and what's its? input offset voltage HH What a coincidence. It's 100 microv volts. Typical, You could go into there.
Uh, but it's going to be 100 micro microv volts input offset voltage. So as you can see, the max 480 is almost ideal for this. Its input offset voltage is exactly the same as uh, our minimum voltage on our input here. That's pretty good.
I Mean ideally you know if you're designing a really high Precision thing, you'd want it to be maybe an order of magnitude low. you know, order of magnitude lower or something like that. but in this case, perfect. Good enough.
We're happy for a one bit uh error there. And of course the input uh offset voltage is just that. it's relative to the input. so this amplifier has a gain.
So the actual Um output uh, the area you're going to get on the output is the input offset voltage Time 5 which is 500 microv volts um error on the output. but because, um, it's scales up five. we're still only talking about one bit uh, error there caused by our input offset voltage. Beautiful.
And as I said, you just can't make that resistor arbitrarily low. CU Not only is there input offset voltages, but then you get um, uh, noise and things like that causing issues. So there you go, that's almost perfect that device and just to get rid of any noise, I've had just a little um RC low pass filter there which then goes down into our existing circuit which we've seen before our Um our constant current Um comparator down the bottom here. And not only that, if you look at the net name there, it also goes over to our analog to digital converter over here one of the channels there it is ADC I out.
Now speaking of the ADC, we've used a four Channel one here and so it's going to measure U Not only does it measure the Um output current via here, it also measures the output current from this microamp Uh circuit over here. So I can measure the current two different ways, either in series with the Uh output. like that. Well, they're both in series with the output. I'll explain this one later, but it measures the output from the microcurrent and it can also measure the output voltage which we'll take a look at there and also the Um ADC input. uh, the voltage input as well coming from your source. So then your software is able to determine whether or not um, it's got adequate voltage and whether or not this regulator is going to actually drop out. So our 2.04 voltage reference here goes into the Uh Dack over here the 12-bit deck and it also goes over to our 12-bit analog to digital converter here.
and both of those are Uh devices From Microchip, this is. The deck is an mCP 4922 and the ADC is an mCP 3204. So why did I choose this specific analog to digital converter and DAC Well, let's find out. Let's go and do a parametric search in Digi key here.
Let's search for ADC and we'll go down here to analog to digital converters ADC There we go. Almost 12 13,000 of them. Can you believe it? And here we go. Here's our parameters: We want a 12bit converter only.
There's no point searching for all the others, so let's drill that down. Bingo We're still. We got 4,434 different Uh converters? Well, uh, because this is a kit we only want through hole. so we'll select through hole over here and we apply the filter and bingo, we're down to 439 Adc's so from these particular manufacturers, Microchip I like them National Texas You know all the biggies are there.
linear Analog Devices But uh, let's sort by price because, well, really? I uh I do care about uh I do care about price. so let's search for that. Let's say we're going to make 100 kits. Let's sort by price based on 100 and uh, bingo.
What comes up first? Not terribly surprising. microchip. They make pretty cheap. uh, anlog Parts People think they and people mostly know them for their uh, uh, pick microcontrollers and stuff like that.
but they make some, uh, pretty cheap analog stuff I'm finding I'm using more and more of them. uh, lately. So basically, uh, let's have a look at the number of converters. It's only got one bang.
Not too happy with that. we want. Uh, basically, we want something with at least four channels in there. so let's select that.
hey, what's going on? No. I Pretty sure there's a microchip one in there, so something's happened to that. Digi Key search I Don't know what's what's gone wrong there. Something horrible.
but uh, here, no, Here we go. Ah, look the digi Keys Got it wrong. Here's my converter. It's a four channel.
It's only got one number of converters one What fail. Okay, so much for that. But there you go. The cheapest devices there.
um, these are single Channel dual Channel and the cheapest uh uh device for channel ADC we can get is a microchip mCP 3204 and bingo that's the one I used purely because it was the cheap cheapest in quantity. it $240 in 100 of quantity. which is you know, expensive. but it is a 12bit uh converter. The next uh nearest brand is um, analog device sorry Texas Instruments ads 782 um but that that won't be a full channel in an eight pin uh package. So really, you know there's no competition. The prices start going up and up and up. So that's why I chose the microchip and I did exactly the same thing for the deck and the matching microchip deck.
Uh, unsurprisingly I guess came up as the cheapest again. So that's why I used them. That's parametric search. and if you're wondering why I just didn't use a microcontroller with a 12-bit analog to digital converter and Pwm in it? Well let's take a look.
I've gone through and selected all the dip devices here. You can't select through hole so I've just want dip microcontrollers I'm searching through the 32,000 microcontrollers available from Digi Key and any brand, any uh manufacturer. So let's uh, take a look over here. ADC At 12 bits, 12 bits, 12 bits it gets a bit tedious.
You have to go through and select your 12 bit ones in here. but if we do that and then if we go through and select just the ones in here with 12bit adc's let's not worry about the Pwm at the moment cuz that's harder to find. But let's just as a first part, find ones with 12bit uh, analog to digital converters. What do we got? We got free scale and we've got microchip.
that's it. So all you atmail Fanboys out there don't come running. Why I didn't use some atmail thing or some. or if you're a TI Fanboy Why I didn't use those because they're not available with a 12-bit ADC in a dip package.
So there you go. and if we go along here and we probably search for say the uh best price over here, let's 100 of quantity. Let's have a look. It happens to be the Uh Free scale the Hcs08 tin.
That's a going to be a tiny a tiny little device that's only a 16 pin dip, not enough pins. 28 pin dip. um may or may not be enough. you know it's just I don't know.
And then you get into the pick devices here and there are quite a few uh P devices uh available with 12bit analog to digit converters. but if you want one with a decent uh number of pins and then you'd have to go through and look at the ones that actually have a um 12-bit capable Um pulse width modulation output. It just gets trickier and trickier and well, was just all too hard. So I Just decided.
Simply decided to use an external ADC and deck and generally, anyway, you're going to get uh, better performance with an external ADC and deck. The ones built into Microc controls aren't they great? So when you start trying to push 12 bits inside a microcontroller, eh, you know you're probably better off going to external 10. That's why most of them only have 10 bits cuz that's generally all they're good up to. Now you see that I've got a couple of Uh voltage buffers down here driving the ADC like this. Now there's a reason I've actually got. That is because: um, when you got a successive approximation ADC like this, you can't have an arbitrarily high input impedance. So in this case, Adcv out is coming from over here. Look at these 10K resistors.
Okay, we've got a relatively high input impedance. Um, driving this um, analog to digital converter and this has sample and holds in here and it can cause you all sorts of problems. so it's good practice to actually buffer that so it provides a low impedance drive to your analog to digital converter. These ones here don't need it because it's coming directly from the output of the Op amp here through three.
A little low pass filter of 330 ohms here. Not a problem that's low enough not to cause an issue and the other comes from the ADC I out, which is the current we looked at before. and once again, it's 330 ohms low enough not to cause an issue. And as always, read the data sheet.
Here's the ADC the mCP 3204, which is the 4 Channel version also available8 Channel version. It actually warned you uh about High Put impedances. and here's the equivalent Circuit of the analog to digital converter. and as you can see, it's got an inbuilt sampling switch here with an internal series resistance of 1K And then it's got a 20 picofarad sampling capacitor on here and basically your input impedance, which I just talked about over here.
Here's your input pin. So this is all inside of the Uh, all inside the analog to digital converter chip. so your external Uh impedance here will actually affect the time that this capacitor takes to charge up. So that's a charge up to the value.
and if you got a 12-bit converter, it's got to get very close to the nominal value not to introduce any additional errors into your analog to digital converter. And if you take a look down here, they actually provide you a graph here. so that actually shows you the input resistance in Ohms 10K here 1K here down to 100 ohms down here and the maximum clock rate in megahertz at different voltages. And as you can see, if you're operating at a low voltage, we're operating at 3.3 Vol.
So it's going to be like in there somewhere, there's going to be another curve which goes in there and down like that. As you can see, if you've got a 10K input impedance, it's useless to you. can't get a 0.1% least significant bit deviation on this thing. So the input impedance matters in practice.
Uh, we may not. um, need these Op amps down here and if we don't need them, well, we can just not insert it and then just short out pins two and three and five and six there. Not a problem, but good practice to put it in if you need it based on your input resistance cuz that can affect your maximum sampling rate. And by the way, it's not just specific to this analog to digital converter either. If you use the one inside your microcontroller, you would have the same issue. Just beware. Now I've actually used a really cheap Garden Variety opamp here. It's an Nmj 1458.
It's a variation on the Um, very common 458 Op and this one has um, five a nominal Uh value. not a maximum value, but nominal of 500 uh, 500 microv volts um, input offset voltage. So that should be good enough for our circuit. But as always, it's a standard pin out.
If we need to put uh, really, um, better Precision Op amps in there, we just drop them in. And as for our 12-bit deck over here, well, it's pretty darn boring. There's some digital input lines here. it's an SPI so we've got a clocker, chip select and data input, a voltage reference input bypass cap, and it just out outputs two different voltages.
It's a dual Channel 12bit deck. this one. it's quite nice. Uh, well, for the price, it's really cheap.
and uh, and so that just generates our V Vet and I set exactly as we would if we hooked a pot onto here like seen in the previous videos. Or we use a pulsewidth modulation output from our digital or from our microcontroller here. we could also drive it. Um, but a nice good 12-bit resolution.
Dack That gives us some great resolution on the output. And as for our current resolution? Well, we've already looked at that. We can actually set, um, the current limit in steps of 500 microamps. Brilliant.
over the whole range of 500 microamps to 2 amps. Fantastic. That's the advantage you get with the 12bit, um, analog 12bit deck. If we used a 10 bit deck, you'd be looking at uh, 2 milliamps per bit.
Not as good, but still, you know might be certainly adequate. So I've just gilded the Lily here. You could have Just use the Uh microcontroller for sure. Depends on your requirements.
Now, as for our voltage output, Well, our deck is going to give out um, 0 to 2.04 volts cuz that's our voltage reference coming in here. So 0 to 2.04 Vols I've put in a gain of five here in this amplifier set by these two resistors here. Exactly the same circuit you've seen before. The tap actually comes from here, so it compensates for these series resistances here.
but that circuit has a gain of five. So once again, I've put an engineering Noe in there and there it is. Gain equals 5 0 to 2.48 Vols input which gives a 0 to 10.24 Vol output with Uh 2.5 Molt resolution for our Um 12-bit analog to digital converter, so we can set our output our voltage output up here on the supply in steps of 2.5 MTS Awesome! And of course, if you used a 10bit Dack or a 10bit Pwm in your microcontroller, you would get a 10 Molt resolution output. Once again, that's still adequate for most purposes.
I'm just gilding the Lily Some of you might be asking why have I put two resistors in parallel here and two resistors in series? Well, if you'll note, they're both, they're all 10K I've tried to basically optimize my design to reuse existing values. um, on my sheets here. so I've got uh, you know, 10K up there 0.1% cuz these resistors are fairly. you know, fairly expensive cuz they're 0.1% uh tolerance. So I've just used them. it's better I think it's better to use them and reduce more of them and reduce your bill of materials than it is to, um, have all these different values and over here which we'll look at later. I've also used 10K there as well and 10K here. So I've bought.
You know you can buy a whole bunch of those so you can consolidate your bill of materials and you only have to buy the one item that's not bad. So I've done that up here. like for this, Um, last time you'll notice that I set um, my current um fixed current output here the LM uh, 334 to 1 milliamp but that required an oddb value resistor here. I'm not using Elsewhere on my circuit, so I decid to use 100 ohm I am using elsewhere in the circuit and it's still good enough.
677 micro amps good enough for a minimum load on our LT 380 component. Consolidation is one of those steps you should do in any good design, so you'll see not only the resistors I've done that, but also Elsewhere on the circuit. I've done that for the capacitors as well if I needed 4.7 7 microfarads and I don't use it anywhere else. Well, but I've used 10 microfarad somewhere else.
Well, I'm going to use a 10 microfarad in there instead of the 4.7 And for output protection I've got a big nice 5 amp uh, reverse shocky diode there. Now this is the output. I'm going to have a load switch uh, external to the board. It's not actually mounted on the board.
That's why It's not showing here. And you'll note that I'm this is my Sense line that senses the output voltage goes back to the analog to digital converter down here. This Uh net here goes down to the ADC. Now the reason I'm doing that is because, um, some people like to have the Sense line directly on the output so that, um, it still reads the voltage when the switch, the load switch is open.
Others prefer it the other way around. They like to know what the output voltage is going to be before they or or what the output voltage actually is regardless of the load switch position. So um, this just having a separate Sense line gives people the flexibility to wire it up any way they like. And once again, I've just got some voltage divider resistors here and that will give me a uh, certain Uh voltage into my analog to digital converter scaled down to Uh, meet my 2.04 Vol voltage reference.
and more than that, it is precisely the voltage here is precisely 1/5 of the output voltage. And coincidentally, remember, I had a X 5 gain over here. So once again, my, that scales perfectly. My if my Max output voltage is 10.24 volts divided by 5, the max input to my ADC is going to be Uh 2.48 volts. or that the output voltage divided by five. So it's perfect. I'm using the full maximum range of my analog to digital converter to measure my output and that's what you want. You don't want to piss away any bits now.
As for the current uh limit Le indicator over here. You know how I use this convoluted opamp before? I Just wanted to show you that you could actually do that as a spare opamp. but that's not the nicest way. It's better to actually use a second transistor here and drive it direct.
And that's exactly what I've done on the circuit here. Here's my current uh, my current limit comparator down here. and as well as driving the Uh, as well as driving the set pin um, as per normal, it also drives a separate a second transistor here because we're already used same type. Very cheap.
You already got them and that current limit goes into your microcontroller. Over here, it doesn't go directly to a lead. I Decided to put input pin and then you can. The software can do intelligent stuff with the lead.
It can blink it and do all sorts of uh things depending on various modes. So there you go. And you don't need a pull-up resistor on there because you can program a pull-up resistor directly on your microcontroller here. and you'll notice the same with the optical rotary encoders that got two outputs here.
They go directly into the microcontroller. Normally they need pull-up resistors on there, but you can do it inside the micro. No problems, Save a couple of resistors save some board space. Now let's take a look at this Uh effectively a microcurrent uh circuit here which allows us to measure.
um, if your if this lab power supply is powering your little micro controller circuit and goes into sleep mode, well you don't have to use your multimeter. this sucker. This power supply will be able to actually measure low values. not as good as the microcurrent.
It only goes down to a maximum of 2.5 microamps per bit as we go into. but uh still. I Don't know any other power supply that can measure the output current down to 2.5 microamps and the way it does that is that. Basically, this circuit doesn't operate all the time.
This circuit will only effectively be in use when you want to measure and uh, want to measure low values and your uh microcontroller knows that uh, the values are very low. It can switch this circuit in and it does that with this uh mosfet. Here it can switch on this and effectively insert another load because our output voltage uh is. Here's our output voltage here, but the ground.
Here's our output, our negative output terminal and instead of going directly to ground, it goes through a current shunt resistor. here a what's called a low side as opposed to the high side current jump resistor we have up here we have an additional lowside one and normally I don't like doing that because then it introduces an offset voltage error here from ground. and depending upon your output current, that's why it very high output currents. We don't want to go through this resistor here. We want to shunt that excuse the pun, we want to shunt that through a much lower value mosfet here so we don't get any errors introduced on our low side. it's going to be effectively ground. So let's say we wanted to only tolerate one bit uh, resolution error on this output. What value do we need? Well, our output voltage is maximum output voltage is 10.25 volts 2.4 volts sorry divided by 4,096 We got a 12bit converter so 2.5 mol.
So basically um, our ADC down here can measure our output voltage to 2.5 MTS resolution. So it'd be nice if this um circuit here only dropped 2.5 MTS or one bit or less. So pretty much we want uh 2.5 molts. maximum drop across this mosfet here when it's switched on and all this circuit is disconnected on our high current range, our maximum resistance there is going to be 2.5 Ms divided by the 2 amps.
uh, maximum current there 1 1.25 Milli ohms. So our fat there needs to get one bit. error is going to need 1.25 mli OHS So that's actually a very low value for a mosfet. If you actually want to meet that, you need a really really beefy mosfet.
I've decided to use one of these. It's cheap, readily available in a nice package. I Like it and it's going to be near enough. It's got a rated um uh, maximum RDS on or a maximum maximum resistance of 8.4 mli.
but that's going to be at the maximum current. It's going to be better than that at the lower current and at higher Uh Vgss as well or higher Um gate source voltages. So in any case, uh, that mosfet should give us a a very, uh, insignificant error at our maximum range of 2 amps. So as I said, the software is capable of switching this mosfet on and to do that, I've actually um to get a higher Um gate source voltage I've actually used rather than drive it directly from the microcontroller which would only be a 0 to 3.3 volt output, that's not really good enough for this mosfet.
I Really want it a nice high value? So I'm going to tie it to V+ here and I'm going to use an external transistor to turn it off and on. So the gate voltage is going to go between zero and V+ which is our input all the way over here. So we get get in a nice High Gate Source voltage because the higher the gate s voltage, the lower the turn on resistance for this mosfet. So you want it as low as possible and during that 2 Amp range, this circuit isn't used at all.
It's still measuring. It's trying to measure something, but we don't read it at all. The micro doesn't read it. We're doing our measurement based on this high side Uh current shunt resistor.
So we've effectively got two different current measurement ranges. So let's have a look at the uh, low value current measurement when this circuit is active. Now what we've got here is we've got four resistors is here: 1 Oh, they're in series parallel combination giving a total uh shunt resistor here. lowside shunt resistor value of 1. Oh now the reason I'm uh using fall like that is well, not only to get a little bit um, extra uh accuracy like we did with the highs side current sh resistor, but a bit of margin for error in case this software selects the wrong range when it's when there's actually a High um output current. So in this case let's say was 2 Amp maximum like that. Um, then in theory, if the software accidentally turned uh, this transistor off instead of on then all that current would try and flow through well would flow through these resistors here and we would get um, a power dissipation those resistors of four Watts So uh, really, you know if you put a tiny little resistor single resistor in there, you might burn it out accidentally? You don't want that to happen. So a couple of extra resistors it's you know it's going to survive any Anyway, it's still not going to be great.
It's going to be very, very hot, but at least survive and it won't blow those resistors. So if we got a 1 ohm current shunt resistor here and uh 1 milliamp flow through there, we're going to have 1 Molt across here. This uh op amp the um Max uh 4238 you've seen in my microcurrent. It's exactly the same.
It's got a gain set by these two resistors here of 200. it's quite a high gain. and uh, so if we got one molt dve across the shun resistor we'll get 0.2 Vols output. So my little engineering note here says it again.
at 200, the V out equals 0.2 volts per milliamp flowing through here and that can. From that, we can determine our maximum range CU our ADC down here. Remember, it's only 2.04 volts maximum so it can only tolerate that voltage. or it can only read that voltage maximum.
So we can have 10 times that or roughly 10 milliamps. Or if you want to round it off, 10.24 milliamps. Uh, maximum is what this circuit is capable of measuring. So the microcontroller when it when it measures over here on this uh shun resistor that the current drops below 10 milliamps Or you can do it under manual control with one of the switches Here it can automatically if it wants, switch on, disconnect this mosfet and then start reading from this circuit over here.
So if your let's say your circuit's powering your microcontroller, but this power supply is powering your microcontroller circuit, it's just gone into sleep mode. The software of this power supply can detect that and it can switch on this circuit and measure that sleep current accurately. I Think that's brilliant. Why can't all power supplies have a feature like that? So just like the highs side.
Uh Current Sense Amplifier: What is, uh, the maximum input offset voltage we can tolerate here before we start getting in errors. Well, if our maximum output is 2.04 Vols Okay, we divide that by our 4,096 we're getting 500 microvolts. Um, is our minimum on the output here. So we're going to read 500 microvolts per bit one bit resolution here, but we got a gain of 200. so let's divide that by 200. Okay, and it can tolerate and that translates to 2.5 5 microvolts is our minimum per bit value across here. And of course, the only way that you're going to get an input offset a voltage error pretty much of 2. down in the order of 2.5 microvolts as you've seen in my microcurrent is to use a Um is to use a chopper amplifier an auto zero in amplifier which is exactly what the max 4238 is and what is its value.
An ultra low 0.1 volts microvolt offset voltage all than order of magnitude more than what we need, but that's typical. but it's maximum at ambient temperature or even over the full temperature range is our 2.5 microv volts. So over the full temperature range, we're only going to get one bit error. Fantastic.
more than what we need little bit Overkill but hell I already used that in the microcurrent. So I'm going to use it here again now because I wanted to make this design into a kit I wanted all the components to be through hole and I tried as hard as I could to make everything through hole, but unfortunately the max 4238 is only in an S So8 package and likewise the max 480 is only in an S So8 package and the voltage reference. Although I can get Uh ones in like a T92 package, they're cheaper and more readily available, especially in the 2.0 48 volt version in a 23. So they're the only three surface mount parts on the entire design.
Everything else is through hole and I pretty much optimized. Um I Chose Parts based on through hole availability. There were maybe one or two others on the market for the current sense amp, but they weren't quite right and didn't have the right gain and it didn't work out the values and it just wasn't nice. I was pretty much forced to use an S So8 there and pretty much an So8 over here.
And because I've used the chip before, oh well. you can't have everything you have to. Um, if you go and build this thing up, you're going to have to. solder a couple of S So8 packages sorry and I've got a little maximum um mCP 1700 3.3 volt uh voltage regulator they? They're quite nice devices.
They're actually, um, got very high, very close output tolerance of a percent or less or half a percent. They're really, really quite NE Neat. You can actually use those almost as a voltage reference at, um, an ambient uh, tempature tempature I think I've mentioned that before. But anyway, I've got a standard Lm7805 to give our 5 Vols out from our us uh for our USB output connector over here.
And because I've um, this is the heat sink I'm actually using. it's from um Electronics here in Australia um I don't think you can buy it anywhere else I think it is uh specific to them. it's a PCB Mount one has got PCB pins. it's upside down there cuz it was in my breadboard before but it's got an extra hole here. so I can mount um both devices on the same heating. but uhuh, just be careful you don't want to, um, put them directly on there like that because then you'll short out the tabs which are connected through to the center pin and in this case it'll be ground and output which should be short in. So if you put uh, this, um uh package here on. If you put both these packages on the same heat sink, you'll actually be shorting the output of your T 380.
So oops, you don't want that? Make sure you put uh, some uh, microw washers or some uh, seal pad in there to isolate them, uh from the heat sink. Now as you'll see down here with the micro, I've actually used every available pin, every single one of them and uh I probably goofed up here I think I'm actually going to change it. Um, because I thought I could get away with using the 8 MHz internal oscillator in here and it be good enough to do my external serial Rs232 coms. But to do Rs232 as a rule of thumb, you need a 1% uh, tolerance, frequency error or better and the oscillator in this thing can be trimmed to 1% um, or better.
In software, you can actually software trim it, but oh, it's not as good as the Pi one. I've done this on the Pi before and they come factory trimmed to 1% or better so out of the factory over temperature, you can actually fairly reliably do RS 232. but I don't think that's the case for the Atmail, so probably going to have to use um I'm going to have to free up these two pins down the bottom and put a oscillator on there the external 8 MHz um, oscillator on there or 16 or whatever you want to use which is Arduino compatible. You can use either and change it, but I'll probably use a ceramic resonator there at 8.
MHz I've got to free up two extra lines here so I can get precision RS 232 serial coms out of here I think it's just you know, it's good practice. a one of those ceramic resonators you'll get you know easily get half a percent. uh Tolerance on those. So more than good enough for Rs232.
Now the reason I've added a separate serial Port Here it'll be a separate board because um, really I want it to be able to do a whole bunch of things. be it just a standard, you know, 9 pin Rs232, you know, have an Rs232 chip to a 9 pin serial interface. or you can have electrically isolated because a power supply. You can get major problems if you if your connectors on the back are referenced to the computer which is referenced to Main's Earth That can be a big problem.
So electrical isolation um can be a big issue. So you can build a separate board with a USB to an isolated USB interface to Rs232 if you wanted to. or you could use one of those uh XB Wireless boards or something like that. So this could a wireless controlled power supply. that would be awesome. There's no reason why you can't do that at all. that would be fantastic. So um, to free up these pins basically my deck up here and my ADC over here.
they're both SPI input devices and because I had enough pins available I just drove them separately. But what I'm going to have to do is actually combine uh, the uh clock pin on both. So instead of having a separate clock pin coming from the micro, I'll have the same clock pin and I'll have the same data input pin as well. They can be shared and I'll just have a separate chip select pin for each.
uh, separate chip select for each for the ADC and Dck and that should do it. Bingo! I free up two pins so I can put the ceramic resonator and we're all sweet for our RS 232 and Arduino compatibility. and I've got the external AVR um ISP interface here so you can program the chip in circuit and download your hex code to it. No problems.
For the LCD display up here: I've chosen a New Haven uh display I rather like them and they're one of the LCD manufacturers that I like. They displays are quite neat and what it is is it's an I Squar C interface. There it is. and SDA uh, that uh requires less pins on your microcontroller.
So I freed up Um pins here rather than using the standard parallel or full bit interface. one I can get away with just well. three lines. Actually, there's an LCD reset line as well, but um, that wasn't the only reason.
Um, here it is. Um, it just so happened that this, um, LCD uh fits nicely into the case that I'm using. It was exactly the right dimensions and it's a 20 character by two line because I figured 16x2 probably wouldn't give be able to give the status displays that I actually wanted. So it's a 20 character x two line display i squ C compatible input.
It's only about 8 or 10 bucks or something. Um, it is the most expensive component in the whole uh in this entire power supply project. but eh, you got to have a decent display. This is actually an RGB backlight one.
I didn't want that, but that's the only one that they had in stock for a couple of months. So um, I'm not using the backlight. it'll just be standard. But there you go.
I Pretty much a lot of my design design decisions for this entire project were actually built around the case. a um, you know the actual case I'm going to build this in and another aspect I haven't talked about the project which you'll find about out about in another video and uh, so I'll talk about that next time. uh I think how to actually how I system engineered this thing to fit into this case cuz that's really a very important decision and that drove a lot of the design requirements in terms of how many switches I used to uh fit on my uh front panel. Whether or not I had room for a USB output connector, you know the type of heat sink I use the maximum power dissipation, all sorts of uh stuff. the room I had for the LCD for the controls how big I could make those the knobs, how big they could be whether or not I could use 10 turn pots and everything just sort of, you know was pretty much revolved around the case I'm using. So this video's been long enough I'll have to make that a separate video and I've already designed the PCB uh for this thing I've got some Timlapse video of me doing that. Um, so there'll be a couple of more videos coming up. In fact, probably more than uh two or three coming up to finish off this power supply project.
So thanks. See you next time.
I like this design 😀
mi lucky charms, sound like a small hyper female.
Does anyone know if he’s gonna guild the lily? He didn’t say…..
Just binge-watched this series and I never binge-watch anything. Dave has cleared up a ton of mysteries for me. I have a cheap SMPS 32V 5A PS with good operating specs but a terrible front panel design that I would like to replace with a more user friendly interface. Hopefully I've absorbed enough of Dave's design knowledge here to finally begin that project.
I have a power supply with 0.0005 ohm shunt. A little surprised at the noise comment.
I know this is a very old video, and also my comment is likely to have been asked several times over, but having OCD, I need to ask:
In this video, there are multiple references to 0-2.048V or 0-10.24V, even a 2.048V voltage reference. But 2048 steps starting at 0V gives you 2.047 and likewise 10.23. I am aware the error is rather small, but it is still an error. Right. Why isn't the voltage reference 2.047V?
Number of channels and number converters are different parameters. Converter are the actually hardware engines
Have u put the code for this project up anywhere I'm building a psu and having trouble getting the mcp4922 working
Thanks Dave
Hey Dave, after tearing down the Tekpower and Tenma "Handheld" Power Supplies it looks similar to what you created. I wonder if the Chinese designers came across your videos.
Use an ESP32 they are dirt cheap (1.5 in qty or 2.5 for one and ~ 4.5 for dev boards) have a ton of features including 16 PWM channels and WIFI + BT. Would be nice if their DACs were more than 8bit but they have a ton of 12bit ADCs.
kill me
Re: the ADC and voltage reference, if you have 12 bits of resolution, 0 current = b00000000000 and full scae current would be b111111111111, that means you really only have 4095 divisions across your scale, so all the math is off and one step actually equals 500.122… mV. Or am I wrong?
WAIT! You had an RGB backlight and you DIDNT program an awesome RGB backlight menu?!
UNSUB!!!
why you did not used a very cheap(2$) stm32f103c mcu it has a lot of 12bit adc and 16bit pwm and a lot of good Features in you project
Why would you need a 1% timebase accuracy for the UART rather than 5% (a drift of less than half a bit per transmission)?
Wow this was just what I was looking for, but I hope to have a 0-20v supply. I might have missed it, but did you have the Arduino Sketch listed yet? Ive been working on a OLED volt meter end so far and figured that 0-20v would give 20mV res., but im not getting stable reading.
Is there a written version of this whole series ? This is a goldmine but I personally learn stuff better than by watching videos.
HI Dave, thanks for the amazing Video, i am using the INA226 Power Monitor Chip and LT3082, What do you recommend a shunt resistor?, my supply is 9v From DCDC converter. i just wanna measure current. i was thinking of 0.5 ohm +-1% what do you think?
I have reported your video I hope your channel will shut down
What is this software you are using?
A typical Dave engineering job. Really great, but over engineered to the hilt.
It appears as if you no longer offer the kit on your website?
I don' think it makes sense to search for controllers with an ADC of exactly 12 bits. More bits don't hurt and it might still be cheaper (and easier) than using three devices (uC, ADC, DAC).