Servo unwanted shaking

Hi there
@Robin2
@zoomkat
@MarkT

Im using Esp32 and potentiometer for control a servo motor (model: Gs-406) which consumes 300mA without load.
The problem is it shakes (vibrates) while I'm not twisting the potentiometer. I have tried high power supplies such as 4 amps but it didn't work.
At first point( 0 degree) the servo rotates about 2-3 degrees which is really abnormal.
Here is the code:

#include <Servo_ESP32.h>

static const int servoPosition = 25;

Servo_ESP32 servo1;

void setup() {
  pinMode(34, INPUT);
int pot=analogRead(34);
    Serial.begin(115200);
    servo1.attach(25);
}

void loop() {
int pot=analogRead(34);
    int servoPosition = map(pot, 0, 4000, 0, 150);
    servo1.write(servoPosition);
    Serial.println(servoPosition);
    Serial.println(pot);
    delay(5);
}

Here is my diagram, I've just changed pin 18 with 25

Can you operate away from the zero point? Although the servo signal is a digital pulse width, and therefore pretty immune to noise, working at the zero point is at the endpoint the internal position-feedback potentiometer, and may mean the servo is trying to sit at zero, but the feedback circuit is seen some small noise component close to zero volts, which is very common in power circuits.
Try your code at, for example, 18 degrees, which is 1/10 of full sweep and corresponds to about 500 mV on the feedback pot; see if that quiets it, if so, then there's your problem.

Thanks for sharing information.

I'm using esp32 wroom v.1 so max voltage coming from command potentiometer is 3v3.
I checked the voltage with multimeter which was zero at 0 degree and 0.4v for 180 degree.
Maybe its because the output is pwm.

I thinh the problem is with fluctuating the analog input of potentiometer which commonly is not stable and it goes up and down about 10 unit, subsequently the output pin's voltage changes.
How can I eliminate this potentiometer input ocilating?

Capacitor from input to gnd. About 0.1 uF.

I did it but didn't work.

What voltage, a PWM output to a servo? Yeah, won't see anything worth looking at with a voltmeter. The RMS voltage will rise with pulse width, but it's very approximate, and quite small - a 2.5 ms pulse in a 20 ms window is 12.5 %.
Sounds like the analog input isn't stable enough for what you're trying to do.

Yeah, that is exactly what I'm suffering from.
Is it related to the quality of the potentiometers or the input analog of esp32 is low?

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.