PWM generator issue

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
Post Reply
Beta_Ravener
Posts: 35
Joined: Tue Aug 09, 2016 6:56 pm

PWM generator issue

Post by Beta_Ravener » Thu Aug 11, 2016 12:48 pm

I've tried to build a simple demo from RGB Led on my ESP8266 running the latest "esp8266-20160811-v1.8.3-6-g4e36dd5.bin" firmware. I'm having problem with PWM output that behaves quite strangely, turning off for some period of time although the duty is set non-zero etc. This causes the Led to blink between colors chaotically which is not very nice.

Here you can see the connection scheme: http://www.schematics.com/project/rgb-led-36964/
And here is the control script: http://pastebin.com/hkvHcVf3

The script iterates through colors and every ~10ms changes the duty to new value for all RGB channels. The PWM is set to 500Hz which should give at least 5 PWM periods per color.

For the sake of testing I edited the code so it only alternates between Red and Green, so that there should be always some PWM signal on both outputs (if there was third color, each output was off for 1/3 of period and it was hard to distinguish error from correct behavior).
With the edited code I let the script run for some time and soon enough the problem appeared.

Here is the full image of the incident from oscilloscope (please ignore the scale, i was too lazy to set it up): https://s10.postimg.org/82xsrg4q1/full_plot.png
The point where the voltage was measured can be seen in scheme. There was clearly a PWM generated before and after the incident, but the PWM did turn of for a period (~1 second) in the middle. However, the script never told PWM to stop. In fact a closer look at the PWM reveals that it was descending from the maximum duty.
Error start: https://s10.postimg.org/45aj21hwp/error_start.png
Error end: https://s10.postimg.org/gind8y7l5/error_end.png
The error appeared when the duty was ~75% and disappeared ~50% duty. I don't think that the problem is related to this specific range, I'm just trying to show that the duty of the PWM was still set correctly by the script and it continued to work even when the LED turned off because PWM stopped generating signal.

I can only conclude that this is an error in the PWM implementation. I don't know what causes it (although very frequent change in duty might be a good place to start looking at), but it would cause problems in many other applications. Has anyone noticed similar issues?

crc9
Posts: 1
Joined: Wed Feb 27, 2019 9:03 pm

Re: PWM generator issue

Post by crc9 » Wed Feb 27, 2019 9:05 pm

Changing freq to lower value did the trick for me.

Post Reply