Introduction: DIY Buck/Boost Converter (Flyback)

In this project I will show you how a buck/boost converter (flyback) works and how you can easily build one that can step up and step down DC voltage efficiently. Let's get started!

Step 1: Watch the Video!

After watching the video you should have the basic knowledge to create your own buck/boost converter. The next steps though will contain additional information to make your life easier.

Step 2: Order the Components!

Here you can find a parts list with example seller:

Amazon.com:
1x ATtiny85: http://amzn.to/2e1mPzU

1x MCP602: http://amzn.to/2e1mPzU

1x 7805 5V regulator: http://amzn.to/2e1mPzU

1x IRLZ44N: http://amzn.to/2e1mPzU

1x 100kΩ Potentiometer: http://amzn.to/2e1mPzU

1x 0.03mH Inductor: http://amzn.to/2e1mPzU

1x 1N5819 Schottky Diode: http://amzn.to/2e1mPzU

2x Screw Terminals: http://amzn.to/2e1mPzU

2x 100nF Capacitor: http://amzn.to/2e1mPzU

1x 100µF, 1x 220µF Capacitor: http://amzn.to/2e1mPzU

2x 10kΩ, 2x 5.1kΩ, 2x 20kΩ, 1x10Ω Resistor: http://amzn.to/2e1mPzU

Ebay:

1x ATtiny85: http://rover.ebay.com/rover/1/711-53200-19255-0/1..
1x MCP602: http://rover.ebay.com/rover/1/711-53200-19255-0/1...

1x 7805 5V regulator: http://rover.ebay.com/rover/1/711-53200-19255-0/1...

1x IRLZ44N: http://rover.ebay.com/rover/1/711-53200-19255-0/1...

1x 100kΩ Potentiometer: http://rover.ebay.com/rover/1/711-53200-19255-0/1...

1x 0.03mH Inductor: http://rover.ebay.com/rover/1/711-53200-19255-0/1...

1x 1N5819 Schottky Diode: http://rover.ebay.com/rover/1/711-53200-19255-0/1...

2x Screw Terminals: http://rover.ebay.com/rover/1/711-53200-19255-0/1...

2x 100nF Capacitor: http://rover.ebay.com/rover/1/711-53200-19255-0/1...

1x 100µF, 1x 220µF Capacitor: http://rover.ebay.com/rover/1/711-53200-19255-0/1...

2x 10kΩ, 2x 5.1kΩ, 2x 20kΩ, 1x10Ω Resistor: http://rover.ebay.com/rover/1/711-53200-19255-0/1...

Amazon.de:

1x ATtiny85: http://amzn.to/2dWIc4j

1x MCP602:http://amzn.to/2dLaboV
1x 7805 5V regulator: http://amzn.to/2dWHC6K

1x IRLZ44N: http://amzn.to/2dL9WKB

1x 100kΩ Potentiometer: http://amzn.to/2dLaikl

1x 0.03mH Inductor: http://amzn.to/2dWIojS

1x 1N5819 Schottky Diode: http://amzn.to/2dLapwo

2x Screw Terminals: http://amzn.to/2aTTLNW

2x 100nF Capacitor: http://amzn.to/2dWJaNW

1x 100µF, 1x 220µF Capacitor: http://amzn.to/2dL9dsO

2x 10kΩ, 2x 5.1kΩ, 2x 20kΩ, 1x10Ω Resistor: http://amzn.to/2aAsWdV

Step 3: Create the Circuit!

Here you can find the schematic and pictures of the circuit that I created. Feel free to use them as a reference. You can also find the schematic on EasyEDA: https://easyeda.com/GreatScott/ATtiny_Buck_Boost_C...

Step 4: Upload the Code!

Here you can find the code that you need to upload to the ATtiny85 before plugging it in the circuit. If you don't know how to upload the sketch then make sure to watch this video of mine:

Step 5: Success!

Awesome! You did it! You just created your own buck/boost converter!


Feel free to check out my YouTube channel for more awesome projects:

http://www.youtube.com/user/greatscottlab

You can also follow me on Facebook, Twitter and Google+ for news about upcoming projects and behind the scenes information:

https://twitter.com/GreatScottLab

https://www.facebook.com/greatscottlab

Comments

author
Abdul GoffarA (author)2017-07-26

Hi, your videos are amazing! I tried to make this version of buck-boost converter. I replace the MCP602 with LM358, and I use Arduino Mega 2560 board, it works well. But I think this converter is not buck-boost, it is buck only.

Because the output voltage is never been higher than the input voltage.

You said that the specification is "Input: 6V-30V Output: 0-20V Output Current: 1-2A."

The input voltage is always higher than the output voltage.

Regards

author
jeverhar (author)2016-10-11

How about a list of specs such as input/output voltage range, output current, etc?

author
GreatScottLab (author)jeverhar2016-10-13

Input: 6V-30V Output: 0-20V Output Current: 1-2A

author

hey scott, does this circuit can works with input 2-7v,and constant output voltage as 5.5v? i want some advice from you.....i am waiting for your answer please?

author
GeorgeN86 (author)ManikandanK42017-07-26

you need at least 6 to 7 volts input in order for the 7805 to be able to regulate it down to 5 volts to power the MCU. however, if you power it up with the aforementioned voltages you can use it as a step-down converter to have a 5v5 output.

author
BramV38 (author)GreatScottLab2017-02-09

if we would replace the 1n5819 diode with a 1n5822 diode, wouldn't it be possible to draw up to 3 A ? (ofc if we take into account that our power inductor can handle this)

author
BrahamL (author)GreatScottLab2016-10-13

Sir, can you added also the calculation for getting the component in the later video. Especially using inductor and resistor and capacitor when making something like buck / boost converter. Thanks ^^

author
GeorgeN86 (author)2017-07-26

interesting project! I was thinking of beefing it up and adding an LCD into an enclosure so it becomes a bench power supply. Do you see any challenges that might prevent me from doing that?

One thing I have noticed that you always use Arduino (I've never used it) and almost never Atmel Studio/gcc to write your codes. I think using C would be more educational and informative. but always thank you for the great ideas :)

author
Varen Greycloak (author)2017-07-21

Do you think I could use this to run a circuit on exactly 3v from an 18650 lipo?

author
T-2 (author)2017-06-07

try diy ltc3780

author
MattiaD8 (author)2016-10-13

how many watts can handle? I'd like to make one for a 120 W load

author
Orngrimm (author)MattiaD82017-04-21

Power electronics are no easy thing...

I would suggest to go with something like

https://www.aliexpress.com/item/10-30V-to-12-35V-Step-Up-CV-CC-150W-10A-DC-Buck-Boost-Converter-Car/32800195388.html for <5$ or if you want a digital interface https://www.aliexpress.com/item/DC-DC-Adjustable-10-40V-To-0-38V-Digital-Step-up-Step-down-Power-Supply-Boost/32789812405.html

author
AMSR1 (author)2017-04-14

Hello~ I have a question. Can I use another OP amp for this project? Im having a hard time finding one here locally.

author
chandan_sharma (author)2017-03-23

Hey scott can you tell me how you calculated the value of inductor and the capacitor used in the circuit?

author
ElectronicaXAB3 (author)2017-03-17

This is really neat. Thanks for the share!

author
shivakumar1995 (author)2016-11-09

is there any change needed if I want to do this on an arduino nano or the other arduino boards?

author

Not really.

author

hey i executed the program and there seems to be an error in the line 12. it says 'TCCR1 was not declared in this scope'. I dont want to bother you with the programming questions, but i tried understanding this code and there are some terms I dont understand. these are the errors it showed when i executed it in the arduino uno.

BuckBoostConverter:12: error: 'TCCR1' was not declared in this scope

BuckBoostConverter:12: error: 'PWM1A' was not declared in this scope

BuckBoostConverter:13: error: 'PWM1B' was not declared in this scope

'TCCR1' was not declared in this scope

author

please just replace these codes with "TCCR0B = TCCR0B & 0b11111000 | 0x01;" because i had same problem firstly

author
wzdl (author)2016-10-09

1 what is the frequency? Increasing frequency might be helpful to efficiency and you can do it with Arduino.

2 why not use a resistor valtage devider for feedback?

3 will you please uplode the code for multi chanal version based on Arduino Nano here?

Thankyou.

author
BramV34 (author)wzdl2017-01-06

indeed, why didn't he use a voltage divider as in his boost converter circuit ?

Im' guessing he did it because it wastes less power but not sure...

author
BramV34 (author)BramV342017-01-20

I've tried to build this circuit and noticed that he used the op amp to get his ground to the same level as the one of the attiny. Just using a voltage divider would result in > 12V on the attiny analog pin which would destroy it. Personally, i don't have this op amp and i'm looking for a good alternative. If someone knows, please let me know :)

author
VikramS61 (author)2017-01-16

I'm very much interested in this project I'm going to start the work but the only thing is that mcp602 Op-amp is not available but I have Lm358 can it be used

author
Tecwyn Twmffat made it! (author)2016-12-28

https://www.instructables.com/id/Super-Efficient-Buck-Convertor-5V-1A-Arduino-Power/

circuit photo 01.jpg
author
Kevinsagen47 (author)2016-12-16

Is it ok if I use 0.02mH or 4.7uH?

author
Bycengo (author)2016-12-08

1. in your shematic R9 not a resitor is it load ?

2. 100nF ceramic cap. you use only on of them at finished photo or i coudnt see it but shematic & bom 2 of them

3.attiny 85 whats the options for programing bod % ldo enable/disabled, 8mhz (int/ext) ?

author
BrahamL (author)2016-11-21

In the code, it's written : if (pwmval > 203)

What ADC value 203 is ? The limit of buck and boost (in this case around 11V at 4:05 in the video) or something else ?

Thanks.

author
ade almeida lopes (author)2016-10-28

What brand perfboard do you use? I hate the cheap Chinese browboard.

author
KROKKENOSTER (author)2016-10-17

I have just gripe on all swithchers and that is NOISE I listen a lot to radio and especially if the signal is on the fringe then BUZZZZZZZZ!!!!!!!!!! How can a poor old feller cure this? I have a UPS for my fridges and the output is "pure sine"wave but matey some days when the batteries get charged BUZZ TACK BUZZZ It is a 3Kw unit and the size of a reps document case and weigh about three kilo's! Try to operate a Medium Wave (AM) radio near a computer's psu!!

author
BrahamL (author)2016-10-11

Why the op-amp resistor divider calculation must be multiplied by 20 ? Was it because it's the maximum voltage that you want ?

author
Bycengo (author)BrahamL2016-10-13

http://www.ti.com/lit/an/slva535a/slva535a.pdf

author
BrahamL (author)Bycengo2016-10-13

so, 20 means the voltage output desire ? thanks for your information !

author
GreatScottLab (author)BrahamL2016-10-13

Correct

author
AnthonyP142 (author)2016-10-13

What the best op amp eqiuvalent?

author
benyblack (author)2016-10-10

i have a 40w laser cutter that keeps blowing the flyback transformer would this be a good replacement

author
pauldg99 (author)benyblack2016-10-11

is it a k40? Look on the google+ user group for k40. I do have the schematic for it and probably cnan help.

author
benyblack (author)pauldg992016-10-11

Yes its a k40 im already a member of the Google + group

author
pauldg99 (author)benyblack2016-10-12

the power supply is easy to repair. Is the 24 volt section not working? The culprit is most likely the rectifying diode in the 24 section which is close to the connectors. When this breaks, everything switches off since the high voltage circuit relies on 12 v derived from the 24 v circuit. Just measure with a multimeter if the diode is a short in both directions. You can replace this schottky diode her308g. Don't use a normal diode because it does not work. The schematic is on the google plus page of the k40 group. I will post a pdf on their as well since people complained about the visibility of the picture. Let me know how you go. And not this flyback circuit is not power full enough to drive the steppers in the k40.

author
benyblack (author)pauldg992016-10-12

thank you

author
Anirudh Ralhan (author)2016-10-09

Nice... It's useful...

About This Instructable

30,845views

304favorites

License:

Bio: Awesome Electronics Tutorials, Projects and How To´s
More by GreatScottLab:Make Your Own ESCDIY Short Circuit (Overcurrent) ProtectionMake Your Own Photovoltaic Off-Grid System
Add instructable to: