Introduction: DIY Buck/Boost Converter (Flyback)

Picture of 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!

Picture of 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!

Picture of 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!

Picture of 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

jeverhar (author)2016-10-11

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

GreatScottLab (author)jeverhar2016-10-13

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

LexenZ (author)GreatScottLab2017-12-07

I can't seem to produce a 1-2A based on this specs, I am only able to get 0.3A at most to charge a smartphone, any solutions on this?

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?

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.

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)

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 ^^

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) ?

Iqbal Samin (author)Bycengo2017-11-04

1. R9 is the load, not a resistor.

2. There are two 100nF capacitors in the schematic. look closely. They are C1 and C2 on the top left corner, next to the voltage regulator.

3. Where do you get these options? When burning fuse? If so, you don't need to burn fuse, you just need to burn the Arduino bootloader.

Bycengo (author)Iqbal Samin2017-11-06

Iqbal thank you for answers. I forgot the questions nearly year passed for 3rd q. at arduino ide if you look closer theese options on section mcu but nevermind now

Iqbal Samin (author)2017-11-04

I can not find MCP602. Can I use NE5532 or LM358?

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.

Iqbal Samin (author)wzdl2017-11-04

As he said in the video, the output is inverted and not referenced to ground. So you can't just use a voltage divider (unless you want wrong results)

A differential amplifier will make sure that the Arduino always reads the voltage potential between the positive and the negative output. That op amp is being used as an differential amplifier.

Hope you get the point.
Pirthul.

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...

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 :)

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?

Not really.

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

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

LexenZ (author)ManikandanK42017-09-08

Hi there, after replacing the code you have given I was given another error message:

Arduino: 1.8.4 (Windows 10), Board: "Arduino/Genuino Uno"

C:\Users\Master John\Downloads\FZE1LU4IU2NFBF2\FZE1LU4IU2NFBF2.ino:1:0: warning: "F_CPU" redefined

#define F_CPU 8000000

^

<command-line>:0:0: note: this is the location of the previous definition

Sketch uses 1250 bytes (3%) of program storage space. Maximum is 32256 bytes.

Global variables use 15 bytes (0%) of dynamic memory, leaving 2033 bytes for local variables. Maximum is 2048 bytes.

avrdude: ser_open(): can't open device "\\.\COM1": The system cannot find the file specified.

Problem uploading to board. See http://www.arduino.cc/en/Guide/Troubleshooting#up... for suggestions.

This report would have more information with

"Show verbose output during compilation"

option enabled in File -> Preferences.

May I know why?

Iqbal Samin (author)LexenZ2017-11-04

Remove this line too:

#define F_CPU 8000000

aayushn5 (author)2017-09-09

Can we use regular 741 op-amp instead of mcp602?

wingweaver77 (author)2017-09-05

hello,can i use this project for solar charge controller?

thank you

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

hedi25253 (author)Abdul GoffarA2017-08-28

You misunderstand the specs :

Input 6v-30v : let's assume it's 7.4V (2 li-ion batteries in serie)

output : 0-20V : let's assume it's 12V.

So, the output voltage is higher than the input voltage.

Abdul GoffarA (author)hedi252532017-08-29

Apologize, I just misunderstood. I think it was my fault, my circuit didn't work well.
Thanks for your response.

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 :)

Varen Greycloak (author)2017-07-21

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

T-2 (author)2017-06-07

try diy ltc3780

MattiaD8 (author)2016-10-13

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

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

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.

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?

ElectronicaXAB3 (author)2017-03-17

This is really neat. Thanks for the share!

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

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

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

Kevinsagen47 (author)2016-12-16

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

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.

ade almeida lopes (author)2016-10-28

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

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!!

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 ?

Bycengo (author)BrahamL2016-10-13

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

BrahamL (author)Bycengo2016-10-13

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

GreatScottLab (author)BrahamL2016-10-13

Correct

AnthonyP142 (author)2016-10-13

What the best op amp eqiuvalent?

benyblack (author)2016-10-10

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

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.

benyblack (author)pauldg992016-10-11

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

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.

About This Instructable

35,912views

312favorites

License:

Bio: Awesome Electronics Tutorials, Projects and How To´s
More by GreatScottLab:Make Your Own Crude Cocktail MachineMake Your Own Solid State RelayMake Your Own Simple Theremin
Add instructable to: