Infra Red Signals - The Bi-Phase (RC-5) Format.

Written by Guy Kuo

Much of the data here was builds on and borrows information from the
Pulse Width Method document by Barry Gordon. You should read that
document and understand how to decode pulse width modulated codes. This document
covers decoding of RC5 phase modulated codes.

The Pronto learned hex code is a series of hexadecimal numbers. The first four of which have special meaning.


Word 1: Type of hex data (0000 means this is a learned code)

Word 2: IR carrier frequency where Frequency = 1000000/(N * .241246)

Word 3: Length of "One TIme" data burst pair sequence

Word 4: Length of "Repeat" data burst pair sequence

The "One Time" data burst is the data sent if the key is pressed momentarily. The "repeat" data burst is sent repeatedly if a key is held down. There is always at least one burst pair sequence in a learned code.

Let's take a learned code and translate it into RC-5 system and command numbers.

0000 006d 0000 000c 0020 0020 0040 0020 0020 0020 0020 0020 0020 0020 0020 0040 0040 0020 0020 0020 0020 0020 0020 0020 0020 0040 001e 0ce8

is a learned code from an RC-5 remote. Looking at the first for words we have:


Word 1: 0000 This is a raw learned code

Word 2: 006d Clock rate for RC-5 carrier signal 35 kHz

Word 3: 0000 This code has 0 words representing a "one time" burst

Word 4: 000C This code has $C (12 decimal) words of "repeat" burst

The remaining $C (12 decimal) words are the actual signal times for carrier on and off. The first word of each pair is how long the carrier is on. The second word of a pair is how long the carrier is off.

0020 0020 0040 0020 0020 0020 0020 0020 0020 0020 0020 0040 0040 0020 0020 0020 0020 0020 0020 0020 0020 0040 001e 0ce8

Let's make the ON times positive and the OFF times negative . . .

+0020 -0020 +0040 -0020 +0020 -0020 +0020 -0020 +0020 -0020 +0020 -0040 +0040 -0020 +0020 -0020 +0020 -0020 +0020 -0020 +0020 -0040 +001E -0ce8

This is the timing information we need to decipher. We know that RC-5 format has a fixed data format. The code is 14 bits long and consists of...

1 run-in bit to adjust AGC (always a logic 1)

1 run-in/field control bit (selects between commands 0-63 vs 64..127)

1 check bit (toggle) to indicate new data has arrived

5 system bits (most significant bit first)

6 command bits (MSB first)

The data bits are detected at the start of each 0040 time intervals.


At the detection time, the carrier is turned on or off to


Indicate the value of each bit.

A logic one is a transition from carrier off to carrier on


A logic zero is a transition from carrier on to carrier off

The trick is to find out if the carrier is going from on to off or off to on at the sampling time. Partition the words every 0040 bit time period.

+0020 -0020

+0040

-0020 +0020

-0020 +0020

-0020 +0020

-0020 +0020

-0040

+0040

-0020 +0020

-0020 +0020

-0020 +0020

-0020 +0020

-0040

+001E -0ce8

Look at the what happens at the beginning of each 0040 bit interval. The transition in the middle of the bit time interval doesn't matter. It only set things up so the transition at the


Next sampling time is in the correct direction to send the next bit. Hence, ignore the


Second word of a 0040 time period composed of two 0020's. If we drop off the mid


bit time words we get..

+0020 carrier switches on = Logic 1

+0040 carrier switches on = Logic 1

-0020 carrier switches off= Logic 0

-0020 carrier switches off= Logic 0

-0020 carrier switches off= Logic 0

-0020 carrier switches off= Logic 0

-0040 carrier switches off= Logic 0

+0040 carrier switches on = Logic 1

-0020 carrier switches off= Logic 0

-0020 carrier switches off= Logic 0

-0020 carrier switches off= Logic 0

-0020 carrier switches off= Logic 0

-0040 carrier switches off= Logic 0

+001E carrier switches on = Logic 1

The encoded bits are thus 11000001000001

Group the bits into the run in/check/system/command bits to get

1 -- run in bit which is always 1


1 -- run in bit/field (1 = commands are 0 to 63. 0 = commands 64 to 127)

0 -- toggle bit (flips between 1 and 0 with each press of button)

00001 -- binary for the system number

000001 - binary for the command number

It's a lot simpler than first glance. Just don't forget to translate the binary number into decimal for entry into ProtoEdit's RC-5 system and command fields.

Now we need a program to do this automatically.

This article was originally posted to http://www.hifi-remote.com/infrared/IR-bi-phase.shtml

 

Connect With Techlore