You are on page 1of 8

instructables

DIY Buck/Boost Converter (Flyback)

by GreatScottLab

In this project I will show you how a buck/boost converter ( yback) works and how you can easily build one that can
step up and step down DC voltage e ciently. Le t ' s g e t s t a rt e d!

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.

https://youtu.be/ZiD_X-uo_TQ

Step 2: Order the Components!

DIY Buck/Boost Converter (Flyback): Page 1


Here you can nd a parts list with example seller Alie xpre s s :
(a liate links): 1x ATtiny85: https://s.click.aliexpress.com/e/_d6SPsKP

1x MCP602: https://s.click.aliexpress.com/e/_dZIAwSP 1x 0.03mH Inductor:


http://rover.ebay.com/rover/1/711-53200-19255-0/1...
1x 7805 5V regulator:
https://s.click.aliexpress.com/e/_d8kqX6x 1x 1N5819 Schottky Diode:
http://rover.ebay.com/rover/1/711-53200-19255-0/1...
1x IRLZ44N: https://s.click.aliexpress.com/e/_dWhSrDl
2x Screw Terminals: http://rover.ebay.com/rover/1/711-
1x 100k Potentiometer: 53200-19255-0/1...
https://s.click.aliexpress.com/e/_dX83GAF
2x 100nF Capacitor:
1x 0.03mH Inductor: http://rover.ebay.com/rover/1/711-53200-19255-0/1...
https://s.click.aliexpress.com/e/_dYct48b
1x 100µF, 1x 220µF Capacitor:
1x 1N5819 Schottky Diode: http://rover.ebay.com/rover/1/711-53200-19255-0/1...
https://s.click.aliexpress.com/e/_dYR45Bh
2x 10k , 2x 5.1k , 2x 20k , 1x10 Resistor:
2x Screw Terminals: http://rover.ebay.com/rover/1/711-53200-19255-0/1...
https://s.click.aliexpress.com/e/_dYbstfZ

2x 100nF Capacitor: Am a z o n. de :
https://s.click.aliexpress.com/e/_dU4FEsB

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


https://s.click.aliexpress.com/e/_d7dOwRz
1x MCP602:http://amzn.to/2dLaboV
2x 10k , 2x 5.1k , 2x 20k , 1x10 Resistor: 1x 7805 5V regulator: http://amzn.to/2dWHC6K
https://s.click.aliexpress.com/e/_dTPpXjt
1x IRLZ44N: http://amzn.to/2dL9WKB
Eba y :
1x 100k Potentiometer: http://amzn.to/2dLaikl
1x ATtiny85: http://rover.ebay.com/rover/1/711-53200-
19255-0/1.. 1x 0.03mH Inductor: http://amzn.to/2dWIojS
1x MCP602: http://rover.ebay.com/rover/1/711-53200-
19255-0/1... 1x 1N5819 Schottky Diode: http://amzn.to/2dLapwo

1x 7805 5V regulator: 2x Screw Terminals: http://amzn.to/2aTTLNW


http://rover.ebay.com/rover/1/711-53200-19255-0/1...
2x 100nF Capacitor: http://amzn.to/2dWJaNW
1x IRLZ44N: http://rover.ebay.com/rover/1/711-53200-
19255-0/1... 1x 100µF, 1x 220µF Capacitor: http://amzn.to/2dL9dsO

1x 100k Potentiometer: 2x 10k , 2x 5.1k , 2x 20k , 1x10 Resistor:


http://rover.ebay.com/rover/1/711-53200-19255-0/1... http://amzn.to/2aAsWdV

DIY Buck/Boost Converter (Flyback): Page 2


Step 3: Create the Circuit!

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

Step 4: Upload the Code!

DIY Buck/Boost Converter (Flyback): Page 3


Here you can nd 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:

//www.yout ube.com/embed/9LjfkjwMqXI

Download
https://www.instructables.com/ORIG/FZE/1LU4/IU2NFBF2/FZE1LU4IU2NFBF2.ino

Step 5: Success!

Awesome! You did it! You just created your own behind the scenes information:
buck/boost converter!

Feel free to check out my YouTube channel for more https://twitter.com/GreatScottLab


awesome projects:

http://www.youtube.com/user/greatscottlab
https://www.facebook.com/greatscottlab
You can also follow me on Facebook, Twitter and
Google+ for news about upcoming projects and

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

Probably, but I believe its actually MCP6022

Not working waste of time

DIY Buck/Boost Converter (Flyback): Page 4


I have problems when connecting my oscilloscope to measure the output voltage. When I connect
the ground clip the output voltage gets modified to aproximate my input voltage. Someone had a
similar problem?
J'ai essayé de charger le code mais voici l'erreur qui s'affiche : exit status 1
'TCCR1' was not declared in this scope/
que faire s'il vous plait ????
May I know what is the duty cycle of this circuit?

hello guys , can someone explain to me where i must connect the voltage regulater part

Is it possible that 2 new ATTINY85 from Reichelt are bricked out of the box?

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


thank you
hey dude ,, did you build it using a solar charger ?

hey , i built the same exact circuit as in the sketch with the same components and i uploaded the
code to the attiney85 ,,, but it didnt work
i received an output voltage of 5volts at my 20kohms load and the potentiometer was not changing
the outpout voltage ,, am thinking that the problem is with the defined pwm inputs and the pot input
in the code ,
any suggestions to help make it work?
The code has seem to be changed, I am unable to replicate the same results as with the previous
code... may I have the older code uploaded?
Is there a way to add current control to this also? I am Novice Newb please help

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

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

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?
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.
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)
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 ^^
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) ?
1. R9 is the load, not a resistor.

DIY Buck/Boost Converter (Flyback): Page 5


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

DIY Buck/Boost Converter (Flyback): Page 6


<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?
Remove this line too:

#define F_CPU 8000000


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

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
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.
Apologize, I just misunderstood. I think it was my fault, my circuit didn't work well.
Thanks for your response.
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 :)
Do you think I could use this to run a circuit on exactly 3v from an 18650 lipo?

No

try diy ltc3780

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

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-
DIY Buck/Boost Converter (Flyback): Page 7
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
Hello~ I have a question. Can I use another OP amp for this project? Im having a hard time finding
one here locally.
Hey scott can you tell me how you calculated the value of inductor and the capacitor used in the
circuit?
This is really neat. Thanks for the share!

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
https://www.instructables.com/id/Super-Efficient-Buck-Convertor-5V-1A-Arduino-Power/

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

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.

DIY Buck/Boost Converter (Flyback): Page 8

You might also like