Is there some reason not to use a microcontroller ( like ie an Arduino ) to drive with PWM a Mosfet and use an analog input to provide voltage feedback and regulate the output, and maybe another analog input to provide some current sense to add a current limit. Frequency would be around 32Khz. Any suggestion in designing capacitor and inductance? Please note this would be an experimental project, but result will be used as a laboratory power supply, so if it is not suitable for this purpose, I will not continue investigate more.

  • 3
    \$\begingroup\$ You mean instead of using a commercial device that does the same thing? \$\endgroup\$
    – Trevor_G
    Mar 13, 2017 at 20:07
  • 6
    \$\begingroup\$ There are many dedicated ICs for making a DCDC converter, have a look at how these work. Any suggestion in designing capacitor and inductance? No, these are components that you buy, you don't "design" them. Don't expect any decent performance from an Arduino based DCDC converter at 32 kHz. So using that as a lab supply will probably end in tears. You make it sound like building your own DCDC converter is trivial. Take it from me: it is not. If you would use a dedicated IC then it becomes more trivial but still not trivial. \$\endgroup\$ Mar 13, 2017 at 20:08
  • 1
    \$\begingroup\$ @Trevor yes, this is for learning purpose, \$\endgroup\$ Mar 13, 2017 at 20:10
  • 1
    \$\begingroup\$ @FelicePollano, you can't expect any of us to answer that here. As Moustache points out, it is not a trivial thing even if you know all the requirements, which we do not. \$\endgroup\$
    – Trevor_G
    Mar 13, 2017 at 20:14
  • 2
    \$\begingroup\$ Oh, and you asked for a reason not to use a uC based (so digital) control for a DCDC converter. Well, some years ago I worked at this department of a well known IC manufacturer, they mainly did DCDC converters. They had a working analog (so not digital) converter working fine. They spend years developing a uC based (so digital) converter. They could not get it to work properly (meaning, as good as the analog one). And those guys knew what they were doing ! \$\endgroup\$ Mar 13, 2017 at 20:21

1 Answer 1


Generally, not depending on your software being bug-free for not burning your MOSFET, inductor or whatever device you're driving with the supply is a big plus for using readily made power supply ICs.

Also, cost might be an issue – simple SMPS controllers literally cost cents, and thus are cheaper than microcontrollers with ADCs.

Bonus is also that dedicated switcher controller ICs typically have a built-in MOSFET or a built-in gate driver, able to source/sink sufficient current to reliably switch the MOSFET.

32 kHz definitely sounds too low for modern standards. Heck, small power supplies switch > 500 kHz. Higher switching frequency means smaller inductors, or better load dynamic compensation with large inductors.

On the other hand, it's not impossible or even inherently hard to build a microcontroller-based supply. In fact, the folks that actually do research on complex switch mode power supplies (especially for complicated loads such as switched reluctance motors and stuff, and bidirectional power flow, and so on) have their own board designs based on microcontrollers, DSPs and FPGAs. They do interesting work on these based on the ability to actually interfere with the switching times, and incorporate more than just the instantaneous voltage into the feedback loop.

For larger systems with high loads, there's little highly-integrated ICs that do the job, so you'll need to design a power supply board for these anyway, and you'll not have a choice but implementing the controller yourself.

So, if you just want to build a good small-to-medium-power supply, go for a SMPS IC. It's cheaper, easier, safer, smaller, probably a lot more efficient than your first couple dozen iterations of your own design, temperature-compensated, current-limited... IC manufacturers have been building these for 30-40 years now, and there's reason to assume they know what they're doing.

If you, on the other hand, have an oscilloscope, time to spare, an interest in the workings of power supplies and cool ideas on how to optimally control them, or just need a really beefy supply:

By all means, build one yourself with a microcontroller! The built-in PWM units, analog comparators, multi-channel ADCs and high clock rates of modern MCUs make that possible (but not easy). I'd actually go as far as to say that a modern MCU-controlled SMPS will probably want a lot of DSP-alike features, so I'd go for a MCU with a floating point unit, much processing power to spare, and maybe quite a bit of RAM to store data (e.g. for analyzing/filtering past voltage measurements, storing matrices for Kalman filters and so on). A Cortex-M-series MCU with dedicated peripherals optimized for control systems might be a good choice. I think NXP sells such under their Kinetis branding, specifically the Kinetis V series (They call it "Kinetis V – Real-time Motor Control & Power Conversion MCUs"; they even foresee the usage in SMPS).

Arduino as platform is not especially well-suited for this kind of thing. Arduino abstracts away a lot of the real-time capabilities of the hardware (timers, PWM, watchdogs, interrupts), and you'll really want to make use of those. So, if you're not yet familiar with bare-metal / Real-time OS programming of MCUs, you should change that, Arduino is not the tool you can use here. I have made nice experiences with ChibiOS, but this really requires that you spend some time understanding what your MCU is and does internally.

EDIT: To cite FakeMoustache:

Take it from me, you will get plenty of learning experience when making a lab supply using a dedicated DCDC converter chip.

That's very true. I've spent a lot of time tinkering with optimal designs around bought ICs. It's really non-trivial, and you'll learn a lot of the stuff you should know before building your own supply. Considering your question "What inductor/cap to use", which reflects a poor understanding of the matter at hand, you should definitely start with that, and a reference design. It's not a bad thing to start with something that works – in fact, I've done the mistake of wanting to build something from ground up before ever having handled a device that just works the way I want my design to work, and it really is a frustrating experience. Wisdom is knowing when to use someone else's experience.

  • \$\begingroup\$ All that is REALLY hard to bedbug though.. It's not like you can plug in an emulator, throw in a breakpoint or step through your code. \$\endgroup\$
    – Trevor_G
    Mar 13, 2017 at 20:43
  • 5
    \$\begingroup\$ "Look here, there's a GDB bug: whenever I add a breakpoint to a function that gets called before I disable the gate driver, smoke comes out of the supply. When I do it after, no smoke." \$\endgroup\$ Mar 13, 2017 at 20:52

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.