Author Options:

Controlling six servos + two motors with Raspberry Pi? Answered

I am currently working on a school project that involves building a vehicle (Must move forward, backward, left and right. Two DC motors are used for this), having a robotic arm placed  on the vehicle (Six servos will be used here), and all controlled by a DualShock 3 Sixaxis Remote. My plan/idea is to use a Raspberry Pi for this. I have only a small amount of knowledge on working with PWM (I do however know what it is), Raspberry Pi programming (All i have used it for was wifi/network related, not to actually control something), and most of what i am about to ask. My question, is can a Pi control six servos, along with two motors? I have seen this, which is suppose to be able to drive up to sixteen servos. I have also seen an Instructable on driving a vehicle remotely. Also, there are guides on connecting DualShock Controllers to Pi's. My question, is it possible to combine the above three? What hardware would i need (I need to build my shopping list fast, and it needs to be on the cheaper end, as the servos, arm, and vehicle wasn't very cheap.)? I already have the two motors for the car, along with the vehicle itself. I need help finding servos (I have never really worked with them to the extent of shopping for them. They need to have decent torque, decent speed, and most importantly, be able to turn 180 degrees), I have the Pi, with a Bluetooth Dongle (And the controller). What else would i need? I did see the IC in the 'able, and i assume i will have to get that as well, along with the 16 channel PWM driver? Will it work? Do any of the Pins overlap to such a point where it is not possible/are conflicting? Currently, i would need a yes/no answer, along with a parts list. Programming comes a wee bit later, but i will also need help with that.


With a combination of pi blaster (pwm simulation program), scratch (due to serious lack of programming skills and time to learn those skills, I went with the ye old GUI), and some remote desktop client, I wrote a simple program that that allowed me to alter the pwm of each pin by 10 on a key press. (I installed raspbian, and left the GUI active.) I then connected to the pi via the remote control client (beats me what it was... I think it was like FTP (IP and port) but with an actual GUI being transmitted. I also had the pi broadcasting a WiFi signal, which was used as the method of data transfer, via local network) and through keyboard, was able to alter the pwm values of each pin.

Unfortunately, this never succeeded due to weather conditions, and lack of time for debugging. The furthest we got was a vehicle that barely worked. By barely, I mean that after a certain amount of time, either the program would crash, there wasn't enough power to the servos (battery powered), or the pi couldn't physically handle it, and the servos would either all power off, or go completely crazy.

I highly recommend going a different route, perhaps an arduino with an interface shield (for WiFi or Bluetooth). Something designed for pwm.

It was fun driving around while it worked though. Was the only WiFi, tablet driven, robotic, overpriced RC car my school ever had :P

The vehicle has since been disassembled, and the project long abandoned.

Might do it again, better, when I have more money, time, and interest.



You don't say exactly what the vehicle is going to do.

Servos - depending on where you are in the world - Google will be your pal - Look for RC servo, Hobby king in USA, Giantshark in UK.

In general all the robots I have built have been one speed only so no need for PWM.

The arm will be picking up smaller objects such as AA batteries, Tennis balls, Legos, and ping pong balls. This is the servo arm we are using, however we ordered it from a source that didn't come with servos. Speed is what our goal is. What do you mean by "Only have one speed only so no need for PWM"? Isn't PWM the only way to control a servo, or am i understanding you incorrectly? I actually would like speed regulation, as i will be using the joystick on the controller to control the arm, and thus would like it to move at the speed of the pitch of the joystick (Like an RC helicopter, the more you push the joystick forward, the faster it moves forward)

The servo needs a pulsed signal - The servo position is set by the ratio of the on and off pulse. The frame rate is 20Msec - PWM is a technique that uses variable pulse rate for speed control (almost but not quite the same.)

Look at the Picaxe system from sparkfun. cheap and designed to drive servos directly - much simplier to programme as well.


How would i use the Picaxe with the Dualshock Controller? Elaborate.

Never used a dual shock controller but the picaxe will serial communicate or I2I. Both fairly standard interface systems.

So should i use the PicAxe with the Pi? Is it capable of driving 6 servos/can six of these chips be attached to the Pi?

Also, i live in the USA, and would like to find servos that are under
$10 USD per piece, as we need 6 of them. If you could recommend a few that would work for my specifications? Which type of servo is used for Pi? Digital or analog? Or does it matter?


3 years ago


You are no programmer, or you would know

The Pi is overkill to the fourth, for this kind of task.

Yes, i know i am not a programmer, Duh. However, I see this as a great beginner project for getting to know more about programming. Of course i don't know, that is why i asked. By overkill, i assume you mean that the Pi CAN handle the above requirements? Would you recommend a different board? I would use Arduino, but last i checked, connecting a Dualshock remote to one isn't easy. That, and because of funding issues, getting an Arduino (Other than an Uno, which i currently own) would be rather pricey, and at this current moment, not affordable. I do, however, already have a Pi.

Stay with the Pi. What facility or what language do you intend to program with ?

I don't know yet :P Currently i am just making plans, finding things (Such as this) out, purchasing the correct hardware, and assembling the vehicle. Any tips, tutorials, or help is greatly appreciated. The only things i did with the Pi, and know how to use, are Network based. I have always been wondering how i could use the pins, and now i have found a project just for that.

You really need to decide what software language it makes a big difference in the servo drive and pwm motor drive.

What would you recommend for language? I have learned the basics of Python, and so i know a thing or to about that language, but would another language be exceptionally better? Or does python not work in this case?

Not being a Python programmer, I ask if you, can access a single output real line on the Pi and make it an input then read its value then make it an output and set it to a high=1 or clear it to a low=0 such that a volt meter on that line will read Vcc and zero ??

I never got as far as combining it with hardware, unfortunately. With that said, i have no clue. What would you recommend as a language to use? Picking up a new language shouldn't be too difficult, and plus i would probably have to learn it at some point anyway.

Can the Pi drive both analog and digital servos? Or just analog?