78xx power supply
A super-simple power-supply design for low-voltage DC
Every electronics project runs on a power-source of some kind. Unless you're messing with batteries (and even then) there's a good chance you'll require a power-regulation circuit like the one presented below:
This design is based around 4 main parts. A transformer (optional in case of DC-input voltage) a bridge rectifier , a smoothing capacitor and the LM78XX chip which contains a 'linear voltage regulator'. This article will explain what they all do, how it works (kinda), how to design and build one and will present some considerations concerning the use of these devices. The design is split up in a part that concerns itself with transforming AC into DC and a part that explains just how to regulate the DC part with the LM78xx chip. For this reason, the design will also be of interest if you are simply looking to transform a DC voltage into a lower voltage to fit your circuit.
Let's say we have a little circuit that we would like to make but it requires 5volt DC power. Unless we can find some pre-made power-supply somewhere, we might have to build our own little power-supply circuit too. Even if we are not faced with the task of going from AC-voltage to DC-voltage ourselves, we might still need to regulate the voltage to get it to be the required 5Vdc instead of, say, 12Vdc that we get from a lead-battery.
In the rest of the article we're going to assume to assume that we want a 5Volt powersupply like the one presented in the figure above. We're going to see how we could build it all from scratch, right down from going to 5Vdc from a wall-socket with 240Vac. Also, we're going to show what part can be left out if you already have 12Vdc (from a lead battery, for example).
Getting from AC to DC
As you might know , electric power is available in both AC and DC flavors. The distinction between the two is that with DC, the 'voltage' or 'potential' between the two poles of the supply is at a steady level.
Let's say, 5Vdc. Looking at it with an oscilloscope would reveal a single straight line with nothing interesting happening. With AC power, the potential between the two poles oscillates between two extremes at a fixed frequency;normally 50 or 60Hz, depending on where you live. The reason for this is explained further in AC , but it's sufficient to realize that it is easier to transform high AC voltages into lower AC voltages than it is to transform high DC voltages into low DC voltages (go ask Nikola Tesla why this is).
For that reason, if you're given an AC-voltage, you will need some way of turning it into lower AC voltage first, and then turning it into a DC voltage. This is where the AC transformer and bridge rectifier come in. Please consider the circuit presented earlier.
The transformer there is a device which uses two copper-wire coils wound around a single metal frame to create a electro-magnetic way of transferring power from one coil to the other. The ratio between the windings on first coil and the second coil determine what voltage comes out of the 'secondary coil' when you put some potential (say, 240Vac) on the 'primary coil'. See the line transformer article for more info about the theory on this.
A fuse is positioned in between the transformer and the next part, the rectifier, to burn through when too much current has been drawn from the circuit; protecting the parts of the power-supply against overload. Essentially it's just a thin wire that will burn through if too much current runs through it; it doesnt do anything to the voltage or the waveform that comes from the transformer.The frequency and waveform of the AC-voltage coming out of the secondary side of the transformer will be the same as that of the primary side; except at a different voltage. That voltage , however, still needs to be turned into something resembling DC before we can hope to use it for most DC-based electronics.
For this purpose we require the bridge rectifier . This is a simple circuit made out of four diodes (in this case of a popular type, the 1n4007) configured in such a way (see diagram) that it will basically 'flip' the negative parts of the AC waveform (see diagram above) and put them on the positive side of the graph. This works because diodes only conduct in one direction and like a broken connection when the polarity is reversed. This results in a fluctuating/oscillating potential between the two outputs of the bridge rectifier circuit that has one pin always be 'positive' in respect to the other output terminal. See the diagram on how this looks. Note that the bridge rectifier can also be bought as a single component with four pins sticking out of it, containing the correct configuration of four diodes inside of it, internally.
After we've achieved the task of making one terminal be positive with respect to the other terminal, we can now take on the task of smoothing away the oscilation. As it is, using this voltage as it is would make parts like logic-gates severely unhappy; not to mention add an incredible buzzing sound to anything that has a speaker connected to it.
How to do this is covered in the next section.
Smoothing the waveform
To get from the bumpy waveform shown above to something that 'comes close' to something we can work with, please consider the diagram below:
Shown here is the large capacitor (470uF in the original circuit) and a picture of what the waveform will look approximately look like if you'd look on an oscilloscope. A capacitor is a part that acts somewhat like a sponge or a reservoir for voltage. It will suck up energy while it's own charge is lower than what's being provided on it's terminals. It will supply energy TO the terminals when the reverse is the case; providing it's energy to the terminals. The specific type of capacitor used in this circuit is an 'electrolythic capacitor' or 'elco' because of the rather 'high' level of capacity required for this circuit (470 micro Farad). You will find that varrying designs for this circuit use different values; just make sure it's at least larger than , say, 100uF and can withstand the voltage-levels you're using (in the case of a 12V supply, a 16Volt model is not a bad idea). Note that these types of capacitors and 'tantalum' models are POLAR, and need to be connected the right way around. Markings on the side of the part will show you what is + and -. Other capacitors (like the others in this circuit) are not as large and they are available in non-polar versions.
This results in the smoothing demonstrated above. It is not quite a straight line yet, but you will notice that the voltage does no longer drop below a certain point anymore. This allows us to now limit the voltage to the required level by use of the next parts in our circuit.
The LM78xx series
This part might look like like a transistor to the inexperienced observer; however this three-pin part houses a full (however simple) linear voltage regulator. What this means is that it has a way of turning a DC voltage into a lower voltage. In this circuit we use the 7805; the member of this series which can handle input-voltages of 7-20VDC and return a stable 5Volt on it's output-pin.
The way this works is that it basically 'short-circuits' any over-voltage to the middle pin, which is connected to ground (the - in the circuit) and turns that into heat. In essence, all the power it has no use for is turned into waste heat. We'll discuss further on below what implications this has for how much current you can draw from this power-supply and how it affects efficiency.
The two small capacitors on either side (0.1uF or 100nF), on either side of the 7805 are put there to counter troubles when connecting this power-supply to some circuit which deals with high-frequency switching of anything that draws power. Think of connecting a little microprocessor that switches a lot of LED's on and off at a high frequency; perhaps even employing pwm to dim them.
What might happen is that the current-draw of the circuit connected to this power-supply might make the voltage drop just a little for a moment. The voltage-regulator will work to compensate, but it takes a little time for it to do this. While it's adjusting, the current-draw might change again and in fact have the opposite effect. Compensating again, it'll adjust.. etc. However, if the time for the regulator to do all this coincides with the frequency of the load-changes, it might end up re-enforcing each other.
This effect is called 'resonance' ; think of it as pushing down on a water-bed with exactly the right rythm to make it slosh more and more wildly. If repeat this rythm of pushing more slowly or more quickly, the effect would be much less effective or dramatic. Now imagine the little capacitors to be like dampeners that'll absorb these types of effects from happening too easily.
These two capacitors cost all of 5ct a piece at most and are well worth investing in to avoid weird and untraceable problems later.
At this point, all we need to cover is what's not shown on the circuit-diagram. You can imagine that you'll want some safe way to connect a power-cord to the transformer. Remember that there's 240VAC connected to the 'primary' side of this device. Touching this end will result in quite a shock indeed, or death, or fire, or worse. A well-mounted cable-connector and/or strain-relief is a must there.
Ofcourse, when using 240VAC on a PCB (in the case of a PCB-mounted transformer), make SURE that the traces are wide enough (take at least 4mm or so ?) and are safely held FAR AWAY from any of the other traces on the circuit. Do NOT surround them with a ground-plane or anything like that. A small piece of cut-off wire left behind somewhere will have catastrophic effects.
The fuse shown in the circuit above is optional, but if there's a good way to integrate a fuse-holder in your circuit, it shouldnt be left out.
At the other side of the power-supply you'll need some way of connecting your circuit to it. Unless this power-supply is on the same PCB as the rest of the circuit, it makes sense to make some kind of screw-terminal or connector to connect wires to that'll lead to the rest of the circuit.
It is not a bad idea to put a 100uF electrolythic capacitor across the input-lines of your circuit where it connects to this power-supply, either; but is optional.
Using this circuit with DC input (batteries)
For using this circuit with batteries or other (too high) DC voltages, simply leave out the transformer, the bridge-rectifier and scale down the first capacitor to something like 100uF or so. It's as easy as that!
Finally, we'll discuss some issues with this power-supply here as there are some limitations and things you'll need to think about when using this anywhere.
The LM78XX series comes a package called 'TO-220'. A picture and the pinout of the LM7805 is shown below:
The part used in our circuit is the 7805; however different models exist that limit the output-voltage to other levels. Helpfully, they are labelled accordingly. A 7812 wil limit the output to 12Volt, etc.
Many manufacturers produce parts with the 78xx name on it; not all start with 'LM' before it, yet all seem to have grossly the same operating specs, as well as the same pinout.
One thing that all the 'normal' versions of this circuit have in common is that they all require at least (about) 1.5V over-voltage to function. What this means is that you can only get 5Volt out if you put at least 6.5Volt in. It would be good to never cut it that close, either, and always provide some extra voltage just in case there are fluctuations on the input voltage.
There are however 'low-drop' versions available are a little higher cost that require less over-voltage; some as low as 0.3Volt.
All of these parts are able to provide up to 1Amp of output-current. It is good to realize that they only succeed in handling that current if you make sure they can keep cool properly. Remember they 'burn' all the excess energy into warmth and thus risk overheating if not provided with a heatsink of some kind. Simply screwing a sheet of metal to the back will help enough. Without a heatsink, drawing more than 500mA from them will result in trouble.
A smaller version of the 78XX series called the 78lXX series; only able to supply 100mA at maximum but are much smaller and a little cheaper.
For all these parts there is one consideration that they all have in common that relates to their (in)efficiency when supplying them with (too high) input voltages and how their inefficiencies increase as you draw more current from them.
Consider our example circuit; let's imagine that the output of the transformer , the rectifier and the capacitor work to a voltage that on average oscillates around 12Volts. Then, with our output of 5Volt, we'll consider two circuits connected to our power-supply; one that draws 100mA from our supply and one that draws the maximum 1A (1000mA) at 5Volts.
In the simplest consideration of this circuit, we'll assume that if 100mA is drawn at the outputs, the 78xx itself draws no current for it's own operation, and thus 100mA of 12Volts is drawn at the input. As we know, 'power' (expressed in Watts) is calculated by multiplying the potential (voltage) by the current (amps). In our 100mA example, this works out into the following numbers:
Total circuit draws: 12V x 100mA = 1.2Watt Circuit connected to our supply draws: 5V x 100mA = 0.5Watt Energy lost in the form of heat: .7Watt Efficiency: 42%
Now consider the same circuit with 1000mA current draw at the output
Total circuit draws: 12V x 1000mA = 12Watt Circuit connected to our supply draws: 5v x 1000mA = 5Watt Energy lost in the form of heat: 7Watt Efficiency: 42%
You can see that the efficiency of the circuit stays the same, but almost 50% of all the energy in this circuit simply results in the LM78XX heating up more.
Now imagine the same circuit with different input-voltages, let's say a case where we use 7volt and 18Volt:
At 7Volt this is how the circuit looks:
Total circuit draws: 7V x 100mA = .7Watt Circuit connected to our supply draws: 5V x 100mA = .5Watt Energy lost in the form of heat: .2Watt Efficiency: 71%
As you can see, the losses are considerably lower. Now let's see what happens if we go for 18Volt:
Total circuit draws: 18V x 100mA = 1.8Watt Circuit connected to our supply draws: 5v x 100mA = .5Watt Energy lost in the form of heat: 1.2Watt Efficiency: 27%
Quite a bit of loss of efficiency. For this reason, be careful of using this circuit with battery-powered applications and consider at least using the low-drop variants of this part; not supplying as much overvoltage as you dare to get away with. For efficiently converting DC-voltages there exists a technique referred to as 'switched-mode-power-supply' but is only named here as a reference for you to google with, for now ;)