Detect unknown IR messages with SX/B
PLJack
Posts: 398
Hi gang.
If you were to try and decode an unknown IR code, how would you go about it.
Would you even need to detect the pulse frequency, thus making the routine frequency independent.
Seems to me that you could measure the delay in between the pulsing using an IR photo transistor.
From what I read about IR you could wait for a delay of 2ms or more to flag the start of the message.
Then count the .6ms and 1.2ms spaces to detect 0 or 1s.
Keep in mind that the IR sensor would only read IR on command so the pulsing (i.e. 38khz) used by
remotes to eliminate stray IR is not that important.
That is the approach I would like to take.
If that approach is valid what technique is best?
RTCC interrupt, port B edge detection interrupt or PulseIn?
I'm just starting this project an would like some advice on how to proceed.
I am using a Sx28A and the internal 4mhz clock.
I've connected the IR photo transistor to RA.0 and am simply toggling a led on RB.0 when the state of RA.0 is hot.
Seems to work great. Each remote control I throw at it has a distinctive blink pattern.
Anyone care to comment?
Thanks, Jack
If you were to try and decode an unknown IR code, how would you go about it.
Would you even need to detect the pulse frequency, thus making the routine frequency independent.
Seems to me that you could measure the delay in between the pulsing using an IR photo transistor.
From what I read about IR you could wait for a delay of 2ms or more to flag the start of the message.
Then count the .6ms and 1.2ms spaces to detect 0 or 1s.
Keep in mind that the IR sensor would only read IR on command so the pulsing (i.e. 38khz) used by
remotes to eliminate stray IR is not that important.
That is the approach I would like to take.
If that approach is valid what technique is best?
RTCC interrupt, port B edge detection interrupt or PulseIn?
I'm just starting this project an would like some advice on how to proceed.
I am using a Sx28A and the internal 4mhz clock.
I've connected the IR photo transistor to RA.0 and am simply toggling a led on RB.0 when the state of RA.0 is hot.
Seems to work great. Each remote control I throw at it has a distinctive blink pattern.
Anyone care to comment?
Thanks, Jack
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas, TX· USA
TV, Stereo, DVD etc.
I originally started with PULSIN. I had it time out at 0.6ms.
If it timed out 4 times in a row I flagged it as a possible message header.
Then tried to use the number returned from PULSEIN to determine the 1 or 0 from the remote.
One timeout would indicate the space between each message packet, or it could be a zero packet.
Needles to say this approach is lame at best. The timing needs to be spot on.
Although it did work some what. Just never found all the packets between the start header.
Again this is "read IR on command" so the pulsing (i.e. 38khz) is of no real use.
What I seem to need is pattern detection, not so much IR detection.
I just love a good puzzle. [noparse]:)[/noparse]
Jack
Post Edited (PLJack) : 5/20/2005 9:28:54 PM GMT
·· We have a book availble form our website that may be able to help you in understanding IR Remote signals.· The link is posted below:
http://www.parallax.com/detail.asp?product_id=28139
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
Yes, I read that, and it is VERY useful. Thank you.
After thinking more about it, what I am really trying to do is measure the time the remote IR LED is off. Not so much what it is doing when it is on.
I think I need to re-read the article you posted. [noparse]:)[/noparse]
Jack
Check out this link:
www.mnsi.net/~boucher/emporium.htm
Click on "My Projects" and then on "Lamp controller". This guy built a PIC chip based lamp controller that has a remote IR learning ability so you can use any remote to control the lamp brightness. The ZIP file contains the source, although it is in assembly. If the source is well commented, you might be able to glean some info from it. If not, perhaps you can contact the author and see if he can provide some details.
Thanks, PeterM
He is using a 40Khz IR demodulator module.
I am trying to avoid using any XXKhz demodulator.
My latest approach is to turn the pin that the IR photo transistor is connected to into a demodulator simulator.
From what I read about demodulators is that they convert the XXKhz pulse lengths into HI/LOW pulses.
So a pulse of XXKhz for 1.4ms would be seen as a LOW for 1.4ms.
Of course the issue with SX chips is that they are so DAMN fast.
When you start working out the numbers you can't help but say out loud, "wow that is fast".
Then last night when I was reading the SX books I saw that I can run the chip at 128Khz.
Just what I was looking for. Makes the math for timing MUCH more simple.
Anyway, that is where I am right now.
I'll post again with an update.
Jack
Well now is your chance to place your thumbs in your ears, wave your fingers and say, Naa-na-na-na-naa.
So moving on.. I have broken the task into smaller goals.
This post is about goal one, reading the IR frequency. Not decode it, just find the frequency that the
led is pulsing at.
The obvious approach seems to be PULSIN.
Please note that I am using a IR photo transistor, not an IR decoder.
I have attached the code and a snap shot of the debug window.
As you can see there is a pattern.
The heart of the code is:
The numbers in the debug snapshot were generated by holding down the up arrow on the remote and pressing the letter "R" in the debug until I got some good samples.
I could use some help with the numbers. I am not sure what I am looking at.
Am I right that the numbers in Val1-val3 are in 10us increments?
So for instance, the number 171 represents 1700us or 1.7 milliseconds.
That does not seem right to me.
Anyone want to share their ideas on the method and math to convert PULSIN data into Khz?
Thanks
Jack
Post Edited (PLJack) : 5/23/2005 2:17:43 AM GMT