I've started learning about Buck Converters, and I made a miniature one on an Arduino prototype shield. But when I turn the thing on, the voltage is stuck at 5v (the voltage input). I tried disconnecting the PWM line, no effect; and grounding the gate on the transistor (a 4800 n channel MOSFET I salvaged from a laptop) only causes a tiny drop (0.5v) on the output. Here is my circuit:


simulate this circuit – Schematic created using CircuitLab

I don't think it's a bad transistor, it took 10 seconds to desolder, and then 15 more to resolder it on a different board. Can anybody show me what I'm doing wrong?

UPDATE: So, I fixed the transistor problem, and made the gate driver an optocoupler. I also added a boost capacitor and flyback diode. Now the problem is that the circuit can't handle any sort of load at all without going unstable. I have updated my schematic. Strangely, the schematic editor doesn't have any opto-isolators, so sorry if that part is a bit messy. For control, I have an Arduino Nano adjust the PWM to a set voltage (3.3 for testing). The regulator is very accurate, only off by 0.01 volts, until I apply a load. Then the voltage drops anywhere to 1.8v for an LED, to 0.2v for a small fan. The transistor also gets very hot when I connect the fan, which shouldn't be the case because it was designed to handle up to 700v and 1.5A. I really don't know what I'm doing wrong here. Also, the flyback diode only had 3107 for the markings. Another note, the voltage takes a really long time to stabilize, even at 100% duty cycle.

  • 1
    \$\begingroup\$ Please read Rules and guidelines for drawing good schematics, and consider improving your schematic to make it easier for others to understand your question. \$\endgroup\$
    – The Photon
    Commented Jun 3, 2015 at 5:09
  • \$\begingroup\$ @ThePhoton Sorry about that, how does it look now? \$\endgroup\$
    – Jaca
    Commented Jun 3, 2015 at 5:16
  • \$\begingroup\$ It will be most clear if the higher potential terminals were at the top of the page and lower potential terminals were at the bottom of the page. \$\endgroup\$
    – The Photon
    Commented Jun 3, 2015 at 5:24
  • \$\begingroup\$ Hint, as you have the circuit connected, the NMOS will be useless because of conduction through the body diode. \$\endgroup\$
    – The Photon
    Commented Jun 3, 2015 at 5:32
  • \$\begingroup\$ @ThePhoton So, I have the NMOS backwards? \$\endgroup\$
    – Jaca
    Commented Jun 3, 2015 at 5:42

2 Answers 2


Arduino- controlled buck regulator power stage

Ok, so this is the scheme i propose.

Disclaimer: in real life you will never do anything like that. This is only good for detailed buck controller study. This is not cost effective, not universal, not very power efficient and not simple at all. If you want a real design, you need to refer to buck controller IC of any descent vendor and read the datasheets accurately.

Disclaimer 2: i am not sure for how long and how deep i will be able to explain the theory. You must study that by yourself, it's not that hard.

So in the scheme i propose, you have a switch MOSFET, inductor and output capacitor that will do a good job for 20kHz PWM (i don't think Arduino can do much better), D1 will allow L1 to keep conducting when the switch is off.

R3 and R4 will provide feedback. Configure them so when the output is stable, the voltage is in the middle of your ADC range, probably it will be 1.65V

Now what made you most of your problems. To drive M1 you need voltage higher than Vs. So there is C2 that will be precharged to VCC at the beginning, and once your output is stable, with VOUT. When M1 will be switched on and the voltage on switching node will rise to VIN, C2 will still be charged, and provide VIN + VOUT voltage, allowing to keep M1 open.

U1 and U2 are used to quickly charge and discharge M1 gate. Pay attention, i use AC optocouplers. For DC optocouplers you may need a bit different input. Under no condition open both of them!!! it will just blow them. Consider logic gate to prevent such event.

Components selection: Define what voltage and current you need on output.

Select the L1 to have 200% of IOUT

C1- 200% of VOUT.

D1- 200% of IOUT and 150% of VIN for reverse bias, low leakage, minimum forward voltage.

C2- 200% of VOUT

C3- 150% of VIN

M1- VDS > 150% of VIN, Idrain > 150% of IOUT, VGS < 80% VOUT, VTH < 80% of VCC

Testing: Start with VIN = 12V and PWM of 20kHz, 50% duty cycle. Put 100R power resistor as load. You will have to measure about 6V, if everything is allright.

Closed loop control OK, this is the hardest part. Mostly because it's a whole theory, but if you have time to discover it, i will provide some basic guidelines to create a PID controller with your Arduino.

Set VFB_Reference = 1.65V

Define interrupt that will be called at the beginning of each PWM cycle Sample the VFB exactly 200nsec after the start of interrupt

Set VFB_Error_Last = VFB_Error

Set VFB_Error = VFB_Sample - VFB_Reference

Set VFB_Integral = VFB_Integral + VFB_Error

Set VFB_Derivative = VFB_Error - VFB_Error_Last

Set Voltage_Command = A * VFB_Error + B * VFB_Inegral + C * VFB_Derivative

Convert Voltage_Command to PWM_Command.

Pay attention: I make all calculations in volts. This is the best way for debug. So don't forget conversions from ADC to volts, working in floating point, etc. Also the VFB_Integral variable should be limited - otherwise it may roll.

A, B and C are coefficients that you will have to adjust. May be just anything, depends on both power stage and load, but also on how well you make all the circuit.

Be very careful with sampling VFB. It must be as accurate and silent as possible.

Be ready to surprises like overshoots, etc. To avoid them use soft start: VFB_Reference will start with 0V and rise slowly to 1.65V over long time, like 100msec.

Diagnose overvoltage. If you see VFB 10% higher than 1.65V, declare fault condition and set VFB_Reference to 0.

Good Luck! It's a serious project. I would say, for me after years in industry, it's doable, but not trivial. If you succeed, you will become (and i am serious about it) a real specialist in switching power supplies, and a really good candidate to become a control engineer, which in turn is really cool.


To open the gate you need Vgs more than the threshold voltage. For instance 5V. But in your circuit you will not get it.

You need boost capacitor and a diode to power up the NPN, and actually you need something like optocoupler instead it, so Arduino would be able to drive it.

And you need a diode between ground and inductor left terminal.

I recommend you to google any TI DC/DC and see how they work. Start with TPS54160.

  • \$\begingroup\$ And the MOSFET should be reversed... Well, this circuit can't work, sorry. \$\endgroup\$
    – user76844
    Commented Jun 3, 2015 at 6:08
  • \$\begingroup\$ The optocoupler helped a lot, but I also had to replace the transistor with something smaller. At least until I can get the darn thing to switch correctly. I place it in the right way, but the circuit behave the same. \$\endgroup\$
    – Jaca
    Commented Jun 4, 2015 at 3:00
  • \$\begingroup\$ You still need boost capacitor and diode. Do you understand what it is? \$\endgroup\$
    – user76844
    Commented Jun 4, 2015 at 3:02
  • \$\begingroup\$ Oh, I put those two in as well. Also improved performance. I just have to play around with the transistor to get it to work. Unless it really is busted. But the circuit works. Only, it's not strong enough to even light an LED without tremendous voltage drop. \$\endgroup\$
    – Jaca
    Commented Jun 4, 2015 at 4:15
  • \$\begingroup\$ First, update the scheme so i can see what you have already done. Second, once the circuit is ready, you have to run it with constant PWM to see that it works. You cannot expect the control loop to work right now. Also please show your feedback scheme. \$\endgroup\$
    – user76844
    Commented Jun 4, 2015 at 4:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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