Page 1 of 1

[Video] ESP32 - Pulse Width Modulation

Posted: Mon Jan 30, 2017 11:54 pm
by kolban
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.

Re: [Video] ESP32 - Pulse Width Modulation

Posted: Thu Mar 09, 2017 2:40 pm
by MrDuco
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

Re: [Video] ESP32 - Pulse Width Modulation

Posted: Thu Mar 09, 2017 3:06 pm
by kolban
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).

Re: [Video] ESP32 - Pulse Width Modulation

Posted: Mon Mar 13, 2017 7:27 am
by MrDuco
Thanks for the answer, I will try again and see if I succeed