Servo Moving Erratically on External Power

Hey I know it’s late but an answer ASAP would be nice.

So i’m building a robot arm similar to the AL5D design, with a Hitec 755HB servo on the elbow. When I try to control it with the arduino, however, it will jerk back and forth uncontrollably. I’m using a 6v 2 amp external power supply to power the servos. I’ve tried many options, but none seem to work, and the problem becomes weirder and weirder.

I’ve tried:

  1. Controlling a different servo with the same output and on the same circuit, it works fine
  2. Connecting it with power straight from the arduino, it works fine
  3. Adding a large delay in the loop, changes nothing
  4. Re-checked wiring many times

Yes, my grounds are connected before anyone asks.

This problem is pretty frustrating, and I can’t really get another servo if this one is defective.

Any help is hugely appreciated, thanks in advance!

Code:
#include <Servo.h>
Servo baseServo;
Servo rotServo;
Servo elbowServo;
Servo gripServo;

int basePotPin = 0;
int rotPotPin = 1;
int elbowPotPin = 3;
int gripPotPin = 2;

int baseVal;
int rotVal;
int elbowVal;
int gripVal;

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

baseServo.attach(9);
rotServo.attach(10);
elbowServo.attach(5);
gripServo.attach(11);
}

void loop() {
baseVal = analogRead(basePotPin);
baseVal = map(baseVal, 0, 400, 0, 179);

rotVal = analogRead(rotPotPin);
rotVal = map(rotVal, 0, 400, 0, 179);

elbowVal = analogRead(elbowPotPin);
elbowVal = map(elbowVal, 0, 400, 0, 179);

gripVal = analogRead(gripPotPin);
gripVal = map(gripVal, 0, 1023, 0, 179);

baseServo.write(baseVal);
rotServo.write(rotVal);
elbowServo.write(elbowVal);
gripServo.write(gripVal);

}

You might try double reading the analog inputs and throwing away the first reading, have you tested the servo with the “Sweep” example sketch?
Try testing the servo with this sketch:

/*
 Try this test sketch with the Servo library to see how your
 servo responds to different settings, type a position
 (0 to 180) or if you type a number greater than 200 it will be
 interpreted as microseconds(544 to 2400), in the top of serial
 monitor and hit [ENTER], start at 90 (or 1472) and work your
 way toward zero (544) 5 degrees (or 50 micros) at a time, then
 toward 180 (2400). 
*/
#include <Servo.h>
Servo servo;

void setup() {
  // initialize serial:
  Serial.begin(9600); //set serial monitor baud rate to match
  servo.write(90);
  servo.attach(9);
  prntIt();
}

void loop() {
  // if there's any serial available, read it:
  while (Serial.available() > 0) {

    // look for the next valid integer in the incoming serial stream:
    int pos = Serial.parseInt();
    pos = constrain(pos, 0, 2400);
    servo.write(pos);
    prntIt();
  }
}
void prntIt()
{
  Serial.print("  degrees = "); 
  Serial.print(servo.read());
  Serial.print("\t");
  Serial.print("microseconds =  ");
  Serial.println(servo.readMicroseconds());
}

Is the 6V supply outputing 6V without dropouts? IE check with a multimeter. That's a high
power servo (6W mechanical out by my calculations, so could easily need more than 2A peak).

MarkT:
so could easily need more than 2A peak).

Datasheet here agrees, 1.8 anyway, so the supply's marginal at best.

MarkT:
Is the 6V supply outputing 6V without dropouts? IE check with a multimeter. That's a high
power servo (6W mechanical out by my calculations, so could easily need more than 2A peak).

Well considering I don't have a multimeter on hand, I took everything else off to test the singular servo. The problem persists in the same manner, which must mean it couldn't be the battery dipping? Or am I wrong about that?

756E6C:
You might try double reading the analog inputs and throwing away the first reading, have you tested the servo with the "Sweep" example sketch?

I just tried exactly this, and the problem is still there, but I was able to get more info on the symptoms: The erratic movement is back and forth, 0 to 180, and the angle that I give to the servo makes the 'back' movement quicker, with 0 being pretty slow and 180 being just as fast as the 'forth' movement.

Hi,
As 756E6C suggests, try a simple bit of code just to move that servo.

During developing your code, did it display this problem.

I hope you developed this code in stages, getting each stage working before going onto the next, and not code everything at once?

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?
Also a picture of your project so we can see your component layout.

Tom.... :slight_smile: