Funny Colors
As others have observed with the neopixel library on #Arduino, I also had issues with wrong colors showing up with my Atrium software and my own WS2812b driver. Interestingly, the behavior was not consistent: the wrong color show showed up most of the time on the first LED, but sometimes on others as well. Above you can see that the first LED is green instead of red - that is not really what I wanted to see.
Digging a bit deeper, the behavior showed an interaction, with parallel running activity on the ESP. The protocol for the WS2812b is pretty timing sensitive - it requires correct timing in the sub microsecond range.
So I wondered, it it might be related to timing, and decided to force the timing sensitive routine into the IRAM of the controller. That way the code gets highest possible performance and much less jitter regarding the execution time. Usually code runs from an external flash ROM on ESP8266 that is attached via SPI and only the currently executed part is being cached in IRAM.
With that change all odd colors disappeared. That was more than a year ago. Only recently, I gave it another look, with an oscilloscope that I did not have at that time.
领英推荐
As you can see in the picture above the timing is incorrect for the first bits, when the code is executed from flash ROM. Forcing the code into IRAM made the timing highly accurate using an internal cyclic counter of the ESP8266.
The timing requirement for the high level of a zero bit is 400ns with a tolerance of plus/minus 150ns. Zooming into the measurement above shows that the timing created with the Atrium code on an ESP8266 is highly accurate.
By the way - in this example the 8 LEDs were run with a supply voltage of 3.3V, which is below the spec of 3.5V. Even with lower voltages the colors showed up correctly, only the intensity of the individual LEDs dropped below the expected brightness.
So from my experience the voltage does not matter. And some controllers are just less prone to timing problems. So, if funny colors show up on your WS2812b LEDs, check the timing of your software.
Happy hacking!