Continuous Servo with Esp32

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

Continuous Servo with Esp32

Postby kaxx1975 » Tue Nov 19, 2024 9:16 pm

Hello
I am using a continuous servo to drive a gear drive for my robot arm joints - so, I need a lot more than just 180 degrees of rotation - more like 5 or 6 complete turns. I am using a Hitec Servo designed for continuous rotation, I also have a GoBilda Servo that is also programmed for continuous rotation. Modding and hacking was not necessary. I'm using Arduino IDE and using the ESP32Servo Library 3.0.5.

My issue is I want to drive the servo REALLY slow at times to get aligned just right. It starts moving forward at 1522, this is the slowest speed without stopping and even though it IS slow enough, I would like it even slower. I could accept that as the PID controller should be able to deal with it but in all honesty the real issue I have is that the speed changes are not proportional to the writeMicroseconds values.

In other words the next speed change isn't until around 1543, and it is an audible and noticeable large step up from the previous speed at 1542, and not "incremental" nor "proportional" as I would prefer. Its like it missed all of the increments from 1523 to 1542 and just jumped straight to the 1543 speed. Same way in reverse, just obviously lower numbers below 1500.

I have not yet looked into this library nor have a complete understanding of how it all comes together. But I do wonder, Is this due to a limitation of the resolution, i.e. 4 bits which is only 255, I would rather have better resolution and have better control of all speeds throughout.

Or has anyone real experience with another library that works better with continuous servos?

aliarifat794
Posts: 200
Joined: Sun Jun 23, 2024 6:18 pm

Re: Continuous Servo with Esp32

Postby aliarifat794 » Wed Nov 20, 2024 7:17 am

You can switch to a programmable digital servo.

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

Re: Continuous Servo with Esp32

Postby kaxx1975 » Wed Nov 20, 2024 8:49 pm

Do you mean something like this one:

https://www.hiteccs.com/actuators/produ ... SR-M9382TH

That servo is one of the 2 that I am noticing this on

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

Re: Continuous Servo with Esp32

Postby MicroController » Thu Nov 21, 2024 11:38 am

Given that the servo is a) a digital one and b) as a servo, made for position control rather than speed control, it may well be that you're out of luck trying to precisely manage the speed.

Have you tried programming the servo for a lower speed setting?

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

Re: Continuous Servo with Esp32

Postby kaxx1975 » Thu Nov 21, 2024 3:12 pm

I can program it slower, but it's the speed changes at every 20 increments that I would like to see if I can smooth out more proportionally, and I think I need higher resolution.

It's like it is mapping my speeds to certain increments based on 256:2000 mapping instead of 2000:2000 mapping.

I hope that makes sense, I know what I mean I just don't always know how to word things so others understand me sometimes.

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

Re: Continuous Servo with Esp32

Postby MicroController » Thu Nov 21, 2024 5:21 pm

Yeah, my thought was that a lower max speed setting might potentially maintain the number of possible increments across the smaller speed range, resulting in smaller absolute increments of the actual speed. But maybe it just caps the speed at the lower value and does nothing else...

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

Re: Continuous Servo with Esp32

Postby kaxx1975 » Thu Nov 21, 2024 6:49 pm

Ya, after I posted I thought about it and that may make sense. I can try it, but with a 7:1 gear ratio at full speed it's already pretty slow.

I will try my Servo Maestro servo controller this weekend or tonight, if the speed is more proportional then I know the error is coming from the ESP32 code and not the servo itself.

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

Re: Continuous Servo with Esp32

Postby kaxx1975 » Thu Nov 21, 2024 9:27 pm

I have confirmed the issue is not with the servo itself.

Its been over a year since I last delved into these servos, but I don't recall having these issues back then. This was during ESP32 board version 2.xx, before 3.0 and all of the changes. I think I would have noticed, because I noticed it immediately when I first fired everything up a few days back.

Something about the coding process with the updated ESP32 3.0 boards may have changed?

I really rather not roll back all of my versions to get this project to work, but before I consider blowing up my servos by (incorrectly) writing my own code instead of using the library, I'm just wondering if anyone has any ideas first.

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

Re: Continuous Servo with Esp32

Postby kaxx1975 » Fri Nov 22, 2024 5:46 pm

Update: Just an issue with the library, I have started writing my own code and it doesn't seem that difficult so far, I am already getting much better results

Quick question, is delay microseconds needed for servo pulse time, or can go without a true delay (like the "blink without delay" example) and yield good results?

I will be receiving and sending messages periodically with esp_now, not sure if using a true delay - however minor the time is - will affect things with either the servo operation or the wifi operations.

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

Re: Continuous Servo with Esp32

Postby MicroController » 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.

Who is online

Users browsing this forum: No registered users and 63 guests