3
$\begingroup$

I'm trying to make an hexapod with 18 servo motors and i'm asking how to control them with a Raspberry Pi. (Never used it). I saw lot's of stuff to control 1, but 18, 20...

Currently I'm working on an Arduino Mega, and a SSC-32 board, but I found the result to slow and jerky.

At this end, I want to add a camera and processing the image, I know an Arduino can't handle that process but a Raspberry Pi can ?

Thank for all information about that subject :)

$\endgroup$
8
$\begingroup$

Raspberry Pi has only one hardware PWM channel and Linux distribution it runs is not a real time system, so software PWM may be very unstable. You are not guaranteed, that your program will be executed at exact frequency you want, so you will have trouble getting precise timing required to drive servos.

If you already have Arduino Mega and SSC-32, I would suggest to make all the computations on the RPi, and just send the results to the servo controller via serial. I imagine your system like this: you have a central controller (RPi) that processes images from camera, detects obstacles, calculates positions for robot's legs and sends them to servo controller. These tasks can be done in various intervals - even if you have 100ms delay, nothing bad happens, because real-time part (requiring exact timing like driving servos) is handled by servo controller, which has hardware features that make it much more suitable for such a task.

Alternatively, to make system more compact, you could use dedicated RPi servo shield, or make your own basing on chips like PCA9685, which is PWM driver controlled via I2C. You can chain these chips to control more channels than 16.

$\endgroup$
  • $\begingroup$ Thank you for this reply, but i'm a newby and i don't understand all what you say. You say Raspberry Pi are slow and unstable and you talk about my Arduino Mega, but you give me some stuff for the RaspberryPi. What is the best choice ? RaspberryPi or Arduino ? $\endgroup$ – Arthur Jun 11 '15 at 19:32
  • $\begingroup$ @Arthur I made edits, that I hope will help you understand. To sum up: Raspberry is fast in complex computational tasks, but not very reliable when directly driving hardware pins at exact frequencies. For that, Arduino, or other dedicated servo controllers are better choice. You can make Raspberry talk to these controller via serial or I2C and send them commands, how to drive the servos. $\endgroup$ – mactro Jun 11 '15 at 21:57
  • $\begingroup$ Okay now I understand why you talking about RaspberryPi are slow. But I don't understand, you say the best composition will be a RaspberryPi on main controller, send legs informations to servo controller (The Arduino Mega + SCC-32 ? Or the Adafruit PCA9685 ?). If i'm right, and you talk about the Adafruit, I'll be able to specify each servo position from the RPi (with maybe 100ms lag) and the servo controller will manage correctly servo until receive a new order from RPi ? I get it ? $\endgroup$ – Arthur Jun 12 '15 at 13:51
  • $\begingroup$ I also saw I can connect directly the SSC-32 board to the RPi, this is a good solution ? I also thinking about a LED chase, or some other thing external to the servo control, the RPi can handle that ? Or the delays will be a problem and it's preferable to do it with Arduino ? $\endgroup$ – Arthur Jun 12 '15 at 14:33
  • $\begingroup$ @Arthur You can use SSC-32 or Arduino or Adafruit module. I think that the easiest for controlling only servos would be SSC, the most universal and expandable would be Arduino, while chaining PCA9685 would allow you to drive the most servos at once. LED chase will probably work on RPi, just give it a try. $\endgroup$ – mactro Jun 12 '15 at 19:51
4
$\begingroup$

You need a controller like this that can address them individually over I2C. These can be chained together to control more than you'll likely ever need:

Adafruit 16-Channel 12-bit PWM/Servo Driver - I2C interface - PCA9685 https://www.adafruit.com/products/815

How to use them with a Raspberry Pi: https://learn.adafruit.com/adafruit-16-channel-servo-driver-with-raspberry-pi

$\endgroup$
  • $\begingroup$ Thank you TomSchober, I already saw this Adafruit composent but didn't give attention cause I was thinking it's working only with 16 Channel (not 18+). But you say I can chain it to use 32, or even 48 servomotors ? It seems to be a shield on the RaspberryPi, how can I put 2 on it ? And for the servomotor control, can I send a different order for each one in the same time ? $\endgroup$ – Arthur Jun 11 '15 at 19:37
  • $\begingroup$ Also check out pololu's maestro line. They have servo controllers that can handle 6, 12, 18 or 24 servos at a time. You would communicate between maestro and rpi via serial or i2c. It is easy to chain multiple controllers on a single i2c bus. $\endgroup$ – Octopus Jun 11 '15 at 20:37
  • 1
    $\begingroup$ @Arthur - the Adafruit board linked uses a communication protocol called I2C to send the signals from your controller to the PWM driver. I2C uses addresses to select which device is being spoken to. The board linked has 6 bits that you can use to set an address, so you could theoretically have 2^6 = 64 PWM drivers connected to one controller, with each driver running 16 servos, so you could run (16x64)= 1,024 servos. Theoretically. $\endgroup$ – Chuck Jun 11 '15 at 22:36
  • $\begingroup$ @Octopus Thank you for the maestro 24 channels, very usefull. Chuck, very nice, i'll be able to create an army with only one Raspberry Pi ! I'm a programmer and I have just the base on electronic. So i'll try to use the I2C protocol to communicate with servo, it's will be fun ! $\endgroup$ – Arthur Jun 12 '15 at 13:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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