Continuous Servo with Esp32

kaxx1975
Posts: 11
Joined: Wed Jan 24, 2024 9:49 pm

Re: Continuous Servo with Esp32

Postby kaxx1975 » Fri Nov 22, 2024 10:12 pm

MicroController wrote:
Fri Nov 22, 2024 7:55 pm
You are required by international law to use a hardware peripheral to control servo motors. - Or I might have made that up just now, who knows.

It's just PWM.
Use the LEDC, or the MCPWM, or maybe even the RMT peripheral if you have to, but please, for everything that's holy to you, don't try to create that PWM signal in software on an ESP32. There are too many things (interrupts, multi-tasking,...) going on in the background for you to get the needed delays with any decent consistency/accuracy.
Using hardware to create the pulses will give you 100% reliable timings, much greater resolution, and much less (i.e. zero) CPU usage.


You are absolutely correct. I tried sending several signals from 5 other boards using the esp_now protocol while using my Servo sweep/ease and.....well it's not a good idea. Those pulse delays are an eternity. By itself it was working great, but add in esp now and later a pid controller and not feasible.

I will look more into LEDC as I was a bit familiar with it before the board update changes, thx for steering me in the right direction

kaxx1975
Posts: 11
Joined: Wed Jan 24, 2024 9:49 pm

Re: Continuous Servo with Esp32

Postby kaxx1975 » Sat Nov 23, 2024 6:05 pm

Thank you for the help, I now have complete control of the continuous servo speed, and even my standard positional servos are playing very nicely.

Everything seems to be working perfectly receiving all messages from espnow without any servo libraries using LEDC. It's also very nice bonus to easily get the real duty cycle using that LEDC read function (can't remember the name ATM), or I would probably be at this all day.

Thank you @MicroController!

MicroController
Posts: 1994
Joined: Mon Oct 17, 2022 7:38 pm
Location: Europe, Germany

Re: Continuous Servo with Esp32

Postby MicroController » Sat Nov 23, 2024 7:32 pm

Glad you got it working :) (And are now in compliance with the DMCA ("Digital Motor Control Act") ;-))

Curiously, the ESP32Servo Arduino library seems to use the LEDC too, so not sure why it didn't work right for you.

kaxx1975
Posts: 11
Joined: Wed Jan 24, 2024 9:49 pm

Re: Continuous Servo with Esp32

Postby kaxx1975 » Sat Nov 23, 2024 9:06 pm

I don't know either, I had to set my resolution set to 14 to get app. 2000 usable positions. Im not sure what the library is set to, I took a quick peek at it, but that was about it.

Edit: 650 positions, not 2000. :? And I'm glad to be in compliance, I definitely want those DMCA guys after me

Who is online

Users browsing this forum: Majestic-12 [Bot] and 115 guests