United Kingdom
Asked
Resolved Resolved by DJ Sures!

Servo Range Restricted With ESP32

Hi DJ and co...

Thanks for all the hard work with the recent ARC updates. I've recently added an ESP32 to my InMoov to control some of the servos using Arc.... And I've noticed that the servos don't rotate the full 180 degrees when connected to the ESP32

Example..... Neck up/down servo on InMoov rotates full 180 degrees when connected to an EZ-Bv4/2.... Only rotates about 90 degrees when connected to ESP-32.

I'm sure this is my own knowledge gap again...but is there anything I need to change in ARC or in the ESP32 Firmware?


Related Hardware Esp32 DevKit v1

ARC Pro

Upgrade to ARC Pro

Stay on the cutting edge of robotics with ARC Pro, guaranteeing that your robot is always ahead of the game.

#1   — Edited

When you go into the servo control by clicking the three dots "..." check to see if you have that servo's Min and Max set correctly.

That's all I can think of because I don't know anything about theĀ ESP-32. Are there settings on that board or a script operating it you need to adjust?

United Kingdom
#2  

Min and Max all set correctly....

But....That's what I'm asking....I can't see anything....but maybe in the Arduino Code for the EZ-B/ESP32 firmware ??

Maybe DJ can help?

PRO
Synthiam
#3  

That's the fun of open source arduino. You never know if it'll work or not. Kind of like a kinder egg surprise.:)

There's a file in the firmware download called ESP32_Servo.h. In there, is a section for the min and max pulse width of the servo. I don't know if it actually works or not, or how accurate it is. But modifying those values may produce some results. Give it a try...


#define DEFAULT_TIMER_WIDTH 16
#define DEFAULT_TIMER_WIDTH_TICKS 65536

#define ESP32_Servo_VERSION           1     // software version of this library

#define MIN_PULSE_WIDTH       500     // the shortest pulse sent to a servo  
#define MAX_PULSE_WIDTH      2500     // the longest pulse sent to a servo 
#define DEFAULT_PULSE_WIDTH  1500     // default pulse width when servo is attached
#define DEFAULT_PULSE_WIDTH_TICKS 4825
#define REFRESH_CPS            50
#define REFRESH_USEC         20000

#define MAX_SERVOS              16     // no. of PWM channels in ESP32

PRO
Synthiam
#5  

Oh - and it appears the ESP32Servo library supports that syntax

United Kingdom
#6  

#define DEFAULT_uS_LOW 650
#define DEFAULT_uS_HIGH 2350

So I googled the PWM ranges for my servos....the JX PDI 2060MG... JX PDI 2060MG MAX PW: 650-2350 STD PW: 850-2150

Changed the code as above and now get 180degrees.

I have a mixture of servo makes/types coming from that ESP32, so will probably have to specify the ranges individually for the servo types...but that's definitely the source of the problem. Some fine tuning to go...but problem mostly resolved.

Thanks for the help.:)