DIY Buck/Boost Converter (Flyback) || How to step up/down DC voltage efficiently

Here is the content rewritten as a well-structured article for a webpage:

The Challenges of Powering Sensitive Electronic Circuits with a 12V Lead Acid Battery

When it comes to powering sensitive electronic circuits that can only handle 12VDC, one common challenge arises when dealing with a fully charged 12V lead acid battery. The battery's initial voltage is 13.1V, and it gradually drops over time to a cutoff voltage of 11V.

One potential solution to this problem is to use a buck converter to step down the voltage above 12V. However, incorporating two circuits into the design can be impractical. For instance, having both a buck converter and a boost converter on hand can add complexity, cost, and space requirements to the project.

Fortunately, there exists a more efficient solution that addresses these challenges: a voltage regulator capable of handling wide voltage ranges.

A better approach is to use a single-stage voltage regulator that can handle wide input voltage ranges. This type of regulator will be able to regulate the battery's output voltage and provide a stable 12VDC supply for your sensitive electronics.

WEBVTTKind: captionsLanguage: enLet's say you have a fully charged up 12V lead acid battery that you want to use the power sensitive electronic circuitsthat can only handle 12VDC.Only problem is that the battery voltage starts out at 13.1V and drops over time to a cutoff voltage of 11V.Now of course we could use a buck converter to step down the voltage above 12V and a boost converterto step up the voltage below 12V. But needless to say, working with two circuits like this is rather impractical.The solution is a so-called "buck- boost converter",which can step up and step down DC voltage in a fluent manner and in this videoI will show you how such a circuit works, and how you can easily build one yourselves. Let's get started!The topology and working behaviour of a buck and boost converter should be known by now.If not, make sure to watch my previous videos about the subjects.But in a nutshell the buck converter outputs a voltage smaller than the input voltagedepending on a duty cycle of the U switch and the boost converter outputs a voltage higher than the input voltagedependent on a duty cycle as well.So wouldn't it be convenient if we could just put the two circuits in series?Well, this method actually exists, and after removing the unnecessarycapacitor in the middle and combining the two coils in series to a single one, we have successfully created a non-inverting buck-boost converter.When switch #1 is closed the buck portion is inactive and switch #2 controls the step-up factor.And if switch #2 is open the boost portion is inactive and switch #1 controls the step-down factorBut since we need to control two switches, a.k.a two MOSFETs, this is not the simplest circuit yet.Because that would be the so-called inverting buck-boost converter, a.k.a flyback converter.All we need is a switch, a coil, a capacitor and a diode.When the switch is closed, current flows through the coil which then builds up its electromagnetic fields and thus stores energy.While that is happening, the diode prevents current from flowing to the capacitor and the capacitor itselfsupplies its previously stored energy to the attached load.Once the switch opens, the stored energy of the coil is then transferred into the capacitorby charging it up and the cycle repeats.But it is noticeable that the positive and negative side of the capacitor is located opposing to the voltage inputsThat is why it is called an inverting buck-boost.For my prototype circuit, I will use a 0.03mH SMD coil,a 220µF capacitor, an 1N5819 Schottky diode and a MOSFET as a switch.Normally I would use a P-channel MOSFET to easily accomplish high side switching.But since its resistance is 10 times higher than an N-channel type,I simply changed the position of the switch so that I can use the IRLZ44N N-channel MOSFET.After building up the circuit on a breadboard, all that was missing was a square wave signal with variable duty cycle for the MOSFET switch.For that I used an ATtiny85 which outputs the required signal on pin 6 with variable duty cycleaccording to the position of a potentiometer on pin 7.But obviously I programmed the microcontroller beforehand with my homemade programming shield.After adding a small load on the output of the converter and hooking up my power supply and the probes of my oscilloscope,it was time to correlate the duty cycle with the output voltage.By using a small duty cycle below 9%,the transferred energy of the coil is rather low and only allows output voltages below the input voltage,so it is in buck mode.But once we use a duty cycle above 9%,the energy of the coil is enough to reach a high output voltage than the input voltage,so it is in boost mode.But here's the problem. If I attach a bigger load to the output,the border between buck and boost mode moves upwards to a duty cycle of 29%.So a duty cycle of for example 20% might represent 8.8V for big loadsbut around 25V for small loads.And that is something a normal buck boost converter does not do. It has a fixed output voltage.So we have to get rid of it.Supplying a feedback voltage to the microcontroller and change the duty cycle according to the set voltage by thepotentiometer would be a decent solution.But since our output is inverted, we cannot directly connect it, unless we want wrong values.What we need is an op-amp which needs to be configured as a differential amplifierwith 20kΩ and 5.1kΩ resistors in order to scale the maximum output voltage of 20Vdown to suitable 5V for the microcontroller.After reprogramming the ATtiny, the circuit held its output voltage steady no matter what kind of load I attached.So it was time to create a more permanent version of it.For that I firstly created a fitting schematic with the help of the free EasyEDA circuit design software.And if you want to build something similar then you can find the codes, this schematic andeverything important in the video description.Afterwards I created a small piece of perfboard,gathered all the necessary components and started soldering the components to one and other according to the schematic.At the end of the soldering process, I used a bit of extra wire to establish the connectionsthat were not realizable with silvered copper wire,and just like that the circuit was complete!Now my sensitive 12V only circuits can easily be powered by a lead acid batteriesBut it is mentionable that there are also disadvantages.In my application example here the boost converter reaches an efficiency of 95%,the buck converter an efficiency of 88%and the buck-boost converter only an efficiency of 80% in boost and buck mode.So the circuit can do both but not as good as each function individuallyI hope you liked this video, and learned something new as well.As always don't forget to like, share, and subscribe,stay creative, and I will see you next time!