external power supply for 9g servo(s) not working

I wired it up basically the same as the image attached (pulled from google images) except that instead of a 6v as labeled it's just another 9v (separate from the one powering the board), and I'm using 5 servos on pins 4, 5, 9, 10, and 11. Before you ask, yes I remembered to connect the grounds.

When I use the same power supply as the Arduino board (I just plug the positive wire of each servo into the 5v pin on the board and the ground wires into gnd), it works just fine except that it is sometimes a bit much for the battery, which is why I'm going for external power in the first place. However, when I use the external power, the process goes as follows:

First, I plug in the external power to the servos. When I do this, all the servos twitch once and then stop, just like normal. Then I plug in the other 9v to the Arduino and the servos do nothing during the second or so of booting up, but as soon as the program runs, instead of going to the appropriate positions they all turn clockwise until I unplug one of the batteries.

Did anyone else have this problem? What did I do wrong? If it all looks right to you, I could just create a schematic of what I have on my breadboard, because I also have a couple of sensors hooked up for input if that makes any difference.

image.jpg

except that instead of a 6v as labeled it's just another 9v (separate from the one powering the board)

Did they smoke when you connected them to the 9v?

zoomkat:
Did they smoke when you connected them to the 9v?

I only had them plugged in for a few seconds -- I unplugged them as soon as I saw what was going on -- so no, if they were going to start smoking i didn't give them a chance. However, now that you bring it up, just one of the servos was not smoking but very hot to the touch when it was connected to the Arduino power and active for a few minutes. That particular servo was acting a bit funny and getting stuck in places; it might just be defective.

I doubt it's an overdrive problem, because I heard that one can power a 9g servo with a 9v no problem. I suppose that could be wrong, but it doesn't seem like that would produce the symptoms I'm experienceing. ...would it?

That particular servo was acting a bit funny and getting stuck in places; it might just be defective.

It has been my experience that if a 9g servo loses its ground connection, it will act erratically and heat up. The over voltage condition can also cause erratic operation.

zoomkat:
It has been my experience that if a 9g servo loses its ground connection, it will act erratically and heat up. The over voltage condition can also cause erratic operation.

hmmm... ok, I'll check my wires when I get a chance. Thanks! Do you have any other theories on why the rest of them just turn infinitely when they are on external power? That problem was with all the servos, not just the one.

Do you have any other theories on why the rest of them just turn infinitely when they are on external power? That problem was with all the servos, not just the one.

Maybe bad code?

mmm... I kinda doubt it... you can check if you want:

//5-joint robo arm
#include <Servo.h>
Servo Yaw;
Servo Shoulder;
Servo Elbow;
Servo Wrist;
Servo Roll;

int yaw;
int shoulderA; //A is for Angle
int elbowA;
int wristA;
int palmA; //same as roll

int potPin = 0;
int btnPin = 2;

int yawWrite = 5;
int shoulderWrite = 6;
int elbowWrite = 9;
int wristWrite = 10;
int rollWrite = 11;

int btnState;
int potLevel;

int joint; //0 = yaw, 1 = shoulder, 2 = elbow

void setup(){
  Yaw.attach(yawWrite);
  Shoulder.attach(shoulderWrite);
  Elbow.attach(elbowWrite);
  Wrist.attach(wristWrite);
  Roll.attach(rollWrite);
  
  pinMode(potPin, INPUT);
  pinMode(btnPin, INPUT);
  
  joint = 0;
  
  yaw = Yaw.read();
  shoulderA = Shoulder.read();;
  elbowA = Elbow.read();
  wristA = Wrist.read();
  palmA = Roll.read();
}

void loop(){
  btnState = digitalRead(btnPin);
  potLevel = analogRead(potPin);
  if(btnState == HIGH){
    joint++;
    if(joint > 4){
      joint = 0;
    }
    while(btnState == HIGH){
      btnState = digitalRead(btnPin);
      delay(5);
    }
  }
  
  int angle = map(potLevel, 0, 1023, 0, 180);
  
  if(joint == 0 && angle != yaw){
    //only increment it by 1 degree per 10 ms iteration due to the
    //arm not being entirely stable yet
    if(yaw < angle){
      yaw++;
    }else{
      yaw--;
    }
    
  }else{
    if(joint == 1 && angle != shoulderA){
      if(shoulderA < angle){
        shoulderA++;
      }else{
        shoulderA--;
      }
      
    }else{
      if(joint == 2 && angle != elbowA){
        if(elbowA < angle){
          elbowA++;
        }else{
          elbowA--;
        }
      
      }else{
        if(joint == 3 && angle != wristA){
          if(wristA < angle){
            wristA++;
          }else{
            wristA--;
          }
      
        }else{
          if(joint == 4 && angle != palmA){
            if(palmA < angle){
              palmA++;
            }else{
              palmA--;
            }
          }
        }
      }
    }
  }
  Yaw.write(yaw);
  Shoulder.write(shoulderA);
  Elbow.write(elbowA);
  Wrist.write(wristA);
  Roll.write(palmA);
  delay(10);
}

I've got a button hooked up to pin 2 and a pot to analog pin 0 for input. And like I said, except for the one servo, they all work just fine when connected to the 5v from the Arduino board.