Arduino-controlled True Switching Regulators





Introduction: Arduino-controlled True Switching Regulators

In this Instructable, I will show my Arduino-controlled buck/boost/inverter converter. And what means that "true" in the title, you ask? Well, you have probably already seen a tutorial where somebody just connected a transistor to the PWM output of an Arduino along with a few other parts and called that a buck/boost/inverter converter (for example here). I admit it, I also used it once in my AVR Universal Charger. It works OK when your load is not changing, but if your load rapidly changes, the controller can't react fast enough and this can lead to a very dangerous over-/under-voltage. So generally this is a very bad idea.

A much better way is to use a chip designed exactly for this purpose. Here, we will use TL494 from Texas Instruments. You can find this chip in most computer power supplies or even classical converters. But did you know that we can control the output of the chip from an Arduino? Basically our Arduino will tell the chip what output voltage and max current we want and the chip will do all the hard work, so we do not have to care about Arduino latency. Also, because this chip is analog (compared to digital Arduino), it is superior as far as accuracy goes.

So, to compare those two solutions:

Pure Arduino-base SMPS:

+ flexibilty

+ (good for educational purposes)

- accuracy

- reliabilty

- latency

=> do not use this if you dont have to

Arduino + converter chip:

+ accuracy

+ reliability

+ latency

++ flexibility

- a few more parts

=> ideal as bench power supply, variable output controller, battery charger

Only converter chip:

+ accuracy
+ reliability

+ latency

- flexibility

=> use for simple tasks

The cost of the extra parts is neglectable - you can get 10 pcs of TL494 from Ebay for about USD 1.30 and you probably have a few resistors laying around the house already. We will build this in a form of a shield for Arduino UNO. I will show you how to build a buck (step down), boost (step up) and flyback (step down or up, the universal one) converters. Some parameters:

Input: 3 - 41 V (it runs even lower, depends on your version)

Output: voltage depends on version, current max 5 amps (but you can really easily scale the whole build)

Cost: without the Arduino a few dollars, depends where you get the parts from

I have not found anything similar on the internet, so I am posting my own research here. But first, let's familiarize ourselves with the TL494.

Step 1: TL494 Basics

So, this chip has been around for quite a while, but I have not found many DIY tutorials using it. Maybe it is because the chip itself looks complicated, but trust me, it is not. Maybe it is old, but it is very very powerful (just look into your computers power supply - chances are really high that you will find one of those there).

If you look onto the pinout (source: datasheet), you will see a lot of IOs. But they can generally be divided into X groups:

  1. Supply & Clock (Vcc, GND, RT, CT, DTC, COMP) - the first two are used to provide power for the chip; the following two are timining resistor and capacitor; don't mess with the last two ones unless you are sure what are you doing. The frequency formula is f = 1 / (Ct * Rt). So, for a 100 kHz, use 1 nF and 10 kOhm. I recommend not going above this frequency, even though the chip can run at 300 kHz without a problem.
  2. Output stage (C1, E1, C2, E2, Vref, OutC) - there is a pair of output transistors (C1 is a collector of transistor 1, E1 is the emitter); the chip also provides 5V voltage reference (10 mA max). Finally, there is OutC (or Output Control), which determines wherever our transistor will be running in parallel or push-pull mode. We will use parallel, so hook it to ground.
  3. Error Amplifiers - again, two paralleled amplifiers - they are the best part about this chip. I will not go into much detail here, just a simple explanation - the chip will try to make both inputs of one amplifier (+ and -) equal (in terms of voltage). So, if we put a reference (either from potentiometer or from a DAC) of 2.5 V on the negative pin and connect the positive pin to the output of the converter, the output will be 2.5 V. If we use a 1:1 voltage divider on the positive input, we will get output of 5 V from the converter.

I recommend that you try and build this circuit first on a breadboard. When it is done, RV1 should control output voltage and RV2 current limit. If it works - you are good to go! If not, hook an oscilloscope to Ct - you should see a 100 kHz ramp wave. Also, check if your amplifiers inputs are really equal.

So we have build a simple step-down converter, but that is not anything special - now we will use an Arduino to control it!

Step 2: Digital to Analog Converter (DAC)

How we will connect an analogue circuit (TL494) to a digital Arduino? We will use a Digital to Analog Converter! Now I do not want to write what was already written, so watch this video to learn about DACs. Basically we have three options:

  1. RC Filter - this is the least complicated but the least accurate method. You can use two of your PWM pins, filter their output and feed it into the amplifiers of the 494, but there are two big problems - firstly, there will always be ripple, which might get amplified by the 494 and your PWM is only 8 bit, so the resolution will be limited to max_output/2^8. So if your maximal output is 40V, then the resolution will be 40/256 = 156 mV. And in real world, it will be even worse! This is fine for experiments but not that much for a real usage.
  2. R2R ladder - this solution does not have problems with ripple, but it consumes a lot of your IO pins and you need a lot of parts. Use it only when you are using for example an Arduino Mega with a lot of IOs.
  3. DAC chip - the best solution. You can get one of them really cheap, they are stable, usually have higher resolution (12 or even 16 bits) and don't need any external parts. I recommend getting 2 channel 12 bit DAC, those are reasonably priced and provide very good resolution (at 40 V, the output the resolution is 9.7 mV). Good DACs are for example LTC1454 (2x12 bits) or MCP4725 (1x12 bits)...

Step 3: Design

Here you can finally see all schematics. For real usage, I really recommend using DAC chips - they are much more accurate than anything you can build. However, if you don't need the output voltage to be that high, you can lower the value of R5/R29/R42 - you will get lower maximal output but higher accuracy (see the formula on the schematic; resolution is Vmax / (2^(DAC_bits)).

Note: on the inverter circuit, the polarity of the output stage is reversed (that's why it's called inverter, obviously)!

To set the output voltage, you can simply set the PWM duty cycle (when using RC DAC) or set the value of your DAC chip.

Step 4: Conclusion

Some general notes on building a switching regulator:

  • keep all power tracks as short and as thick as possible
  • try to keep all power switching components away from the Arduino and opamp
  • use 1% or less tolerance resistors for measuring the current and voltage
  • try to use power and digital grounds and avoid ground loops

The final build can be very accurate and reliable. I also learned a lot from it. In the future, I plan on building a smart battery charger with balancing for lithium cells based on this design. The total cost is very low, since there is no special components involved.

I hope you liked this build. This circuit can be used in many ways, from a simple voltage conversion to charging batteries, it depends just on you. If you have any comments, suggestions or questions, feel free to leave them in the comments.



    • Water Contest

      Water Contest
    • Oil Contest

      Oil Contest
    • Clocks Contest

      Clocks Contest

    26 Discussions

    Hello Martin,

    Can you upload the schematics in pdf format, as the images are very blur and one cannot read it clearly. I am designing one for my Wind Turbine.

    Hello Martin,

    Is it possible to get schematic for flyback configuration (step down or up, the universal one) converters.



    3 replies

    You mean like isolated? Because there is already a schematic for inverting converter, which can be called "universal"....

    Hello Martin

    Rather like a buck boost in single configuration. Is it possible to vary output voltage above and below a given fix input voltage? Keeping hardware configuration same. Just varying DAC setpoint output only.


    Well, you would need to use 2 MOSFETs then, and somehow control them. I fear TL494 cannot really do this, or I do not know about it. You could use 2 TL494, this could be possible, but why dont use the flyback inverting one? The only downside I can think about is its lower efficiency...


    1 year ago

    Could I know which program are you using for schematics? Thanks.

    1 reply

    Hello Martin,

    Can I have your email address for some more questions please?



    1 reply

    1 year ago

    thats great, you use current sense 10A at high side, maybe you better if use DCSR method for increase efficiency, measure dc resistance of the inductor, and use n mosfet to get lower rds on

    1 reply

    Yeah, this came to my mind too, but I thought it would make the whole build more complicated and harder to understand....And using N-MOSFET is a very good idea, they how lower rds on and even more, I think they more common and thus easier to get. Thanks.

    MartinD; I'm sorry for being so harsh in my comment. I thought u were just posting to win the contest.

    Now as for Loop Comp... No u do not have any and perhaps u should read a little about what it is and what it means. then you will know that I am saying is the truth and not trying to be mean to you. it is much too involved to explain online like this. if it was simple I would try. and it has nothing to do with the TL494. it has to do with the fact that u have an LC filter at the output and u are feeding back to the controller (TL494 or any other). an LC filter is a 2 pole filter and one pole needs to be cancelled and you don't have it anywhere in ur schematic. the op-amps, etc. that u mention do not make compensation. what u have there are merely sensors and they only close the feedback loop without the Loop Comp.

    The schematic in the datasheet is incomplete in that they do not show the Loop Comp components. they only mention it when they are suggesting a layout. it was written in 1983 and at that time loop comp was not very well understood by a lot of engineers so it was omitted from the schematic in the datasheet. if u look at some modern day datasheets or app notes you should see the components and design notes of how to do it.

    1 reply

    Hi, thanks. Well, when you look at almost any generic step-down converter (whether it is TL494, UC384x or LM257x based), they all use the same layout with only a few modifications. They always feed the output into some sort of error amplifier, sometimes with exposed negative input, sometimes not. They are all build this way, even the commercial ones. And they all work. I have been researching this for like 2 weeks, and the generic design is nothing unknown, it is all over the internet. My biggest contribution is the Arduino-control part.

    But for the sake of both of us, lets end this. Nobody else complained about anything, and I (and you too, I think) do not want to spend my time writing what was already written.

    sticking a 1Meg Ohm resistor at the comp pin and adding a note that using a different value may be ok.... no it is not ok! you already knew that it did not work but u went ahead and published it. why did u do this? for the contest?

    3 replies


    firstly, it works - I have build it onto a breadboard and then as a standalone shield. If you do not believe me, do not believe me - that is your problem. However, look at my other Instructables, I am not some newbie. As for your arguments:

    1. loop compensation is done by two error amplifiers, they are connected to the voltage output and the current shunt. They get their reference from the RC filters, that come out of the PWM pins. The only reason it is also connected to the Arduino is that I display the output values into Serial Monitor. All the compensation is done by the TL494 (that is why I think this is better than connecting the whole thing directly to an Arduino)

    2. sticking a 1Meg resistor at the comp pin is OK. The datasheet states, that it should not be left floating, but it also should be protected against false triggering. So a resistor with high enough value is used (I have seen this in many designs) - it does not matter if it is 820K or 1M, I wanted to help the potential builders in telling them which values are not that critical.

    3. I do not provide a code because outputting PWM from Arduino is so simple that if you cannot do it, you are probably not able enough to build this.

    Honestly, I am very disgusted by your comments. Some notes I would like you to read:

    1. Instructables has "be nice" comment policy. You firstly accuse me and than call this a fake (or I do not know how to call it) without waiting for my reply. This can discourage other people from posting on Instructables!

    2. I bet you havent even read the whole Instructable or the TL494 datasheet. You just looked at the schematics and made your opinion.

    3. When I look onto your profile, you accused a lot of other Instructables this way. So everybody else is stupid and your are the smartest person on planet Earth, right?

    3. You asked a very good question - why would I post something which does not work? I have posted 3 other Instructables, all of them working fine. I do this in my free time. I do not have anything from it apart from good feeling (yeah, I have joined a contest, I have like zero chance of winning). I thought the idea is worth a share, so I have written this.

    Overall, if you are a man, you should apologize for the way you have accused me. I am OK with a discussion - tell me what would you improve, and I will think about it. Otherwise, I am not going to spend my time replying to your rude comments.

    have a nice day John.

    There will always be haters, even on a great I'ble like this one. Luckily, the amount is fairly low here.

    Don't let him ruin it for you - if they aren't nice, report and move on.

    Go MartinD_CZ Go.. Don't let them pessimist's turn out the incredible light of innovation. This forum "Instructables" is just for guy's like you and me. Let's make "something new", ...somebody in the 1700'th centure in UK, (was it UK in those days?), in the parliament said: "There's nothing more to innovate, the world has all the knowledge for a mankind need to know", and this was declared in the parliament of the Upper house. Hmmm????

    on second look at the design... Martin D: sorry to be so critical but where is the loop compensation? There is no loop compensation so this cannot work!!! the most fundamental part is missing and based upon the schematic the design is a mess. the feedback VOLT_OUT etc, goes to the TL494 as well as to the Arduino analog input (which should have the potentiometer inputs as in schematic #1). Designing a switching power supply is not so simple as to copy the power section from a data sheet and then add a command. for this to be regulated it needs feedback which you have. without feedback it is not regulated and may not put out what u tell it to. with the feedback the LC filter is a two pole filter and u have added another RC delay after the Arduino. did you look at the output with a scope? WWWAAAAAAAAAAAAA Your design never worked!!!!! showing a photo of the build is not enough.

    2 replies

    Unless I am mistaken, the loop compensation is Labeled as "Volt Out", "Volt Ref", "Amp Out" and "Amp Ref". From the chips these refer to the Contorller "... Ref" and the feedback ("... Out").