Power Supply Basics
"Input, input!" was a common phrase of the Johnny 5 robot in Short Circuit, and if our robots talked incessantly they would probably say the same. However, we fail to ever see Johnny 5 screaming "Electrons, electrons!". He must have had some sort of cool nuclear reactor on-board.... unfortunately, such a device is not available for home use yet, so we will have to stick to good old batteries.
This tutorial shows how to put together a quick, clean, and easy power supply that runs off a 6-20V source, typically from a battery.
The Battery and the Regulator
Batteries are the source of power for all but the largest of robots. But of course you can't just hook a battery up to your microcontroller without blowing something up. You end up needing a regulator in the power circuit.
A regulator is a simple to use electronic device that takes an input voltage and outputs a constant voltage, typically at a voltage level less than the input voltage. I would assume that nearly anyone who hasn't been scared away yet by this tutorial knows of the 7805 regulator. This little work-horse is the universal 5V regulator. It takes a voltage >7V and gives you a nice and constant 5V supply, with a current of up to 1A. The reason that it needs at least 7V is that there is a diode drop inside the device. A good regulator will output a nice, clean, steady power supply, with a minimal use of external components, such as capacitors. The 7805 is available in a number of case styles, the TO-220 being the most popular mainly for heat dissipation and ease of mounting concerns.
There is of course a problem here. When using a 7805 with a 7.2V battery, we will barely get any runtime. A NiMH battery with a nominal voltage of 7.2V would have 6-cells. Fully charged, these cells may be as high as 1.35-1.4V, but they quickly fall to 1.2V and then all the way down to 1.1 volts. A large portion of our available power will be output during this 1.2V->1.1V duration. With a traditional 7805 regulator, we might only be able to use half of our battery's capacity before the regulator stops working correctly. Installing a higher voltage battery will be troublesome, for power dissipation reasons discussed later. Thus, we must find a regulator which can work at lower voltages.
This brings us to the discussion of the Low-Dropout Voltage Regulator. An LDO device will have a much lower voltage requirement than a similar non-LDO device. Our example here is the LM2940, which is an LDO regulator with a wide range of parts that output different voltages. We will look at the LM2940CT-5.0, which is designed for a regulated 5.0V output. This regulator needs only 6V to operate. This is a great improvement for us roboticists.
A regulator typically needs a few external components. Variable regulators, which can be adjusted to output different voltages, typically require some resistors to tune the output voltage. A simple linear regulator like the LM2940CT-5.0 needs only a few capacitors. I use the circuit below in many of my AVR-based controllers.
I would assume most people at this point understand what a capacitor does: it holds charge. For our regulator this is quite important. The current demanded from a circuit will change over time, so we really need to be able to handle those changes, and a large capacitor on both the input on output side will help. I tend to use something on the order of a 47uF on both the input and output side of an LM2940CT-5.0 (Capacitors C1 and C2 in the circuit above). Insufficient capacitance will cause the regulated output to be of poor quality, and can even damage the regulator itself.
There is also the issue of decoupling capacitors. No regulator will be able to source a perfectly constant voltage all the time, we will need some decoupling capacitors to help with that. To understand what a decoupling capacitor is, we need to see how capacitors react with time-varying inputs. I'm sure that in electronics 101 you learned that capacitors don't allow current to pass through them -- and they don't, but given a time-varying signal, they can pass higher frequency signals. Often, time-varying signals of different voltage levels can be coupled using a capacitor of correct size. In our case, we can use capacitors to pass signals to ground... and variations in our power supply's output voltage are nothing but signals! If we have a variety of different capacitors we can pass signals at many frequencies. Decoupling capacitors are typically put near each chip in a circuit (Capacitors C3, C4, and C5 would be placed physically close to chips such as microcontrollers).
Power Dissipation Concerns and More Advanced Power Supplies
Our supply shown above is a simple linear one. What that means is that it simply takes an input voltage, and outputs and output voltage. It turns the difference into heat. This has some serious implications, especially at higher current. Our regulator will get much hotter when running at 12V rather than 6V. The reason here, is that the excess voltage is converted into heat, and we have to be careful about power dissipation. We of course have learned that P=IV, where V is the voltage drop across the regulator, thus our power dissipated goes up linearly with both current and voltage. If our 5V regulator as to source 1A of current, it will have to dissipate 6 times as much heat when supplied 12V instead of 6V. Thus, while our regulator may be rated up to some very high voltage, say 28V in the case of the LM2940, it can't handle a high current without additional heat sinking.
Since we can't handle huge currents without lots of heat loss (and thus loss of efficiency), how can we build a better power supply? The answer is a switching regulator, which actually turns the flow on and off and then smooths the output. Designing a switching regulator is a much more complicated task. There are some easier to use chips out there, but they typically require a decent number of external components. There are also a few companies selling ready to go switching regulators, in small packages.
There are other protections we can add to our regulator as well, such as reverse polarity protection if you plug in your power supply wrong, but I won't go into that here.
Recap and Conclusion
There are a few things to remember with our power circuits:
- Battery voltage changes over time
- Linear regulators take an input voltage and output a lower voltage
- Linear regulators need sufficient capacitance
- Decoupling capacitors are important
- Pay attention to power dissipation and heat concerns
Back to So You Want To Build A Robot?