How to use a linear regulator to make a power supply

Let's say we want to make a power supply that produces a nice 5V output from a 9V battery. This would be suitable for powering a microcontroller, or charging USB devices. We can't power these things directly from the battery, because the voltage is too high and they'd fry! An additional benefit of using the regulator is that the voltage would remain constant even as the battery got a little flat.

Choosing a regulator
We have two options: Choose a 5V fixed regulator, or set up an adjustable regulator to produce 5V. As 5V fixed regulators are very common, it will probably be easiest to choose one of these. The most common is the 7805.

First thing to check about the 7805 is the current capacity: 1.5A. Is this enough for what we want to power? USB devices are in theory limited to 250mA each, however it's often the case that things like portable hard disks use more (which is why you see them with those double-ended cables). Microcontrollers tend to use only a few mA, even when they are running full bore, and those LED's you've got flashing use not more than about 20mA each. Either way, we should be well in. We're more likely to be limited by the 9V battery not being able to keep up!

Next, we need to check the 'dropout voltage'. You'll find this in the 7805's datasheet: 2 - 2.5V. This is how much more voltage we need to put into the regulator than we get out of it, i.e.

Vout <= Vin - Vdo

This means, to properly operate, the L7805 needs at least 7V (maybe even 7.5V). Our 9V battery should supply this even when a little flat, and even when drawing a little bit of current.

''Note that the dropout voltage is generally for the regulator running flat-out (i.e. producing 1.5A). Often, we don't use nearly as much current as it can provide, and it will happily produce 5V from a 6V supply. Good design, however, indicates that we shouldn't rely on this unless we're certain it's going to work: so go experiment, and read some datasheets!''

Making a circuit
Now we know that we've got a suitable regulator, we can design the circuit for it. Generally, datasheets for these things give you a little diagram. Regulators tend to require a capacitor on the input to ground (for the L7805, 0.33uF, or 330nF) and a capacitor between the output and ground (7805 needs 0.1uF, or 100nF).

This looks like the following:



It's important to know which pin is which on the regulator. Many are protected against being put in backwards, but this is not always the case, and not a safe thing to assume! Again, the datasheet will tell you what each pin is.


 * The +ve power supply (i.e. the +ve terminal of our 9V battery) should be connected to the 'Vin' or 'input' pin (pin 1 on the L7805).


 * The ground (pin 2 on the L7805) should be connected to both the -ve terminal of the battery as well as the ground of our 5V circuit. The grounds are shared between the output and input.


 * The supply to our 5V circuit should be connected to the 'Vout' or 'output' pin (pin 3 on the L7805).