Summary
When using a robotics controller board with small DC motors on Raspberry Pi, you need to consider how you will power it in such a way as to minimise cost, weight, complexity and maximise flexibility, reliability and power.
These two sets of requirements are not necessarily mutually inclusive. In this article, I discuss three options and try to give the pros and cons objectively and factually:
- Power the Pi and the Motors directly from the same 5V power source
- Power the Pi from a 5V power source and the Motors from a separate power source (voltage to suit)
- Use a voltage to suit the Motors and a regulator to create the 5V for the Pi
For all of this we are assuming the use of small DC motors like these:
At 6V, these require 120mA running, but stall current can be as high as 500mA
1. Powering Pi & Motors from Same 5V Power Source
This is not recommended.
Pros:
- You can use a simple 5V USB power source
Cons:
- Pi will suffer when the motor takes excess current. Simply starting the motor could generate enough of a glitch to cause a problem: network interface is likely to be lost first
- When the battery voltage gets too low the motors will just go slower, but the Pi will stop and can easily corrupt the SD card
- With an inductive load – even using flyback diodes – the spikes on the 5V line can cause serious problems and potentially damage the Pi
2. Powering Pi & Motors from Completely Separate Power Source
This is a highly safe solution – recommended in many scenarios
Pros:
- You can use exactly the right power source for both components: 5V USB power for the Pi, any voltage/current source for the Motors
- No wasted energy (heat) so nothing gets hotter than it needs to
- Can design smaller control boards as no need for voltage regulator, associated components or heatsink
- Easier to support as no issues with regulators
Cons:
- You need two sources of power 5V
- More expensive solution as you need the same batteries as solution 3, plus something like a USB power bank
- Heavier solution – small models may not be able to take the 2 sets of batteries
3. Powering Motors from Battery Pack and use 5V Regulator for the Pi
This solution is recommended in some scenarios
Pros:
- Only a single battery source needs to be used
- Only one battery pack to recharge or switch on and off
- Reduces weight and overall product cost
Cons:
- When the power gets too low, the Pi will stop and potentially corrupt the SD card
- Regulators get hot. At least, linear regulators get hot – switching regulators (see Mo-Pi) are a lot more efficient. Typically 90% or so.
4. How Hot do Regulators Get and Why?
This is the killer question and is the main reason that I recommend using separate power supplies (Option 2 above) in many situations.
Linear regulators take an input voltage (say 7.2V nominal for 6 rechargeable cells) and output a fixed voltage (5V for our Raspberry Pi). To do this, they effectively act as a resistor which automatically varies to keep the output voltage constant. We all know Ohm’s law: V = I x R. The power (heat) of the resistor is easily given as V x I. So if the input voltage is 7.2V, the output voltage is 5V and the current used by the Pi is 0.7A, then the power dissipated by the regulator is: (7.2-5.0) * 0.7 = 1.54W
Now 1.5W doesn’t sound very much, but unless you have some way of dissipating that heat, the temperature will only increase. For small input voltages of 7.2V and less, you may be able to do without a heatsink. However, to dissipate this heat properly you should use a heatsink. We generally use a small one that is rated at 21°C / W. This means that thermal equilibrium is reached at a temperature of 21°C above ambient temperature for every Watt that is dissipated. For the 1.54W above, this means that the temperature of the regulator and heatsink would be 32°C above the ambient temperature. This is warm, but is acceptable and definitely within the relevant British Standards.
The problems come when a) the input voltage is a lot higher than 7.2V, or b) the Pi takes a lot more power than 0.7A. So you should:
- Keep the input voltage down to something reasonable. We recommend 6 cells of rechargeable batteries as a maximum (ie. 7.2V nominal)
- Note that the regulator needs some voltage “headroom” to work with. Some require a minimum input voltage of 2.5V above the output voltage (eg. 7805) so that means you have to put in more volts and thus generate more heat. (we use the L4940V5 which has a minimum input voltage of 6V)
- Do not overload the 5V (or 3.3V) on the Pi with lots of directly powered addons
- Use a heatsink if planning on using for extended periods (ie. more than a few minutes minutes at a time)
Finally, the power taken by the motors is irrelevant as far as the heat generated in the regulator goes. It will affect the driver chip of course, but that is a different issue entirely and not to be confused.