RC-5 Arbitrary Code Transmitter

When a good friend came to me with two obscure pieces of HiFi equipment (Micromega amp and tuner) which lost their remote controls I decided to build a QnD (Quick 'n' Dirty) PIC kludge. Unable to find a solution online I had to write my own code.

Luckily I already had done that before (Pentax Remote) so I quickly built the needed hardware:

The schematic was done in no time because it is not a whole lot:

The idea is that the DIP switches select the system and the command:

But first let's take a step back and look at what happens here. The RC-5 protocol is well documented (see for instance Wackypedia). It consists of 889 µs bursts of 36 kHz pulses that are Manchester encoded. Whatever. There are 14 bits: two start bits, a toggle bit to differentiate between separate key presses and holding a key, five address or system bits and six command bits. The second start bit doubles as seventh command bit (aka "field bit") to enable an extended command set. Since the second start bit S2 already is "1" C6 is inverted.

My kludge has four buttons. The TX button is programmable by the 12 DIP switches. The VOLUP, VOLDN and PWR buttons are fixed but the system is set by the address switches. The green LED shows the toggle state until the PIC goes to sleep and the red LED is the TX (transmit) indicator. The infrared LED has no current limit resistor, the PIC does that for me. Power is decoupled with an electrolytic cap of 470 µF (not in the schematic) and the power is taken from an 18650 lithium cell that I had lying around (from a dud laptop power pack). Two mini penlites (AAA) will work fine as well. Lots of SMDs to keep it small.

As for the code. It is straightforward. Interrupt generated by keypress (RBIF) wakes PIC, buttons are decoded, DIP switches read, pulses sent out. Once the button is released the PIC goes back to sleep. I had to use a separate scan line to decode all 12 DIP switches. Only one burst should be enough for a successful decode but in case of noisy environments more may be needed. The toggle bit will let the micro of the device being controlled know whether another command has been given. So far I have not encountered any issues with this pause.

Using it was great fun. I used an existing remote to get all its codes by decoding images like this one:

You can see half a start bit (1), the second one (1), toggle bit (1) and then the rest of the message (00001100001). This actually is a weird result as the expected system code for "tuner" is 0x11 and this remote sends 0x01. Oh, and to get this image I just used a remote eye from my junk box (satellite receiver) and hooked my scope's probe tip to its output. By setting this pattern into my arb TX I could control this device. Of course the code could also be rewritten to emulate an RC-5 remote from scratch. The availability of programmable remotes on the market would make this a bit of a redundant exercise except for making sure that the remote being replicated does exactly what it should do.


Back to the homepage

Date: 26 August 2020, updated 28 August

This software is licensed under the CC-GNU GPL.