RC5 Protocol decoder using PIC16F887 and mikroC

After I build NEC remote control decoder using Microchip PIC16F887 8-bit microcontroller and MikroElektronika mikroC PRO for PICcompiler, now let’s see how to decode IR remote controls which use RC-5 communication protocol. NEC decoder project link is below:
NEC remote control decoder with PIC16F887 and mikroC compiler

Also I made the same project which I’m going to do but using CCS PIC C compiler, project link is below with some information about the RC5 protocol:
RC-5 Decoder with PIC16F887 microcontroller and CCS C compiler

Components Required:

  • PIC16F887 microcontroller   —> datasheet
  • IR Receiver
  • 1602 LCD screen
  • 10K ohm variable resistor
  • 5V Power source
  • Protoboard
  • Jumper wires

The Circuit:
RC-5 decoder with PIC16F887 circuit diagram is shown below.

NEC remote control decoder circuit

In this example the PIC16F887 microcontroller runs with its internal oscillator and MCLR pin is configured as digital input (configured in the software).
The IR receiver has three pins: VCC, OUT and GND. The output is connected to pin RB0.

The 1602 LCD screen (2 rows and 16 columns) is used to display the RMS value of the applied voltage, it is connected to the PIC18F46K22 MCU as follows:
RS —> pin RD0
E   —> pin RD1
D4 —> pin RD2
D5 —> pin RD3
D6 —> pin RD4
D7 —> pin RD5
VSS, RW, D0, D1, D2, D3, and K are connected to circuit ground
VEE to the variable resistor (or potentiometer) output
VDD to +5V and A to +5V through 330 ohm resistor.
VEE pin is used to control the contrast of the LCD. A (anode) and K (cathode) are the back light LED pins.

RC-5 decoder mikroC code:
Before writing the C code of the decoder, I drew a simple state machine of the RC5 protocol which helped me a lot in the code. The state machine is shown below.

RC-5 protocol state machine

Where:
SP : Short Pulse (About 889µs)
LP : Long Pulse (About 1778µs)
SS: Short Space (About 889µs)
LS : Long Space (About 1778µs)
The resolution of the code is good as we’re working with interrupts.
Rest of code description is below.

The video below shows a simple hardware circuit of the decoder:


Discover more from Simple Circuit

Subscribe to get the latest posts sent to your email.

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to Top