Servo Chatter and Servo Automatically Reposition Itself

Hi everyone,

I have a pan-tilt using a set of servos that I put together and control with an Arduino, however I have two questions I was hoping you could help me address.

Firstly, whenever I sent my servos to a position, there is significant servo chatter, or noise from the servos, even though it appears they aren’t doing anything. Is there a reason for this, or a way to minimize it?

Secondly, sometimes, and without warning, the servos will pan and tilt away from the position I have given them, and then automatically turn back to that position all in one motion. I assume they’re just repositioning themselves for whatever reason, but I would like for that not to happen. Any suggestions?

Here’s a the code I have:

#include <Servo.h> 
 
Servo tilt;
Servo pan;

 
int pos = 0;    // variable to store the servo position 
 
void setup() 
{ 
  tilt.attach(8,1000,1500);
  pan.attach(9,1050,1950);

} 
 
 
void loop() 
{ 
  tilt.write(40);
  pan.write(90);
} 

void servo_off()
{
    tilt.detach();
    pan.detach();
}

I have the detach commands in there as I was hoping it would cut down on the servo chatter, but no avail. Any suggestions would be most appreciated.

Thanks.

Hi,
I suggest you so not detach the servos, the only thing that lets them hold position when you detach them is the friction of the internal gears, you can't rely on it.

You don't mention how you are powering the servos, its the starting point for any discussion of servo problems.

Check the two links in my signature for an demonstration of and solution to the most common servo problems.

Duane B

Most common issue is trying to power the servo from the arduino and a lack of common grounding when using an external power supply.

Thank you both for your replies. For my power supply, I'm using a 9V 1.5A power supply (of course the USB is still connected to the Arduino but I assume it no longer delivers power once I attach the external power supply). As far as grounding, I have the ground wires of both my servos going into a common node in a breadboard, and then I'm pulling a wire out of there into the ground in my Arduino. Is that sufficient for common grounding?

Thanks again!