Snippet - WS2811 Led Strip SPI driver

I have it set to 40, but I did find somewhere else in code where 240 was hard-coded so I changed it to the NumberOfLeds variable and now it works.

I’ll have to look farther as I have another issue. All of the LEDS come on white and stay white. You can see them slightly changing color but with them all bright white it’s hard to see.

@ JerseyTechGuy - what board are you running it on?

I bet a Hydra…

Actually From a Netduino :frowning: as I don’t have a spare GHI board at the moment. Will be ordering some new stock later this week.

Trying to drive a WS2811 strip from a Netduino Plus2, and am finding that there is no way to set the SPI clock such that the timing matches the WS2811 datasheet. (As measured on a scope.)

I was able to get a strip to light up white and flicker a bit with the v3 code, by changing the hard-coded value 240 to NumberOfLeds (line 109, Example.cs) and using the default S800KHZ value (which is 3200 in SPI Config).

Basically the WS2811 requires that a bit fit within 1.25 or 2.5 microseconds, and no timing value for the SPI bus fits this on the Netduino Plus2. It “steps” in larger increments which are unknown to me, and I can get the waveform to be faster or slower than this requirement, but not within the 150 ns that’s required.

Is there some way to adjust the SPI timing more precisely?

Just checking/validating pin configuration here…

the only pin that matters is MOSI, right? The CLK and CS and MISO are not relevant. So we only need MOSI to push data into the DI pin on WS2811/WS2812.

Correct.

Thanks dude. Now get back to making something for TGIF day which is only hours away ! And yes I subscribe to your youtube channel, I know how wacky some of your latest stuff is :slight_smile:

@ Redtailed - Just your post on “driving a WS2811 strip from a Netduino Plus 2”. I’m also using a Netduino Plus 2 and wondering if you had any luck getting this to work…i.e. adjusting the SPI timing?

@ rf007 - No, unfortunately. For the product we wound up using a third-party device which uses an Atmel ARM controller. For my personal use at home (same LED driver) I am experimenting with Arduino and AVR. I basically gave up on the Netduino 2.

@ Redtailed - Thanks for letting me know your experience. There’s very little information on a working example of Netduino Plus 2 with WS2811. I’m trying to build something with WiFi and WS2811 at the same time. I’d like to avoid having an external WiFi dongle. I’ve looked at using Arduino with a WiFi shield, but the WiFi shield uses the SPI interface, which may not make SPI available for the WS2811.

Just use a Cerb and your away

Hi Nicolas 3,

first i have to say it is realy cool work what you have done. I am trying to start with your example to get it running.
But i am not getting it to run.

Btw the Problem with the index out of range is just that the Loops requires a Minimum of led’s. If you want to run this program with a small amount of LED’s the loop-Maximum sould be reduced to number of LED’s you use…

Now to my Problem. This is what i am using :

I have several small Problems with this Setup:

  • Which Pin should i use for the SPI. when i am right this Cerb40 II has only 1 SPI port. Am i right that it is the Pin “PB3”?
  • I understand the code and can debug it. One thing i don’t unterstand. When initializing the SPI.Configuration you assign the “Cpu.Pin.GPIO_NONE”. Is this correct for the Cerb II or do i Need to update this?
  • When i am measuring the Strip, i am getting the 5V power supply at beginning and at the end. So i think it is wired correctly. The DI Signal is is only measureable at the beginning. there i am getting 0.5V - 0.75V (If i am at the correct Pin). But already at the second LED i am not getting any Signal to measure. Is this correct or is this even measureable?

Finally i am not getting any LED to light. And i have no clue where to continue searching the error.

I would be very glad if you can help me. I am fully stuck in this.
Either i have made something small wrong or everything :slight_smile: But help is realy welcome…

Kind Regards,
Ralf Röttcher

hi Ralf, welcome to the forum,

Can you give us more details (a picture?) of how you have the power configuration set up? In particular the interest will be in how you have the 5v to the LEDs configured.

[quote]I have several small Problems with this Setup:

  • Which Pin should i use for the SPI. when i am right this Cerb40 II has only 1 SPI port. Am i right that it is the Pin “PB3”?
  • I understand the code and can debug it. One thing i don’t unterstand. When initializing the SPI.Configuration you assign the “Cpu.Pin.GPIO_NONE”. Is this correct for the Cerb II or do i Need to update this?
  • When i am measuring the Strip, i am getting the 5V power supply at beginning and at the end. So i think it is wired correctly. The DI Signal is is only measureable at the beginning. there i am getting 0.5V - 0.75V (If i am at the correct Pin). But already at the second LED i am not getting any Signal to measure. Is this correct or is this even measureable?
    [/quote]

Cerb40 does only have one SPI channel, SPI1. PB5 is MOSI, PB6 is MISO, PB3 is SCK. These LEDs need just a data signal, so you need to use PB5. PB3 will toggle, but that isn’t used by the LEDs.

Hi This is my Setup.

  • Signal cable now connected to PB5 (yellow) (goes to “DI” at the strip)
  • Cerb II has no external power supply, just connected to USB
  • 5V directly connected to the Strip (5V)
  • Ground directly connected to the Strip (GND)

When i am right the signal on the Strip needs to get connected to DI (Data Input) and than goes out with DO (Data Output) to the next DI of the next LED.

In the sample code i have not changed the SPI. I am using SPI1.

But still with no success…

Kind Regards,
Ralf Röttcher

You need to ALSO connect GND to the Fez, otherwise the signal reference and the 5v reference on the LEDs will not be able to understand that there is a “signal” when the fez outputs it. Can you also tell us about what your 5v source is? That’s actually more like what I wanted a pic of :slight_smile:

Here’s another way to test this. If you have a regular old LED, connect that as you would normally (through a resistor to GND) to the PB5 pin, and run your application gain. You should see a lot of data is sent, causing the LED to flicker. If you see nothing, you may have an app issue. (and you can test that your LED is working by using another program that just cycles a pin every second or something)

Hi Brett,

I just tested your settings. Connecting the ground also to the fez does still not light any LED. But i have an RGB LED (not old but works) and i connected it to my Signal Port. It is not a realy bright LED but i can see the LED glowing sometimes, but not realy flashing. Sometimes it glows sometimes not.

Beside you can see a picture of my Power Supply (5V 600mA 7.2VA) and also a picture of the whole Setup with which i am testing.
The sourcecode is just minimal changed (only the Loops), because of my small test strip.

Kind Regards,
Ralf Röttcher

OK, then we’re running out of options. Can you tell us whether you’ve validated the 5V is actually at 5v?

What I’d expect to see on a “normal” LED if you’re connecting to the correct pin is just a dim glow. It’ll run far too fast to see anything other than pretty solid light. Perhaps you can change your routine to cycle through some of the WS2811 strip and pause for a second or two at which time you should see the standard LED go out.

Hi Brett,

I am now away from home til friday. I will test it as soon as possible.

The pauses between the several signals i can see. The LED is not glowing all time.

What i can say about the 5V is that i have at the begionning and at the end of the Strip something between 4.95 and 4.99 V. About the Ampere i am not sure.
When i am trying to measure the Signal of P5 i get at the first DI of the Strip values between 1.5V and 2.5V. What i am wondering about is that the Strip is not transfering it to the next LED. AT the first LED i can measure the Signal at “DI”. But on “DO” i cannot measure it anymore. The first LED does not let the Signal through. Is this correct or is my stripe defect?

Kind regards,
Ralf Röttcher