PDA

View Full Version : [Question(s)] Servos causing Ardweeny Resets/Hangs



Glenn
05-30-2010, 03:01 PM
I recently purchased a pair of pan/tilt servo kits from Trossen. I am trying to use them with an Ardweeny using the servo library in Arduino-0018. I wrote a simple program that just outputs random servo positions on pins 5..8. I have a 1A, 5v power supply and I'm using a breadboard.

The Ardweeny is resetting or hanging every dozen or so seconds.

I've tried using separate power supplies for the Ardweeny and servos, but I get the same result.

I'm new to all this. Any suggestions?

thanks,
glenn

MikeG
05-30-2010, 03:36 PM
Glenn, it's easier for people to help you if you post a schematic (or description) and your source code.

Glenn
05-30-2010, 04:05 PM
#include <Servo.h>

Servo myservo1;
Servo myservo2;
Servo myservo3;
Servo myservo4;

int pos1 = 0;
int pos2 = 0;
int pos3 = 0;
int pos4 = 0;

void setup()
{
Serial.begin(9600);

myservo1.attach(5); // right 90-180
myservo2.attach(6); // right 0-180
myservo3.attach(7); // left 0-180
myservo4.attach(8); // left 90-180

randomSeed(1);
}

void loop()
{

if ( random(100) > 80) { pos1 = random(90, 180); }
if ( random(100) > 80) { pos2 = random(0, 180); }
if ( random(100) > 80) { pos3 = random(0, 180); }
if ( random(100) > 80) { pos4 = random(90, 180); }

myservo1.write(pos1);
myservo2.write(pos2);
myservo3.write(pos3);
myservo4.write(pos4);

Serial.println(pos1);
Serial.println(pos2);
Serial.println(pos3);
Serial.println(pos4);

delay(5);
}

Glenn
05-30-2010, 04:16 PM
I just cleaned up the wiring on the breadboard. I took a picture of it (instead of drawing up a schematic). The servos are now happily jiggling. Lesson learned: check connections. Then check them again.

picture of wired breadboard and Ardweeny: http://meaning.com/wiki/Image:IMG_0472.JPG

Why would a loose servo connection cause the Ardweeny to freeze or reset?