To decode Sony SIRC codes output by my Harmony 880 remote control, I connected a Panasonic PNA4602M infrared sensor to P0.4 (CAP0.1). It's a 38kHz type sensor, so it works great with standard remote controls. Rather than work blind, I connected a 16x2 character LCD in 4-bit mode with busy flag checking to display the codes.

It's a fairly simple project, but very useful for all kinds of things.

The sensor works inverted (high idle). When it receives a signal the output pulses low. The program measures the pulse-widths and builds a 12-bit "word" in buffer that contains the 7-bit command and a 5-bit address (always 1, for TV, in my case). Remote controls send every command three times. The program detects and processes all three, but only the last one is used.

The code sets P0.4 up as CAP0.1 and watches for a falling edge. It interrupts on a falling edge, saves the timer counter value as start and sets to watch for a rising edge. When it detects that it calculates the width of the pulse, processes it accordingly and sets to watch for a falling edge again.

Here's an overview of the project. Wiring is ugly, but totally reliable. A closer view (right) shows the PNA4602M IR sensor behind the LCD. The sensor and the LCD both need 5V power, so the breadboard has its own power supply. The input pin (P0.4) on the ARM is 5V tolerant, so no worries there.

You can find a partial list of SIRC codes and pretty good information at this site.

Without my Saleae Logic I would have found this project incredibly difficult to get working right. My remote control's output pulse-widths are different enough from the spec that I wasted a lot of time trying to get it going, with very flaky results. Then I hooked up the Logic and could immediately see that the actual pulse-widths were a bit longer than the spec. Adjusted the code to suit and she works great now!

I'll draw a schematic soon, but this whole thing is pretty simple. You should be able to figure it out for yourself.

Here's the code, done in Eclipse/yagarto. Header file at the bottom.
Oops. Code lost for now.

Next Post Previous Post