How does a modern Power Supply work?! (230V AC to 5/12V DC) DIY Flyback Converter!

Würth Elektronik Has Done It Once Again

Würth Elektronik has done it once again, sending me a bunch of components and only providing me with a piece of paper that reads "Do your best! Hint: Flyback." I was excited to receive this package, as I knew that Würth Elektronik had sent me a component that would be the star of my next video tutorial. The components arrived, and after taking a closer look, I realized that they were some kind of transformer.

Not Those Kinds of Transformers

The transformers in question were not large and heavy, as those are typically used to convert mains voltage directly into DC power. Instead, these transformers were small and light, and they seemed to be designed for use in commercial switched-mode power supplies. As a electronics enthusiast, I was eager to learn more about these flyback transformers and how they could be used to create efficient and reliable power supplies.

What is a Flyback Transformer?

A flyback transformer is a type of transformer that uses a flyback mechanism to store energy in the magnetic field when the voltage is increasing. This stored energy is then released when the voltage is decreasing, allowing for a smooth and efficient transfer of power. Flyback transformers are commonly used in switched-mode power supplies because they can provide high efficiency and reliability.

The Transformer Type

I chose this transformer type for my first test because it came with 6 identical windings. The components used in this circuit were pretty much the same as I described in theory, but there was one exception - an additional diode in combination with a resistor and capacitor. This combination absorbed the energy that was not transferred to the secondary side and protected the MOSFET from over-voltages when it opened.

Building Up the Circuit

After building up the circuit, I used my function generator to switch the MOSFET on and off with a frequency of 68kHz. It was time to capture some voltage and current waveforms after powering everything with 12V. As you can see on the oscilloscope, the waveforms pretty much corresponded with the theory.

Creating an Adjustable Voltage

As a simple example, I went with an output voltage of 5V. However, this value would go down as soon as we drew more current on the output because of higher voltage drops across the resistive elements and diode in this open-loop operation. To compensate for that and transfer more energy, we would have to increase the duty cycle of our square wave control signal. This basically meant that we needed a feedback system.

Feedback System

Of course, we could create such a system ourselves with, for example, an Arduino microcontroller. However, when it comes to mains voltage, it definitely makes more sense to use an established controller IC. In this case, I used the NCP1010, which was actually recommended by Würth Elektronik website.

The NCP1010

With the help of its datasheet, which came with tons of information, and in combination with a flyback transformer, I was able to create a half-decent switched-mode power supply that could convert 230VAC into 5V DC on its output. However, I have to warn you that working with mains voltage can lead to major injuries if not handled correctly.

A Warning

My powersupply design does not care about safety at all, which can be seen by the trace distances, a missing inrush current limitation, and no kind of EMC filter. It only acts as a demonstration and should not be rebuilt. With that being said, here is the schematic.

The Schematic

The fundamental components are pretty much the same in comparison to the previous flyback converter schematic but of course we do need a full bridge rectifier this time in order to convert our 230V AC into 325V DC. The other big difference is the feedback system which consists of an Optocoupler and a TL431 programmable reference voltage.

Conclusion

The general functional principle of a modern switched-mode power supply should be pretty clear, and I hope that you learned a bit about flyback converters and transformers. Don't forget to like, share, subscribe, and hit the notification bell. Stay creative and I will see you next time.

WEBVTTKind: captionsLanguage: enWürth Elektronik has done it once again.They just sent me a bunch of components andall I received along with it was a piece ofpaper onto which was written: “Do your best!Hint: Flyback”Well, in this case the components seem tobe some kind of transformer.But not those kinds of transformers whichare big and heavy and get directly poweredwith mains voltage in order to convert itdown.No!Those transformers are small and some of themvery light; and diligent viewers have seenthem in a previous video of mine in whichI talked about transformers for 11 minutes.You can often find them in commercial switchedmode power supplies that convert our mains230V AC voltage into for example 12V DC.A lot of those transformers use a so calledFlyback topology in order to perform sucha voltage conversion.And OK I get it, that was the hint from WürthElektronik and that means in this video Iwill be showing you how such a Flyback circuitof a Switched Mode Power supply functionsand how we can use it for ourselves for lowvoltage applications.Let’s get started!This video is sponsored by the Würth ElektronikeiSos group.First off, we should have a closer look atthe Flyback transformers and with closer lookI mean we should take one apart.Like always with transformers we have a primarycoil and a secondary coil which sometimescome with an identical amount of windingsto one another and sometimes not.But this winding relation to one another canalways be found in the datasheet.Now a big difference of such a Flyback transformerin comparison to a mains transformer is forone that its used material is a kind of ferrite,while normal mains transformers use laminatedelectrical sheets.The other difference is that the core comeswith a small air gap which is absolutely mandatoryfor a Flyback converter, but more about thatin a minute.Because before that; let’s talk about theferrite material which is used in order tokeep the eddy currents low.Those need special attention this time incomparison to a mains transformer, becausethe Flyback transformer gets used with a muchhigher frequency and thus it would be ableto create way bigger eddy current losses.As an example; this commercial switched modepower supply uses a frequency of around 68kHz.The frequency is of course on purpose so highin order to keep the size of the transformersmall, while still being able to convert quitea bit of power.For example this mains transformer here canoutput around 21.6W while this switched modepower supply with a similar size can outputalmost three times as much while being lighterand featuring a higher efficiency.So in a nutshell, such Flyback transformersare essential for modern and efficient switchedmode power supplies.So how can we use them with a Flyback convertercircuit?Well, here you can see a simplified schematicwhich only consists of a voltage source, thetransformer, a MOSFET switch, a diode, a capacitorand a load.There exist 2 switching states and those areeither MOSFET switch closed or MOSFET switchopen.So let’s begin with switch closed at whichpoint the voltage source pushes a linear increasingcurrent through the primary side.The current does in this case only rise slowlydue to the inductance of the transformer andits air gap in which now energy gets stored.And that is also why the air gap is so important,since it can store lots of energy, while preventingthe transformer from reaching its magneticsaturation too early.But since current is now flowing through theprimary side of the transformer, there shouldbe a voltage and current flow on the secondaryside, right?Well, actually no; because of the windingdirection of the primary side to the secondaryside, identifiable by the two points at thetransformer symbol, there exists a voltageon the secondary side which would let a currentflow reverse-biased to the diode.And that is of course not possible.But it is noteworthy that during this phase,the load still gets supplied with energy throughthe capacitor which in the now following secondswitch state will get charged up.In this phase the MOSFET switch opens.Thus the primary side current falls abruptlyand the whole stored energy gets transferredto the secondary side, in which a now a lineardecreasing current runs in flow directionto the diode.And of course we can create a higher or lowervoltage at the output of the circuit dependingon the winding relation of the transformer.At the end it is noteworthy that such a circuitoften gets used with mains voltage since itsinput and output side is galvanically isolatedfrom one another which is an important safetyfeature against electrical shocks.But before we get lost in the theory, aboutwhich we could talk for hours with subjectslike the difference between the DCM and CCMmode, we should probably move on to creatinga practical Flyback circuit.I chose this transformer type for my firsttest which comes with 6 identical windings.You can see the used components here and thoseare pretty much the same as I described themin the theory.But there is one exception which is this additionaldiode in combination with a resistor and capacitor.This combination absorbs the energy not transferredto the secondary side and thus protects theMOSFET from over voltages as soon as it opens.Such non transferred energy by the way doesexist since no transformer is perfect andthus features a leakage inductance which weshould obviously keep as small as possible.But the transformers from Würth Elektronikdo a pretty job at achieving that.But nevertheless, after building up the circuitand using my function generator to switchthe MOSFET on and off with a frequency of68kHz, it was time to capture some voltageand current waveforms after powering everythingwith 12V.And as you can see on the oscilloscope, thewaveforms pretty much correspond with thetheory and now we can create an adjustablevoltage on the output depending on how weset the Duty cycle for the MOSFET becausethat determines how much energy we transferto the secondary side.But as a simple example I went with an outputvoltage of 5V.This value obviously goes down as soon aswe draw more current on the output since wealso got higher voltage drops across the resistiveelements and diode in this open loop operation.To compensate for that and transfer more energywe would have to increase the duty cycle ofour square wave control signal.And that basically means we have to constantlymonitor the output voltage and according tothat either increase or decrease the dutycycle in order to maintain a constant outputvoltage.Simply put; we need a feedback system.Of course we could create such a system byourselves with for example an Arduino microcontroller.But when it comes to mains voltage then itdefinitely makes more sense to use an establishedcontroller IC.This can be for example this NCP1010, whichwas actually a recommendation from the WürthElektronik website.With the help of its datasheet, which comeswith tons of information, and in combinationwith a flyback transformer I received; I wasable to create a half way decent switchedmode power supply that can converter 230VAC into 5V DC on its output.But as a warning I have to tell you that workingwith mains voltage can lead to major injuriesif not handled correctly and since my powersupply design does not care about safety atall which can be seen by the trace distances,a missing inrush current limitation and alsono kind of EMC filter, it only acts as a demonstrationand should not be rebuild.With that being said here is the schematic.The fundamental components are pretty muchthe same in comparison to the previous flybackconverter schematic but of course we do needa full bridge rectifier this time in orderto convert our 230V AC into 325V DC.And the other big difference is the feedbacksystem which consists of an Optocoupler anda TL431 programmable reference voltage.Simply put, this TL431 quickly reacts to smalloutput voltage changes and thus alters theoperating bias point of the optocoupler inorder to fine adjust the duty cycle.But since there is so much to talk about thisadjustable voltage reference, there will bean extra video about it.And with that being said, the general functionalprinciple of a modern switched mode powersupply should be pretty clear and thus I hopeyou learned a bit about flyback convertersand transformers.If so don't forget to like, share, subscribeand hit the notification bell.Stay creative and I will see you next time.