I'm trying to drive a ws2811 LED strip with my Arduino Due, but every library I've found so far is made for older arduinos(they use the AVR library suite, which is incompatible with ARM chips). Can anyone help me out?
Have a look at https://github.com/adafruit/Adafruit_NeoPixel this library works for WS2811.
Unfortunately, it doesn't work with an Arduino Due because it uses assembly in some parts of the code.
I ported Neopixel to Teensy 3.0. That code can probably work on Due, perhaps with only slight modification?
If you’re going to use a LOT of WS2811s, you really should look at OctoWS2811…
I took a look at your code, and I'd like to try to port it over to use on the Arduino Due, but I'm confused by some of the following statements:
GPIOD_PCOR = 0xFF;
// DMA channel #1 sets WS2811 high at the beginning of each cycle DMA_TCD1_SADDR = &ones; DMA_TCD1_SOFF = 0; DMA_TCD1_ATTR = DMA_TCD_ATTR_SSIZE(0) | DMA_TCD_ATTR_DSIZE(0); DMA_TCD1_NBYTES_MLNO = 1; DMA_TCD1_SLAST = 0; DMA_TCD1_DADDR = &GPIOD_PSOR; DMA_TCD1_DOFF = 0; DMA_TCD1_CITER_ELINKNO = bufsize; DMA_TCD1_DLASTSGA = 0; DMA_TCD1_CSR = DMA_TCD_CSR_DREQ; DMA_TCD1_BITER_ELINKNO = bufsize;
Are these statements particular to the Teensy, or DMA? I've never used DMA before, and I tried googling a few of the statements but didn't get anywhere. Could you give me a pointer?
Your best bet for Arduino Due would be adapting my contribution to Neopixel. It's simple code. You probably only need to tweak the timing parameters, ideally using an oscilloscope or logic analyzer, but maybe trial-and-error might work?
In Neopixel, the 96 MHz parameters for Teensy 3.0 are probably very close to what Due needs at 84 MHz. They might even "just work" on Due, since the speeds are so close. Due has better faster flash memory caching than Teensy, which might compensate or even over-compensate for the 12 MHz difference in core clock speed.
mitocho: I took a look at your code, and I'd like to try to port it over to use on the Arduino Due, but I'm confused by some of the following statements:
That OctoWS2811 code is very specific to the DMA controller on the Teensy 3.0. Arduino Due has very different hardware, so the code is not compatible and not easily adapted.
For documentation, here is the datasheet:
The TCD registers are documented in chapter 21 beginning on pin 333. They're extremely complex and not a good beginner level project! That's why I wrote OctoWS2811... to put all that difficult stuff into a well documented library that makes these types of projects easy. OctoWS2811 is designed around the Teensy 3.0 hardware and probably would be more difficult to port to Due than simply writing a brand new library from scratch.
However, Neopixel should be fairly easy to port to Due.
I really simply installed the code from Adafruit and compiled the Example for Due and it worked, I cannot remember if I changed something to it. It works, just give it a try. KR, Rudy
I checked once more, the librabry you need is https://github.com/vheun/Adafruit_NeoPixel Sorry for the confusion, this works Kr, Rudy
So I downloaded the Adafruit neopixel code, and I got it to compile. I just had to change the interrupt subroutines to use interrupt() and noInterrupt() instead of cli() and sei(). I also had to change the type of the port variable from unit_8 to uint_32, but it compiles fine. Still no lights though...
I'm beginning to suspect my power supply may not be enough to power this thing. I have a two meter piece powered by a 5V 2A wall wart... I figured it should be enough to power it, but perhaps not. At the very least though, I should be able to see the lights very dimly right?
Just hooked up a second 5V 2A wall wart in parallel, and still nothing. I'm starting to suspect my wiring, but I don't see how I could have screwed it up.
Here's what I have:
+5V: connected to red line (which says +5V) Pin 6: connected to Blue line(which says D0) Arduino GND and PSU GND: both connected to the Black line(which says GND).
Seems pretty simple to me. But I don't get anything. No light whatsoever...
Simple fix: Your blue wire is connected to the wrong end of your strip. D0 is actually Data Out.
Have a look at the other end of the strip, there should be DIN.
Blue wire from DIN to Pin 6 and you should be good to go ;)
Sorry for not replying for so long. Just got back, and soldered some new leads on, but the darn thing still isn't working.
Should the strip turn on at all when just connected to the power supply, or does it remain completely unlit until initialized by the WS2811?
Thanks again for everyone's help.
Should the strip turn on at all when just connected to the power supply,
or does it remain completely unlit until initialized by the WS2811?
Did anyone figure this out? I am using the Neopixel Adafruit library and an Arduiono Due. I'm using WS2811 chips found here http://www.ebay.ca/itm/111126360488.
Getting a tone of jittering, especially the first LED. seems to be okay when all LEDs are set on, but a ton of jittering when all LEDs are set off. I am testing with 0 - 15 LEDs and a 1A/5V power supply and get the jittering even with 1 LED.
Other relevant settings are I am using 15200 baud rate and a 10ms refresh in the Arduino Sketch. I can post the code on request, but don't have access to it at the moment.
There have been some discussions of modifying the Adafruit Neopixel library, adding a 50-100 Ohm resister between the board and data in of the first WS2811, etc. I'm not sure where to start, though! (because I am a n00b :sweat_smile:)
tried the same WS2811 strip with an Arduino Uno and the test color wipe from the Adafruit Neopixel library seemed to work okay (a bit jittery on the first LED) . It looks like a timing or signal issue because the Due seems to work about 20% of the time.