Easy, Cheap IR Remote Control Decoder for Robotics

Overview This project uses a PIC 12C508A microcontroller to interpret commands sent by a Sony IR Remote Control (SIRCS format), or any universal remote programmed as a Sony unit. The received command is returned to a host microcontroller via a single pin at 2400 baud (8-N-1). The unit should be fully compatible with all microcontrollers that can accept serial data at 2400 baud. It has been tested with the Basic Stamp II and the BasicX BX-24 controller from NetMedia. In addition to the 12C508A, only 3-4 additional components are required for a fully functioning remote decoder. I have provided here a circuit diagram, parts list and the source code for the 12C508A, which is the heart of the circuit.

I use this circuit to remotely control my robot, but it should be of general interest wherever IR remote control is desired for a particular project.

NOTE: For those without PIC programmers, I can sell you pre-programmed 12C508As for $6.00 USD + $1.00 postage and handling. Contact me at mikey@swampgas.com if interested..

Schematic and Parts List
  • U1 - PIC12C508A
  • U2 - IR Remote Detector module. Examples of suitable modules include the Sharp GP1U58, Sony SBZX series, LiteOn, etc. The Sharp units are available from Radio Shack (pn 276-137 USD$3.59) or any number of surplus sources. The Lite Ons (which I personally prefer) can be had from Digi-Key (pn 160-1158-nd USD$2.50). Any detector that operates at 38 to 40 khz should work, but note that this circuit has only been tested with the LiteOn modules.
  • C1 - A .1uf bypass cap for the 12C508A
  • C2 - A 47 uf bypass cap for the IR module
  • R1 - a 47 ohm resistor. You may be able to get by without this part.

Of course you will also need either a Sony Remote, or any Universal remote programmed as a Sony remote. The Universal Remote should run you less than $10.00 USD.

The circuit can be built onto your own PCB, but I just built mine onto a simple protoboard -- the smallest Radio Shack makes. You can optionally add an LED to this circuit to show when data is being received from the IR Remote. Connect the cathode to Vout on the IR Decoder. Connect the anode to the power supply via a 10K ohm resistor. This LED will then flash whenever any signal is received from the remote.

To see a photo of an assembled board, click here. This board includes the test LED discussed above, a 4-pin header and a diode on the Vcc header pin to prevent bone-headed polarity reversal when hooking it up to the microcontroller (I had no keyed connectors on hand when I built this). Note that there is still plenty of room on this board for more stuff -- the complete IR decoder circuit uses only about 1/2 the board.

IR Remote Modules are available from a number of sources, including DigiKey and RadioShack. You can also probably pull them out of old VCRs or Television sets. Note that if you do not use the Lite-On module, your pinouts may be different from the schematic above. Note also that many of the non-Lite On units want to have their cases connected to ground. Some of the Sony units actually have no explicit ground lead -- you MUST connect the case itself to ground.

Program Listings and How to Use the Circuit When the circuit detects and decodes a new command from the remote, it will bring Atn (GP4) high. To read the command, signal the 12C508a by pulling the Trig/Data line (GP5) low, waiting 45 ms or so, then pull it high again. Then make Trig/Data an input and read the 8-bit command value at 2400 baud, 8-N-1 using the host controllers standard serial functions. Note that all serial logic is non-inverted TTL -- to read from a PC, you will need to add line inverting/conditioning hardware to the circuit above. Most microcontrollers will not need such hardware, however. Once the command byte has been read, the Atn line is pulled low by the 12C508A.

If you want to poll the circuit for new data, you can ignore the Atn line, and just periodically check for data by just using the Trig/Data line. This allows a simpler one-wire interface to the unit. If there is no new data since the last call, 255 will be returned as the command byte. When using this method to read data, make sure your serial read function does not hang indefinitely waiting for data (specify a timeout), since it is possible to hang here if the 12C508A misses the low/high pulse.

Links
  • http://www.edcheung.com/automa/sircs.htm has a great reference on the SIRCS protocol, including a list of which command represent which keypresses on the remote. Should this site be down, the document is mirrored here (by permission).
  • Personal Robotics News May 1999 Issue has a good article on using a Stamp to decode SIRCS commands from a remote, and was part of the inspiration for this project. Note that you may need to join the group to actually access this file. Go to http://www.egroups.com to join.
  • Dennis Clark's Robotics page has a number of 12C508-based projects that served as the inspiration (and starting point) for this project. Highly recommended.
  • Feel free to contact me at mikey@swampgas.com with any questions, comments, threats, etc.