FastLED / FastLED

The FastLED library for colored LED animation on Arduino. Please direct questions/requests for help to the FastLED Reddit community: http://fastled.io/r We'd like to use github "issues" just for tracking library bugs / enhancements.
http://fastled.io
MIT License
6.46k stars 1.64k forks source link

WS2818 is not working #1407

Open kokospalme opened 2 years ago

kokospalme commented 2 years ago

Hello, I have a custom Board with an WS2818B chip, but FastLED does not work with it. The Board the Signal comes from, is an ESP32-board (also custom) with an opto-isolation-circuit (6N137 optocoupler). I already tried seveal configurations (WS2812, WS813, WS2811 ...) but none of them worked with the WS2818. Furthermore the datasheet of the WS2818 says, for example the low-level-time has to be 580nS - 1 uS, but the WS2813 has a low-level-time of 220nS-240nS. So the timings are sligthly different. I wondered why others got their WS2818 ICs working with FastLED and the WS2813 configuration...

Can i change the timings within the fastLED library or something? Thank you!

zackees commented 2 years ago

Yes, you have create your own LED controller class and pass that into the addLeds() function override.

https://github.com/FastLED/FastLED/blob/b5874b588ade1d2639925e4e9719fa7d3c9d9e94/src/chipsets.h#L577

kokospalme commented 2 years ago

according to this post: https://github.com/FastLED/FastLED/issues/1311 I changed the timings, but nothing is happeing... Are the variables T1, T2 and T3 correct?


template <uint8_t DATA_PIN, EOrder RGB_ORDER = RGB>
class WS2818BController : public ClocklessController<DATA_PIN, C_NS(300), C_NS(300), C_NS(600), RGB_ORDER, 4> {};
/*
 * T1       == T0H (220 … 380  nS)  —> T1 = 370
 * T2+T3    == T1L (580 … 1000 nS)  —> T2 = 600 - 300 = 300 ,   T2+T3= 300+600 = 900
 * T1+T2    == T1H (580 … 1000 nS   —> T3 = 600 ,           T1+T2 =370+600 = 900
 * T3       == T1L (580 … 1000 nS)
 *
 * RES =  > 280 uS??
 *
 */```
zackees commented 2 years ago

I don't know if your timings are correct, you could debug further by directly subclassing CLEDController

kokospalme commented 2 years ago

I don't see, where I can change the reset timing. At WS2812B it's >50uS. The WS2818B should have >280uS. Is there a chance of also changing the reset timing? Now I have tried these values (without luck):


 * T1       == T0H (220 … 380  nS)  T0H: T1    = 250
 * T2+T3    == T0L (580 … 1000 nS)  T0L: T2+T3 = 380+400 = 780
 * T1+T2    == T1H (580 … 1000 nS   T1H: T1+T2 = 250+380 = 630
 * T3       == T1L (580 … 1000 nS)  T1L: T3    = 600
 * --> RES = 1230
 *
 */```
zackees commented 2 years ago

what if you just do a delay() after the draw? What happens if you use the adafruit WS2812 (neopixel) library?

smurphyUSI commented 2 years ago

The WS2818 is an improved variation of the WS2811, so the timings should be working. Make sure they are wired correctly, because it's not the usual affair as 4-wire units.

Unfortunately, between revisions of different 'WS28XX' units, and clones, the timings are sometimes incorrectly documented. I would suggest trying again, running as WS2811 and then WS2812. Regardless of the variation, the timings should be one of those two.

kokospalme commented 2 years ago

I could change the timings, even the reset-timing like this, but without luck:


class WS2818BController : public ClocklessController<DATA_PIN, C_NS(250), C_NS(380), C_NS(600), RGB_ORDER, 4, false, C_NS(1230)> {};```
smurphyUSI commented 2 years ago

If the WS2811 and WS2812 tests don't work, then I suspect something else is wrong, such as your pinout selection for your board. You may want to tests those pins seperately with a scope or multi-meter to make sure your code is actually outputting to them.

As you said it's a custom board, I suggest moving this topic over to Reddit, but please provide the model of microcontroller you are using. There will be more people over there with experience with a specific controller. https://www.reddit.com/r/fastled

kokospalme commented 2 years ago

Alright, thanks for the quick answers! Maybe it's the optocpoupler's signal that's not good enough or something... I'll post if that caused the error, in case others facing the same problems

PureTek-Innovations commented 2 years ago

I've often used WS2818s with FastLED and have had no problems. The fault is somewhere else, try without the optocoupler

zackees commented 1 month ago

Following up on this, you can use this python script to calculate T1,T2,T3 from the T0H/T0L, T1H, T1L timings from the data sheet. If this fixes you then our timings are wrong.

If you get vastly different numbers than us then our timings are wrong:

// print("Enter the values of T0H, T0L, T1H, T1L, in nanoseconds: ") // T0H = int(input(" T0H: ")) // T0L = int(input(" T0L: ")) // T1H = int(input(" T1H: ")) // T1L = int(input(" T1L: ")) //
// duration = max(T0H + T0L, T1H + T1L) //
// print("The max duration of the signal is: ", duration) //
// T1 = T0H // T2 = T1H // T3 = duration - T0H - T0L //
// print("T1: ", T1) // print("T2: ", T2) // print("T3: ", T3)