RC5 Protocol Decoding with 8051 microcontroller (Embedded C)

By | August 7, 2013

RC5 Protocol Decoding with 8051 microcontroller :-

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:

Let’s consider a remote controller with 38kHz frequency output,

 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)

16×2 LCD Display to display commands and addresses.

IR Sensor : TSOP1738

 Circuit Diagram / Schematic:

Embedded C code for RC5 protocol decoding: 





9 thoughts on “RC5 Protocol Decoding with 8051 microcontroller (Embedded C)

  1. sakru

    Can you help me I need a refrence code for decoding RC5 protocol. plzzzzzzzzzzz

    Reply
    1. blogadmin Post author

      We will update above post with code snippet of RC5 decoding.

      Thanks.

      Blog Admin,
      ProEmbSys Technologies Pvt Ltd.

      Reply
  2. Einstein

    I love your post. thanks. You said it is interrupt based, but there are no initialization commands for the interrupt, and also no commands for the lcd which it is connected to. Please could you enlighten me? thanks.

    Reply

Leave a Reply to Varnas Paul Cancel reply