RoboticsBrno / ServoESP32

⚙️ Generate RC servo signal on a selected pins with ESP32 device and Arduino framework.
MIT License
131 stars 31 forks source link

Frequency parameter is not working as expected #31

Open reivaxy opened 3 months ago

reivaxy commented 3 months ago

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 commented 3 months ago

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.

thijstriemstra commented 2 months ago

what board are you using?

reivaxy commented 2 months ago

XIAO ESP32-S3