barretto
Posts: 1
Joined: Wed Jan 15, 2020 2:50 am

Glitchy WS2812B LEDs

Wed Jan 15, 2020 3:16 am

Hi!

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.

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.

Code: Select all

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.2V
4. I've found an article (https://ben.artins.org/electronics/glitchy-neopixels/) 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!

User avatar
Burngate
Posts: 6160
Joined: Thu Sep 29, 2011 4:34 pm
Location: Berkshire UK Tralfamadore
Contact: Website

Re: Glitchy WS2812B LEDs

Wed Jan 15, 2020 11:29 am

barretto wrote:
Wed Jan 15, 2020 3:16 am
...
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!
Dropping the 60A 5.3V to 4.7V wastes a lot of power, so not a good route to go down

Raising the data voltage can easily be done - have a look on google for "bidirectional level shifter circuit"

njh
Posts: 44
Joined: Wed Aug 09, 2017 2:07 pm

Re: Glitchy WS2812B LEDs

Wed Jan 15, 2020 11:57 am

  • Doesn't need to be bidirectional in this case -- a 74[A]HCT125 should do the trick. Tie unused inputs to GND, the used OE/ to GND, and pull the used data line to GND as well using a large-value resistor.
  • In general a non-inverting level shifter circuit will be more compatible with existing software than an inverting one.
  • Don't mix up the 3.3V and 5V domains or the Pi will fry. If you power the Pi from the same 5V supply, take care with the wiring to avoid loops or anything that could allow large currents to flow through the Pi.

User avatar
Burngate
Posts: 6160
Joined: Thu Sep 29, 2011 4:34 pm
Location: Berkshire UK Tralfamadore
Contact: Website

Re: Glitchy WS2812B LEDs

Thu Jan 16, 2020 10:09 am

Don't want to start an argument, here, but the question was "Can I use transistors".
A single FET is a transistor, though a couple of resistors are also needed!

A 74HCT125 also contains transistors, of course, so fits the bill, but just seems rather overkill for this job.

Otherwise, you're absolutely correct.

njh
Posts: 44
Joined: Wed Aug 09, 2017 2:07 pm

Re: Glitchy WS2812B LEDs

Thu Jan 16, 2020 2:24 pm

Ah, you're right - I suggested a buffer partly because it's buffered, but mostly because it's easier (for me at least) to understand than the FET circuit!

Return to “Troubleshooting”