Here is an attempt at designing a buck regulator based on a ATtiny84a as the PWM controller. It should go from a 4S LiPo battery (12.8 - 16.8 volts in) to a reasonably regulated 12V output, used to drive servo motors that accept 10-14V inputs. 4S LiPo is slightly too high, and 3S LiPo is slightly too low, especially as I want the rated 12V torque. The design is intended to deliver 40 amps worst case (stalling out a majority of the motors.)

I can't buy one of these, because as soon as I leave the 10-15A range, all the DC DC converters are designed for industrial use and have heavy cases, are really expensive, require 24V input, or other such mis-matches with my present requirements.

The idea is to use the built-in analog comparator in the AVR to detect over/below target voltage, and generate a pulse of a definite duration when the under is detected.

I would build this on breadboard with 20 gauge wires soldered across the component leads for the high-power paths.

I know about keeping the "switching node" and feedback path as short as possible, when trying to do layout. I would also ground all breadboard traces that are not used, to make for a poor man's ground plane.

I've tried choosing a choke where the saturation current matches my max output current, and a buck inductor where the saturation current is higher than my max output.

The corner frequency of 94 uF and 3.3 uH is about 9 kHz, and I imagine the AVR will run much faster than that. I'm thinking a 5 us pulse each time under-voltage is detected, and then just go back to look for under-voltage again. That gives a max frequency (at close to 100% duty cycle) of 200 kHz.

And here's the schematic: Switching Buck Converter based on ATTiny84a https://watte.net/switch-converter.png

  • 2
    \$\begingroup\$ The PFET is upside-down, and where's your diode??? \$\endgroup\$
    – Dave Tweed
    Dec 15, 2012 at 4:57
  • \$\begingroup\$ The circuit completion diode is in the same place my IC de-coupling diode: Not there yet because I forgot to add them :-) \$\endgroup\$
    – Jon Watte
    Dec 15, 2012 at 6:31
  • \$\begingroup\$ And, yup, the P-fet is upside down, as you kindly noted. But, if I fix those things, and this circuit "just works" at 40A, I'd be amazed -- I've got to have forgotten something. Also, I didn't spec the capacitors (for ESR) yet. Starting from the top: Would the fixed on-time, varying off-time approach work alright? Are the inductors actually too big? Will the second LC filter do anything for me, or is it useless? \$\endgroup\$
    – Jon Watte
    Dec 15, 2012 at 6:33
  • \$\begingroup\$ And the input voltage for the analog comparator is too high for the AVR. Which brings up the next question: Is it a reasonable idea to use a resistor ladder for the voltage feedback here? Other things missing: Overcurrent sensing/protection, Overtemperature sensing/protection, Reverse power protection, Short circuit detection/protection. But one thing at a time. Perhaps I should just break this question into 8 questions ;-) \$\endgroup\$
    – Jon Watte
    Dec 15, 2012 at 6:45
  • \$\begingroup\$ Wouldn't the switch-off of the series PFET be terribly slow? \$\endgroup\$ Dec 15, 2012 at 7:45

2 Answers 2


In addtion to the concerns brought up in the comments (incorrect P-FET polarity, no catch diode/MOSFET), I have some at-a-quick-glance concerns:

  • The microcontroller won't be able to drive the gate of Q1 very hard (usually GPIO pins can only source a few milliamps) so your turn-on and turn-off will be very slow. This will limit how well your high-side switch will behave.

  • You don't have a gate-to-source resistor on Q1, so you're solely dependent on the GPIO keeping the MOSFET on or off. If the GPIO pin goes high-impedance, the MOSFET may turn itself on if the gate picks up a charge from the environment.

  • If your 70R P-channel gate resistor is solidly on (if Q1 is saturated), it's going to burn

    \$ D \cdot \dfrac{(16V)^2}{70 \Omega} = D \cdot 3.65W\$

    which is crazy high power since D is going to be high (input is close to output). Also, the 225mA or so that will flow will also be burned in Q1, which isn't healthy since it's a relatively small device.

    (You need \$V_{GS}\$ of around 4V to draw ~400mA through Q1, and you need \$V_{GS}\$ of -7.5V for 40A in Q4).

    • Your purely resistive feedback network is a bad idea. You really need some compensation and/or filtering. Your comparator will be hyper-fast and could react to switching noise, pickup, ripple, etc. - since you don't seem to be using an error amplifier with compensation to control the gain and phase, you're going to need some cap across R5 (and some luck).

    • You don't have any current monitoring or over-current protection in your power train.

    • You don't have any over-voltage protection in your power train.

    • You don't have any over-temperature protection in your power train.

    • You don't have input reverse-polarity protection and an input fuse in your power train. Big no-no, especially when the source is battery-based (big short-circuit sourcing capability).

This is a simpler project if you use an off-the-shelf analog synchronous buck controller. I don't understand why you would want to use the ATtiny for this.

That being said, this isn't a simple project by any stretch. Your schematic is largely incomplete and lacks basic safety protection that any power supply (especially ones that run at high power levels like yours) will need.

Think about your requirements, calculate all the losses, design in some protections and come back with rev. 2.

  • 1
    \$\begingroup\$ I would add you to my fan list man. Sir could you please take a look at this too. It sounds you have some much experience on designing SMPS. electronics.stackexchange.com/questions/51325/… and also here OP could use that chip TL494 , because it provides two error amplifiers which is ideal for this case. \$\endgroup\$ Dec 15, 2012 at 17:20
  • \$\begingroup\$ I understand an error amp controlling gain... but phase? What phase control would be needed? \$\endgroup\$
    – akohlsmith
    Dec 15, 2012 at 18:30
  • \$\begingroup\$ Phase margin is the most important part of stability analysis. If you have negative feedback with 180 degrees of phase shift, your negative feedback becomes positive feedback and your power supply becomes an oscillator. \$\endgroup\$ Dec 15, 2012 at 18:48
  • \$\begingroup\$ Thanks for the comments! I already noted the safety pieces as missing in comments above. The phase sensitivity is important, and I'm actually not sure the AVR analog comparator is up for it. It works as the "error amplifier" and I don't know what the bandwidth gain product of that is. Burning 3W to regulate 480W isn't so bad. It saves components compared to driver ICs. And if I go driver, I might as well go all the way and use a high-side N-channel for the switch. \$\endgroup\$
    – Jon Watte
    Dec 16, 2012 at 1:29
  • 1
    \$\begingroup\$ If anyone else sees this question, let me save you some time: I have learned more about buck switching power supply design since I posted this -- partly because of this great answer, and partly by trying things, measuring the failure, and repeating. I've learned that it's better to use dedicated control circuits and dedicated MOSFET drivers and synchronous rectification and high-side N-channel switches with charge pumps. There's a reason these circuits exist, and this is it! Also, even FR4 breadboard with soldered additional wires isn't particularly great; a proper 2oz PCB is better. \$\endgroup\$
    – Jon Watte
    Sep 1, 2019 at 4:08

You are designing a Buck regulator for:

  • Vin of 12.8 to 16.8 Volts from a high capacity LiPo battery.
  • Vout of 12V @ 40 Amps.
  • Control technique is Constant on time, and variable off time.

Even after the good answer by Madmanguruman, there are additional things that should be noted. The main difficulty with this design will be the high current being processed. I'll pay attention mainly to the power processing components, power modulator, and filtering.

  • Power FET is P channel. IRF4905: Rdson=0.02@25C, 0.034@150C; Ciss=3500pF. Conduction loss will be very high. For Vin=16.8V, Vo=12V, Iout=40A, Pcond = \$\text{D } \text{Iout}^2 \text{Rds}\$ = (.7)(1600)(0.034) = 38W. After considering the thermal resistance of the TO220 package and case to sink junction, a heatsink with 2C/W will be required to meet 150C junction with an ambient temp of 25C. It is much better to use N channel FETs for high current situations. An otherwise equivalent N channel FET will have 1/3 the Rdson as a P channel FET.

  • Gate Drive. There is no adequate gate drive in this design. Especially for turn off. With 70 Ohm turning off a FET with Ciss of 3500pF, turn off time will be at least 500nSec. This will mean huge switching loss in the FET, probably at least 15W of additional loss in the FET. This design has to have a much better gate drive. Since the gate drive needs to be improved anyway; it would be very beneficial to change to an N channel switching FET, and use a matching synchronous rectifier with a gate drive IC (like IR2104 or LM5104 or some such).

  • Hysteretic Control. There is no problem with constant on time, variable off time control. Hysteretic control can (if you are careful) work well, and have excellent transient response. But, the problem here is using the comparator in the uC. There needs to be access to the comparator to provide added hysteresis. So, a comparator with hysteresis, and with a response time less than 500nSec needs to be added. You would want to add hysteresis of about 100mV.

  • Output filter. Good inductor, L1. At 40A plus ripple current it will be on the verge of saturation. It would be better to have a higher current part, but it is not a major concern. It looks like the output capacitors C1 and C2 are ceramic, which is a good choice, should be able to have a total ESR of less than 20 mOhms for a ripple voltage ~100mV. It is interesting, that the load resistance at maximum load (~0.3 Ohms) is very close to the characteristic impedance of the output filter (~0.2 Ohms). This is lucky, since it means that the filter is well damped, more about this later. If you are only driving motors with this supply there should be no need for the second stage filter (L2, C3).

There are some functions left out that need to be there:

  • Current limit, there needs to be one, for your own safety if nothing else. With the amount of current being handled, surprises can come up in a hurry. You haven't lived until the top of the power switch explosively separates from the bottom and flies off to stick in the ceiling. Anyway, some kind of current limit, even if its just a fuse.

  • Input filter. It is not clear about the rest of the system, but the input of this supply will be the source of huge amounts of EMI. Normally this would be a big problem.

Input impedance is also a concern here. Switching regulators have negative input impedance, and can make good oscillators (unfortunately). The source impedance, of the LiPo and distribution network have to be less than 1/2 the input impedance of the supply to prevent oscillation. I think high capacity LiPo batteries have impedance of about 20 mOhms (although this goes up with age). The input impedance at full load (40A) of this supply with it's current output filter (L1 with C1 and C2) has a minimum of about 100mOhms (at 9KHz), which looks good if the source distribution network impedance is kept low. But,remember the output filter damping that looked so good at the 40A load, well if the load drops to 10A damping is not so good. That means at load of 10A the input impedance minimum drops to about 50 mOhms (at 9KHz), which would make the source distribution really tight and problematic. What a paradox, for this to be a light load problem caused by variable output filter damping.

  • \$\begingroup\$ This is also a great answer, and the kind of feedback I was looking for to learn more about this area. As I note in my comments, a lot was left out, including overcurrent and overheating protection. The heat loss in the switching transistor is looking really bad, and I'd probably do well to go with N-channel -- or, even better, parallel N-channel -- devices. It's interesting you should mention the IR2104 -- I actually have a couple in the parts bin. I have always thought of it as a "H bridge driver" but you're right -- it's also a synchronous rectifier driver. \$\endgroup\$
    – Jon Watte
    Dec 18, 2012 at 5:49
  • \$\begingroup\$ Btw: with the IR2104, do I need a Schottky diode, or is any fast-recovery diode good enough? \$\endgroup\$
    – Jon Watte
    Dec 18, 2012 at 5:54
  • 1
    \$\begingroup\$ For the bootstrap diode, a fast recovery type should be fine. \$\endgroup\$
    – gsills
    Dec 19, 2012 at 3:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.