IR Remote Control Module

Several of my projects, such as the scanning laser clock, use common infrared (IR) remote control units.  Since just about every electronic gadget comes with one these days, they are pretty cheap at surplus sources.  Decoding a remote control unit can be a problem, though.  However, I've managed to decode several remote control units using a universal decoding program.

The first issue is to understand how typical remote control units transmit their signals.  Below is a signal I captured using an oscilloscope of the response of a Panasonic PNA4613 IR remote control detector to a General Instruments INRC-42 remote control unit (i.e., the controller for a satellite television receiver).

The signal from the IR detector  is normally high, but is pulled low when it detects a properly modulated IR signal (in the case of the PNA4613, 40Khz).  I triggered on the falling edge of the IR detector signal to capture the above display.  The IR remote control module signal has a preamble of a long low pulse, a short high pulse, followed by the bits of the message.  Wide high pulses correspond to '1' bits, and short high pulses correspond to '0' bits.  Each bit is seperated by a short low pulse.  The message of the above signal is 0100 1000 1100.

All of the IR remote contril units that I have tested use the above protocol.  Therefore I can write a universal IR remote control unit decoder.  The main issue is to determine the lengths of the pulses.  My wife, who knows me too well, gave me a Bitscope oscilloscope/logic analyzer as a christmas gift a couple of years ago.  The Bitscope is a very nice oscilloscope for its price, but it is a little bit expensive.  The pulse lengths are typically in the millisecond range, so a sound card oscilloscope can be used for the measurements (see http://www.tech-systems-labs.com/test-software.htm for a list of sound card oscilloscope programs).

The unversal remote control decoder is here, written in C for an Atmel Mega8.  Lines 62 through 78 are the timing settings.  I use a timer-based interrupt to poll the status of the IR detector input and move through a state machine.  The while loop starting at line 398 is used to determine the message emitted by each button of an IR remote unit.  I use this information to populate the detect_code() function, line 208.  Once this is populated, I can run the main loop at line 376, which prints an ascii code corresponding to the key press on the UART (this program will also perform the function of turning the scanning motor on and off), and lighting an LED for visual feedback.

I've found that its important to use high-quality IR detectors; the ones I've picked up from RS or via surplus have often been junk.  I've had good luck with the Panasonic line, and Digikey sells them for less than $1.50 each.  Plus they are small enough to put into the smallest RS project enclosure, along with a feedback LED.  I've glued together stacks of pennies and put them in the enclosure to give it some weight so that it doesn't slide around as much.