Hi there, I've hit a little roadblock while working on a robotic arachnoid quadruped. Here's the setup:
(Ignore the power regulator circuit, I've stopped using it)
As you can see, it is a four-legged robot powered by 12 small servos from Sparkfun (Servo - Generic (Sub-Micro Size) - ROB-09065 - SparkFun Electronics), with four-segmented legs printed on a MakerBot. I'm currently using a CD as a test chassis and powering the motors off of a breadboard connected to a 6V / 800 mA RadioShack wall wart. Control cables are connected to digital outs 2-13 on a new Duemilanove. Arduino ground (digital side) is connected to breadboard ground.
I seem to be having a problem with the servos. At first, they were going completely haywire until I realized I needed to add pull-down resistors to the control cables. They are now coherently addressable, but are giving me a harder to track problem: When I first supply power to the motors and turn on the Arduino to control them, several of them often go haywire and try to spin in directions they shouldn't be. As far as I've figured out, the only way to fix this problem is to cut power to the motors, unplug the control cables, bring power back up on the motors and then plug the control cables back in, one by one (the motors then spinning solidly to the correct angles, one by one)... And even then they sometimes end up going bonkers again. I've found that it happens more often with a few of my motors than it does with the others, and that it's more likely to get stuck in "freak-out mode" when more motors are being controlled.
I've thought of several possible causes but I'm not sure how to determine which one is the culprit and was hoping that maybe a member of the community here would point out an insight about controlling servos that I wasn't aware of? Perhaps not enough voltage or amperage? Crappy servos? Incorrect pull-down resistor ratings (mine are a mix between 10k and 100k, I believe)? Something about refresh times with the Servo library?
Below is my code. Thanks in advance!
#include <Servo.h>
Servo One_1;
Servo One_2;
Servo One_3;
Servo Two_1;
Servo Two_2;
Servo Two_3;
Servo Three_1;
Servo Three_2;
Servo Three_3;
Servo Four_1;
Servo Four_2;
Servo Four_3;
void setup()
{
One_1.attach(2);
One_2.attach(3);
One_3.attach(4);
Two_1.attach(5);
Two_2.attach(6);
Two_3.attach(7);
Three_1.attach(8);
Three_2.attach(9);
Three_3.attach(10);
Four_1.attach(11);
Four_2.attach(12);
Four_3.attach(13);
}
void loop()
{
setEverything(90);
}
void setEverything(int x)
{
One_1.write(x);
delay(25);
One_2.write(x);
delay(25);
One_3.write(x);
delay(25);
Two_1.write(x);
delay(25);
Two_2.write(x);
delay(25);
Two_3.write(x);
delay(25);
Three_1.write(x);
delay(25);
Three_2.write(x);
delay(25);
Three_3.write(x);
delay(25);
Four_1.write(x);
delay(25);
Four_2.write(x);
delay(25);
Four_3.write(x);
delay(25);
return;
}