archieroques
Posts: 26
Joined: Sun Mar 16, 2014 8:13 pm

Multiple servo control

Thu Apr 30, 2015 7:58 pm

Hi,

I am working on a robotics project for a competition, and I need to control 3 continuous-rotation servo motors from a Raspberry Pi A+.

I've planned it all out with a bill of materials and everything, and have ordered some transistors (2N2222, from Pimoroni) to drive the servo motors, as described in this tutorial: http://www.doctormonk.com/2012/07/raspb ... servo.html

I've now realised that there is potentially a problem in that that tutorial was for one servo and I need to drive three servos.

Can I do this with these transistors? I've organised an external 5V supply to power the servos (and Pi) but I don't know if I need to get any extra components. Ideally I wouldn't have to, as I have done a whole bill of materials and ordered all the stuff, and I really don't want to be sending things back and reordering things.

Additionally, I have an Adafruit Trinket, if that would be of use to help solve this issue. I also have an Arduino Uno R3 SMD, but I'd rather not use that if possible.

Thanks in advance,
Archie

User avatar
joan
Posts: 13667
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Multiple servo control

Thu Apr 30, 2015 8:07 pm

You can drive multiple servos direct from the Pi. It may not have been the case in 2012 but things have moved on since that article was written.

You can drive as many servos as you have spare gpios with my pigpio library or servoblaster.

archieroques
Posts: 26
Joined: Sun Mar 16, 2014 8:13 pm

Re: Multiple servo control

Fri May 01, 2015 12:48 pm

Fantastic! So, do I need to use the transistors at all? What would they do? And would I just connect servos like in that article, but to different pins?


Thanks,
Archie

User avatar
joan
Posts: 13667
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Multiple servo control

Fri May 01, 2015 12:58 pm

archieroques wrote:Fantastic! So, do I need to use the transistors at all? What would they do? And would I just connect servos like in that article, but to different pins?


Thanks,
Archie
I have no idea what the transistors were for. The sort of hobby servos I have don't need the signal amplified.

Generally you power servos externally from a 5V or 6V supply.

A servo will have a wire for power, a wire for ground, and a control wire.

Connect the power and ground wire to your external power supply. Correct the control wire directly to a gpio or via a, say, 1000 ohm resistor if you are worried.

Also connect a Pi ground to the external power supply ground (the control signal needs a return path).

Then send pulses to the gpio and the servo will move to the commanded position.

E.g. https://www.youtube.com/watch?v=5luZQFxfLCo

The ribbon cable is just for convenience.

Return to “Automation, sensing and robotics”