I am following the Servo Guide at "DroneBot Workshop" and getting an error at the very first line of the example sketches in this guide. That line is:
#include "ESP32Servo.h"
The compile/verify error is:
In file included from /Users/Mohan/Documents/Arduino/libraries/ESP32Servo/src/ESP32Servo.h:84:0,
from /private/var/folders/8x/0wjsj3bn4pj_dc1lhdnm5m9w0000gn/T/.arduinoIDE-unsaved2026115-6424-11wdq99.rtge/sketch_feb15a/sketch_feb15a.ino:1:
/Users/Mohan/Documents/Arduino/libraries/ESP32Servo/src/ESP32PWM.h:28:10: fatal error: esp32-hal-ledc.h: No such file or directory
#include "esp32-hal-ledc.h"
^~~~~~~~~~~~~~~~~~
compilation terminated.
exit status 1
Compilation error: exit status
I have been doing lot of independent research for the past 24 hours without any practical hint and ready to give up.
I would greatly appreciate any practical advice in getting past this issue.
I need to set custom min and max limits and the control signal period. These functions are not available in standard servo library as per the examples I read.
According to Arduino Uno R4 WiFi datasheet, ESP32-S3 is available as a co-processor, and the example usecases refer to including ESP32Servo.h in code.
Yes. This is for a undergrad project. The Actuonix P16R allows one to vary the control signal frequency from 50–300Hz to reduce jitter. My understanding is one can use setPeriodHertz() function in ESP32Servo library for this purpose. I intended to use frequency of 250Hz (equivalent 4000 microsecond period).
Thanks for your reply. Being new to this, I don’t understand why all the servo examples for R4 mention this capability! Now the real question is, if I do need the functionality to control frequency of the control signal along with setting minimum and maximum pulse width at varius duty cycles, what is the right solution. Any help/recommendations are greatly appreciated.
It's literally a one line change in the library to change the frequency. A few more lines if you want to add a function to make it programmable at runtime.
Thanks. I did lost of experimentation with min and max already using the standard servo library. It did not meet the requirements - this is why I researched and tried to use the esp32 library. In any case, it looks like that is not a meaningful route either. Thanks again.
I found an example of changing the control signal frequency using the Arduino Uno R4 (RA4M1 chip) with the built-in PwmOut class that allows you to specify a custom period or frequency. I will try it out and if it works, I will report back.
Only you know these "requirements".
According to the specs you linked, hard to believe it wouldn't run with standard servo.h.
With insufficient power supply different story though...
Thanks. I did not want to complicate the thread by providing details that were not relevant to my basic issue of compiling an example sketch. However, since you asked, here is the basic (again, very simplistic) description.
The experiment is about constructing a small scale wave tank to study effects of architectural choices in mitigating damage from waves in coastal areas. The tank has to simulate waves moving at, at least, 3 different speeds (slow, medium, fast) and, for each speed, 3 different amplitudes (low, normal, and high). Pretty much all parts are ready except for the actual instrumentation. The P16R, a linear actuator (with external 12V 1A power supply), drives a paddle to generate waves. The paddle stroke size (sweep angle) controls amplitude of the generated waves. How fast a wave moves is controlled by instrumenting 3 different duty cycles (10, 15, and 20%) with peak voltage fixed at 12V. From my novice understanding of how servos work, I can effect the duty cycles by controlling the pulse width. For example, at fixed control frequency of 250Hz, desired pulse widths are 400 (10%), 600 (15%), and 800 (20%) microseconds.
Hopefully, it makes sense now. It is my mistake. I thought these details were irrelevant to the basic problem. I am sorry.