Servo jittering

I know, this has been discussed before but i haven’t found the same case as i’m experiencing.

I have one servo connected to the Arduino Uno R3(5V, GND, Pin 10)

I’ve reduced my sketch to the bare minimum but still the servo is jittering. Not really changing position but there’s an audible jitter going on. I’ve tried 3 different brand/size servo’s.

My bare minimum sketch:

#include <Servo.h>

Servo servo;

void setup() {
servo.attach(10);
servo.write(90);
}

void loop() {
}

The Arduino is powered via an USB cable(attached to MacBookPro). Servo is powered from the Arduino’s 5V pin.

Could this be related to electronic noise ?

The Arduino is powered via an USB cable(attached to MacBookPro). Servo is powered from the Arduino's 5V pin.

Could this be related to electronic noise ?

Could be. First it is never a good idea to provide +5vdc power for a servo from the arduino 5V pin, it just isn't. Arduinos are great at controlling servos, but they suck at powering them. An external regulated power source is the recommended method to power servo(s). However if it's a small servo, with little or no mechanical load on it, and it's not too hungry in it's current consumption you might be able to get away with powering just one servo from the arduino board, but again so many have problems when they do try to do that. You might try some power bypass capacitors on the +5vdc to ground close to the servos to see if that helps or not. Again I wouldn't waste time on it even if you just have to use four AA alkaline battery cells in series to power the servo, do it. Don''t forget you must add a wire from the external voltage negative terminal to an arduino ground pin when using external voltage sources to power your servo.

Lefty

retrolefty:
An external regulated power source is the recommended method to power servo(s). However if it's a small servo, with little or no mechanical load on it, and it's not too hungry in it's current consumption you might be able to get away with powering just one servo from the arduino board

One servo i tried was tiny, it came with the Sparkfun's starterkit.

But I'll try with a separate battery.

Thanks!

Servo test code you can use to try different servo positions. Poor servo grounding can cause servo issues.

// zoomkat 10-22-11 serial servo test
// type servo position 0 to 180 in serial monitor
// or for writeMicroseconds, use a value like 1500
// for IDE 0022 and later
// 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.writeMicroseconds(1500); //set initial servo position if desired
  myservo.attach(7);  //the pin for the servo control 
  Serial.println("servo-test-22-dual-input"); // 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

    // auto select appropriate value, copied from someone elses code.
    if(n >= 500)
    {
      Serial.print("writing Microseconds: ");
      Serial.println(n);
      myservo.writeMicroseconds(n);
    }
    else
    {   
      Serial.print("writing Angle: ");
      Serial.println(n);
      myservo.write(n);
    }

    readString=""; //empty for next input
  } 
}

I have the same problem. I use a regulated 5V supply for the servo and connect the 0V to the Arduino GND. I think it is just normal servo operation so I just ignore the intermittent jitter. Maybe due to a low quality servo with a noisy internal feedback pot.

warren631:
I think it is just normal servo operation so I just ignore the intermittent jitter. Maybe due to a low quality servo with a noisy internal feedback pot.

Could be, yes. I’ll test the servos with an RC Receiver. Will let you know the result.

Hi,
You will get a 1 ro 2% jitter from interrupt clashes in the Arduino, this happens when a timer interrupt is running and the servo library cannot run its ISR until the timer completes so the pulse is a little bit longer meaning your servo thinks you want it to move.

The error is a little larger if you are reading the signal in as well as outputting it, this is because there are that many more interrupts happening and the clashes can effect both the initial measurement of a pulse (measurement can be longer or shorter than actual) and the effort to reproduce the pulse (can be longer than measurement).

Again this should not lead to errors of more than 2 or 3%. I would describe these errors as ticks rather than jitter.

The best idea might be to post a link to a video so that we can judge whether you have accepatble ticks or unacceptable jitter which would indicate a real problem somewhere.

Duane B

rcarduino.blogspot.com

DuaneB:
Hi,
You will get a 1 ro 2% jitter from interrupt clashes in the Arduino, this happens when a timer interrupt is running and the servo library cannot run its ISR until the timer completes so the pulse is a little bit longer meaning your servo thinks you want it to move.

The error is a little larger if you are reading the signal in as well as outputting it, this is because there are that many more interrupts happening and the clashes can effect both the initial measurement of a pulse (measurement can be longer or shorter than actual) and the effort to reproduce the pulse (can be longer than measurement).

Again this should not lead to errors of more than 2 or 3%. I would describe these errors as ticks rather than jitter.

The best idea might be to post a link to a video so that we can judge whether you have accepatble ticks or unacceptable jitter which would indicate a real problem somewhere.

This could well be, but with my bare minimum test i would have expected this to be no issue. What i'm seeing could be classified as "acceptable ticks" as it not really influencing the position of the servo. It just doesn't feel "robust". If the problem persists i might try with a PMW chip(TLC5940)

Hi,
Its totally robust, I run cars at 60Km/h using interrupts to read the incoming signal and generate the out going servo signals.

This car has no direct connection between the RC Receiver and the steering servo or ESC, its all being read by and then generated by Arduino - with those little ticks which as you have seen in your own project 'are not really influencing the position of the servo'

Project details here -

I guess all of the Arduino quadcopters also stay in the air because this effect is minimal.

Duane B

rcarduino.blogspot.com

just tested: No more jitter with a separate 5V battery (GND's connected)

Case solved.