Flickering Neopixels WS2812B

I am working on a WordClock. First, I want to give you all the details needed and then I will ask my question. So, for this WordClock I used the Arduino with the FastLED library. I made a PCB (350 x 350 mm) on which I positioned the 90 Neopixels (WS2812B). I am using a DS3231 RTC for the time. Currently, I am testing all of this on a breadboard. Because of 90 LEDs I have two power injections: in the middle and at the end (and of course the one at the beginning). For the data line, I use two 220 ohm resistors in series and I have a 1000 uF capacitor on the 5 V and ground rails. I also use a 5 V / 2 A power supply (I have common round everywhere). The Arduino is powered from my laptop. When I turn on all LEDs, it works perfectly fine. Now, here is the problem: Say for example, it is 12 o’clock. For the word ‘twelve’ to light up, the LEDs at the bottom should turn on. They do turn on, but they have this effect of flickering. See the video.

In short: The LEDS which are further from the data-input are flickering.

I did my research on this. First of all, I thought maybe the LEDs at the end do not get enough voltage (because voltage drop occurs). Therefore, I added two injections, at the middle and end, but this didn’t help the problem of flickering. Then, I came across a lot of people with the same questions on other forums. Most of them solved the problem with these lines of code:

#define FASTLED_ALLOW_INTERRUPTS 0
#define FASTLED_INTERRUPT_RETRY_COUNT 0

But these also didn’t help me.

Let me tell you how my code works now:

I made if-statements for each time and in the statements, I put which LEDs should turn on. I put all of these if-statements in a function called “tijdsWeergave”. Then in the loop, the first thing is to convert the string data from the DS3231 library to integers. After that, I call the “tijdsWeergave” function and add a delay of 1000 ms. It seems like, every 1000 ms it flickers. If I use 10000 ms, it flickers every 10000 ms. Does anyone know how I can fix this problem?

Here is my a part of the Arduino Code (I let you guys see a part, because it is all the same code over and over again. One picture of the setup and loop, and also one picture with an example of how all the if-statements work.

You can find my code here: https://codeshare.io/GABKYE

I hope I gave you all the information needed to answer my question.
I know this has nothing to do with KiCad, but I already asked a few questions here about the PCB I designed for this WordClock. And I didn’t get any reply on the Electrical Engineering StackExchange.

Thanks in advance,
Hilmi

This is not the right forum to ask stuff like this. We are a support forum for the pcb design tool KiCad not a generic electronics design forum and most definitely not a arduino support forum.

Yeah, sorry. How can I delete this? I was too desperate because it just doesn’t work.

It can stay here. My guess is that if somebody truly knows something then they might help you anyways. But in reallity you will be much better of asking at a place where more people with general electronics knowledge and especially arduino knowledge are found. Something like stack exchange electronics, eevblog or even the arduino forum.

2 Likes

No where close!

You are guessing that the problem could be voltage, or even, code deviations.

What you really need to solve this problem is an oscilloscope.

But, there are a couple of suggestions I throw out there.

You might try the recommended decoupling cap on each NeoPixel (or a 0.1”F cap) input lead as close to the lead as possible.

You can try slowing the code down so that you can watch the effect of the code on each NeoPixel.

2 Likes

Guys at AVRfreaks.net are happy to answer such questions.
My best guess s it’s some timing issue in the software.
WS2812 is a quite finicky protocol with 800kHz timing issues.
For that a EUR 7 Logic analyser is a great tool to diagnose such things.
Search Ali / Ebay / China for “8ch 24MHz” and use that LA with Sigrok + Pulseview.

If you have signal integrity issues in the analog domain, you need a DSO. I seem to recall the WS2812 buffers and re-sends the data, which would lessen analog problems, but maybe timing gets worse. It might be fun to see the buffering and delays on a LA.

1 Like

Thank you man, I never thought of this! I don’t know if this will solve the problem, but I definetely need those caps on each neopixel.

Thanks, I will sign up on AVRfreaks and post my problem over there. I also read about a timing issue. A lot of people solved there problem with some few extra lines of code, but these did not help me. Maybe the decoupling caps as Sprig said.

WS2812 definately need decoupling caps.
When these are missing then getting into worse trouble the farther you go from the power supply will be a logical result. Put on those caps first.

Just glazed over the code from my phone.
Is it nescessary to do the Fastled.clear(), before doing .show()? Perhaps try outcommenting Fastled.clear
If it is nescessary, it would probably be better to have clear right before show

This is a concept that some don’t quite get. Why is “clear” any different than “showing” nothing?

I don’t know what the FastLED library is using in the hardware, but if it is the Atmega SPI hardware interface, there is a specific timer that the SPI hardware uses. This timer does not roll over in sync with the main timer.

Yes, tho I notice world-semi have some variants that now include the cap inside the package.
http://www.world-semi.com/solution/list-4-1.html

1 Like

That’s where I’d start . . . . but then, once upon a time, my business cards gave my title as “Analog Artisan”. At the very least, a 'scope will quickly tell you whether or not there is a problem related to the supply voltage.

It may be helpful to kludge a circuit that detects the flickering, so the 'scope can show whether the flickering is correlated to other things. A phototransistor, photocell salvaged from an old camera, or even an LED operated as a photodiode can create a signal related to the flickering.

Hopefully, @hilmi28 has a spare pin on the microcontroller that can be toggled at specific points in the code to discover when, during the execution sequence, the Neopixels dim (or brighten).

If the flickering seems to track with the microcontroller’s clock frequency it might be possible to isolate the problem by single-stepping through the code, or executing up t carefully placed breakpoints.

Dale

If I don’t include FastLED.clear, it remembers the LEDs that were on, thus everything gets mixed. Thanks

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.