I am creating a Raspberry powered WiFi car, called the PiCar :P

In the current design the entire system is powered from a single 9V battery which was salvaged from the same RC car which provides the 'base' for my project. I am currently using a UBEC to regulate the output between the 9V battery and a 5V rail from which the raspberry pi and a servo draw power from. The UBEC spec states that from a range of voltage inputs it will supply a 5V (constant) and 3Amp (max) output however i believe that the battery pack isn't sufficient to allow the UBEC to provide the 3Amp output.

My reasoning behind this belief is that during light usage, wifi dongle not transmitting large amounts of data and the servo position not changing rapidly, the system runs fine, however during 'peak' loads i think the servo and dongle are drawing enough current to cause the raspberry pi to cutout.

Here is my circuit diagram.

enter image description here

My question is therefore how would i modify my circuit to include some form of protection against this? I have read about using capacitors to achieve this but I am unsure of how to implement them and would like to avoid damaging my pi by overloading it accidentally.

What i envisage is some form of capacitor, or two, on the 5V rail that the Pi and servo run off?

  • 4
    This belongs on Electronics Stack Exchange. – Piotr Kula Sep 16 '13 at 16:27
  • 1
    @ppumkin edited to fix the grammer. – D Mason Sep 16 '13 at 17:15

This question is more about electronics design than about the Pi.

Some guidelines would be:

  1. Use a LiPo battery instead. Like a 3 cell cell used for RC cars. These batteries are good at delivering loads of power during peak activities.
    1. Having more Volts at the battery will allow you to use more power (amps) after it has been regulated. 12v, 15v or even 18v battery cells.
    2. Try to use switching regulators as they are more efficient than traditional transistor regulators. The UBEC is a good example of efficient regulator but is more expensive than a stand alone regulator.
    3. The 9volt battery is not going to last long as its best used for low activity devices. Like smoke detectors.
  2. Capacitors will help smooth out power dips but they are most effective as close as possible to the source of high drain, after voltage regulators.
    1. So a capacitor near each motor and near the Wifi. Suggested to use low emf labelled, something like 200uf for motors and 400uf for WiFi. Those are ball park figures though.
    2. The voltage rating must be more than the voltage being used. So if your motors run 6volt use a 10volt cap. Even if you are using 2 volts 10volt caps are fine as long as they are higher than required voltage.
  3. Power the Pi and motors using their own dedicated cables, regulators and capacitors directly from the battery. This prevents voltage dips on the "rail" and the capacitors help smooth out the "rail" during peak current draw.If all motors draw a large current the Pi will be less effected by this as its regulating its own "rail" supply and relies on its own filtering capacitor.
    1. As you have the motor wired directly to the Pi's I/O- That is the first thing that needs to be moved to its own power rail, complete separate from the Pi.
    2. I/O's are used as low voltage gates that control other devices, like relays or transistors. Running motors of the GPIO will cause the Pi to reset constantly.
  4. Calculate the peak current in amps used per rail and make sure the gauge of the copper cable can handle this efficiently. To thick cable causes unnecessary resistance and to thing cable will not be able to deliver peak power requirements. Refer to ohms triangle. Amps = Power (Watts) / Volts
    1. The Pi Model B clearly needs a good 1 amp supply but it draws about 300~600ma on its own. Adding WiFi to the USB port will start to reach 1 amp during peak. That mean the Pi could use up to 5 Watts of power.
    2. All these calculations help you determine the best battery and regualtors to use.
    3. Your motors, for example are rated at 5 watts using 9 volts. That is 0.55 amps per motor during full load! That is just an example- I do not know what motors you are using.
  5. Under powering the Raspberry Pi will not damage anything. Brown outs caused by power dipping below a threshold will cause the GPU to reset. This reset might cause file system damage as it could have been writing something to the SD card and not had time to finish the process. There are very few devices that will get damaged if they are underpowered but they are usually commercial devices that use allot of power. The only thing you will experience is erratic behaviour form the Pi, WiFi dropping out and motors not running at full capacity.
  6. Drawing more current than designed for will inevitably cause permanent damage. Like burning the traces on a PCB or burning out regulators due to overheating. The Pi has a few poly-fuses that help protect against normal usage but using the GPIO's on the Pi give you unprotected access.
    1. For example the 5volt power rail on the GPIO, when used incorrectly can cause serious damage if shorted, back fed or applied with an incorrect voltage.
    2. That is why using buffers on the GPIO is very important but butter yet a requirement that is overlooked. Like previously mentioned, use them to control relays or cheap transistors like PNP 2N2222.
    3. Transistors are cool because you can reuse old "broken" power supplies (or other devices) transistors for simple power switching, like controlling motors. Just type in the transistor code into the internet and read the data sheet on how what the voltage and power limits are. Usually for low voltage application like this most will suffice if not overkill. But they are free :) You should learn how to test transistors though, to ensure you are not using the "broken" element that may cause you a sleepless night of tinkering.
    4. You may look at this simple circuit on how to use the GPIO to drive the transistor. 1 denotes a low power output which is connected to the BASE (GATE/SWITCH). It is 0v when off and 3.3v to "turn on" the circuit. The arrow tells you what way the circuit should flow. in NPN its from COLLECTOR --To-> EMITTER.

As you can see this is purely electronics engineering and requires some time to think about the requirements and study other solutions.

Good luck with your PiCar :) , ;). I hope it becomes a success.

  • Thanks for the fast and in depth response. I think i described the 9V battery incorrectly, it is a 'RC Car' style battery. Unfortunately it is also lacking most of the label leaving only a the top half from which i can work out that it is either 9 or 90 V (i made an educated guess there) but not its type or capacity unfortunately. It may not be giving enough power because it is old (second hand from car boot so i have no idea of age or the amount of use it has received). I am not powering any of the motors from the GPIO ports (correct me if i am mistaken). I will try caps and separate 'rails' – D Mason Sep 16 '13 at 20:21
  • Go on eBay and buy a multimeter. They cost about 5 squid and they are your best friend for this! Sorry, I thought you were powering form the GPIO. The schematic is very tight and I misinterpreted the diagram. 9v lithium cells are perfect then but if they are old (older than 2~3 years) they will not hold charge for long. – Piotr Kula Sep 16 '13 at 21:22
  • 1
    I have been considering buying one since the last problem you helped me solve. I guess it's time i got some electronics equipment! – D Mason Sep 17 '13 at 7:21
  • Ahh right. :) Sorry I did not connect the dots to the other post. You know some of the stuff I said already and I see you implemented it on this design :) Frankly... I do not know how you managed without a multimeter this far! Seriously , it will help you. Its getting on then. One problem at a time :) – Piotr Kula Sep 17 '13 at 7:56
  • mm yes it is progressing but somewhat slowly at the moment. I think the main reason for the slow progress, right now, is due to me trying to create a cross platform controller for it (i.e an app :P). I found i got annoyed with having to sit behind a laptop when i wanted to play with it! – D Mason Sep 17 '13 at 8:16

WOW! That said - the first answer - a 9V@200mah battery would last minutes if all went right! Have you considered using something bigger (6x1,5V AA)? For the sake of glitching, another battery+5Vreg dedicated to the motor at least would isolate symptoms!

Not the answer you're looking for? Browse other questions tagged or ask your own question.