help with WS2812B LED

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Mohammedabujarad
Posts: 14
Joined: Wed Mar 25, 2020 12:35 am

Re: help with WS2812B LED

Post by Mohammedabujarad » Sun Apr 26, 2020 5:39 am

OutoftheBOTS_ wrote:
Sun Apr 26, 2020 3:43 am
I have always been able to get any addressable RGB LED strip to work without needing a 3.3v to 5v level shifter but I haven't used every single LED strip ever made so some out there may have problems with 3.3v.

Every single time I have had trouble with getting an addressable RGB LED strip to work it has always been because of timing problems (it maybe with 5v they r less sensitive to timing problems than at 3.3v). I normally just try all the different timings from all the different datasheets till I find the one that works.

Although sellers of the products all call them by the same thing they are usually selling a clone that can have a different IC on it, if you look under the microscope you can see the different ICs used and they all have different timings.

Here are some of the datasheets that I get timings from:

https://cdn-shop.adafruit.com/datasheets/WS2812B.pdf
https://cdn-shop.adafruit.com/datasheets/WS2812.pdf
http://www.peace-corp.co.jp/data/WS2812 ... 1.0_EN.pdf
https://cdn-shop.adafruit.com/datasheets/WS2811.pdf
https://datasheet.lcsc.com/szlcsc/World ... 114584.pdf
https://cdn-shop.adafruit.com/product-f ... sheet+.pdf
Thank you for your response. I am new to all this and I am not sure how to deal with timing problems. It will be very helpful if you gave some examples to work with. Also, I will look on to it.

OutoftheBOTS_
Posts: 847
Joined: Mon Nov 20, 2017 10:18 am

Re: help with WS2812B LED

Post by OutoftheBOTS_ » Sun Apr 26, 2020 6:39 am

The data (values of Red, green and blue for all LEDs) is sent via a pin where if it is high for a certain length of time followed by low for a certain length of time this will be seen as a binary 1 and if the pin is high for a different length of time followed by low for a different length of time it will be seen as a binary zero.

Each different code of the addressable LEDs has a different needed timing of high and low.
Capture.JPG
Capture.JPG (44.96 KiB) Viewed 5041 times
Capture.JPG
Capture.JPG (44.96 KiB) Viewed 5041 times
Attachments
Capture2.JPG
Capture2.JPG (21.57 KiB) Viewed 5041 times

Mohammedabujarad
Posts: 14
Joined: Wed Mar 25, 2020 12:35 am

Re: help with WS2812B LED

Post by Mohammedabujarad » Tue Apr 28, 2020 7:23 am

i made the led works, so i had a timing problems with the code. all i did is follow this code and changed the timing to one that worked with my LED. Thank you for the help
here is the code i followed and all you need to change is line 13 to 16 and 24:
https://gist.github.com/nevercast/9c485 ... 4a22062795
here is the forum that i got my timing from that worked with WS2812B LED. you will find it in page 3:
https://cdn-shop.adafruit.com/datasheets/WS2812B.pdf

OutoftheBOTS_
Posts: 847
Joined: Mon Nov 20, 2017 10:18 am

Re: help with WS2812B LED

Post by OutoftheBOTS_ » Tue Apr 28, 2020 8:10 am

Mohammedabujarad wrote:
Tue Apr 28, 2020 7:23 am
i made the led works, so i had a timing problems with the code. all i did is follow this code and changed the timing to one that worked with my LED. Thank you for the help
here is the code i followed and all you need to change is line 13 to 16 and 24:
https://gist.github.com/nevercast/9c485 ... 4a22062795
here is the forum that i got my timing from that worked with WS2812B LED. you will find it in page 3:
https://cdn-shop.adafruit.com/datasheets/WS2812B.pdf
I would be interested to know if once you got the correct timings do you still need the voltage level shifter or will it work fine running the data pin at 3.3v

Mohammedabujarad
Posts: 14
Joined: Wed Mar 25, 2020 12:35 am

Re: help with WS2812B LED

Post by Mohammedabujarad » Tue Apr 28, 2020 2:53 pm

OutoftheBOTS_ wrote:
Tue Apr 28, 2020 8:10 am
Mohammedabujarad wrote:
Tue Apr 28, 2020 7:23 am
i made the led works, so i had a timing problems with the code. all i did is follow this code and changed the timing to one that worked with my LED. Thank you for the help
here is the code i followed and all you need to change is line 13 to 16 and 24:
https://gist.github.com/nevercast/9c485 ... 4a22062795
here is the forum that i got my timing from that worked with WS2812B LED. you will find it in page 3:
https://cdn-shop.adafruit.com/datasheets/WS2812B.pdf
I would be interested to know if once you got the correct timings do you still need the voltage level shifter or will it work fine running the data pin at 3.3v
No you will not need a voltage level shifter, but you have to connect you voltage supply to the VIN Pin which will supply 5V to your LED strip

OutoftheBOTS_
Posts: 847
Joined: Mon Nov 20, 2017 10:18 am

Re: help with WS2812B LED

Post by OutoftheBOTS_ » Tue Apr 28, 2020 9:03 pm

Mohammedabujarad wrote:
Tue Apr 28, 2020 2:53 pm
OutoftheBOTS_ wrote:
Tue Apr 28, 2020 8:10 am
I would be interested to know if once you got the correct timings do you still need the voltage level shifter or will it work fine running the data pin at 3.3v
No you will not need a voltage level shifter, but you have to connect you voltage supply to the VIN Pin which will supply 5V to your LED strip
This is what I found so far with these addressable LEDS. You have to supply the LEDs with 5v but once you get correct timing then they are happy with 3.3v signals on the data pin.

User avatar
jimmo
Posts: 2754
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: help with WS2812B LED

Post by jimmo » Tue Apr 28, 2020 11:55 pm

OutoftheBOTS_ wrote:
Tue Apr 28, 2020 9:03 pm
This is what I found so far with these addressable LEDS. You have to supply the LEDs with 5v but once you get correct timing then they are happy with 3.3v signals on the data pin.
Yup, this has been my finding too. This is also temperature dependent -- I noticed that a micro:bit neopixel board (https://smalldevices.com.au/products/mi ... -micro-bit) became more or less reliable depending on whether I placed it next to the CPU fan exhaust on my laptop.

OutoftheBOTS_
Posts: 847
Joined: Mon Nov 20, 2017 10:18 am

Re: help with WS2812B LED

Post by OutoftheBOTS_ » Wed Apr 29, 2020 12:20 am

jimmo wrote:
Tue Apr 28, 2020 11:55 pm
OutoftheBOTS_ wrote:
Tue Apr 28, 2020 9:03 pm
This is what I found so far with these addressable LEDS. You have to supply the LEDs with 5v but once you get correct timing then they are happy with 3.3v signals on the data pin.
Yup, this has been my finding too. This is also temperature dependent -- I noticed that a micro:bit neopixel board (https://smalldevices.com.au/products/mi ... -micro-bit) became more or less reliable depending on whether I placed it next to the CPU fan exhaust on my laptop.
Does micro bit have a crystal to create a consistent clocking signal??

A crystal oscillator will tend to keep a constant freq with change in temp (it is why they use them in watches for keeping time) but if the MCU is just using electrical circuits to create the timing freq then the freq will change with temp.

User avatar
jimmo
Posts: 2754
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: help with WS2812B LED

Post by jimmo » Wed Apr 29, 2020 1:22 am

OutoftheBOTS_ wrote:
Wed Apr 29, 2020 12:20 am
Does micro bit have a crystal to create a consistent clocking signal??

A crystal oscillator will tend to keep a constant freq with change in temp (it is why they use them in watches for keeping time) but if the MCU is just using electrical circuits to create the timing freq then the freq will change with temp.
Yes the micro:bit does, but the WS2812s do not, so I believe this is why this occurs.

OutoftheBOTS_
Posts: 847
Joined: Mon Nov 20, 2017 10:18 am

Re: help with WS2812B LED

Post by OutoftheBOTS_ » Wed Apr 29, 2020 6:04 am

jimmo wrote:
Wed Apr 29, 2020 1:22 am
OutoftheBOTS_ wrote:
Wed Apr 29, 2020 12:20 am
Does micro bit have a crystal to create a consistent clocking signal??

A crystal oscillator will tend to keep a constant freq with change in temp (it is why they use them in watches for keeping time) but if the MCU is just using electrical circuits to create the timing freq then the freq will change with temp.
Yes the micro:bit does, but the WS2812s do not, so I believe this is why this occurs.
I would be interested for you to try the timing for the Sk6812 which is the most common clone for the WS2812B(AKA NeoPixel).

The timings for SK6812 are quite close to WS2812B and will normally still work when using WS2812B timings but can have intermittent problems.

See the Sk6812 timings here https://cdn-shop.adafruit.com/product-f ... sheet+.pdf

Can you tryu these timing with the same Microbit and put it next to your hot fan and see if you have the same problem.

Post Reply