Analog vs Digital Servo: Massive jitters

Hello!

I'm trying to build a camera stabilisation system with the arduino nano ATmega328, the MPU6050 and a digital Servo TrackStar TS-411MG. The problem is that the servo has massive jitters and jumps even with the Servo.h Sweep test. I tried an other analog Servo the TowerPro MG995 which runs without jitters and jumps but it is not smooth and fast enough for camera stabilisation. The power source of the servo is an external 6V battery pack and i run the servo on pin 9. Any suggestions how i can fix that?

Regards,
FunnyItsElmo

No, servos are not suitable for camera stabilization. Gimbal motors exist for a reason.

Any suggestions how i can fix that?

Could be your code. Please read below:

http://forum.arduino.cc/index.php/topic,148850.0.html

MarkT:
No, servos are not suitable for camera stabilization. Gimbal motors exist for a reason.

I just need a one axis stabilization like the one in this video - YouTube

zoomkat:
Could be your code. Please read below:

http://forum.arduino.cc/index.php/topic,148850.0.html

/* Sweep
 by BARRAGAN <http://barraganstudio.com>
 This example code is in the public domain.

 modified 8 Nov 2013
 by Scott Fitzgerald
 http://www.arduino.cc/en/Tutorial/Sweep
*/

#include <Servo.h>

Servo myservo;  // create servo object to control a servo
// twelve servo objects can be created on most boards

int pos = 0;    // variable to store the servo position

void setup() {
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object
}

void loop() {
  for (pos = 0; pos <= 180; pos += 1) { // goes from 0 degrees to 180 degrees
    // in steps of 1 degree
    myservo.write(pos);              // tell servo to go to position in variable 'pos'
    delay(15);                       // waits 15ms for the servo to reach the position
  }
  for (pos = 180; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees
    myservo.write(pos);              // tell servo to go to position in variable 'pos'
    delay(15);                       // waits 15ms for the servo to reach the position
  }
}

I also tested some other scripts with no mentionable result.

But there is no problem with the Servo at all i tested it today with a RC car

ALL grounds connected?

Poor/improper grounding between the servo and arduino can produce erratic operation. Also if the servo is overloaded performance issues can arise.

justone:
ALL grounds connected?

zoomkat:
Poor/improper grounding between the servo and arduino can produce erratic operation. Also if the servo is overloaded performance issues can arise.

Thanks for the answers! This is my setup:

It should be connected correctly because it works with the analog servo!

This is a longshot, as I have never played with digital servos on an Arduino - but try reducing the value of the delay()s from 15 to 10 to 5 - and see if that improves anything.

cr0sh:
This is a longshot, as I have never played with digital servos on an Arduino - but try reducing the value of the delay()s from 15 to 10 to 5 - and see if that improves anything.

I don't think that would change anything. I think the servo library sends refresh signals at 50Hz so any updates to positions faster than this refresh rate would be noticed.

Digital servos can draw lot of current. Most jitter problems are caused by insufficient power supplies.

Here are some recent threads discussing powering servos.

I would suggest you NOT use the standard servo examples. The default limits are outside the range of many servos and the Arduino example code can damage servos by driving them past their physical limits. The forum has many examples of people damaging their servos by using the example code.

Very simple servo command code you might try to see if the digital servo moves smoothly from point to point.

//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="";
  } 
}

I just did zoomkat's servo example for two servos and my digital servos jittered. I replaced them with analog servos and now they are rock solid.

I fly RC and the new digital servos have problems on older receivers. I think they don't like the 50hz refresh rate and want something faster.

DuaneDegn:
I would suggest you NOT use the standard servo examples. The default limits are outside the range of many servos and the Arduino example code can damage servos by driving them past their physical limits. The forum has many examples of people damaging their servos by using the example code.

Yes i know i already crashed a analog servo with the example code :smiley: But digital servos are limited by their own!

DuaneDegn:
Digital servos can draw lot of current. Most jitter problems are caused by insufficient power supplies.

I dont think the power supply is insufficient but how can i check it?

zoomkat:
Very simple servo command code you might try to see if the digital servo moves smoothly from point to point.

//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="";
  }
}

Thanks but the servo is still jittering :confused:

Barn-E-Stormer:
I just did zoomkat’s servo example for two servos and my digital servos jittered. I replaced them with analog servos and now they are rock solid.

I fly RC and the new digital servos have problems on older receivers. I think they don’t like the 50hz refresh rate and want something faster.

Or maybe the pwm accuracy is to imprecise?

Or maybe the pwm accuracy is to imprecise?

If the servos are made for use with standard RC receivers, then the arduino should be able to control them just as well. Note that some digital servos are programmable with variable settings. If the servo is programmable then the jitter might be caused by hunting if the dead band is set too tight.

zoomkat:
If the servos are made for use with standard RC receivers, then the arduino should be able to control them just as well. Note that some digital servos are programmable with variable settings. If the servo is programmable then the jitter might be caused by hunting if the dead band is set too tight.

Hmm i dont think that the servo is programmable bacause it works without issues with a standard rc receiver. I have no idea :confused:

If you want solid stabilization standard hobby servos have too much backlash and too much
vibration - this could be partially fixed with visco-elastic damping of some sort, but if you want
anything approaching solid stabilization a gimbal motor system is needed - no backlash, highly
responsive control loop to swallow up vibrations/perturbations.

MarkT:
If you want solid stabilization standard hobby servos have too much backlash and too much
vibration - this could be partially fixed with visco-elastic damping of some sort, but if you want
anything approaching solid stabilization a gimbal motor system is needed - no backlash, highly
responsive control loop to swallow up vibrations/perturbations.

Yes youre propbly right but the servo has massive jitters and jumps and i want to know why!

int servoPin = 9;
long mic = micros();

void setup() {
  pinMode(servoPin, OUTPUT); 

  cli();
  
  TCCR1A = 0; // set entire TCCR1A register to 0
  TCCR1B = 0; // set entire TCCR1B register to 0
  
  TIMSK1 |= (1 << TOIE1); // enable Timer1 overflow interrupt

  TCNT1=25552; // set start count

  TCCR1B |= (1 << CS11); // set CS10 bit so timer runs at clock speed: (no prescaling)
  
  sei();

}

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

}

ISR(TIMER1_OVF_vect) {
  digitalWrite(servoPin, HIGH);
  delayMicroseconds(1500);
  digitalWrite(servoPin, LOW);
  TCNT1=25552; //set start count
}

I wrote and tested this code but still have the same issue! The servo moves to 90 and jitters at this position for a while. After 1 or 2 seconds it is stable but if i move the servo again manualy it turns back to 90 and jitters again.

As zoomkat pointed out, digital servos are made to work with normal RC gear. It's very unlikely the 50Hz refresh rate is causing the problem. It's very likely the power supply is causing the problem.

A power supply which works fine with an analog servo will not necessarily power digital servos without issue.

Four AA alkaline cells is not a "good" power supply for these sorts of servos. Alkaline cells can't source as much current as many rechargeable cells.

Five AA (or larger) NiMH cells would likely power a couple servos okay.

DuaneDegn:
As zoomkat pointed out, digital servos are made to work with normal RC gear. It's very unlikely the 50Hz refresh rate is causing the problem. It's very likely the power supply is causing the problem.

A power supply which works fine with an analog servo will not necessarily power digital servos without issue.

Four AA alkaline cells is not a "good" power supply for these sorts of servos. Alkaline cells can't source as much current as many rechargeable cells.

Five AA (or larger) NiMH cells would likely power a couple servos okay.

I replaced the AA alkaline cells with 4 AA NiMH cells 1.2V 2100mAh and the servo runs much more smoth now! Thanks! But there are still some jitters do they occur because the cells are quite old? How would you power the servo?

A 4.8V NiMh receiver pack for RC use works great.

You can also use a power supply set to 5V.

I often use a ESC (electronic speed contol) which has a BEC (battery eliminator circuit) to run the radio gear in a RC plane. You can power the ESC with anything from a NiMh battery to a 3 or 4 cell Lipo, even a car battery, and get your regulated 5V. A simple ESC like this one will supply one amp regulated 5V from a wide input voltage range. [ http://www.ebay.com/itm/RC-ESC-20A-Brushed-Motor-Speed-Controller-BEC-5V-1A-Without-Brake-/331314631342?hash=item4d23e412ae:g:GucAAOxyB9RSzPF5](http:// http://www.ebay.com/itm/RC-ESC-20A-Brushed-Motor-Speed-Controller-BEC-5V-1A-Without-Brake-/331314631342?hash=item4d23e412ae:g:GucAAOxyB9RSzPF5)

For any of these methods be sure to tie the ground from the power supply to the ground on your Arduino.

FunnyItsElmo:
How would you power the servo?

Did you follow the links in reply #8?

Barn-E-Stormer:
A 4.8V NiMh receiver pack for RC use works great.

Often this is true. It's certainly possible to find servos which would not work well from such a pack.

The BEC of an ESC is often a good way to power a servo but the BEC built into many ESCs are linear regulators which dump the voltage drop as heat.

A switching regulator will not waste as much power (in the form of heat) as a linear regulator will waste.

Barn-E-Stormer:
For any of these methods be sure to tie the ground from the power supply to the ground on your Arduino.

I haven't forgotten lately, but I've amazed myself by how often I've forgotten to make sure grounds had a point in common.

Just don't have the return path of the current through the servo, pass through the Arduino's PCB.