IRremote library missing

Post Reply
Posts: 102
Joined: Sun Oct 26, 2014 2:50 pm

IRremote library missing

Post by GastonLagaffe » Tue Aug 04, 2015 9:59 am


am I right that the IRremote library that comes with the chipKit core is not written for chipKit? Looking through the forum and the web resources, I cannot find a IRremote library that runs on chipKit. The forum example I found (viewtopic.php?t=389) is not working (returns nothing but 1).
I do not have a complex IR project, I just want to read a simple IR remote control that comes with the beginner kit for Arduino using the IR sensor (i.e. Elecfreaks beginner kit).
Before diving into reinventing this old wheel I just want to check if there is really no IRremote lib available

Ciao, Mathias

User avatar
Jacob Christ
Posts: 723
Joined: Sat May 28, 2011 6:34 am
Location: Southern California

Re: IRremote library missing

Post by Jacob Christ » Sun Jun 12, 2016 2:42 am

What version of the dev tools are you using? Do you know if the library uses interrupts? I'm having trouble with interrupts with chipKIT-core 1.1.0

PONTECH Quick240 an industrial form factor platform for chipKIT and Arduino users.

User avatar
Site Admin
Posts: 2188
Joined: Wed Nov 09, 2011 7:51 pm
Location: UK

Re: IRremote library missing

Post by majenko » Sun Jun 12, 2016 10:16 am

There is no IRremote library in chipKIT core. Can you point to where you found the library?

Writing an IR receiver library is not actually that hard - as long as you have a demodulating receiver. The typical demodulated signal consists of a series of pulses of varying length. Different remotes use different combinations of lengths. The trick is how to identify the different remotes and decode them properly. Most send a unique header code using their own pulse lengths, and those pulse lengths may well be different to the payload pulse lengths. The spaces between the pulses as well often form part of the actual data stream. That's known as "Mark / Space" combinations. The relationship between the length of the mark (1) and the space (0) defines the value of the symbol. It's basically a form of PWM - it's possible to encode a number of different values into a single symbol then. Some remotes use just binary symbols (short/long and long/short), but some use maybe 4 values encoded in one symbol (0 = #____, 1 = ##___, 2 = ###__, 3 = ####_ for example).

The best possible library to write which would give the most accurate results whilst at the same time being non-blocking would use the Input Capture peripheral to grab the length of each mark / space segment and add them to a queue to be decoded - with a "space too long" timeout to indicate an end of transmission. That really limits the pins you can use though. Most libraries use interrupts set to CHANGE mode (which the PIC32 doesn't have) and capture the millis() or micros() value at each change from LOW to HIGH or HIGH to LOW.

Since that interrupt method can't be done on the PIC32 (well, it can if you change the edge trigger in the interrupt setting register from within the interrupt routine so it looks for the next edge - but that's nasty) it may be better to use the Change Notification interrupts. This not only gives you more pins to choose from, but can also work in CHANGE mode rather than just RISING or FALLING modes.
Why not visit my shop?
Universal IDE:
"I was trying to find out if it was possible to only eat one Jaffa Cake. I had to abandon the experiment because I ran out of Jaffa Cakes".

Post Reply