IR Remote Control - Philips RC5 Protocol Encoder & Decoder
This demo showcases the PIC16F's ability to concurrently perform RC5 encoding and decoding while taking advantage of Microchip's eXtreme Low Power (XLP) sleep mode during idle time. The provided source code is written 100% in ANSI C and is completely interrupt-driven.
About this Code Example
Demo: IR RC5 Transmitter & Receiver
Device: PIC16LF1509-I/P (PDIP Package)
IDE: MPLAB X v2.00
Compiler: XC8 v1.21
Hardware: PICKit 2 Low Pin Count Demo Board (part no. DM164120-1)
Optional: PIC16LF1509 Debug header (part no. AC244052)
This demo shows the ability to concurrently perform RC5 encoding and decoding while MCU is in sleep mode during idle time.
A PICKit Low Pin Count Demo Board was used with a PIC16LF1509-ICE Processor Extension Pack (a.k.a. Debug header part no. AC244052)
for debugging purposes.
To run the demo right out of the box, a normal PIC16LF1509-I/P PDIP device can be programmed to operate in stand-alone mode.
In addition to the IR Tx and Rx pins, one of the pins is used to simulate what the IR Rx demodulated signal would look like for the
IR Tx modulated data that's generated for the IR LED so that a simple loopback test can be performed
(i.e. simultaneous decode of the IR transmission).
The SW1 button provided on the Low Pin Count Demo Board is used as the user button input.
Hold the button down to see the RC5 packets get transmitted continuously. To see the RC5 decoded data stream via UART,
connect the TXD pin to an external serial port's RXD @ 115200 baud (may need an RS-232 level translator if using a Host PC).
Quick Demo Setup/Sequence:
(1) Install PIC16LF1509 device into socket of Low Pin Count Demo Board
(2) Connect a temporary jumper wire between RC4 & RA2 (use header J1 for convenience)
(3) Program the PIC for stand-alone mode using PICKit3, ICD3, REAL ICE, etc.
(4) After power is applied to the board, the DS1 LED should come on
(5) While pressing down on SW1, the three DS1/DS2/DS3 LED's should each flash at different rates
(6) After letting go of SW1, the DS4 LED should come on (signifying that a valid RC5 packet was last received & decoded successfully)
(3) CLKOUT [OUTPUT] - (Fosc / 4) whenever device is active/awake
(4) RA3 [INPUT] - User Button (active low - i.e. pull to ground to activate)
(5) PWM1 [OUTPUT] - IR Tx Modulated to LED
(6) RC4 [OUTPUT] - IR Rx Demodulated (outputs a simulated Rx signal for loopback testing)
(10) RB7 [OUTPUT] - EUSART TXD
(12) RB5 [INPUT] - EUSART RXD
(13) RC3 [OUTPUT] - Cleared in RC5 Decoder ISR; Set whenever valid RC5 data has been received
(14) RC2 [OUTPUT] - TMR2 ISR Toggle
(15) RC1 [OUTPUT] - TMR1 ISR Toggle
(16) RC0 [OUTPUT] - RC5 Decoder ISR Toggle
(17) RA2 [INPUT] - IR Rx from sensor (weak pull-up enabled)
* RC5 Encoder - PWM1, TMR1, TMR2
* RC5 Decoder - TMR0
(1) SLEEP mode is used; button presses and IR Rx activity will serve as wakeup events
(2) To verify concurrent Tx and Rx functions, connect RC4 to RA2 to perform a simple loopback test
(3) Repeated packet function is supported - if user button is held down, repeated packets will be sent out every 114 msec
(4) On every SW1 button press, the address and command data fields are both incremented by one, and the toggle bit should switch between 0 & 1
(5) PIC16LF1509 Debug header (part no. AC244052) is required to use the SW1 pushbutton while in Debugger mode
(6) If using the AC244052 Debug header, it needs to be selected in the project's "Properties" Configuration page
- Jan 14, 2014
Added support for UART to send out decoded RC5 data stream
- Jan 10, 2014
- Current Version:1.0.1
- Created:Jan 10, 2014
- Updated:Feb 26, 2015
- MPLAB Version:MPLAB X v2.00
- C Compiler:MPLAB XC8 v1.21
- Development Tools:PICKit 2 Low Pin Count Demo Board (DM164120-1), PIC16LF1509-ICE Processor Extension Pack (AC244052)
- Supported Devices:PIC12F, PIC16F, PIC16LF1509