Infrared remote control - NEC format

Use this section to discuss your embedded Flowcode projects.
Post Reply
mnfisher
Valued Contributor
Posts: 938
http://meble-kuchenne.info.pl
Joined: Wed Dec 09, 2020 9:37 pm
Has thanked: 104 times
Been thanked: 502 times

Infrared remote control - NEC format

Post by mnfisher »

I recently wrote a bit of code to receive Philips RC5 format IR data.

Whilst testing this - I found that most of my remote controls use NEC format (5 out of a 'random' selection of 5). Reading NEC format didn't take much change to my existing code - so for anyone who needs it - an NEC format IR code reader... Note that I use the 'state machine' from the RC5 code - and this is actually a simpler system, but I didn't rename the states to reflect this.
NEC IR.fcfx
(21.83 KiB) Downloaded 115 times
This should run on anything - with the proviso that the clock is accurate (1s flash test is compulsory for PIC :-) ) - it needs to measure 562.5uS (and multiples thereof) pulses/spaces (this is of course a long time for a MCU!)

The NEC IR 'transmitter' sends 32 bits but, usually, the second and fourth bytes are the inverse of the first and third (as an error check) - however in some cases it is used as 16 bits command and address. There is a comment in the code - if you need to alter this. (I don't check for errors - but I use 8 bit data)

Repeated data (button held down) is indicated by the 'repeat' flag being set to true (ReadIRData returns true for new or repeat data)

It is currently set to expect a 'pulse' to pull data pin low, infrared detector is connected to a data pin (reversing this is straightforward)

At present - main 'busy' waits for the data pin to go low. I'd envision the MCU being in a sleep mode and waking on an pin-change interrupt - however this will vary depending on application.

Ben/Martin - would you like as/like to convert to a component?

Martin

medelec35
Matrix Staff
Posts: 1432
Joined: Wed Dec 02, 2020 11:07 pm
Has thanked: 506 times
Been thanked: 469 times

Re: Infrared remote control - NEC format

Post by medelec35 »

Thanks, Martin
That's brilliant!
I will have a play.
I will also chat to Ben about it.
Martin

mnfisher
Valued Contributor
Posts: 938
Joined: Wed Dec 09, 2020 9:37 pm
Has thanked: 104 times
Been thanked: 502 times

Re: Infrared remote control - NEC format

Post by mnfisher »

Thanks Martin,

I also did a Transmit.. Can't test it with a TV etc because I don't have an IR LED to hand - but outputting data to 'scope it looks good...
NEC IR.fcfx
(28.91 KiB) Downloaded 95 times
In this case it just re-transmits the address and command received or outputs 'repeat' if that was received...

Martin

mnfisher
Valued Contributor
Posts: 938
Joined: Wed Dec 09, 2020 9:37 pm
Has thanked: 104 times
Been thanked: 502 times

Re: Infrared remote control - NEC format

Post by mnfisher »

Had an attempt getting transmit to work.

So the first macro in Transmit has a typo - it needs the last line changing to data[3] = ~.cmd

But - no joy. Looking at the led using a phone camera it appeared very dim compared to the remote control (using a pin and 220ohm resistor). I added a transistor and brightness issues were solved.

However, Still no TV response (I tested the Arduino library send as well with similar lack of success). Anyone any thoughts on what is missing / wrong??

Martin

Post Reply