WS2812B (NeoPixel) Integration

I have just got round to having another look at this. I hooked up the trusty Saleae. They have just added a WS2812B decoder in the logic beta. I’m getting some repeated data on the output but logic (and the led) don’t think its valid. This is the capture:

I will see if some printf’s give any more insight.

Has anybody got this new functionality to work in 4.0 yet?

I notice that SERVOx_FUNCTION does not display the neopixelx options in the wiki nor in MP, so I assume that the code is not finished or integrated?

I would like to add some WS2812B LEDs to the rear of my craft so I can see its status while it is up in the air …

@Taipan,

This looks like a mistake in the SERVOx_FUNCTION parameter descriptions. I’ll fix this up but until then you should be able to manually set the parameter to 120 (for NeoPixel1) to get it working.

Thanks for the report!

I have a Pixhawk 2.4.8 FC which has 8 MAIN outputs and 6 AUX outputs.
I am using AUX5 (which I believe is SERVO13?) to provide the digital data to the WS2812B LED.
I have set SERVO13_FUNCTION to 120 and NTF_LED_TYPES to 455 which includes NeoPixel in the bit-mask of types.

The WS2812B LED (a linear string of 8 LEDs) is powered by a separate +5v source.

I assume that the colour of the WS2812Bs should mimic the main LED on the Pixhawk. But all I get are all 8 LEDs as white, which means that they are not getting any valid data. I am obviously doing something wrong - but what?

I think you need to run a lua script to change LED colors. But I am not sure.

I hope that is not the case as I have no knowledge of Lua …

All that I am trying to achieve is to get the various patterns of the internal LED displayed on a WS2821B LED that I will fit to a part of the drone where it is visible to me while flying.

If I understand the instructions here in the wiki correctly, then all I need to do is what I described above?

But, I am not sure that anyone has managed to get this new functionality working?

1 Like

According to @tridge, the LEDs should show the default pattern. Looks like we have a few people who can’t get it working so I’ve added this to our Copter-4.0 issues list so we don’t forget about it.

Not sure whether it is a stupid question😉,
will this work?

which servo output did you use in the settings for the led output?

To be frank, I haven’t set anything !. I was just asking whether the LED pin (connection) in Kakute F7 will work. As this build doesn’'t have a status LED like Pixhawk, I would like to have one.
So waiting for some experts to chime in.

EDIT:- Tried connecting like in the above picture.
Not working…

@ambattuhari,

I think if we can figure out which servo output (i.e. which “x” in SERVOx_FUNCTION) corresponds to the LED pin on the Kakutef7 it might work. Maybe @andyp1per knows.

So far though I haven’t actually seen any user get the NeoPixels working with Copter-4.0.

@rmackay9,
Thank You for sparing your valuable time.
I will be waiting eagerly for it to happen.

Just had a little play with this, CubeOrange both scripting and notify neopixles work. Interestingly the Saleae did not detect the protocol when it was working on the CubeOrange either so possibly my previous test is invalidated.

So after more poking about I concluded that the voltage was to high for the signal level on the MatekF405. The Cube would drive the led’s powered by the Matek and the Matek would drive the the led’s powered by the Cube. Measuring the voltages showed 4.5v powered from the Cube and 5.5v on the Matek. I would guess, but did not test, that the Cube also has a higher signal level. I added a diode between the Matek 5v and the LED power and it all started working. This shows the test, and the final installation.

Since it was now working I flashed back to Copter 4.0 and can confirm NeoPixles work as they should. (@rmackay9)

A little change to the code and I now have all 6 leds working.

2 Likes

@iampete, thanks for this. So I guess we need some more information added to the wiki to tell users what they might need to do to get it working with some boards. I wonder if you could give some more info to @hwurzburg about where the diode is connected?

1 Like

of course, but I would hope that this is just a peculiarity of my setup rather than something that everyone will have to do.

this is an old old issue with NeoPixels…WS2812 specs min input high logic level as 0.7vxVCC…0.7x5v=3.5V…our FC outputs are 3.3V max…since this is worst case spec…MOST leds will work, but get 5% high on 5V or 5% low on 3.3V regs on autopilot, or just a worst case tolerance LED (and a lot are floor sweepings from China) you are hosed…easy fix is diode in WS2812 supply…but you loose brilliance…better fix is to cut a minimal amount of the strip that you can isolate, hopefully just one led, power it from the diode, then power the rest from 5V using its signal output,which is now 4.3V swing…

PS I havent checked but maybe Neopixel changed the spec in these last years so that the “real” one will use uP logic levels…will try to find an official current DS…then we say “just use new Neopixel OEM devices”…but that is rather cramping also…will check

update: even the B versions on the Adafruit site have this same spec…so most of the time, no problem…corner cases need the diode or the more complicated fix…will add to leds page I’m working on before merging

3 Likes

I have finally got this to work, but it appears that it will only work if the AUX output is configured as a PWM and not a GPIO, which is the opposite of this note in the wiki:

I have a string of 8 WS2812B LEDs connected, but of course, only the first LED in the string responds to the data from the AUX output. Ideally, I would like to have a group of 4 (or more) LEDs respond so it is bright enough to see when the copter is flying. I guess that this is where Lua scripting gets involved?

Does anyone already have a working Lua script that I could use to control multiple LEDs, please … :wink:

This is a example script from Tridge.

There is also this PR to allow you to confige how many to use on as notify leds.

That Wiki tip is defiantly backwards, this PR corrects it

2 Likes

Thanks @iampete … the PR to “Change NeoPixel Length for NTF LEDs” is exactly what I am looking for :grinning:

I just need to wait now until it is available in the 4.x released code?

how many do you want on what board? Copter?

1 Like