A You Tube video on the ESP32 and Pulse Width Modulation (PWM):
https://www.youtube.com/watch?v=rarE-WI_Y0A
Illustrates LED dimming and servo motor control.
[Video] ESP32 - Pulse Width Modulation
[Video] ESP32 - Pulse Width Modulation
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32
Re: [Video] ESP32 - Pulse Width Modulation
Hi kolban, you are really doing a greate job with all your videos!!!
I wonder if you can help me in the right direction. I'm trying to control a servo, and have succeded to complie and run your servoSweep example.
But I cannot for the world figure out how to move the servo to a certain point, as you descibe in the video (and document)
I have tried to read all there is about PWM and changing values in your code, but no success. Can you give any tips or example how this could be accomplished.
Thanks
I wonder if you can help me in the right direction. I'm trying to control a servo, and have succeded to complie and run your servoSweep example.
But I cannot for the world figure out how to move the servo to a certain point, as you descibe in the video (and document)
I have tried to read all there is about PWM and changing values in your code, but no success. Can you give any tips or example how this could be accomplished.
Thanks
Re: [Video] ESP32 - Pulse Width Modulation
A servo is controlled by a PWM signal. Commonly they have a period of 20ms. That means that the signal repeats every 20ms. However, common servo encoding uses the first couple of ms to control the position. If we imagine a PWM signal as being broken into two parts ... the time that the signal is high and the time that the signal is low.
Commonly:
if the signal is high for 1 ms and low for 19 ms, then the servo turns 100% in one direction.
if the signal is high for 2 ms and low for 18 ms, then the servo turns 100% in the other direction.
if the signal is high for 1.5 ms and low for 18.5ms, then servo turns 50% of the direction.
... and so on ...
So algorithmically ... if the signal is high for 1 + n/180 then the servo turns n degrees (based on granularity of the servo device itself).
Commonly:
if the signal is high for 1 ms and low for 19 ms, then the servo turns 100% in one direction.
if the signal is high for 2 ms and low for 18 ms, then the servo turns 100% in the other direction.
if the signal is high for 1.5 ms and low for 18.5ms, then servo turns 50% of the direction.
... and so on ...
So algorithmically ... if the signal is high for 1 + n/180 then the servo turns n degrees (based on granularity of the servo device itself).
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32
Re: [Video] ESP32 - Pulse Width Modulation
Thanks for the answer, I will try again and see if I succeed
Who is online
Users browsing this forum: No registered users and 43 guests