Figure 2. Bi-Phase encoding.
but there the similarity ends. The packet format looks like
that in Packet 2. By ~Device ID and ~Command, I mean
that it is inverted, or 1’s complement of its respective
Device ID and Command. To check for a proper reception,
all you need to do is AND the byte with its respective
complement; if it comes up all zeros, then you have a good
reception. When you hold down a button on the NEC
remote, it does not send out the same command over and
over; it sends out a special signal called the Repeat Code.
The NEC protocol has four timing values that we care
about, and one we don’t (the Lead Out). Table 2 shows the
ones that we pay attention to.
Phillips RC- 5 Format
Some useful information on the Phillips RC- 5 format
Figure 3. RC- 5 packet.
can be found here:
www.hifi-remote.com/infrared/IR-bi-phase.shtml
and here:
http://home1.stofanet.dk/hvaba/fprc5rx/index.html
The last of the big three formats that I’m going to talk
about is the Phillips RC- 5 protocol. Rather than using PPM
encoding like SONY and NEC, the RC- 5 format uses Bi-Phase
encoding. This means that the transition from a logic ‘1’ to
a logic ‘0’ and vice-versa is shown by a change in the bit
phase. If you are like most of us, your eyes just glazed over
at that description. This is one time that a picture is pretty
much needed to explain what I mean (see Figure 2).
Note that it isn’t the timing that shows what the bit is,
but rather the phase of the timing. But how — you ask — do
you know what a ‘1’ is and what a ‘0’ is? You know because
the bit stream of RC- 5 starts out with two 1 bits and then a
toggle bit, which on the first press of the button is a 0. Figure
3 shows how a transmission is formatted. An RC- 5 packet
consists of the preamble of 1 1 0, then a five-bit address and
then a six-bit control. RC- 5 packets are encoded with the MSB
(Most Significant Bit) first. Because you know that the first
bit is a 1, then any bit transition from that point onward
you can track to know what the current bit is — a 1 or a 0.
Figure 3 may look a little odd because I put both same
and switch phases in every bit cell except for the start bits.
Just to make it more confusing though, I’ve read that the
start bits can be either 1 1 or 1 0. I hope not; it’d make it
hard to figure out the 1 startup. The RC- 5 protocol will
repeat the button press every 113.8 ms, but every packet
after the first one will have the Toggle bit toggled
differently than the last start bit.
Figure 4. IR detector schematic.
18 SERVO 07.2008
How to Decode IR Transmissions
Okay, now that the explanations are over with, how
Part
C1
C2-C4
R1
R2
R3
D1
S1
U1
U2
U3
J1
J2
J3
Description
110 μF 25V capacitor
.1 μF 25V capacitor
10K 1/4W 5%
2.2K 1/4W 5%
1K 1/4W 5%
Green LED
N.O. button
PIC16F688 DIP
7805 regulator
PNA4602 IR demodulator
Power connector
Four-pin male .1” connector
RJ- 11 six-pin connector
Table 3. IR detector parts list.