ServoESP32 icon indicating copy to clipboard operation
ServoESP32 copied to clipboard

Frequency parameter is not working as expected

Open reivaxy opened this issue 11 months ago • 3 comments

Hi and thanks for this library.

It seems like the frequency parameter that can be passed to the attach function is not actually changing the frequency but the pulse width. I have initialized two Servos like this:

  myservo1.attach(servoPin1, Servo::CHANNEL_NOT_ATTACHED, Servo::DEFAULT_MIN_ANGLE,
            Servo::DEFAULT_MAX_ANGLE, Servo::DEFAULT_MIN_PULSE_WIDTH_US,
            Servo::DEFAULT_MAX_PULSE_WIDTH_US, 200);

  myservo2.attach(servoPin2);

Here are signals measured on two pins, the first (yellow) one was set at 200Hz, and the second (blue) one was left at default value which is 50Hz And both signals are actually at 50Hz image

Here is what is expected: the yellow signal has a frequency 4 times higher: image

reivaxy avatar Mar 20 '24 19:03 reivaxy

Also tested with frequencies 200 on pin1 and 400 Hz on pin2 and both pins show a 400 frequency. If I reverse and set 400 on 1 and 200 on 2, both have a 200Hz signal: the last pin attached set the frequency for all.

reivaxy avatar Mar 21 '24 18:03 reivaxy

what board are you using?

thijstriemstra avatar Apr 16 '24 15:04 thijstriemstra

XIAO ESP32-S3

reivaxy avatar Apr 16 '24 16:04 reivaxy