Dlloydev / ESP32-ESP32S2-AnalogWrite

ESP32 PWM, Servo, Easing and Tone. Smart GPIO pin management and advanced control features.
MIT License
100 stars 17 forks source link

Jittery servo sweep with ESP32-C3 #29

Closed nickrehm closed 1 year ago

nickrehm commented 1 year ago

Servo sweep example leads to jittery servo response which also affects other added servos commanded to static position. Also observed this behavior in a 50Hz and 10Hz loop with 6 servos--When any of the 6 was given a changing value in the loop (smooth sweep up/down, for example), all of the other servos jittered (5-10degrees) about their commanded static position.

This was also observed with a single servo.

Possibly due to writeServo() calling attach() on every call and resetting something?

Dlloydev commented 1 year ago

Thanks for reporting your observations. I haven't tested servos with actual ESP32-C3 hardware, but I have a few examples in Wokwi using 6 servos that don't reveal this behavior. The attach() function only attaches to a pin once, then it just returns the attached channel number. ESP32_C3_6_Servo_Knob.ino ESP32_C3_6_Servo_Sweep.ino Do you have an example I could take a look at?

EDIT: I see you've created some amazing drone designs ... very inspiring! I'll setup some real hardware for testing and see what I can find.

Dlloydev commented 1 year ago

I've completed a new Wokwi scope chip which showed the jitter and helped with resolving the issue. An update to the library (4.2.5) will be published shortly. Thanks for your feedback!