Glitchy WS2812B LEDs

I'm very sorry to post something related to Raspberry Pi here, but the main questions are about electronics and droping voltage or increasing data line voltage. Please read and help if you can.

I'm currently developing a project where I'm controlling 1012 WS2812B LEDs using a raspberry pi 3 B and I'm having an annoying issue where my LEDs keep glitching. For example, if I drive all the LEDs green at the same time, they flick or chunks glitch blue or some LEDs turn red for a few microseconds. I've tested with an Arduino and I don't have the same issue, but since the Arduino has much less memory it is much more hard to create interactive animations, so I've switched to rasp and I'm using pygame to render things and then sending screen pixel values to the LEDs.

This is my setup:

  • Rasp 3 B
  • 1012 WS2812b connected as a stripe
  • External 5V 70A power supply
  • Infrared sensor (this is irrelevant to the problem, since LEDs flick even without using the sensor)

This is a sample blinking code, that illustrates something that is enough to make my LEDs glitch.

import board
import neopixel
import time

pixel_pin = board.D18

num_pixels = 1012
color = 0

pixels = neopixel.NeoPixel(pixel_pin, num_pixels, brightness=0.5, auto_write=False, pixel_order=neopixel.GRB)

while True:
    pixels.fill((0, 255, 0))
    pixels.show()
    time.sleep(1)
    pixels.fill((0,0,0))
    pixels.show()
    time.sleep(0.2)

Well, I did my troubleshooting as follows:

  1. Yes, the GNDs are all connected (external power supply, LEDs and Rasp), checked continuity with multimeter and they are, indeed, all connected;
  2. Tried a similar code using Arduino and they all blink fine, no gliches so the LEDs are ok;
  3. Tested power supply and its delivering steady 5.3V
  4. I've found an article (Staccato Signals: Avoiding NeoPixel glitches) that says:

The root of the problem here is that — according to the NeoPixel data sheets — the NeoPixel data line voltage (in logic-high state) has to be at least 0.7× the NeoPixel power voltage.
5. LEDs drive 60mA when at full power, so at most they will draw 60.72A
6. External power supply has 3 connectors for GND and 5V and I've divided the LEDs almost equally in 7 groups/lines connected to VCC and GND even though they are all connected through Dout->Din. They are all connected to the same power supply, I've just tried balanced the current going through the cables.

In other words, the power voltage has to be at most 1.43× (= 1 / 0.7×) of the data line voltage. Therefore, if the data line is at 3.3V, then the highest voltage you can put on the power line and still have a reliable NeoPixels is 1.43 × 3.3V = 4.71V.

As a result, if your NeoPixel power is close to 4.7V, the NeoPixels will be unreliable in interpreting its data line, resulting in flicker and random color changes.

It seems to me, until now, that I have only two ways to go from here:

  1. Match my data line voltage to at least ~3.7V (70% of my 5.3V power supply )
  2. Match my LEDs VCC to maximum ~4.7V (143% of my 3.3V data line voltage)

So, I know that sometimes making things simple are not possible but I would like to keep it as simple as possible. Main questions are:

  1. Can I use transistors to match my data line voltage to something close to 5V?
  2. How can I drop my current from 5.3V to 4.7V, considering it might draw 60A? Diodes drop more voltage as more current is drawn, right? Rectifiers?

Any other ideas, hints and thoughts are much well appreciated!

Cheers!

Hi and welcome to the forum.

Do you have a 250~500R resistor on the data line? Do you have large caps across the power lines at the start of the strip and at each point you inject power supply along the strip? If you have those things then I suggest you use 74hc14 as a logic level shifter to boost the data signal up to ~5V. The logic level shifters sold for use boosting i2c circuits are not fast enough for ws2812b.

I would recommend 74hct244, the t in the name is rather important. Two gates in series from a 74hct14 can also do the job.

HKJ-lygte:
I would recommend 74hct244, the t in the name is rather important. Two gates in series from a 74hct14 can also do the job.

But I would suggest they are not. I have had many projects published in the MagPi magazine that use WS2812 LEDs ( Mike’s Pi Bakery ) and I have found that the 74HC14, 74HCT14 and even the 74LS14 will all work fine. In fact the latest issue of the MagPi, Jan 2020 has the circuit in it along with a physical layout, as did Dec 2019. Available as a PDF to download free on line, or in the shops for money.

Can I use transistors to match my data line voltage to something close to 5V?

You can but at the frequency they are used at then not any old transistor will do. It is a bit of a tricky design that needs an oscilloscope to see if you have it right.

How can I drop my current from 5.3V to 4.7V, considering it might draw 60A?

Put a software brightness limit on the LEDs. This is applied globally and is very effective. Do not use a diode to drop the supply voltage, because it will have to be enormous at that sort of current, and you will then be driving the strip with a voltage greater than the supply, something you should not do long term.

Grumpy_Mike:
But I would suggest they are not. I have had many projects published in the MagPi magazine that use WS2812 LEDs ( Mike’s Pi Bakery ) and I have found that the 74HC14, 74HCT14 and even the 74LS14 will all work fine. In fact the latest issue of the MagPi, Jan 2020 has the circuit in it along with a physical layout, as did Dec 2019. Available as a PDF to download free on line, or in the shops for money.

Typically it will work, but it is borderline according to the specifications in the same way as using a WS2812 from a 3.3V processor is borderline. Publishing bad designs is sadly something many magazines do.
A HCT will always be well within specifications when using it to translate from a 3.3V level to a 5V level.

Look again at those specifications, we are talking about the threshold on a 14 buffer, not the general TTL input specifications.

Grumpy_Mike:
Look again at those specifications, we are talking about the threshold on a 14 buffer, not the general TTL input specifications.

They are not specified at 5V, but at 4.5V voltage must be above 3.15V and at 6V above 4.2V, this is in both cases 70% of Vcc and would be 3.5V with 5V supply (More correctly it would have to be calculated for 5.25V and there it is 3.68V). This is rather difficult to reach with a 3.3V chip.

CMOS inputs usually works at around 50% of Vcc, but to stay within specifications you usually have to secure that low is below 30% of Vcc and high above 70% of Vcc.
HCT is different and are closer to general TTL inputs in voltage levels, that is the reason they work fine with 3.3V outputs.

It's been quite a while since I worked with Raspberries. I use them for my MQTT broker, Node Red and Home Assistant. But all of my projects have been on an Arduino or similar boards like the NodeMCU and Wemos D1 Mini.

For buffering, I use the SN74LS244N Octal buffer / Line driver. Mostly because I had a bunch in my parts box.

The WS28xx datasheet shows the minimum voltage for the data line is 3.5V, so it may or may not work with a 3V3 processor. If the first LED works, then subsequent LEDs will also because each WS28xx chip sends a new data signal to the next, at the proper voltage.

If the LED flickering seems to be at random, then you have a timing issue.
If the LED flickerings begin at the same LED on the strip or string, then the first failing LED is bad.

This past Christmas, I had such random flickering that developed days after putting the project into a box under the tree. Christmas Eve, to be exact. I finally traced the problem to a bad IC socket. I removed the socket and soldered the '244 chip to the board and the problem went away.

You don't say which Arduino you tried to use, but if it were the Uno, then you only have 2 kB of RAM, and you have to have some RAM for the program to use. For my LED strip (or string) projects, I use the Wemos D1 mini because it is Arduino IDE compatible, has 4MB of RAM, plus WiFi (which allows OTA programming). Plus a SN74LS244N Octal buffer.

And the Wemos is only $5. You can buy seven of them for the price of a single Pi 3B. (That's another reason most of my projects are on the Wemos D1 Mini).