How do I convert 9 V DC to 5 V?

What's a good way to reduce the output from a 9V battery to the 1.8V to 5V required by an ATmega328 controller? The context is a small robotics platform with low power requirements (very slow movement).

-
Is 9v dc converted into 5v dc using 7805 ,0.33microF cap & 0.1 microF cap? pl answer me fast.. –  user3209 Mar 2 '11 at 4:38
@Rajesh, yes, this does get the job done. –  Kortuk Mar 2 '11 at 7:31

I would use a 7805 to get 5 volts simple circuit. Here is a image:

idea: please make sure that caps are ceramic/polymer caps. The ceramic caps only have low ESR value. specially the right hand one.

-
And for reference, here is how to decide what value to make the capacitors electronics.stackexchange.com/questions/8121/… –  Kellenjb Dec 21 '10 at 0:23
+1 since the 7805 is simple and good for rapid prototyping. But remember that this solution will drain the battery really fast! So if you are thinking about power management go with another solution. –  Johan Dec 22 '10 at 12:13
What would be the ground current for a 9v input with an LM7805? –  Isaac Sutherland Dec 27 '10 at 23:47
@Kortuk, ground current is related to power wasted irrespective of load. According to the Fairchild LM7805 datasheet, graound current for lm7805 is 5mA typ, 8mA max, and doesn't change much with load or input voltage. This current will drain a standard 9V Energizer 522 flat in about 100 hours, so if the circuit will be on standby it would be better to use a more modern regulator with lower ground current. –  markrages Mar 1 '11 at 7:40
@markrages, I did not know the term ground current and took a shot at answering since he asked a while ago. Thank you for taking the time to clear that up! –  Kortuk Mar 1 '11 at 7:54
show 1 more comment

Since you want to power from a 9V battery we have to look out for possible current losses. While a three-legger like LM7805 may be an obvious choice, this regulator has a ground current of 8mA maximum. An LDO (low drop-out) regulator typically needs far less, e.g. the ground current of an LP2981 is only 800$\mu$A maximum. That's only 10%!
LDOs are as easy to use as an LM7805. The output capacitor is a bit larger, though, important for stability.

edit
Johan wanted an example:

If not used, the ON/OFF input must be tied to $V_{IN}$. The output capacitor value of 3.3$\mu$F is the minimum required for stability. "More capacitance provides superior dynamic performance and additional stability margin" (dixit NS)

edit 2
You can even save more power, but it's probably not worthwhile; your motors may consume a lot more than the LDO's 800$\mu$A.
Anyway, there are LDOs with < 1$\mu$A ground current, like the Seiko S-812C50. Input voltage up to 16V, output voltage is selectable from 2V to 6V in 100mV increments. Output current is limited, however, to 50-75mA.

-
+1 for something with a LDO, but how about a example? –  Johan Dec 22 '10 at 12:16
A example is always nice :) –  Johan Dec 22 '10 at 16:15

I might consider just providing the ATmega328 unregulated power unless you have something that actually requires it on the board. 2-3 AA cells should remain within 1.8 to 5.5 V over their life.

A schottky might be prudent if you insert the batteries the wrong way (probably will need 3 cells then), and you could add a TVS if you want to be even safer.

-
+1 for the best solution. –  tyblu Dec 20 '10 at 21:24
yea this is almost certainly the way to go, on the other hand the QA is asking specifically about using a 9V battery... –  vicatcu Dec 20 '10 at 21:34
@tyblu: it can't be the best solution since it doesn't comply with the given input voltage of 9V. Isaac may have his reasons to use a 9V battery instead of AA cells, like a stock of 2000 of them :-) –  stevenvh Dec 21 '10 at 12:10
My particular application uses motors that I intend to run at 9v. –  Isaac Sutherland Dec 27 '10 at 23:43

A similar question, but with different voltages: What is the coolest way (using passive cooling only) to step 12V DC down to 5V DC

-
Different voltages and different currents, but a good reference. –  Kortuk Dec 20 '10 at 23:33

It depends how efficient you need it to be. Simplest would be an LM317, but it will waste a lot of power. A switcher would be better, like those made by Nat Semi.

I wouldn't use a 9V battery, though.

-
What power supply would you suggest instead? -- I'm curious to know what you would suggest as a good power supply for using during development as well. –  Isaac Sutherland Dec 20 '10 at 19:23
Four AA cells would be a lot better, with an LDO if you need 5V. I use a bench power supply for development. –  Leon Heller Dec 20 '10 at 19:40
@Issac Sutherland, AA batteries are simply better batteries than 9V cells. A boost regulator would allow you to follow a "constant power performance" curve on a battery datasheet and drain it to just over 1V/battery (fully drained), whereas a linear regulator would follow a "constant current performance" curve and drain each to ~5.35V/#batteries (best for 5+ AA's). You have to run the numbers to figure out for sure which solution is best, but it's usually the switcher that comes out on top. –  tyblu Dec 20 '10 at 20:21
a 9V battery isn't a bad choice in terms of physical size if you can live with the inferior mAh they tend to provide. –  vicatcu Dec 20 '10 at 20:39
A 7805 (as shown in Dean's answer) is simpler because it doesn't require any resistors. –  Kevin Vermeer Dec 20 '10 at 21:58

if you want an efficient solution, using a Buck Converter would be a smart choice. you can build it with discrete components (inductor, diode, capacitor and transistor) or you can use some IC.

-