NEC(?) IR remote control protocol

I want to decode the output from a remote control handset that uses what some call the "NEC" protocol, reference:

formatting link

Not sure if "NEC" is the official name for it, as Googling for that does not get many results.

It's a very simple protocol so I can write the decoding source from scratch, but if there is some around already I'd be grateful of the time-saving, plus any extra robustness that it might have over my attempts ;)

FWIW I'm targetting a PIC12F629, but code for any microcontroller (assembler or C) would be great, thanks.

Jim

Reply to
Jim
Loading thread data ...

Jim,

This stuff easily fits into 12C508. I do it quite a bit for a client. Because of this, I can't give you the software. You can buy cheap chips (12cxxx and 16cxxx based) from him if you need a quick solution. You can get them from

formatting link
Done properly you can even get by with the internal 4.0MHz RC oscillator.

Other than that, you will want to download the datasheet from a TSOP1238 from Vishay. You'll need to compensate for the pulse stretching and pulse width distortions cause by modern IR receiver internal AGC and filter circuits.

Noel

Jim wrote:

--
Noel's Lab
www.noels-lab.com
Chips, firmware, circuits and embedded systems
Reply to
Noel Henson

Many thanks for the info, Noel. In fact I need to use a PIC12F629 as it's got other work to do as well as the decoding. It's a great chip for our application - internal 8MHz oscillator with +/-1% accuracy or so and runs ok from 3.3V. I don't think it costs much more than the gold ol' 12C508.

In fact, I've already got an IR receiver module (actually a Hero Electronics HIM702HM, as it was easier and cheaper to get hod of than a Vishay for me at the time). The output from it looks fine after some crude distance/obstacle testing, so I'm ready to start coding. Just didn't want to rewrite the wheel if someone has already done it and it's available.

Thanks too for the head-up re pulse stretching and distortions. That's exactly the kind of thing I'm worried I'll miss if I write the code myself. If I do my own code, I'll build in some slack for those possibilities.

Jim

Reply to
Jim

Internal osc is 4MHz, not 8MHz.

Reply to
Mike Harrison

can

TSOP1238

pulse

ok

You're right of course. Thanks for the correction.

- Jim

Reply to
Jim

Jim,

The BEST way to test your code is to use one of the outputs as a temporary test signal. While using a scope or, preferably a logic analyzer, you can monitor the input from the receiver and the test signal. Have the test signal Change state to show the start and stop time of your timing windows, that way you can make sure that you are sampling in the center of the window. Or, if you're using an interrupt-on-change function along with a timer, you can use the test signal to show timeouts.

One of the easiest ways to decode on the 629 is to use the interrupt pin set for any edge. Use a timer to measure the time between the edges. You can then use a simple 'within-range' function or subroutine to determine what the bits are and if they are valid.

Have fun!

Noel

--
Noel's Lab
www.noels-lab.com
Chips, firmware, circuits and embedded systems
Reply to
Noel Henson

Hi Noel,

Thank you for more of your tips; it's much appreciated. I will do as you suggest, using an interrupt-on-change from the input pin plus a timer, with the provisos you've mentioned. A simple state machine should be sufficient hopefully for the command decoding.

As an aside, I really enjoy coding towards this kind of task, but thought I should check there isn't already some free source code out there first! ;)

Jim

Reply to
Jim

You're a quick study. It looks like you'll do just fine. Noel

--
Noel's Lab
www.noels-lab.com
Chips, firmware, circuits and embedded systems
Reply to
Noel Henson

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.