forkineye / ESPixelStick

Firmware for the ESPixelStick
http://forkineye.com/
542 stars 172 forks source link

Flickering Issue on NodeMCU 1.0 and Wemos D1 Mini #139

Closed redwolf3 closed 5 years ago

redwolf3 commented 5 years ago

I'm attempting to use a couple of NodeMCU 1.0's or Wemos D1 Mini's running the ESPixelStick firmware to control about 500 12 RGB LED's (WS2811).

Everything seemed to be fine when running basic tests in the lab (garage), but now that I'm setting up my show I'm running into issues with my pixels flickering on certain colors.

After a bunch of experimentation it seems like the issue is only occurring when I have the brightness of individual channels set to anything other than near max brightness. It doesn't seem to matter what color or mix I am using, if I have the brightness of any channel set below about 250, I get flickering until I get down to about 50 (at which point you really can't see the light very well).

I've read through a lot of common issues and have tried the following things:

  1. Initially I was running the latest version which looks like it has some prototype changes so I went back to Release 3.0. This had no affect.
  2. I verified that I am programming the ESP8266's with 160 MHz.
  3. I tried disabling the Wifi Status Light using wifi_status_led_uninstall(). This had no affect on the flickering (it also didn't seem to turn the WiFi status light off, it just disabled the blinking).
  4. I've tried both my NodeMCU 1.0's and D1 Minis and they both exhibit the exact same behavior.

Additional information:

Looking at the output of the LED's, it ALMOST looks like there is some sort of timing drift that is causing them to get inconsistent signal timing. I suspect that max brightness works fine since this is effectively all "1" values, where as the drift affects the signal more at intermediate levels, but this is just a guess.

I also have a very simple driver / e1.31 adapter I wrote before I found the ESPixelStick firmware. This driver is written using a synchronous e1.31 library and the NeoPixelBus library. This driver does not exhibit the flickering at any color level or range I have tested with. I have also successfully run a couple of sample shows with this setup and driven the LED's without issue.

I can probably get through this year with my basic Firmware, but I really like a lot of the functions provided by the ESPixelStick firmware, so I'd love to get that working if I can.

Any suggestions you can provide or places I can look or try to tweak to diagnose or address the flickering would be greatly appreciated (I'm more than willing to dive into the code, submit PR's, etc. as appropriate).

forkineye commented 5 years ago

So are you using a 5v buffer and the 330 ohm resistor following that or separate cases of each? Have you tried it direct from the NodeMCU with no buffer or resistor?

redwolf3 commented 5 years ago

@forkineye Sorry, I missed a couple of important things:

Here's what it looks like: NodeMCU <--> LLC <--> 330 ohm <--> ws2811 Input 1

I tried things without the logic-level converter and resistor when writing the NeoPixelBus-based firmware and received no output if it the LLC was not present. I saw no significant difference with or without the resistor (I believe this is just here for over voltage / current protection though).

I had similar issues with flickering when using the FastLED and NeoPixel libraries. When I was reviewing similar issues using those libraries they all reported issues with the ESP2866 modules I'm using due to the lack of hardware timers combined with the way they bit-banged to set the timing combined with contention from the WiFi module processing. That's what initially lead me to the NeoPixelBus library which has worked flawlessly with wireless on the NodeMCU and D1 mini.

I haven't tried using a 5v buffer in-place of the logic-level converter. I can try this as well if you think it might net different results.

NOTE: I'm on the road right now so won't be able to test anything in hardware for the next 5 days.

gjccat commented 5 years ago

I use the following circuit for 5v and 12v WS2811 and WS2812 Pixels, both the bullets and Strips. I run at various brightness

esp

redwolf3 commented 5 years ago

Thanks for the information and suggestions @forkineye and @gjccat

Based upon your feedback I tried removing the LLC (Logic-Level Converter) and the 330 Ohm resistor in all 4 possible combinations. Flickering occurred in all permutations. It seemed like there was slightly less flickering with both removed, but the flickering is pseudo-random so its hard to quantify.

Here's a video of the flickering I'm seeing on the NodeMCU 1.0: https://youtu.be/hQOySCpXBJU

redwolf3 commented 5 years ago

The only variance I can see between my setup and the diagram provided by @gjccat is that I'm powering mine off of a 5v input as opposed to 3.3v. I have some 3.3v converters on order so i'll try it with that once they are in.

I also tried things out with both a NodeMCU 1.0 and a Wemos D1 Mini. Both exhibit almost the exact same flickering.

I'm also wondering if different WiFi Security / Encryption types could cause issues. I'm using WPA Personal for WiFi security right now. I'm wondering if this security mode has more overhead than others. I will try playing with this next time I get a chance as well.

redwolf3 commented 5 years ago

I did a bunch of testing on several additional NodeMCU and Wemos D1 Mini units which yielded some different results, or at least some information.

The 4 original NodeMCU and Wemos D1 Mini's I was testing with all showed the Flickering issues consistently, regardless of hardware configuration, vin voltage, etc. I then flashed some simpler firmware I was testing on and noticed it exhibited the flickering at intermediate brightness with full speed (25 fps) animations with e1.31 but not at lower refresh rates. After toying around I found that reducing the update frequency by calling show() at a slower rate that the flickering went away.

I then went back to the ESPixelStick firmware and modified the refresh algorithm to add some additional delay between refreshes (calls to show()). Adding 30 uS seemed to solve the issue on all of my test units. One unit I was able to fix by just changing the refresh check from return (micros() - startTime) >= refreshTime; to return (micros() - startTime) > refreshTime;. Others seemed to need more delay to resolve.

I also bought a new batch of NodeMCU's (same brand, same seller, just a few new units) while doing this testing. I tested 4 of these new units and all of them worked perfectly fine with the ESPixelStick firmware out of the box with no issue. I was able to bump them up to full refresh rate with no issues or flickering.

The units that had issues with flickering did it even when driving via e1.31 or just using the Static Testing methods. The flickering on all of the problematic units was resolved in both modes by adding additional timing.

Based upon this it appears that there must be some variance in the clock accuracy of some of the ESP8266 units. Maybe the first batches I got just had issues, not sure.

Since the issue seems resolved for me (or I have found the source at least) I will close this issue out.

Thanks @forkineye and @gjccat for all the help!