Closed zigarrre closed 9 years ago
Here is interesting blog post about PWM http://tech.scargill.net/esp8266-pwm-on-one-output/
Has ESP real HW PWM on some pin or everything is only emulated?
I tried it and flickering is minor problem, much bigger problem is that ESP is completely unresponsive during PWM.
The ESP has a hardware PWM peripheral (on pins 12-15, which the link you posted is using) but the PWM implementation in Sming is software PWM. The problem is the suboptimal implementation in Sming.
The software PWM implementation in NodeMCU (which i'm using now) works perfectly fine without any flickering, even at the lowest duty cycle.
According https://github.com/esp8266/Arduino/issues/424#issuecomment-111876468 ESP has no HW support for PWM
SDK 1.1.1 has some new driver for PWM http://bbs.espressif.com/viewtopic.php?f=5&t=554
@zigarrre can you please see if 1.1.1 fixes that? Thank you!
@kireevco : I don't think sming uses the new PWM drivers yet. They are in libpwm.a and that is not used by sming
@kireevco @hreintke : hreintke is right, Sming uses it's own software PWM implementation (see https://github.com/anakod/Sming/blob/master/Sming/SmingCore/PWM.cpp).
Current PWM implementation needs update. Good example: https://github.com/sh4d0w12/esp8266_IRremote/pull/1
@anakod Sming's PWM.cpp is using ostimer. Bellow is written in latest SDK 1.2 documentation on Page 15.
"Please be noted that os_timer APIs listed below are software timer, they are executed in task, so timer callback may not be precisely executed at the right time, it depends on priority. If you need a precise timer, please use hardware timer which will be executed in hardware interrupt, refer to hw_timer.c. "
Also latest SDK PWM api seems to be using hw_timer. (bellow is from page18)
"APIs in hw_timer.c can not be called when PWM APIs are using, because they are using the same hardware timer."
So we should make change Sming PWM to use hw_timer. I think this will solve "Flicker" problem.
@hrsavla do you think you could add that change via PR?
Is flickering problem solved?
Software PWM generated in Sming will generate flickers as timers are of not higher priority and some Network routines will interrupt it. Solution is to use ESP sdk pwm api or write whole new PWM class using hardware timer. I am able to make Esp sdk PWM to work with sming. I still need to format the code in Sming way Class files. I will do it and make a PR within 6 hours. (I will let you know).
@hrsavla Did you remove your implementation of hw pwm?
I am resubmitting it in an hour as per git flow. On 6 Sep 2015 12:08, "crosofg" notifications@github.com wrote:
@hrsavla https://github.com/hrsavla Did you remove your implementation of hw pwm?
— Reply to this email directly or view it on GitHub https://github.com/anakod/Sming/issues/70#issuecomment-138047044.
How can I combine two features? I want to implement rboot and Hw pwm. what changes needs to be done?
In progress. See PR #375
When driving a LED with PWM it flickers. This is probably caused by timing issues in the PWM implementation which cause a varying duty cycle. The lower the duty cycle is set the more drastic will be the flickering.
Minimum sample to reproduce the problem:
LED connected between GPIO2 and GND.