Soo I found cheap servos on eBay and bought 20 of the little badboys. They're now on a ship somewhere making their way to my house, and when they arrive I have a few ideas for projects I want to get them involved in.
My issue is though, that I've been looking around online to find out how to control a lot of different servos at the same time. So far I've come across the red back spider control board, but I'm struggling to find out whether that actually allows me to control all servos at the same time doing different things through code.
So my question is, how does one most efficiently control multiple servos doing different things at the same time, ideally through an Arduino?!
I use the SD20 chip (with its resonator). I’m using it with a Picaxe 40X2 and soon a FEZ Panda II, but you can use it with any microcontroller that offers I2C functionnalities.
How many of those 20 servos do you wish to control at once? As LordGG pointed out, there is more than one way to skin that particular cat. There is also a serial servo controller that can handle 20 to 30 servos at once, on its own.
Since you asked about a redback spider specifically, here’s what I can tell you. The RBS is bascially an Arduino Mega with a form factor that’s improved for servo use, and includes a 5v 3a power supply. It can indeed operate 48 servos at once, and there is a video here on LMR, (probably on the RBS blog page.) that proves it.
However. . .There are a couple of "Gotcha’s."
The video is apparently just cycling through 48 servos, having them swing their arms back and forth. It’s not taking watching any buttons or pots, or any sensors of any sort, or calculating paths or anything else. (Oddbot, correct me if I’m wrong.)
The Arduino servo library uses one or more timers depending on how many servos you are using, and certain pins share certain timers.
Quoting from RobotFreaks “Timers and Interrupts” tutorial. . .
Servo Library uses Timer1. You can’t use PWM on Pin 9, 10 when you use the Servo Library on an Arduino. For Arduino Mega it is a bit more difficult. The timer needed depends on the number of servos. Each timer can handle 12 servos. For the first 12 servos timer 5 will be used (loosing PWM on Pin 44,45,46). For 24 Servos timer 5 and 1 will be used (loosing PWM on Pin 11,12,44,45,46)… For 36 servos timer 5, 1 and 3 will be used (loosing PWM on Pin 2,3,5,11,12,44,45,46)… For 48 servos all 16bit timers 5,1,3 and 4 will be used (loosing all PWM pins).
Pin 11 has shared functionality PWM and MOSI. MOSI is needed for the SPI interface, You can’t use PWM on Pin 11 and the SPI interface at the same time on Arduino. On the Arduino Mega the SPI pins are on different pins.
tone() function uses at least timer2. You can’t use PWM on Pin 3,11 when you use the tone() function an Arduino and Pin 9,10 on Arduino Mega.
The servo library doesn’t use PWM, but it could keep you from using it on other pins.
You can also use 2 Arduinos linked through I2C to control 24 servos. Cost effective would still be to use a Mega, but there are many methods available, so you can chose what ever fits your need best.
Thanks, that’s a lot of useful suggestions. Might have a go at using the SD20, looks like a cheap and flexible option, not entirely sure again how easy it would be to actually have it control up to 20 servos properly, but will have a play with it for sure.
Looks like I’m going to have to read up on timers and interrupts either way so will start doing that whilst I wait for all the parts to get here.
Basically want to build some sort of walking type robot, with lots of servos, but want to have a play about with everything first before I decide exactly how many servos I want to use for each bit and how many legs I want to use and all that jazz.