Cyroq
Posts: 58
Joined: Sat Dec 14, 2013 2:40 pm

Power RasPi and servo with one source

Sat Nov 19, 2016 5:55 pm

Hi all,

I have a Raspberry Pi that is controlling LEDs and a servo. When I power the Pi via usb which is connected to a computer, I can control the servo directly without any problems. However, when using a separate usb adapter the Pi shuts down at the moment the servo should be turning. My conclusion: the servo draws too much current to control via GPIO.

So, I had this idea of powering the servo externally. I bought a micro usb split cable. One end into the Pi, the other end stripped to it's +5V and GRND, and connected to the servo. The data line is connected between the Pi and the servo. If I power up the Pi all is fine, until the moment I plug in the GRND of the servo (in fact connecting both the grounds of both circuits, through the usb splitter). Then the whole thing shuts down. This even happens when the servo isn't controlled at all.

I'm confused, because I thought connecting both grounds would be the way to go. What am I doing wrong? What is the right way to power the Raspberry Pi and a servo using one power source?
The purpose of my setup is an automatic cat feeding machine so I'd rather have one power adapter to connect to my power grid, instead of two.

Thanks in advance!

Major Tom
Posts: 65
Joined: Wed Feb 03, 2016 8:13 am
Location: Strung up in heavens high.

Re: Power RasPi and servo with one source

Sun Nov 20, 2016 12:11 am

Cyroq wrote:Hi all,

I have a Raspberry Pi that is controlling LEDs and a servo. When I power the Pi via usb which is connected to a computer, I can control the servo directly without any problems. However, when using a separate usb adapter the Pi shuts down at the moment the servo should be turning. My conclusion: the servo draws too much current to control via GPIO.

So, I had this idea of powering the servo externally. I bought a micro usb split cable. One end into the Pi, the other end stripped to it's +5V and GRND, and connected to the servo. The data line is connected between the Pi and the servo. If I power up the Pi all is fine, until the moment I plug in the GRND of the servo (in fact connecting both the grounds of both circuits, through the usb splitter). Then the whole thing shuts down. This even happens when the servo isn't controlled at all.

I'm confused, because I thought connecting both grounds would be the way to go. What am I doing wrong? What is the right way to power the Raspberry Pi and a servo using one power source?
The purpose of my setup is an automatic cat feeding machine so I'd rather have one power adapter to connect to my power grid, instead of two.

Thanks in advance!
Your conclusion is correct, but your solution could be different. If the Pi + servo will work when connected to a PC USB port it means that it's possible to do what you want. Probably the problem is not that the servo takes too much current, but that your power supply cannot provide enough current. Get a bigger power supply.

I have a project running 3 servos (only one at a time) from a 3.1A PSU. The servos are all connected to 5V and GND on the GPIO header, and the control wires are connected to three different GPIO pins. Occasionally I see the low-voltage warning (rainbow square) on the monitor when a motor is running, but everything works.

Your USB cable experiment sounds bogus. I suspect there is a problem with the USB wire colours. Try buzzing them through with a multimeter to be sure the colours match the 5V and GND pins on the USB socket.
My circuit's dead, there's something wrong.

Cyroq
Posts: 58
Joined: Sat Dec 14, 2013 2:40 pm

Re: Power RasPi and servo with one source

Sun Nov 20, 2016 4:11 pm

Thanks for your reply. I'm using a 2A power adapter now, I thought that would be sufficient. When I power everything through PC-usb, The LEDs do dim shortly when the servo changes direction, so I'm not sure how happy the Pi is with this setup. Because of this, a setup with the servo powered seperately (not through GPIO) would still be my preferred method.

I'll check the usb cable, you could be quite right about weird coloring of the cables.

EDIT:
You were right! The red wire is ground, the black is +5v... At least I know what the problem is now. The servo starts turning now, but still the Pi shuts down when the servo changes rotation. Not always though, which implies the supplied current just below what's needed, I guess.
I'm using a SM-S4306R continous servo, how much current should my power adapter provide for this + Pi?

Major Tom
Posts: 65
Joined: Wed Feb 03, 2016 8:13 am
Location: Strung up in heavens high.

Re: Power RasPi and servo with one source

Mon Nov 21, 2016 10:39 am

Hello again,

Glad to hear I was on the right track with the wiring. In general I have found red to be positive and black to be negative, but no-one is ever going to look inside the cable (right?) so the colours don't matter. Until they do.

If your servo is doing a lot of work (i.e. heavy load, or a lot of mechanical resistance) then you probably should have a separate power supply. The motor might work with a light load, but when it's pushing against a something then the motor will draw more power and eventually drop the voltage, which will cause the Pi to reset.

My servo is also a continuous-rotation servo (the Adafruit one), but I know it only has a light load, so I am happy to power it off the 5V line on the GPIO header. It sounds like you ought to have a separate power supply to stop the Pi browning out.

Connect the motor positive supply to the motor positive terminal only. Connect the motor negative supply to the motor negative terminal and the Pi ground (GND, 0V, etc.). Connect the motor signal line to a Pi GPIO. It means you have two power supplies, but the motor won't cause the Pi to brownout and reset if there is a heavier load on the motor. The internet says that servo could draw up to 1.2A, which is quite a lot, but it depends on the mechanical load (or if the motor is stalled).
My circuit's dead, there's something wrong.

Return to “Troubleshooting”