I plan to make some project(s) with infrared remote controls, so i had to get some experience with the various protocols. I chose to begin with the Philips RC5 protocol, because first it is a very popular protocol (not only for Philips devices) and second because i already own a Philips TV and a Philips DVD. I am aware that there are tons of information around the internet regarding this protocol, but my best way to learn something is to write a theory about it - Writing a theory page requires in-depth knowledge of the subject.
The RC5 Protocol specifications
Here are the specifications of the RC5 protocol as per the Philips datasheet:
Modulation type: Manchester code (bi-phase) - LOW to HIGH for ACE (1), HIGH to LOW for ZERO (0)
Carrier frequency: 36 KHz
Start bits: 1
Field bits: 1
Toggle bits: 1
Address bits: 5
Command bits: 6 or 7 (if RC5-extended)
Bit period (transmission clock): 1,778 mSec
Total signal duration: 24.892 mSec
Signal repetition interval: 100 mSec
Let's examine these bits one by one:
The Start bit (1)
This is the very first bit that is being transmitted. This bit is always 1 and initiates the receiving sequence.
The Field bit (1)
This bit has dual functionality. Normally, this is considered as a second start bit and it is always 1 as well, like the start bit. Later on Philips introduced the RC5 extended protocol when they realized that 64 commands (6-bits command length=64) are just not enough. To maintain compatibility with the original RC5 protocol they decided to use this bit for a 7th command bit. This way the RC5-extended protocol has 128 commands (7 bits). Care must be taken though with this bit. If it is used as the 7th command bit, it must be inverted!
The Toggle bit (1)
The toggle bit is a bit that it maintains the same as long as a key is pressed continuously, but if a key is released and is pressed back again (the same or a different key), the toggle bit is inverted. If for example you press the button "1" button and you keep it pressed, the remote control sends the RC5 protocol with 100mSec repetition interval, and all these repetitions have the same toggle bit (for example 1). Now suppose that you release the key and you press the same or another button. The next series of packets will be sent with the toggle bit inverted (0).
The reason for this bit is for the receiver to recognize the double-click from a long press. If for example you press button 1 twice (to switch to channel 11), the receiver will understand this from the toggle bit that will appear inverted the second time.
A list with the devices for the RC5 protocol
The Address bits (5)
This set of 5 bits represent the device ID (address) that each remote control addresses to. This way, the operator can have more than one devices which use the RC5 protocol in the same room, without the remote control of the VCR for example to affect the TV. You can find a complete list of these devices in wikipedia.
The Command bits (6)
The last 6 bits carry the command to be executed. This can be for example a channel switch on the TV set, a volume up or down on the CD player, the power button on the VCR. Generally, these bits carry all the possible commands that the remote controls can have.
An RC5 transmission example
Let's see a typical transition with the RC5 protocol...
How to identify the aces and the zeros
Bit F and Bit T stands for the Field bit and the Toggle bit respectively. There are two very simple ways to recognize if a bit is 0 or 1. The first way is to identify the polarity switch in the middle of the bit transmission. In the previous example i have drown 14 thin red vertical lines to separate the bits. Notice that between two red lines, right in the middle, the bit changes polarity - It turns either from HIGH to LOW or from LOW to HIGH. If this change is LOW to HIGH, then the bit is an ACE, otherwise the bit is ZERO.
The other method is to see how the bit begins or ends. If the beginning of the bit is LOW, then this bit is 1 otherwise it is 1. The same but inverted stands for the bit-end. If the bit ends HIGH then this bit is 1, otherwise it is 0.
The Toggle bit - How it looks like?
The RC5 protocol is pretty straight forward, except of the toggle bit which can be sometimes be confusing. To understand how the toggle bit works, check out the following transmission timing charts:
Both transmissions have precisely the same address and data bits set. The only difference is the toggle bit. On the top transmission, the toggle bit is 1 while on the bottom it is 0. This shows that the button with the command number "001000" was pressed - released and pressed back again. - thus the toggle bit was inverted.
Continue to the next page to see a real-life example - i monitored the output of an RC5 compatible remote control with my oscilloscope.