Go Down

Topic: WS2811 and Interrupts Usage (Read 1 time) previous topic - next topic

HopWorks

Greets everyone,

I ran into an issue a few minutes ago when I tried to implement timer interrupt handling in a sketch I was writing to control some RGB LED effects. I am using the Adafruit NeoPixel library which works very well when directly accessed. Before I spend hours trying to figure out what is wrong, I thought I would ask...

When using this library to control a strip of 45 WS2811 LED's, can I use interrupt handling? If not, are there other libraries I can try?

The stuff I am doing is pretty simple so I thought I would throw a Arduino Pro Mini 328p (5vdc) at it, but I wanted to use timer controlled interrupt handling to keep the effects stable and clean. I can use a Teensy 3.1 to do it, but I have a bunch of the pro mini's laying around and wanted to use them if I can.

When I use a timer triggered interrupt handler to write a 45 count 32 bit array to the strip via the library, I get nothing. If I do it directly through the main loop it works fine.

I realize my post is a bit vague but you should be able to get the picture. If not, let me know what else you need me to add and include.

Thank you for your valuable time!

Grumpy_Mike

Have you declaired the variables used both inside and outside your ISR as volitile?

If you have and still have the problem then post your code in code tags.

Helmuth

#2
Dec 11, 2014, 10:53 am Last Edit: Dec 11, 2014, 10:58 am by Helmuth
The WS2811 require such a tight timing, that basically all libs I know disable interrupts on AVR while pushing out the data to the leds.

FastLED allows it on ARM, but your ISR needs to be really short.

Quote
but I wanted to use timer controlled interrupt handling to keep the effects stable and clean
Could you elaborate on that? What are you going to do?

Helmuth

#3
Dec 11, 2014, 10:54 pm Last Edit: Dec 11, 2014, 10:55 pm by Helmuth
Daniel Garcia wrote about it on G+ today:

Quote
...This is also why interrupts are allowed on the due, but not on AVR w/WS2812's, because it turns out that it is really really really difficult to write a useful AVR interrupt handler that will run in under 80 cycles...

HopWorks

Quote
but I wanted to use timer controlled interrupt handling to keep the effects stable and clean
Could you elaborate on that? What are you going to do?
I am performing different effects on different "zones" of the strip. Some of the effects are a little more elaborate than others, like fades, random flashes, etc. I need the strip updated at a set rate and the routines that change the numbers will take a variety of clock cycles. I was able to do this with a Teensy just fine, but the cost is considerably higher than my pro mini's.

Have you declaired the variables used both inside and outside your ISR as volitile?

If you have and still have the problem then post your code in code tags.
I have not, and I will correct that and try again. If it fails again, I'll post the code. Thank you sir for the reminder!!

HopWorks

Daniel Garcia wrote about it on G+ today:

Interesting thought. My INT handler is very small though. And since the library appears to use a buffer, and if I can read back from the buffer (I thought I saw that done somewhere), all I need to do is do a strip.show in the handler.

Go Up