jgarff / rpi_ws281x

Userspace Raspberry Pi PWM library for WS281X LEDs
BSD 2-Clause "Simplified" License
1.78k stars 622 forks source link

Incorrect color output - fixed by setting LED count to double what it actually is #319

Open garrettrathbone opened 6 years ago

garrettrathbone commented 6 years ago

I've been having weird issues with the RGBW NeoPixel strip – LEDs flickering random colors, as well as having different intensities of colors that bring about reproducible-but-unexpected results - IE Color (0,0,0,127) makes LED 0 off, and LEDs 1 and 2 Green. When fading from Color(0,0,0,0) to Color(0,0,0,255), it starts fading white correctly up until around the 40% mark, then all shut off, then part of the LEDs go green (around the 127 mark), then all shut off again, then go back to all white and work correctly. Same with different intensities of different colors. It always seems that Green will be triggered every 3rd number or so.

Oddly, I fixed it by putting my LED_COUNT as double what it actually is. So if I have 3 LEDs, I state I have 6, and the problem goes away. Is there any rational explanation for this? I have them wired correctly with a 300 ohm resister in the data line, a 5v 15amp power supply with a 1000uh capacitor, and the grounds connected together.

Side note: I'd been having a hell of a time getting the LEDs to behave correctly before this. First they would flicker randomly and produce random results every other time I ran the script, they worked better when using the 5v directly from the pi, then once I started using a 5v 15amp power supply, it would immediately go bright white the second I even touched the data-line to connect it to the pi. Solved it by getting some insulating coating goop (Super Corona Dope), and coating the portion that I soldered on the back-side of the LEDs. I believe the amperage was so high that it was jumping to the data-line and faking a 1. So if this isn't a library issue, that's fine, I can keep playing with it. Just seems odd that it's continually reproducible and can be solved by tricking the library.

penfold42 commented 6 years ago

What level shifter are you using ?

VictorioBerra commented 6 years ago

I am having the exact same problem but i have not been able to fix it.

shifter.

LEDs.

VictorioBerra commented 6 years ago

Got it! I was NOT SUPPOSED TO GROUND THIS WIRE

image

I found this by consulting the ebay pinout and got lucky that I could understand it.

VictorioBerra commented 6 years ago

Still not perfect... I have one LED green for some reason and some LEDs are purple. I tried to set them all to one solid color.

image

VictorioBerra commented 6 years ago

I put the ground back because I think I actually do need it. No matter what I try I am not able to get a smooth animation with a uniform color.

penfold42 commented 6 years ago

Pins 4.5.13. 12. 10 and 9 should also be grounded. Unused inputs should always be tied high or low and not left floating.

Try changing the led frequency to 400khz instead of 800khz

VictorioBerra commented 6 years ago

To clairfy you mean those pins on the level shifter right?

VictorioBerra commented 6 years ago

Do I have to recompile after editing the main.c to adjust the frequency or can I just change it in the python test scripts?

penfold42 commented 6 years ago

Yes the pins on the 74hct125

Strandtest.py can just be edited and run.

If you are using the c example, you will need to recompile it

garrettrathbone commented 6 years ago

@penfold42 I'm using the 8-channel bidirectional level shifter from Adafruit.

Like I had said before, it's odd but reproducible, which made me think it could somehow be library related (like maybe the library alters the signal or bits based on how many are listed as in the LED string?). I haven't had a chance to test the LED_COUNT issue since I solidified my layout on a chip and soldered it in yesterday. I ran a test to see if the LEDs lit correctly with the double-LED_COUNT-hack (they did) and then ended up leaving for a few days on vacation.

penfold42 commented 6 years ago

From memory, they don’t like driving long lines. I think they’re designed for chip to chip on a PCB.

Can you try a 74HCT series chip like a 74HCT125

pwr33 commented 5 years ago

I was having problems running on the spi pin, at 3.3v with 2 rgb leds, not working, was odd colour shifting, I set the number of pixels to 4 and an odd improvement, different colours, I set the number of pixels to 8 and it works! (with my two pixels)