ESP8266 Webserver Project

Moderator: Sprite_tm

User avatar
By Avoncliff
#61677 I am impressed with your httpd, builds and runs just fine.
But I am having problems adding PWM control, I have copied some of the IoT example code and am calling pwm_init, pwm_start and user_light_set_duty all with parameters copied from the example. It is doing something as the pins I am setting now pulse at aprox 1msec intervals, but the pulse is only 2.5usec wide and does not alter. The pulses are also intermittent there for a second gone for 2 as a regular patten.
I am guessing this is a conflict with some other timer setup, but removing everything else in user_init made no difference.
Has anyone got pwm working with httpd?
Is there any default timer config I need to disable?
If I am right about timer clashes can I run httpd without a timer?
Thanks
User avatar
By Avoncliff
#61795 OK mostly my mistake, sorry for the noise.
I was using far too low values for the pwm, for some reason I thought 100% was 255.
Turns out if you set the period to 1000, you get each pulse start at 1100usec intervals, and you can set the high period between 0 and 1000usec, so I can never get to 100%. The value to set for 1000usec on time is 22000.
Similarly with a period of 2000 ie approx 500hz 44000 gives 95% on as the max.
All numbers measured so not precise.
Not what I was expecting but quite usable.