RC-5 protocol was developed by Philips in the late 1980s and it is still most widely used. A remote control is a component of an electronics device most commonly a television set originally used for operating the device wirelessly from a short line-of-sight distance. Commonly, remote controls are Consumer IR devices used to issue commands from a distance to televisions. Remote controls for these devices are usually small wireless handheld objects with an array of buttons for adjusting various settings such as television channel, track number, and volume. Most of these remote controls communicate to their respective devices via infrared signals.
PROTOCOL: It’s set of rules or agreement between sender and the receiver.
Here the TV remote which is the transmitter transmits set of pulses of infrared light in a specific format (that is nothing but protocol) which is decoded and understood by the receiver that is our tele-vision.
DESCRIPTION: PROTOCOL BASICS
RC-5 protocol is 36kHz pulsating infrared signal so to decode it one will have to use TSOP 1738 sensor and it’s output can be given to any microcontroller interrupt pins. Building up of sensor receiver is beyond the scope of this topic hence, assuming that the ir receiver is already built up and now ready to decode then let us start,
The pattern of RC-5 protocol is as shown:
Fig. 1: Image showing typical pattern of RC-5 Protocol
There are totally 5 sub divided bits:
· Bit 1 & bit 2 — AGC control bit
· Bit 3—– check bit.
· Bit 4 to bit 8——system address bits (in our case TV ).
· Bit 9-bit 14——– command bits.
AGC CONTROL BIT– The purpose of which is to provide a controlled signal amplitude at its output, despite variation of the amplitude in the input signal.
CHECK BIT- Every time you press a key at the remote, even pressing repeatedly the same key, this bit flips state. Suppose you pressed number “1” at the remote (trying to select channel 15 at TV) and holding it for 2 seconds, then your other hand just blocks the Infra Red signal. The TV would receive two trains of pulses, generated by your hand breaking a long train in two. Other systems would understand transmission of two keys “1” selecting channel “11”, but this do not happens in the Philips system. This bit flips state every time you press a key, so blocking the signal with your hand doesn’t change this bit, so the TV will understand that still the same key pressed. To select channel “11” you should press key “1” really twice.
ADDRESS BITS- The next 5 bits, #4 to #8, are used for SYSTEM ADDRESS, or to identify which kind of device should execute the COMMAND bits.
COMMAND BITS- The next 6 bits, #9 to #14 are used as order to be executed by particular sytem which is selected using the address bits.
RULES TO RECOGNIZE BIT PATTERN:
1. The RC5 code uses the bifase modulation technic which means that every bit consists of 2 parts which are never the same.
2. So a bit is always a high/low or a low/high transisition. By the RC5 code a “1” is decoded as pulse having low to high transition.
3. And a 0 is decoded as a pulse having low to high transisition. For all the bits when the signal is transmitted first there comes AGC BITS àCHECK BITàADDRESS BITSàCOMMAND BITS(first followed by “MSB BIT” of the command bit first & then, the lsb bit) the most significant bit is transmitted first.
4. The IR receiver used (like TSOP 1738) gives the signal inverted that is: A “high” at the sensor is outputted as “low” & the low at the input is outputted as “high”.
5. So one can change definition as a LOW to HIGH now becomes a “0” and HIGH to LOW now becomes a “1”.
We can know see how to decode the patterns and thus write an algorithm to decode the signal & make use of it.
BIT LENGTH AND SIGNAL LENGTH OF RC-5 PROTOCOL:
So having the knowledge about the ir receiver one can know that if there is no IR signals detected that is: if no button is pressed on the remote control then, the output of the IR receiver will always be high i.e a “1”.
When you press a key at the remote, it transmits the train of pulses, and your microcontroller will receive first bit . It will be sensed right after the middle of the bit when it changes from high to low level means it is logical bit “1”. This is the first time that your microcontroller will “see” the incoming IR signal.
Now one need not to decode those first three bits and address bits because( if you are not doing a TV for yourself ) to control any devices may be at your home just command bits are enough as there are 6 command bit’s & depending on number of keys on the remote I had more than 32 key so, those many devices can be controlled.
So it is necessary that we decode the signal right at the starting of the “COMMAND BITS” and to make this happen a proper adjustment in time delay is to be made this can be done by skipping the time taken for “ the starting 3 bits (AGC & CHECK) + address bits” at the time the first pulse is detected. One can even decode the address bits and increase the number of devices to be controlled.
Now, how much time is required to be skipped such that we exactly come at the start of the “COMMAND BITS” ?.
First of all, Philips adopted or created the RC5 standard that uses fixed bit length and fixed quantity of bits. Each time you press a button at the Philips remote control, it sends a train of 14 bits. And each bit is 1.728ms wide. The length of 14 bits= 1.728ms*14=24.192ms. the whole train is repeated every “130ms” if you keep the button pressed . This is important point as say one has programmed for number “3” and the person presses no “3” for 1 second so if the decoding & detection of the key took around 30ms the programmer should see that the other time that is of 130ms is somehow wasted such that the microcontroller doesnot misinterpretus it as “33”.If not understood don’t get confused I have explained it in more deatil while writing algoritm. So as we know now that each bit is of 1.728ms bit length. And each bit is detected as “high to low” or a “low to high” that is: Each bit is sliced in two halves. The left and right half has opposed levels(this is already explained in rules). So a bit has a two states a high & a low each with equal length as shown:
Fig. 2: Diagram showing Amplitude and Period in a Digital TV Remote Signal
As shown the length of “ONE BIT” that is period (as per diagram) =1.728ms.
And each high and low levels are of equal length =[1.728ms/2]=0.864ms.
So, notation as per rules 5 th point will be considered to detect a high and a low bit.
Let me repeat how each bit will be decoded at the “output of the IR receiver” –LOW to HIGH is a bit “0” and HIGH to LOW is a bit “1”.
Bit “0” is detected as bit “1” is detected as
Fig. 3: Diagram showing Low to High and High to LOW Transition on RC-5 Encoded TV Remote Signal
Steps to Decode the RC-5 Protocol
1. When a first pulse is detected that is when a button is pressed on the remote control a train of pulses are detected by the receiver, for the very first bit detected that is at the start of the AGC bit the receiver output goes to zero.
2. We could observe the direction of the changing at the middle of the bit that is 0.5 bit(1st agc bit) + 2bits(2nd agc bit + check bit) +5 bits ( address bits) +0.25bit (to ensure that we are correctly now present at the command bit) =7.75 bits =13.392ms. (+or – 0.1ms is ok).
3. As each bit is of two states(a high & a low) It means that the second half of the bit is actually the same meaning of the bit to be transmitted, If you want to measure the correct logic level directly from the Receiver Output, you should measure at the first half of the bit and need not to measure the whole bit length of 1.728ms.
4. Now starts your command bits with 0.25 of the bit already skipped in step2.
5. Hence now we are exactly at the middle of the “half bit” (our first command bit) . as shown:
mid of the half of the bit
Fig. 4: Diagram representing a Half Bit on RC-5 Encoded TV Remote Signal
6. We can scan for 0.25 bit length and find whether low or high if the very first scan gives us high that means necessarily the other half (0.5 bit) of the bit should be low so as per rules : highàlow means a “1” And vice- versa for a “0”. Store this scanned bit & remember this is a MSB bit so left shift this bit in a register. Remember one need not to decode whole 1.728ms bit length. As now say scanning decoding & shifting took around 0.5 of bit length (it changes from controller to controller depending on machine cycles to execute a task ).
7. Still 0.25 bit of already decoded bit is remainig hence spend 0.25 + another 0.25 bit =0.5=1.728ms*0.5=1.296ms bit time to enter exactly at the mid half of the next command bit. Again scan decode & right shift in the same register used to rigght shift the first bit this is second command bit. Repeat steps 6 & 7 till all 6 command bits are recovered.
8. As already explained this train of 14 pulses repeats after every 105ms if key is kept pressed hence as once 14 pulses are decoded give a long delay say of about 5 seconds till the person releases the the key pressed this way one can avoid the misinterpretation by the micrcontroller of pressing the same key & false determination of the command.
Fig. 5: Image of Flowchart representing algorithm to decode RC-5 Protocol encoded TV Remote Signals
Filed Under: Electronic Projects