Arduino Forum

Using Arduino => LEDs and Multiplexing => Topic started by: 3615gregoire on Dec 03, 2017, 12:12 am

Title: WS2812B Wrong colors
Post by: 3615gregoire on Dec 03, 2017, 12:12 am
Hi!

I am making a project from instructable  Arduino Powered Headdress (https://www.instructables.com/id/Arduino-Powered-Headdress/)

Most of the LEDs are not producing the expecting colors. On the picture attached, all LEDs should be green.

There are 88 LEDs : 2 strips of 11 (the eyes), and 1 strip of 66 (the dome)

Only the eyes and 5 groups of 2 in the front are consistently correct, all other ones are consistently the wrong colors.
Since the issue is with the same LEDs with different programs, I concluded that it was a hardware problem, so I swapped a "correct" one with a "wrong" one, and the issue is at the same place, meaning that the LED or the wiring is probably not at fault
Only with 100% white I can get all LEDs the same color.

- I use a mix of  those two products:
Amazon (https://www.amazon.de/dp/B01M6WVCW3/ref=pe_3044161_189395811_TE_dp_1)
and
Amazon (https://www.amazon.de/dp/B01N4VUJVJ/ref=pe_3044161_189395811_TE_3p_dp_1)

- The board is a Arduino pro mini atmega328 p 5V

- Schematics:
(https://cdn.instructables.com/F1Y/5MQ9/J0MOMHRP/F1Y5MQ9J0MOMHRP.MEDIUM.jpg)

- The code (error is the same with all the other codes)
Code: [Select]

// NeoPixel Ring simple sketch (c) 2013 Shae Erisson
// released under the GPLv3 license to match the rest of the AdaFruit NeoPixel library

#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
  #include <avr/power.h>
#endif

// Which pin on the Arduino is connected to the NeoPixels?
// On a Trinket or Gemma we suggest changing this to 1
#define PIN            6

// How many NeoPixels are attached to the Arduino?
#define NUMPIXELS      88

// When we setup the NeoPixel library, we tell it how many pixels, and which pin to use to send signals.
// Note that for older NeoPixel strips you might need to change the third parameter--see the strandtest
// example for more information on possible values.
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);

int delayval = 10; // delay for half a second

void setup() {
  
  pixels.begin(); // This initializes the NeoPixel library.
}

void loop() {

  // For a set of NeoPixels the first NeoPixel is 0, second is 1, all the way up to the count of pixels minus one.

  for(int i=0;i<NUMPIXELS;i++){

    // pixels.Color takes RGB values, from 0,0,0 up to 255,255,255
    pixels.setPixelColor(i, pixels.Color(0,150,0)); // Moderately bright green color.

    pixels.show(); // This sends the updated pixel color to the hardware.

    delay(delayval); // Delay for a period of time (in milliseconds).

  }
}


The instructable mentions:
According to the Neopixel online guide it specifies 1000uF capacitors on the live and ground lines and a 300-ohm resistor on the signal lines, I have omitted these in my build by mistake, it has not affected the lights in any way but you may want to add them to be sure on your build.
Can it be the issue?



Any help appreciated!


Title: Re: WS2812B Wrong colors
Post by: larryd on Dec 03, 2017, 12:50 am
Measure the voltage to the strips and controller.
What do you get?


The series 330Ω resistor and the 1000μF capacitor is to protect the neopixels strips from damage.


.
Title: Re: WS2812B Wrong colors
Post by: 3615gregoire on Dec 03, 2017, 11:19 am
I get  5.7V at the controller, 5.5V at the beginning of the main dome strip, and 5.1V at the middle.

Title: Re: WS2812B Wrong colors
Post by: Grumpy_Mike on Dec 03, 2017, 03:18 pm
Quote
it has not affected the lights in any way
Not only is he a normal idiot that many Instructables authors are, he is arrogant as well. Of course it has affected his lights, it is just that he is too stupid to do the tests that show this and probably hasn't got the equipment nor skill to use it.

This shows what the waveform looks like with and without the resistor. See those spikes? Each one is punching a tiny hole in the oxide layer of the LED controller and eventually it will fail.

(https://forum.arduino.cc/index.php?action=dlattach;topic=514957.0;attach=235895)


Their is a lot more to electronics than something appearing to work, that is why we put out good advice only for idiots to think it dosn't matter.

By the way your colour problem has its roots in the fact that some strips need RGB colour order and others need GRB colour order. It looks like the code and your hardware do not match, normally you just need to change your code so they do. But this idiot has wired all three strips to the same pin, so you will have to wire each strip to a different pin and then write the code to output to each strip holding a different pattern ( RGB or GBR ) to suit the hardware you have. He should have done that in the first place so the colours would be more flexible.

Nice photo by the way.
Title: Re: WS2812B Wrong colors
Post by: 3615gregoire on Dec 03, 2017, 05:41 pm
Thanks for replying Grumpy Mike,

I think your comment is harsh: he has generously shared his build, and specified that he was not a arduino specialist. He is certainly not arrogant, and calling him an idiot is not very nice.

Thanks for explaining why the resistors are necessary, I'll add them.

I think the RGB / GBR is not the issue here: I use 2 different kind of LED, since the color in the program is 0,150,0 I should have Green and Blue lights. instead I get red, white blue and more on both types of LEDs.

Can it be that the data is corrupted because of the lack of resistor / capacitor?
Title: Re: WS2812B Wrong colors
Post by: larryd on Dec 03, 2017, 05:52 pm
Do not omit the capacitor!

It absorbs power spikes on power up (without it, you may see LEDs flicker when turned on, causing damage).

Colours could be affected without these if you have damaged the pixels without using them.

Show us a good image of your wiring.


.
Title: Re: WS2812B Wrong colors
Post by: 3615gregoire on Dec 03, 2017, 06:05 pm
Thanks Larryd!

I'll add the resistors and capacitors asap.

I don't think the color issue is due to damaged LEDs since I swapped the 1st and the 2nd ones on the main main dome strip and colors are wrong the same way: it's position-related.

I can't really give a better image of the wiring: it's crammed in a box. What do you need to know that is not on the drawing in the first post?
Title: Re: WS2812B Wrong colors
Post by: larryd on Dec 03, 2017, 06:23 pm
Often we find out, too late, that things are not wired as in a schematic.

Did you try the things mentioned by Mike?


.
Title: Re: WS2812B Wrong colors
Post by: 3615gregoire on Dec 03, 2017, 06:46 pm
Quote
Often we find out, too late, that things are not wired as in a schematic.
Fair enough! It will be difficult to check, but we are making a second helmet, we will see if we have the same issue.


Quote
Did you try the things mentioned by Mike?
He mentioned the capacitor and resistor, which I will do as soon as I receive it and using both RGB and BRG LEDs, which can't be the issue.
Title: Re: WS2812B Wrong colors
Post by: Grumpy_Mike on Dec 03, 2017, 07:17 pm
Quote
Can it be that the data is corrupted because of the lack of resistor / capacitor?
No.
It is because of what I said in reply #3 in the next but last paragraph.

Quote
he has generously shared his build, and specified that he was not a arduino specialist.
So getting you to build crap is OK because he said he was not a specialist. In my book it is arrogance to even think he can tell anyone how to build any electronics when he knows so little. If he had any decency he would have asked here about his circuit first.

Did you know you need a resistor for each of your LED strips, not one for all three?
Title: Re: WS2812B Wrong colors
Post by: larryd on Dec 03, 2017, 07:54 pm
I get  5.7V at the controller, 5.5V at the beginning of the main dome strip, and 5.1V at the middle.
5.7 volts is too high at the controller power pin.


Title: Re: WS2812B Wrong colors
Post by: 3615gregoire on Dec 03, 2017, 11:21 pm

Quote
Did you know you need a resistor for each of your LED strips, not one for all three?
Yes, thank you!


Quote
It is because of what I said in reply #3 in the next but last paragraph.
The RGB / GBR difference between the 2 kind of LEDs? Then how come I get different colors on BOTH types of LEDs?
The only color in the code is 0,150,0, and for both kind of LEDs, I get some green, some blue, some red and some white.

If it was the issue, one kind of LED would be green, the other one blue, or am I missing something? (which could very well be).
Title: Re: WS2812B Wrong colors
Post by: 3615gregoire on Dec 03, 2017, 11:29 pm
Quote
5.7 volts is too high at the controller power pin.
Thanks, I changed the setting on the buck converter to have 5V.
Title: Re: WS2812B Wrong colors
Post by: Grumpy_Mike on Dec 04, 2017, 12:11 am
Ok then strip it back, just try a code that simply fills one strip with the same colour, green will do. Post that code so we can look at it. And say what number led gives what colour.

Are you using a real Arduino Pro Mini or is it a ripoff clone?
Title: Re: WS2812B Wrong colors
Post by: 3615gregoire on Dec 04, 2017, 11:22 pm
Quote
Ok then strip it back, just try a code that simply fills one strip with the same colour, green will do. Post that code so we can look at it. And say what number led gives what colour.
I have tried on my girlfriend's helmet, which is the a similar build, and we have temporarily connected only the main dome, so 1 strip, 1 color (0,150,0)  in the program, and we also get multiple colors displayed.


On my helmet:
Strip 1 (eye): 11 LEDs, all green
Strip 2 (eye): 11 LEDs, all green
Strip 3 (main dome) 66 LEDs:
LED:   Color:
0   White
1   Blue
2   Red
3   White
4   Blue
5   Red
6   Green
7   Green
8   Green
9   Green
10   Green
11   Green
12   Green
13   Green
14   Green
15   Green
16   White
17   Blue
18   red
19   White
20   Blue
21   red
22   white
23   blue
24   red
25   white
26   blue
27   red
28   white
29   blue
30   red
31   white
32   blue
33   red
34   white
35   blue
36   red
37   white
38   blue
39   blue
40   white
41   blue
42   red
43   white
44   blue
45   red
46   white
47   blue
48   blue
49   blue
50   blue
51   blue
52   blue
53   blue
54   blue
55   blue
56   blue
57   blue
58   blue
59   blue
60   blue
61   red
62   red
63   red
64   red
65   white


Code is still the simple one, with only one color (other codes tried give unexpected colors, with only 6 to 15 being right):

Code: [Select]
// NeoPixel Ring simple sketch (c) 2013 Shae Erisson
// released under the GPLv3 license to match the rest of the AdaFruit NeoPixel library

#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
  #include <avr/power.h>
#endif

// Which pin on the Arduino is connected to the NeoPixels?
// On a Trinket or Gemma we suggest changing this to 1
#define PIN            6

// How many NeoPixels are attached to the Arduino?
#define NUMPIXELS      88

// When we setup the NeoPixel library, we tell it how many pixels, and which pin to use to send signals.
// Note that for older NeoPixel strips you might need to change the third parameter--see the strandtest
// example for more information on possible values.
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);

int delayval = 10; // delay for half a second

void setup() {
  // This is for Trinket 5V 16MHz, you can remove these three lines if you are not using a Trinket
#if defined (__AVR_ATtiny85__)
  if (F_CPU == 16000000) clock_prescale_set(clock_div_1);
#endif
  // End of trinket special code

  pixels.begin(); // This initializes the NeoPixel library.
}

void loop() {

  // For a set of NeoPixels the first NeoPixel is 0, second is 1, all the way up to the count of pixels minus one.

  for(int i=0;i<NUMPIXELS;i++){

    // pixels.Color takes RGB values, from 0,0,0 up to 255,255,255
    pixels.setPixelColor(i, pixels.Color(0,150,0)); // Moderately bright green color.

    pixels.show(); // This sends the updated pixel color to the hardware.

    delay(delayval); // Delay for a period of time (in milliseconds).

  }
}





Quote
Are you using a real Arduino Pro Mini or is it a ripoff clone?
I use generic ones, I have tried with two makes with the same results:
This one (https://www.banggood.com/Wholesale-New-Ver-Pro-Mini-ATMEGA328-328p-5V-16MHz-Arduino-Compatible-Nano-Size-p-68534.html?rmmds=search&cur_warehouse=UK) and this one. (https://benselectronics.nl/arduino-pro-mini-atmega328-p-5v/)

Thank you for the help!
Title: Re: WS2812B Wrong colors
Post by: Grumpy_Mike on Dec 05, 2017, 12:21 am
Thanks for that. Yes those two boards are fakes so their might be a quality issue here.

Can you do some tests for me as I have not got your system?
With only the long strip connected reduce the green value from 150 down to 8. Now disconnect the wire from your boost converter to the 5V line of the Micro and power it from the USB socket of your computer, does it show all green now?
Title: Re: WS2812B Wrong colors
Post by: 3615gregoire on Dec 06, 2017, 11:52 pm
Thank for your continued help Mike.

As suggested, I have:
- Disconnected the eyes strips
- Added a capacitor on the power to the LEDs strip
- Added a resistor on the Data cable
- Disconnected the power cables from the converter
- Changed the program for color: 0,8,0
- Power the system from USB


The color sequence is the same as before, at least for the 15 first LEDs (I haven't checked them further one by one).

We have done the same on my girlfriend's helmet, she as also a string of different colors. We use 2 different makes of the Mini Pro.

I'll be away from home for a week, but if you have more suggestions, I'll be happy to try more.
Title: Re: WS2812B Wrong colors
Post by: Grumpy_Mike on Dec 07, 2017, 10:10 am
Quote
We use 2 different makes of the Mini Pro.
Are any of these real or are they both ripoffs?

Do you have any other sorts of Arduino you can try?
Title: Re: WS2812B Wrong colors
Post by: 3615gregoire on Dec 07, 2017, 11:55 am
They are both not original. I can't seem to find an original for sale online since it has been been discontinued.


I'm going to try to simplify further: reduce the length of the cable, maybe also the length of the strip.
Title: Re: WS2812B Wrong colors
Post by: Grumpy_Mike on Dec 07, 2017, 10:12 pm
Well I set up a Pro Micro and ran your code in reply #14. This is what I got.

(http://forum.arduino.cc/index.php?action=dlattach;topic=514957.0;attach=236486)
So I am not seeing the same issue as you.

If I have got this right then with two strips connected, a short one and a long one, both on the same pin. Are you getting all 11 of the short strip green but the first 11 ( at least ) of the long strip different colours? That seems to suggest you have a problem with the long LED strip rather than the code or timing.

I notice from the schematic of the Pro Mini that it could be fitted with a 8, 16 or 20 MHz crystal. What is fitted on yours, it should be marked on the top.
Title: Re: WS2812B Wrong colors
Post by: 3615gregoire on Dec 18, 2017, 05:15 pm
Sorry for the long silence, I was away from home.

I found what the issue is: it's one of the 2 kinds of LED that I purchased that creates it...
individual LEDs (https://www.amazon.de/dp/B01M6WVCW3/)

I have replaced them by the other model (LED strip (https://www.amazon.de/dp/B01N4VUJVJ/)), and voila...

I though it was not the hardware because:
- Some from the strip also had wrong colors. I suppose the signal was polluted though the individual LEDs?
- When I swapped the 2 first individual LEDs, the wrong colors remained the same, according to their position, not to the LEDs itself.

Thank you very much for your help Mike!

Title: Re: WS2812B Wrong colors
Post by: Grumpy_Mike on Dec 18, 2017, 08:40 pm
Quote
Thank you very much for your help Mike!
Your very welcome, and thanks for the feedback to conclude this thread. Often people just leave things hanging, or just say it is solved without saying why.
Title: Re: WS2812B Wrong colors
Post by: larsdav on Apr 11, 2019, 03:05 am
I know this is an old post - But I wanted to seal it up so people knew what the problem was.  I am 99% sure you were using RGBW (note, the forth LED, WHITE).  That will then create a chain of issues since you need to send FOUR individual codes per LED.  It chains over to the next one in line, and goes forever. 
Title: Re: WS2812B Wrong colors
Post by: Pete-Repeat on Aug 02, 2020, 12:13 am
Just adding to this rather than creating a new thread. But one of my strip is showing randomly wrong colour leds, however only when below 50 percent brightness. If I fade it down then some led stay in brightly with the wrong colours. If I put full brightness and then reduce then the colours are all as expected until the brightness get low again.

This is only on one strip, my other strip with the same code is perfectly fine.

I have a 1000uF cap on the +/- supply of the strip. I have a 220 ohm resistor on the data pin of the strip. All cable lengths are reasonably short.

I believe the supply is just over 5V at the start (5.15V off memory) and very close on 5V at the end.

Should I look at my power supply, changing my resistor or looking at using a new gitial pin.

Its a buy of a pain to change things in situ which is why I haven't tried these things yet.
Title: Re: WS2812B Wrong colors
Post by: Grumpy_Mike on Aug 02, 2020, 07:35 am
Quote
This is only on one strip, my other strip with the same code is perfectly fine.
Look to see if this strip has a ceramic capacitor on every LED. I once got a strip that only had them fitted on every eighth LED.
Title: Re: WS2812B Wrong colors
Post by: Pete-Repeat on Aug 03, 2020, 07:33 am
I cut a 5m strip in half at the cut marks and made thr two strip's. So each strip is the same, other than the one working 100 percent running off a lab power supply with no capacitor or resistors yet, and the one not working right when dimmed down running off a plug pack however has the capacitor and resistor in it... I had hoped addimg the capacitor and resistor would fix it but it made no difference to random wrong pixel colour (or individual pixels night when the rest are off).

I will check about the capacitors on the strip however.

As the led work fine at 50 percent and upwards in brightness I was thinking that the strip isn't damaged and it's not to do with voltage drop. But this is an uneducated stab at the problem.
Title: Re: WS2812B Wrong colors
Post by: Grumpy_Mike on Aug 03, 2020, 04:03 pm
Quote
and the one not working right when dimmed down running off a plug pack
I am assuming that a plug pack is some sort of power supply. I am also assuming that the ground of this plug pack is also connected to the ground of the Arduino and the +ve is only connected to this second strip.
Is this correct?

Quote
running off a lab power supply with no capacitor or resistors yet,
Well put them in as soon as.
Title: Plug pack
Post by: Paul__B on Aug 04, 2020, 12:20 pm
I am assuming that a plug pack is some sort of power supply.
(https://atlasgentech.co.nz/media/catalog/product/cache/1/image/9df78eab33525d08d6e5fb8d27136e95/a/c/accessories_50144_12vdc_1_amp_plug_pack_web.jpg) (https://en.wikipedia.org/wiki/AC_adapter)
Title: Re: WS2812B Wrong colors
Post by: Pete-Repeat on Aug 05, 2020, 10:50 am
I am also assuming that the ground of this plug pack is also connected to the ground of the Arduino and the +ve is only connected to this second strip.
Yes common ground for the strip and the wemos.  The positive of the supply is only powering the wemos mini and the strip it's controlling.

Well put them in as soon as.
Yes that is the plan before I keep using them. However thats the strip with no problems. But I realise that over time it could damage them.

I am assuming that a plug pack is some sort of power supply.
Yes like linked above. I haven't checked is it's regulated or switch mode... I know it's not an unregulated supply though.
Title: Re: WS2812B Wrong colors
Post by: Grumpy_Mike on Aug 05, 2020, 10:52 am
Quote
I haven't checked is it's regulated or switch mode... I know it's not an unregulated supply though.
It will be a switch mode supply given the size and weight.
Title: Re: WS2812B Wrong colors
Post by: Pete-Repeat on Aug 05, 2020, 11:06 am
Any thoughts why it's only a problem at lower brightness or off? Could it be a data line issue?? Or perhaps the strip is damaged? Although seeing it works perfectly fine at the higher brightness makes me think power and the leds plus drivers are ok? This is a question not a statement as obviously I'm not too sure.

Maybe I try a different value resistor or maybe try a different digital out or perhaps borrow the esp8266 from the strip working properly? Problem is I may need to pull the strip's down and unsolder plus resolder so I'm a little hesitant unless there is reason for the problems to only be at the lower brightness or off for me to do that.