Can't use IR receiver with Neopixel Rainbow Function

Post here about your Arduino projects, get help - for Adafruit customers!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
dannya
 
Posts: 111
Joined: Thu Nov 14, 2013 7:35 pm

Can't use IR receiver with Neopixel Rainbow Function

Post by dannya »

Hi!

I've got a NeoPixel shield running rainbow(20) on a loop (from the Neopixel shield sample code). I'm trying to use an IR receiver so I can turn the shield on and off. The IR receiver alone is working fine, however, when the rainbow function is running, the IR receiver is never getting through. Is there a way to set up the IR receiver on an interrupt or something?

Thanks!

User avatar
Franklin97355
 
Posts: 23910
Joined: Mon Apr 21, 2008 2:33 pm

Re: Can't use IR receiver with Neopixel Rainbow Function

Post by Franklin97355 »

I'm sure there is some way to do that. What IR receiver are you using and post your code using

Code: Select all

 tags or the code button </> also tell us how you have things connected.

User avatar
SeiRruf
 
Posts: 82
Joined: Thu Sep 04, 2014 3:07 am

Re: Can't use IR receiver with Neopixel Rainbow Function

Post by SeiRruf »

dannya,
I have had this same problem and have not been able to come up with a solid solution myself, yet.

I was able to find out one thing though. The problem relies within the timing used to control the NeoPixels. The IR receiver so happens to be quite picky with receiving commands, and being how the NeoPixels completely disable the internal inturrupts, there becomes no room for the IR receiver to function properly as they are then required (which explains why it stops working when your LEDs are cycling the rainbow, the arduino is constantly updating them every 20ms, but in other modes, I am guessing your animations aren't as constant).

The trick.
I ended up writing code to check for an IR signal before the neopixles are updated. This may delay some animations, but it worked quite nicely.

Something like:

Code: Select all

void stripShowCheckIR ()
{
  if ( irLibrary.check() == 0 ) { //irLibrary, as an example (won't work, replace with your setup)
    //delay (20); //you mayyy need some delay here. Kind of depends, commented out for now.
    //do IR processing here
  }
  //then push the strip on
  strip.show ();
}
That function would replace occurrences of strip.show() in your existing code.

I hope this sends you in the right direction. :)

EDIT:
clafrieda was able to achieve this, and posted his complicated source code here (not sure why he chose to library-ify everything, but it's sweet):
http://forums.adafruit.com/viewtopic.ph ... 2&p=288672
Last edited by SeiRruf on Fri Sep 12, 2014 5:08 pm, edited 1 time in total.

User avatar
adafruit_support_bill
 
Posts: 88087
Joined: Sat Feb 07, 2009 10:11 am

Re: Can't use IR receiver with Neopixel Rainbow Function

Post by adafruit_support_bill »

Interrupts are disabled in the neopixel show() code in order to meet the tight WS2811 timing constraints. Checking for IR between calls to show() is about the only option - other than adding a second processor for the IR.

User avatar
michaelmeissner
 
Posts: 1821
Joined: Wed Aug 29, 2012 12:40 am

Re: Can't use IR receiver with Neopixel Rainbow Function

Post by michaelmeissner »

In terms of adding a second processor for IR, there are some chips that do the decoding of IR, and emit a signal that you can read to off-load the IR handling.

User avatar
michaelmeissner
 
Posts: 1821
Joined: Wed Aug 29, 2012 12:40 am

Re: Can't use IR receiver with Neopixel Rainbow Function

Post by michaelmeissner »

As a footnote, decoding IR signals has similar timing constraints to neopixels, except it is on input instead of output (i.e. you have to wait and see if you got a short pulse or a long pulse). Controlling servos and reading encoder pulses is other areas where neopixels turning off interrupt handling for relatively long periods of time can be a problem.

User avatar
dannya
 
Posts: 111
Joined: Thu Nov 14, 2013 7:35 pm

Re: Can't use IR receiver with Neopixel Rainbow Function

Post by dannya »

Could I do it this way?

Hook up the Neopixels to the Arduino, and add an ATTiny to the project, whose sole function is to interface with the IR receiver? Then, I can have the ATTiny trigger a transistor or a relay which will allow the power to flow to the Neopixels?

Also, I just got the Neopixel board, which seems to have greater power requirements than the shield, and I read that it needs to have a separate power supply. Can I take the 5V 2A power supply, hook it up to the breadboard, and wire that to both the Neopixel board AND the Trinket? Or is that too much power draw (if I have all the LED's lit, but not all of them on white ever at the same time)?

Thanks!

User avatar
adafruit_support_bill
 
Posts: 88087
Joined: Sat Feb 07, 2009 10:11 am

Re: Can't use IR receiver with Neopixel Rainbow Function

Post by adafruit_support_bill »

Then, I can have the ATTiny trigger a transistor or a relay which will allow the power to flow to the Neopixels?
It is not a good idea to be sending control signals to an un-powered neopixel. Better to keep it powered and have the ATTiny trigger the Arduino to start displaying things on the pixels.
Can I take the 5V 2A power supply, hook it up to the breadboard, and wire that to both the Neopixel board AND the Trinket?
The best way is to wire the power supply direct to the Neopixels (your main power consumer) and then run wires from that back to the Trinket and/or Arduino.

User avatar
dannya
 
Posts: 111
Joined: Thu Nov 14, 2013 7:35 pm

Re: Can't use IR receiver with Neopixel Rainbow Function

Post by dannya »

Thanks!

So I should have the transistor/relay sit in between the power-out pin from the neopixel board to the Vin pin on the Trinket? Meaning, when the relay is "off" the Arduino will have no power, correct? If I kill power to the Arduino (via the relay), won't the Neopixel board remain lit with whatever the last command sent was? Or if it loses it's data input pin does it go completely dark?

Is it preferable to use a relay or a transistor?

Does the Neopixel board have power out and ground out pins (I don't have it with me, traveling at the moment)?

Thanks!

User avatar
dannya
 
Posts: 111
Joined: Thu Nov 14, 2013 7:35 pm

Re: Can't use IR receiver with Neopixel Rainbow Function

Post by dannya »

....and I would need the ATTiny to always have power to receive the IR commands, so how do I give THAT power? Directly from the 5v 2a wall wart wires?

User avatar
adafruit_support_bill
 
Posts: 88087
Joined: Sat Feb 07, 2009 10:11 am

Re: Can't use IR receiver with Neopixel Rainbow Function

Post by adafruit_support_bill »

Just keep everything powered full time. and use the IR commands to tell the Arduino how to control the pixels.

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino”