Servos with arthritis... [USED 5V, PROBLEM SOLVED]

Hey fellow Arduino guys!

I got 12 Towerpro MG995s... (please forgive me) controlled by an Arduino mega. for example purposes, say i was to set one of them to 120 degrees.

Here comes the problem...

it just does full rotations between 120 and 0 constantly. and if i try to stop it, it will after a few tries, then if i put load on it, it does the same thing...

At first I thought it was electrical noise, so i thought about getting some ferrites to put on the cable, but now I'm wondering if it's a weird ppm signal that the servo can't understand at times...

EDIT: now it just randomly has the same problem at times. Here is the code:

#include <Servo.h>

Servo myservo;

void setup() {
 // put your setup code here, to run once:
  myservo.attach(10);
}

void loop() {
 // put your main code here, to run repeatedly:
   myservo.write(150);
}

any help?

Regards
-Kyle

capacitors on power and signal maybe? even a 0.1uF capacitor on the ppm wire

I tried it with a flex resistor, and the same thing happens, but only if i flex the sensor too fast

How are you powering everything?

with an external 6v battery. the grounds are common of the arduino and power supply

What happens if you do this ?

#include <Servo.h>

Servo myservo;

void setup() {
  // put your setup code here, to run once:
   myservo.attach(10);
   myservo.write(150);

}

void loop() {
  // put your main code here, to run repeatedly:
}

MAS3:
What happens if you do this ?

#include <Servo.h>

Servo myservo;

void setup() {
  // put your setup code here, to run once:
  myservo.attach(10);
  myservo.write(150);

}

void loop() {
  // put your main code here, to run repeatedly:
}

same thing, but with 150 degrees... I went out and got a 0.1 uf capacitor and put it across the ground and pwm wires. no change

Does the Knob example work? Does Sweep?

Isaac96:
Does the Knob example work? Does Sweep?

they work, but instead of staying at the angle it should, it continues to rotate between the angle it should be at and 0 degrees

I must add that all 12 servos so the exact same thing.

Have they been modified for continuous rotation?

Isaac96:
Have they been modified for continuous rotation?

nope

I changed out the servo for an LED connected to the ground and signal wires. when setting an angle with the serial servo sketch, I can change the brightness of the LED. no big brightness jumps...

with an external 6v battery. the grounds are common of the arduino and power supply

Is the arduino AND the servo both powered from the same 6v power source? If so, you will probably need separate power supplies.

zoomkat:
Is the arduino AND the servo both powered from the same 6v power source? If so, you will probably need separate power supplies.

arduino via usb, servo via battery

Attached is a typical servo external power setup. Is this setup similar to yours?

servo-wire.jpg

exactly the same

zoomkat:
Attached is a typical servo external power setup. Is this setup similar to yours?

should i send images?

Very simple servo test code using the serial monitor. See if you can successfully control a single servo with the other servos disconnected. If that works keep adding servos to see when the problems start.

//zoomkat 7-30-10 serial servo test
//type servo position 0 to 180 in serial monitor
// Powering a servo from the arduino usually *DOES NOT WORK*.

String readString;
#include <Servo.h> 
Servo myservo;  // create servo object to control a servo 

void setup() {
  Serial.begin(9600);
  myservo.attach(9);
  Serial.println("servo-test"); // so I can keep track of what is loaded
}

void loop() {

  while (Serial.available()) {
    char c = Serial.read();  //gets one byte from serial buffer
    readString += c; //makes the String readString
    delay(2);  //slow looping to allow buffer to fill with next character
  }

  if (readString.length() >0) {
    Serial.println(readString);  //so you can see the captured String 
    int n = readString.toInt();  //convert readString into a number
    Serial.println(n); //so you can see the integer
    myservo.write(n);
    readString="";
  } 
}

zoomkat:
Very simple servo test code using the serial monitor. See if you can successfully control a single servo with the other servos disconnected. If that works keep adding servos to see when the problems start.

//zoomkat 7-30-10 serial servo test

//type servo position 0 to 180 in serial monitor
// Powering a servo from the arduino usually DOES NOT WORK.

String readString;
#include <Servo.h>
Servo myservo;  // create servo object to control a servo

void setup() {
  Serial.begin(9600);
  myservo.attach(9);
  Serial.println("servo-test"); // so I can keep track of what is loaded
}

void loop() {

while (Serial.available()) {
    char c = Serial.read();  //gets one byte from serial buffer
    readString += c; //makes the String readString
    delay(2);  //slow looping to allow buffer to fill with next character
  }

if (readString.length() >0) {
    Serial.println(readString);  //so you can see the captured String
    int n = readString.toInt();  //convert readString into a number
    Serial.println(n); //so you can see the integer
    myservo.write(n);
    readString="";
  }
}

problem begins with one servo. it jsut goes forward and back 180 to 0 constantly