Details :
About Infrared:
Infrared light is electromagnetic radiation with longer wavelengths than those of visible light. Infrared light is used in industrial, scientific, and medical applications. Most of the remote controllers use IR light to send information.
RC5 Protocol:
This protocol was developed by Phillips using Manchester Encoding. Information is sent in frames, where each frame is consist of 14 bits. First two bits are start bits, the next bit is flip bit, which toggles every next frame if same command is sent. Next five bits are system address (remote specific) bits and last 6 bits are command bits, which actually stores command. Each bit is of 64 IR pulses.
RC5 Protocol Frame:
Manchester Encoding:
Every bit in an RC5 transmission has uniform duration, and contains one transition. '0' is encoded by a high to low transition, and a '1' by a low to high transition. There is a transition in the middle of the bit. So bit containing '0' value will be encoded as first 32 high pulses and next 32 low pulses, while '1' will be represented by first 32 low pulses and next 32 high pulses.
An Example:
So, Let's consider a remote with 38kHz frequency,
Manchester Encoding:
Every bit in an RC5 transmission has uniform duration, and contains one transition. '0' is encoded by a high to low transition, and a '1' by a low to high transition. There is a transition in the middle of the bit. So bit containing '0' value will be encoded as first 32 high pulses and next 32 low pulses, while '1' will be represented by first 32 low pulses and next 32 high pulses.
An Example:
So, Let's consider a remote with 38kHz frequency,
T= 1/38,000=0.000026316 ≈ 26µs
Now each bit consists of 64 IR bits,
64 pulses x 26µs = 1664µs = 1.664ms
So total time for a protocol frame is
14 x 1.664 = 23.24 ms
Decoding with 8051:
We have used TSOP1738 sensor to decode RC5 protocol, this sensor gives active low output, so '0' received is first 32 pulses low and next 32 high. The out pin of TSOP1738 is connected to interrupt source of 8051, decoding can be done in both ways, either polling or interrupt based,
Here we will consider interrupt based mechanism, so when it will receive a first start bit (i.e. 1, start bits are always 1 in RC5), it will be first 32 pulses high, and next will be low, here interrupt will occur, to decode information we can skip start and flip bit, i.e. MCU should skip 2.75 bits, so after an interrupt wait for 4.57ms to get next bit.
Here comes decoding of the next 5 system address bits, which holds the address of remote controller, here after each bit time i.e. 1.664ms , MCU gets value of OUT pin and stores in a variable. Same way the next six bits are decoded and command value is calculated from protocol frame.
Components :
MCU: P89v51RD2(8051 Core)
Remote Controller: RC5 (Phillips TV remote controller)
16x2 LCD Display to display commands and addresses.
IR Sensor : TSOP1738
Circuit Diagram / Schematic: