My Servo Is Jittering, and Sometimes Disregards the Code

Hi all, I'm trying to make a camera gimbal, and am having trouble with my servos.
Firstly, here is the link to the servos I'm using: https://www.makerstore.com.au/product/elec-servo-mg945/
The servos, when I plug them into the 5V and run the code, start out well enough, but soon start to jitter, and it looks as if they are disregarding the code.
I think the servos might not be getting enough power, but I don't know how to provide it.
Do you know if that is indeed the problem, and if so, how to fix it?
I would greatly appreciate any help.

Jitter is usually due to an inadequate servo power supply, or failure to connect the grounds.

The Arduino 5V output must not be used to power servos or motors. Avoid all tutorials that suggest otherwise, as those are written by people who don't understand the problems this can cause.

A 4xAA battery pack is enough to power ONE MG945 servo (which briefly draws 1.2 Amperes every time it starts moving, regardless of the load), connected as shown below:

I assume you have the correct voltage level. Measure the voltage while the servo(s) is in use. Does the voltage drop below the rating? Verify the amperes/current rating of the power supply is sufficient. What do you observe when you only use one servo, without a load?

Ok, I can try that. Is there a better way to power two servos than using two separate battery packs?
Thanks for the useful insight!

Unfortunately, I don't have any means of measuring the voltage and amperes, as far as i know. Thanks anyway.

Yes, get an external mains power 5V power supply with at least 1 Amp per servo.

How are you writing data to your servo? If you are using write micros method and expecting the servos to hold that position? Then the precision of the servos you require might be greater than the feedback resolution capabilities of the servo, then it will jitter no matter what the power supply is.

What do you mean by the write micros method?

You might see a label on the servo giving the numbers.

See the servo reference page in the Arduino documents

The methods to control the servos are at the bottom of this page. Click on each to see more about what they do.


Here's My setup. I've double checked everything is wired how you wired it(i am aware of the change in PWM pins- I changed it to pin 9 and but it isn't doing anything. Not moving, nothing. The code is fine, because I connected the servo to the 5V and Ground directly and it worked, but with the jitter. Why isn't it doing anything?

Hi, @lukemccfilms

Thanks for the pictures.

Can you please post the code you are using?

Thanks.. Tom.. :smiley: :+1: :coffee: :australia:

Sure Tom,

#include <Servo.h>

Servo Servo1;

int servoPin = 9;

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

void loop() {
  // put your main code here, to run repeatedly:
  Servo1.write(0);
  delay(1000);
  Servo1.write(50);
  delay(1000);
  Servo1.write(100);
  delay(1000);
  Servo1.write(150);
  delay(1000);

}

It looks like you have used electrical tape to fix batteries and wires together . I suspect that one of those connections is bad. You really need a meter to debug it - beg, borrow or buy one.

I believe you're right. It works if it's held really tightly, and only then. But I can't hold it for long enough to tell if it will jitter, so I'll see if I can get a proper battery pack and try it then.

I would go for a 4 pack rather than a 3 one.

It looks from the photo as if there actually is a fourth battery lurking at the top.

Yes, There is.

I strongly recommend using a battery holder something like this, with soldered connectors:

Thanks Guys, I got it working. I bought a 4x AA battery holder, and used the wiring that jremington mentioned.
:slight_smile: