Here are my list of goals:
- 1. Provide an accurate and stable 5V DC supply , measured on TP-1 and TP-2
2. Design it such that a large number of DC supplies can be used
3. Fully automatic boot, shutdown, powerdown and restart mechanism.
4. Protect the SD card from corruption due to power issues
5. Ride out brown-outs or a mains drop with a minimum of a 1 Hr. period
6. Use a prototype board to build the circuit with through-hole parts.
7. Use parts that are easily available, inexpensive and avoid SMD if possible.
8. Make the design as simple as possible for non engineers to understand and build
9. Design it for embedded and desk-top applications
10. A complete How-To that can also be used in a class room project.
The Pi is also critical to the voltage level of 5V DC supply, especially if you connect hardware to the USB ports. Also, there are too many 5V wall-warts and USB cables (chargers) that are simply not up to the task. They cannot supply the current needed, or there is too much of a voltage drop in the USB cable before it reaches the Pi. The goal is to supply 5V, as measured between TP-1 and TP-2 on the Pi PCB.
Worse, if there are brown-outs in the main supply, this typically means that the Pi will lose power and will crash. If you have no provisions for a proper shutdown process, and the Pi gets locked-up somehow, most just “pull the plug” to reset the Pi. Not only do you lose whatever data the Pi was manipulating or worse, the SD card can become corrupted if the Pi was writing to it.
One solution is to use a battery supply to ride out the main power problems, or to automatically do a shutdown and again there are several samples on how to implement that too. (I also published a couple of variations to that theme on this forum)
However, this means that if the Pi is Halted, you have to do something to let the Pi reboot again. You either pull the power plug and stick it back in, or if you have added a button to the J6 connector, or to the GPIO pin 5 (GPIO-SCL) and GPIO pin 6 (GND) you can use that to wake it up from the Halt state.
Needless to say, this is cumbersome, so again there are some solutions available to make this more automatic as well. The majority of these solutions cut the power to the Pi, or send a reset signal to the above pins. Most solutions I found involve a single chip processor to do all this.
Two years ago I set out to design such an “automatic” supply for my “embedded” project, a web based thermostat controller. For six months out of a year, I am on another continent, so I needed a way to make the Pi automatically shutdown and reboot. Here is the (long) thread that documents the discovery process that resulted in a working solution: http://www.raspberrypi.org/forums/viewt ... 37&t=50470
The final solution that was the result of the discovery process has been working flawlessly ever since, but I wanted to make a new one that is simpler, and also designed in a way that others could build it easier. This will not be the most sophisticated solution from a high tech perspective, but it will work reliably while following the specifications I listed above.
Here we go:
Let’s discuss the scenarios the Pi goes through, so we can find solutions for the challenges as we go.
As I mentioned above, the Pi will start to boot as soon as power is applied to the micro USB connector, or to the GPIO connector. The boot process takes about 35 seconds, but this is variable based on the drivers that will be loaded, if a file check is performed, etc. The first thing we need to do is to make sure that this boot process is not interrupted by a power problem.
This can be done quite easily by using a back-up battery system that will take over through a switch if the main supply goes away. Two diodes are used as a switch to connect (OR) the two supplies together. Whatever supply offers the highest voltage will win the job to supply power to the Pi. If one drops, the other will take over, and the Pi will not notice this IF both supplies supply the same voltage within a small margin (100mV or less). We’re going to use a neat solution for that challenge. I always like to use Schottky diodes for this purpose. For one their voltage drop is about half of that of a normal diode which cuts the voltage lost over the junction. However you can also use the popular 1N4001 diodes. This design is based on supplying up to 1 Amp to the Pi, at the end I’ll show you what you need to do to increase that.
OK, next step.
In order to make sure that we always have full batteries when we need them, we really need re-chargeable cells and a charger.
Modern cells are a bit complicated to charge quickly, so we’ll limit ourselves to a slow maintenance charge, or trickle charge. This will only be possible with NiCad or NiMH rechargeable cells. Don’t play with Li-Ion cells, they can explode when not handled properly.
If we keep to a so called maintenance charge, or trickle charge, we don’t need an elaborate charging circuit. Just a few parts will handle that job as can be seen in the circuit below.
For the sake of this design, we’ll use a 12 V DC wall-wart supply that can supply a healthy 1Amp. So how does this work? Diode D1 is needed to make sure the trickle-charge current only flows where we want it to go. If there is no main supply, we don’t want the cells to supply voltage in that direction. The maintenance charging current for the cells needs to be set and we need to reduce the voltage to a safe charging voltage for the cells.
The charging voltage for NiCAD or NiMH cells is not to exceed 1,7V per cell. A Zener diode is used to set that limit, and 5.6V sets that limit for 4 cells to 1.4V each.
The charging current we need is depending on the capacity of the cells. 2200mAh cells are available for good prices and will provide plenty of juice for most applications. The recommended maintenance charge varies quite a bit, but a middle of the road factor is 0.045. This formula can be used to calculate the needed charge current : I = 2200mAh * 0.045 = ~100mA. The resistor value can be calculated with: R = V / I. V is the voltage over the resistor and that is 12V – 5.6V for the Zener and - 0.6V for the Diode junction drop = 5.8V. The resistor value R is then 5.8V / 100mA = 58Ohm. The wattage is V * I = 5.6V * 100mA = 0.56 Watt. Do not skimp on the wattage of the resistors, they will get hot. Go for 1 Watt minimum, and raise them a bit from the PCB and also keep them away from other critical parts.
To keep close to the calculated resister value, and to reduce the heat generated, we can use two resistors of 120Ohm of 1Watt each in parallel. A (sliding or toggle) switch is needed to turn off the battery voltage; otherwise our circuit will always be on.
Up to part 2