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 (affiliate links):
Aliexpress:
1x ATtiny85: https://s.click.aliexpress.com/e/_d6SPsKP
1x MCP602: https://s.click.aliexpress.com/e/_dZIAwSP
1x 7805 5V regulator: https://s.click.aliexpress.com/e/_d8kqX6x
1x IRLZ44N: https://s.click.aliexpress.com/e/_dWhSrDl
1x 100kΩ Potentiometer: https://s.click.aliexpress.com/e/_dX83GAF
1x 0.03mH Inductor: https://s.click.aliexpress.com/e/_dYct48b
1x 1N5819 Schottky Diode: https://s.click.aliexpress.com/e/_dYR45Bh
2x Screw Terminals: https://s.click.aliexpress.com/e/_dYbstfZ
2x 100nF Capacitor: https://s.click.aliexpress.com/e/_dU4FEsB
1x 100µF, 1x 220µF Capacitor: https://s.click.aliexpress.com/e/_d7dOwRz
2x 10kΩ, 2x 5.1kΩ, 2x 20kΩ, 1x10Ω Resistor: https://s.click.aliexpress.com/e/_dTPpXjt
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:
Attachments
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:
3 People Made This Project!
- _PurplePower_ made it!
- PJnap123 made it!
- Tecwyn Twmffat made it!
87 Comments
Question 12 months ago on Introduction
Hi , I just a beginner in electronic field. I really interested in your project . for the 5V source in the circuit diagram, Do you add the 5V from the external source or use the input 12 V ? Could you also explain the part around 7805?
1 year ago
can anyone advise me the function of the op amp in the circuit?
Reply 1 year ago
It is for the feedback loop. The ATtiny will adjust the PWM duty cycle to control the output voltage under changing load. Now in order to simplify the circuit, the MOSFET switch is between the load and ground (called low-side switching) so neither the - nor the + of the output are shared with the - and + of the input. The opamp computes the voltage difference between output + and output - (the two sides of the resistor called Load) and feeds the result to the microcontroller.
Question 1 year ago
Hello. The place where I buy electronics from does not have the MCP602, and I can't find any laying around. So, can I use the LM358P instead of the MCP602?
Answer 1 year ago
I think you can, i've used an LM385N with inverting configuration and it worked.
Reply 1 year ago
Thank you so much
3 years ago
Not working waste of time
Reply 1 year ago
worked for me!
Question 1 year ago
what is the current capacity of the output ? and how to make this circuit to have 10A output capacity ?
Question 2 years ago on Step 5
Does anyone know how to increase the PWM frequency.
Answer 1 year ago
I believe it's the Potentiometer that controls it
Question 2 years ago
Where is the code?
Answer 1 year ago
#define F_CPU 8000000
const int pwm = 1;
const int potinput = A1;
const int feedbackinput = A3;
int potinputval;
int feedbackinputval;
int pwmval;
void setup() {
TCCR0A = 2 << COM0A0 | 2 << COM0B0 | 3 << WGM00;
TCCR0B = 0 << WGM02 | 1 << CS00;
TCCR1 = 0 << PWM1A | 0 << COM1A0 | 1 << CS10;
GTCCR = 1 << PWM1B | 2 << COM1B0;
pinMode(pwm, OUTPUT);
pinMode(potinput, INPUT);
pinMode(feedbackinput, INPUT);
digitalWrite(pwm, LOW);
pwmval = 0;
}
void loop() {
potinputval = analogRead(potinput);
feedbackinputval = analogRead(feedbackinput);
while (feedbackinputval < potinputval){
if (pwmval > 203){
analogWrite(pwm, pwmval);
potinputval = analogRead(potinput);
feedbackinputval = analogRead(feedbackinput);
}
else {
analogWrite(pwm, pwmval);
pwmval = pwmval + 1;
potinputval = analogRead(potinput);
feedbackinputval = analogRead(feedbackinput);
}}
while (feedbackinputval > potinputval){
if (pwmval == 0){
analogWrite(pwm, pwmval);
potinputval = analogRead(potinput);
feedbackinputval = analogRead(feedbackinput);
}
else{
analogWrite(pwm, pwmval);
pwmval = pwmval - 1;
potinputval = analogRead(potinput);
feedbackinputval = analogRead(feedbackinput);
}}
}
2 years ago
I'm getting error that TCCR1 PWM11 are not declared. How can I solve this?
Reply 1 year ago
(948) Program the ATTINY85 with Arduino 1.8.13 (2020) - YouTube
Once you do those stuff the code compile without errors. Just worked for me
Question 4 years ago
Hi
i tried to replicate the results with following changes
used a breadboard
1.used an arduino nano
2.replaced irlz44n with irfz44n
3. didnt use 100nf cap at output of 7805
4.used attached code
5,didnt use the feedback circuit
i powered the circuit with a 12v rectified filtered(not regulated) output
when i adjusted the pot and went above 16v something (i suppose 7805) started to make a buzzing noise i kept going up and my nano behaved erratically and windows refused to detect the nano for a while.
can anyone tell me what went wrong?
Answer 2 years ago
your code is wrong (ıdk in the screenshot it is)
5 years ago
I can not find MCP602. Can I use NE5532 or LM358?
Reply 3 years ago
Probably, but I believe its actually MCP6022
Question 5 years ago on Step 4
whats is the logic of using "cont int" instead of "int " ???
i never under stand when to use which.............