Alex's Linear Power Supply Build Log


Ok, so I’ve done a bunch of testing and so far here is what I learned. The power linear regulator works great so far with only a 5% or so drop in load regulation at full load. Tested it at a few voltages throughout the range. I ran into a bunch of problems in my layout so I’m probably going to re-do the board at some point once I’m sure I have all the kinks out. The two op amps for the voltage and current regulation were laid out inverse (my own fault for not triple checking) and so was the high side current sense amp. Lessons learned as this was one of those projects that has thus far spanned months of downtime as I was away for work or on other projects etc.

One question I did have at this point is if anyone has a good suggestion on a better on board power supply is. What I realized when I was testing the fan outputs is that the current 7805 is definitely not going to cut it!

They run fine at low speeds as expected but above 30% or so their current draw becomes such that it starts to drag the 5V rail down as the 7805BG over heats. I know this is due to the fact that I’m drawing upwards of half an amp overall (170Ma per fan X 2 fans plus whatever the other digital components are drawing) and my input voltage is 19.8 volts. That puts things at just over 5 watts of power the little Dpak-3 has to dissipate, NOT GOOD! My first thought was to add a second regulator in a larger package just for the fans but now I’m thinking a small buck converter for the whole 5V rail instead. My concern with that is the noise of a switcher as I’m trying to make this as low noise as I can with it being a fully linear power supply and all.

Anyone have more experience with the overall output noise on switchers than me? I’m also aware that I can use a linear regulator as a post regulator to smooth things out as well. Say, buck the voltage down to 7.5-8V then a 5V regulator from there but that’s starting to increase my parts count and board space which I’d like to keep down as well. As well as my limited working experience with working with switch mode parts.



You are already driving the fan motors with PWM off the 5V power. Why not use a smaller duty cycle and connect straight to the 19.8V? Or better yet add a 12V regulator for just the fans. They are inductive loads and will damp much of the pulses. 7812s will work fine because keeping the apparent voltage to the fans of 5V will keep the duty cycle under 40% so the current load stay under .15A and with an 8V drop that would be just over 1W. Adding bigger capacitors than usual on either side of the 7812 will further smooth out the ripple. The schematic you posted doesn’t show what capacitance you are using around the 7805. Typical is I think .1uf to 1uf. You might want to increase them. Looking on Digikey they have 22uF by 25V ceramics in single unit quantities for less than $1 and 47uF under $2.50. Make the frequency of the fan PWM switching as high as possible, and If you draw the fan power from upstream of the main power linear regulator that will further damp the ripple from the PWM of the fans from reaching the power out pins.

Or use the 7812 and swap the 5V fans for 12V fans. Then you can keep the longer duty cycles and don’t need to worry about burning out the fans if the PWM gets stuck on. If the 12V fans have the same power rating as the 5V fans then the current load will be less than half, if they also draw 170mA each then they will be twice as powerful and only need half duty cycle to provide the same cooling level. And even then power dissipation will be under 2 1/2 watts.


At an ambient temperature of 25C the 7805 will only dissipate about 2W max. without a heatsink, and if the inside of your enclosure gets warmer than that then it can dissipate even less before the thermal protection becomes active. You are trying to dissipate 5W. It does look like you have a bit of copper there and some vias to another layer. Even if that was enough it would still run very hot. The more heat you generate from your output transistor the more likely the 7805 will shut down and that would be the worst time to have your fans stop.

I would stay clear of linear regulators and use a switch mode DC-DC converter. Go to TI’s WeBench Design Center for an easy way to design a DC-DC converter. They run much cooler than a linear regulator especially with a large difference between input and output voltages.

If you mounted your heatsink so that it protrudes out the rear of the enclosure you may not need the fans at all, and you could have a smaller enclosure, as well as keep the PCB cooler.


I’m definitely leaning towards a switchmode for my 5 v rail. I like linear regs because they’re easy to I’m pop lament and have minimal parts but I this application I dont want to run the fans on the 19.8v rail in case like was mentioned the pwm gets jammed on for whatever reason. I dont really want several rails at 5v 12v etc. Either it just seems uneccesary since the fans I bought are made to work at 5v. The 7805 was definitely thermally regulating after I investigated during testing the 5v rail was more like 2.8v and it didn’t pass the finger test either.

I’ll check out the TI site and see how that goes. I was searching on mouse yesterday and found a few TI or infineon switches mode controllers I might buy as well and test out before putting in the layout. Thanks for the tip about the webench I hadn’t heard of it in a while and forgot about it.


I would agree with the others as far as using a switch mode supply. You could use an LDO linear regulator after your switching regulator if you wanted to reduce the output noise. There are actually some switching regulators that have an LDO on the output for this reason.

If it helps, here is a simple project I built last year that incorporates a boost converter to switch a single cell li-ion 3.7v to 12 volts to power an 80mm PC fan. I’m by no means an expert in this field, but if something I’ve done can help you in your design feel free to use it. In your case you would need a step-down converter since your input voltage is much higher.


As I continue to think about it, I lean more in the direction of your earlier comment that the whole idea of a linear power supply for bench work is to keep switching noise out. I agree that the digital circuits need much cleaner, more stable power than what you are currently getting with fan power above 30%. But I still like the idea of second power circuit for the fans, probably with a bigger heat sink. But I can also see the appeal of a fix it once and done approach of a much more powerful switching step down or buck converter. They are certainly becoming very popular!

If you want to go to a buck-down converter, there are many new chips out there which would take care or the switching, some needing very few additional components and most having very high efficiencies. But if you want to save some time and trouble there are also many already made ones out there for fairly cheap. Save some time and work and you would already have all the right component values for the extra parts. After a quick google here are a few ready made ones. I listed them at 5V output but many have a wide range of output voltages as well as input.
5V at 2A out, 4.5 to 40V in
another 5V at 2A output, 8-32V in
and if you want crazy strong,5V at 15A, 4-32V in

You could also decide to adjust the DC-DC converter to output 7V and feed that in to a 7805 for the digital subsystem and a second 7805 for the fans. But with some good capacitors between the DC-DC converter and the linear power supply there would little difference in output ripple with or without the 7805s. So if you want the DC-DC converter, it probably does make sense to have it directly drive all he 5V stuff at the same time. And if you decide to ‘roll-yor-own’ DC-DC converter, remember to include some good MLCC capacitors on the board as close to the switching chip as you can to neutralize any switching spikes.


Hey guys,

Been working a bit on the board and made some changes. Got the linear power part working the way I expected and started writing some test firmware for the digital end. So far I like it but I wanted to re-do the layout and add a few things as were suggested in some of the comments. Here is a new copy of the schematic that has more explanations and documentations added as well:

Lab Bench Power SupplyV2.5.pdf (272.7 KB)


I like the layout of this schematic better than the last one, especially the regulator section, looks cleaner and a little more organised. No DACs yet though.:wink: I’ve had a brief look and the only thing I noticed is that I think you have the “TEST” and “VFEEDBACK” reversed. Shouldn’t “test” be on the output side of the fuse?

I know you are fond of the 555 but you could save a fair bit of space with something like the MAX6817.

Have you done any transient response testing of the regulator?


I think that as long as the Test and VFeedback are on opposites sides of the fuse then you will still get a positive indication. However, if VFeedback is going back into the analog section to regulate the linear supply, it could cause problems if it suddenly went to zero while the linear supply was still active trying to keep VFeedback at precisely the requested value. If the linear drive circuit is being controlled by the micro then there is no problem. In the same moment that you detect the fuse blown you disable the output and turn off the linear. But if the linear is controlled separately, it is possible that it will suddenly go to max output to try and get VFeedback back up from zero volts to the programmed level. If you are using an entirely analog voltage feedback section, then you want VFeedback to equal Vin as closely as possible. Then, like 1.21Gigawatts said, it would make more sense to reverse the two and put Test on the output and VFeedback on the source side.

However, that means having a single, unprotected line going back from the output connector straight into the side of the micro! If you do swap them around, I recommend putting a 10K resistor between the output voltage divider and the micro, then adding protection diodes to ground and +5v, and lastly a 1uF ceramic close to the chip to soak up any ESD that gets zapped into the system when you plug a new circuit in for testing. Having an unprotected line going from the micro straight to the outside world is a good way to have strange and mysterious things start to happen after an unoticeably small zap take place.

I like the addition of the rotary switch and the SD card. I think you will eventually have lots of fun with those!

One other minor point. Sensing VFeedback with one device, which is 12bit, low noise, internal voltage reference, and then comparing it to Test which is read in by a different device which is 10 bit, a busy microcontroller which is not as much low noise and has it’s own internal Vref and then comparing them closely could cause problems. You would want the two chips to be close together so their grounds would be the same and chip temps the same, but the opportunity for drift between them is still a concern. It might be better to add a second ADS1015 (cheaper than going to a 6 input, 12bit, I2C ADC) and split the current functions from the voltage functions. It is not that you need a super precise value for Test, just that you don’t want it thrown off by ground loops or Vref drift. If you put Vset, VFeedback, and Test on one chip and Iset and IFeedback on the other you would have a clean separation and be comparing apples to apples. And protecting the micro from the lighting rod to the outside world. And have 3 spare 12 bit analog inputs just begging for something interesting to do!

In general I agree. It is looking pretty nice!


It is usually a good idea for a closed feedback system to stay closed. :wink:

You do have the schematic don’t you?

The regulator is not controlled by the micro and disabling the output is of no consequence when the fuse is open.

As for sensing the open fuse I would simply have the output connected to an optoisolator to indicate fuse open status. Then the micro is isolated from the output and you don’t need to worry about surge currents etc when comparing the voltages. However, this may not work well for low (<2V) output voltages. In which case your current approach might be superior if well implemented.

Personally I would have the micro monitor the output current and when it exceeded the max threshold for a max period of time I would disable the output and indicate an overload before the fuse had a chance to open. In this case the fuse would only be for safety reasons.


[egg on face] My digital background is showing again. I am accustomed to using spiffy new power mosfets as switches and making transistors do the hot, sweaty work of linear regulation so I saw Q2 as a switch to remove power from the output if the voltage or current settings were ever exceeded and kept expecting to see a power transistor just beyond Vin. That was why I thought VFeedback might be only a digital input to the voltage regulating function of the micro, or to some other analog circuit also just beyond Vin. Now I understand some of what didn’t make sense before.

I can’t find any listings for 1F34AD but I did find one for FDA38N30 with a 312W max rating. I assume Q2 is a power mosfet designed to operate in the linear region without thermal runaway (current focusing?). And now I agree completely with 1.21Gigawatts about keeping VFeedback on the same side of the fuse as the device it is controlling. And I take it that Q4 is not an over current crowbar switch that shorts out the voltage feedback whenever the current is exceeded but actually modifies the output of U5B to lower the output voltage until the current drops back down to the limit setting? I still tend to think of them as switches and if you used them in a feedback setting like this they would oscillate until they found their resonant frequency. Still hard for me to think of them as only operating in linear mode under their safe operating area.

Which leads me back to one of the other concerns us digital guys try to avoid. With the direct feedback and only two 47uF caps to dampen things out, isn’t there some concern that this could start a high frequency oscillation in either voltage or current regulation mode? Especially with the two driver op amps being operated at full gain with no feedback? I am guessing that a small, high frequency cap from VFeedback and IFeedback to ground to short out a high frequency AC component and still allow the DC regulation to operate unchanged would help with that. Or is that just something the analog guys would tell us in class to scare us and keep us in line :grinning:?

One more feature I would suggest considering since you already have Vset, Iset, a rough estimate of Vin, and an LCD display is to compute the maximum power dissipation for (Vin - Vset) * Iset and compare that with your derated power rating given your heat sink and fan combination and warn the user if it might lead to overheating before the fans reach top speed. Might as well show off all those fancy things you have already included!


You might also want to recheck your equation:

Vfb = (R19 / (R12 + R20))*Voutput

The equation is wrong but you get the correct answer. :thinking:


From just over two weeks ago …

While operating as a voltage regulator the circuit tries to maintain Vfeedback according to Vset. But once Ifeedback reaches Iset the circuit starts to regulate the current by dropping the voltage. Of course this causes the voltage regulator part of the circuit to fight back as it tries to control the voltage. Not quite the way I would arrange that circuit.

MOSFETs are very linear devices which is what makes them suitable for amplifier applications.

But they do have feedback. It would be more apparent if you rearranged the circuit.

Some feedback compensation would probably be a good idea. You’ll notice a few posts back I did ask if he had done any transient response analysis, but we haven’t heard from him since. I wouldn’t expect the circuit to oscillate but there may very well be some ringing.


hey guys,

Sorry for not posting in a while, got called away fro work and had to do some traveling. definitely got the Vfeedback and Test outputs backwards! Same with the resistor divider equation. I have not been able to do any transient response tests of the circuit yet but as soon as i get back to my bench at home I’ll ding back into it.
I like the suggestion for the MAX6817 debounce IC I’ll probably give that a go.

I think I will take the suggestion of putting another ADC on instead of trying to use the on eon the micro. I did some looking and found a slightly cheaper ADC from Mouser as well that I think I will switch to, the MAX11612EUA.


Sounds like some good changes. The last time I had looked getting a 12bit AC with 6 or more channels in a single package cost more than using two 4 channel devices. But with the one you found the 11614 you get 8 channels for about the same price as two 4 channel 11612 devices. That makes it dealers choice to use two small ones that can be placed closer to their signal sources, or a single bigger one save a little board space.

1.21Gigawatts, I still don’t fully understand the mixing of the voltage control portion with the current control portion of the regulator drive. You said that there are other ways to do this. I was wondering if running both drive voltages into a single summing junction with diodes so that the one with the lower drive voltage would control the output drive voltage (higher if an inverting stage). That way they would operate symmetrically. If that approach works at all. It would need the non-regulating channel to go high so that it would not interfere with the other side. I guess that you would have to combine the anodes to the summing junction and cathodes to each drive voltage so that the one going high will be reverse biased and be isolated while the lower one will pull down the op amp input and set the drive level and output voltage of the regulator. Would a 100K resistor from Vin to the summing junction to keep it from floating lower value than the voltage/current limited drive signal be necessary?And there would still have a diode drop shifting things a bit. This would be so much easier in digital where a single compare statement and pick which one to send to the PWM or DAC output :stuck_out_tongue:.

To keep piling bells and whistles on, you already have VFeedback and IFeedback, you can have the micro compare them to see which is in control and indicate on the LCD which mode the power supply is in. There may be some cases that you want to stop the moment it switches to current limit and having that on the display could be helpful.


I guess Im Convinced! DAC’s on the way, and another encoder just to have the physical differentiation between voltage and current settings. Im going to do some research and see what DAC I want to use. The options and benefits seem to outweigh the 7$ a piece price tag for the analog pots I am using.:rofl:


I hope the next iteration goes well!

You might look at the MCP4728. It is a 12bit DAC with 4 channels out, I2C control, internal Vref with 2X output gain, on board EEPROM to hold power up defaults and I2C addressing, settling time of 6 micro seconds for under $2.50. There is no need for four channels out, only one is currently indicated, but it is always nice to have some expansion as long as the cost is low. Similar devices with only 1 channel are about half the price. And using the DAC instead of analog feedback, you can decrease the op amp count to one for the current sense and one to add a gain of around 3.66 to the DAC output to reach 15V gate drive, so adding the chip for the DAC should be balanced by reducing the op amp packages by one. And with Vset and Iset determined by digital control will free up to analog inputs to the ADC so only one package will be needed there.

The one concern with doing it all in digital is if the micro locks up and the load changes then the output regulation will be off. One approach is to put the output regulation in an independent, fast interrupt routine and also set the watchdog timer to shut everything down if the interrupt fails.

In the interrupt routine, read the ADC for the VFeedback and IFeedback, select which one is in control, write it out to the DAC, then reset the Watchdog timer. Since the Vset and Iset are determined by the software they don’t need to be measured as well. With the Watchdog timer set for 16msec if the micro locks up or something and misses 16 cycles of the interrupt, the watchdog timer trigger and will allow setting the DAC to zero and then shutting down to prevent runaway output.

The ADC converts in about 300 micro seconds and the DAC output settles in 6 micro seconds, so you would need to program one of the timers for around 1msec to leave slack time for the main program to run. You can even implement a PID in software in the interrupt loop to get rapid return to voltage with changing loads and still eliminate any oscillations. The ATMeage does not have much arithmetic capability so if you want to linearize the moset output or do a PID keep the calculations as simple as possible.

Reading the rotary encoders and writing information to the LCD, handling all the menus and sub-menus and pretty much all the other microcontroller operations can be done in the main code looping around indefinitely. Startup would program the DAC to zero as well as setting the EEPROM to output zero at power up, starting the mosfet gate control loop then setting up the watchdog timer. With Vset and Iset deterined by software, you can also change them as needed to prevent over heating. If the user is turning the current limit knob up too high you can lower Vset at the same time to compensate or do the same with Vset changing Iset.

The specs on the FDA38N30 make it look like the linear mode is not especially linear, and one possibility is to measure the current conduction of the FDA38N30 for the full range of gate voltage inputs and then work up on your computer a piece-wise linear correction factor to make the mosfet conductivity a flat, linear function of the digital gate control value generated in each interrupt loop above. However, the feedback process will correct for the non-linearity in the mosfet. The linearity of the power supply will be the combination of the ADC converter for Vfeedbck and IFeedback and the digitally generated Vset and Iset.

With the speed of the ADC allows about 1msec response to changes in the load. Not as quick as the analog circuit but not too slow. With a 1msec response time, a 30A surge would drain the two 47uF caps by about .350V. To get a smoother output under worst case conditions you would need to increase the size of the caps.

If all this sounds like too much, you can always stick with what you have now. It is mostly just a matter of personal preference and how much you need the extra features.


I’m not trying to “convince” you, it is your design you should do what you are comfortable with.

I think the second encoder is a good idea.

If you do go that route there are chips that have both the ADC and DAC in one package.

Only one? :thinking:

:astonished: Only a digital person would even say such a thing! There would be no point in measuring the transient response of such a power supply as it would be guaranteed to be abysmal by design.

Let’s not forget the time spent communicating with these devices over a serial bus.

It looks pretty linear to me between 1 and 10 amps, and even more so below 2.5 amps which is the limit in this case.

No, it’s mostly a matter of having a design that works vs one that doesn’t. :wink:


Actually, if he wants one for Vset and one for Iset, which I think is a very good idea, he either needs to setup some way to multiplex one or both of the rotary encoders to also operate the menus, change settings, etc. Having three encoders would allow instant change of voltage or current limit, even while navigating the menus and all the extra functions. Or you can use a single one with switch and LEDs to indicate voltage, current, or menu mode and use the push button to cycle through them. So three encoders reduces confusion, allows instant access to voltage and current controls, and reduce cases of changing the wrong one, especially when you are in a hurry.

Some how this has completely slipped past me. So I looked and found one that is rather like the micro pins, each of the 8 channels can be individually set to analog voltage out, analog in, digital out, digital in with I2C for about $7. That would be a possibility for this project.

Well, even I felt a little uncomfortable with the slow response time. In this case, at least 2 DAC channels for Vset and Iset, use the rest of the feedback as is except possibly use digital control to switch from voltage regulation to current regulation or back. That could simplify the control mixing without slowing the normal load current response time.

This is one for the digital guy. I left out the serial communication time for the second conversion because it is small compared to the conversion time (roughly 1/5th) and included the DAC output settling time just as information. Since the DAC is an output not an input, it can be set and then return from interrupt whereas the ADC conversions must complete before they can be read. The results of the first are read during the second conversion, the second adding the com time you mentioned but having little effect on the interrupt service time

At normal I2C speed of 400Khz the communication time would be around 1/5 the sample time, and I think you can start the second sampling while reading the first. This particular ADC chip has a high speed version of the I2C bus as an option. It is 3.4Mhz, about 9 times faster than the 400Khz.

2.5 amps. Some how I was always vague about the intended current range but I was thinking it was much larger. I was also trying to use figure 1 to derive the linearity, which has no reading below a gate voltage 5.5. Looking at figure 2 it is a log-linear with the response curving downward. Always hard to judge linearity on a log-linear so I eyeballed the numbers and replotted on linear-linear. There it curves upward more strongly. With only 2 points below 2.5 amps and none below 1 amp it still looks like it is not terribly linear. But the feedback system will take care of all of that so I raised a mote point earlier

So true! At least in software you KNOW that it will not work the very first time, but you can keep iterating until you get it to mostly work and you have slowed down on adding bells and whistles!

And it would seem that I still need to work on my remedial note reading for schematics, as well as basic


Three now? :laughing:

I don’t know how you arrive at that figure. I haven’t looked into the exact command set of these ADC/DAC but, depending on the mode you are running the ADC in, you typically send at least a single byte command to begin a conversion. That’s 8 bits plus the start condition plus the acknowledge bit plus the stop condition, That’s 11 bits, at 400KHz that’s 27.5us. To read the results is another command plus reading 2 bytes per channel, plus start, stop and ack = 5 bytes/40 bits + 3 bits = 43 bits or 107.5us. Then writing the new data to the DACs will again take about 107.5us, that’s a total of 242.5us or ~81% of the conversion time.

Edit: The above is based on a two channel ADC instead of four so it should instead read:

… 2 bytes per channel, plus start, stop and ack = 9 bytes/72 bits + 3 bits = 75 bits or 187.5us. … that’s a total of 322.5us.

Ooops! I only counted one ack bit above when there is actually one per byte:
Start conversion: 27.5us
Read from ADC (4ch): 207.5us
Write to DAC (2ch): 117.5us
Total: 352.5us

Wonderful! If only the ATMega supported that.

From post 11:

Yes, Figure 2 titled “Transfer Characteristics” is a semi-log graph and, looking at the 25C plot, it curves slightly to the right, but it is also almost vertical so the log nature of the Y axis has less effect. Do the math, for Vgs of about 5.25V Id = 1A, Id=10A when Vgs is about 5.9V. Picking a point in the middle, Vgs=5.6V, to be linear Id would equal about 5.8A. Looks pretty close to me. But then, as you said, it is irrelevant.