Tuesday, June 28, 2011

SIRC Decoding and Appliances Control

In this tutorial i will show you how to decode the Sony SIRC protocol and control the home appliances like bulb, fan etc with the Sony remote control. Infrared remote control has been around for a very long time now. Each manufacturer use different set of protocols. For example, RC80 is used by Panasonic, RC5 is used by Philips, and SIRC is used by SONY, which is one of the simplest to decode.

Modulation is used to prevent the other light sources interference. This modulation is center around different frequencies depending on manufacturer and varies from 32KHz to 56KHz. In the case of SONY, the modulation center is 38-40KHz which means we need a IR-receiver that can receive the modulation infrared light and convert it to a TTL signal for a PIC. There are a number of IR-receivers available, each having a specific center frequency that they are more sensitive too.You can use whatever you want just remember the pin outs; i am gonna use to local IR receiver.


SONY protocol, SIRC (Serial Infra-Red Control) protocol is an infra-red light remote control communication that uses a form of pulse width modulation (PWM) to build serial interface.The most common protocol is 12-bit interface but 15-bit and 20-bit version are also available. The figure shown below is a series of pulses build up 12-bit packet.
SIRC Format
The Header is 2.4ms in length, logic 1 is 1.8ms ( 1.2ms high + 0.6ms low), logic 0 is 1.2ms ( 0.6ms high + 0.6ms low). The packet consists of Header, Command code (7-bit) which presents the actual button pressed on the remote control, and Device code (5-bit) which presents a TV, VCR, CD player and etc. Table shown below is some list of key Command code for TV (Device code = 1).
Command Code (Hex) Function
0 Key 1
1 Key 2
2 Key 3
3 Key 4
4 Key 5
5
Key 6
6
Key 7
7
Key 8
8
Key 9
9
Key 0
0x10
Channel +
0x11
Channel -
0x12
Volume +
0x13
Volume -
0x14
Mute
0x15
Power
0x0B
Enter
0x25
Input
0x74
UP
0x75
DOWN
0x33
RIGHT
0x34
LEFT

Now it play time; what i am gonna do is to control the two energy saver and one fan in my room. To do this i will use PIC16F876 microcontroller, you can use 628a as well (but have to compile). The output of IR receiver is connected to the RB0 pin and i am using the external interrupt for it. Every time when a valid key is pressed PIC is interrupted the take the appropriate decisions. Rest of the appliances are connected with RB1, RB2, and RB3 pins. Relays are used to switch on/off the selected device. IR remote buttons used, in my code, are 1 for fan, 2 and 3 for energy saver. After applying the power when you hit a button, respective device will energize. To deactivate the same device just hit the same button again. All three devices can be operated independent of each other.

Schematic:
Now come towards the hardware design.
Update: Please note in schematic NC terminals of relays are connected with hot wire by mistake, instead of them NO terminals should be shorted with hot wire.
IR based appliances control circuit
Hardware Design


Download:
Code and schematic can be download from here.

Components Required:
R1---------------10K ohm
R2-R4-----------1K ohm
Q1-Q3-----------BC547
RL1-RL3--------5v relays
D1-D3-----------1N4007
Xtal--------------16Mhz
Capacitors--------33pF
IC1-----------------PIC16F876
IR Receiver

7 comments:

  1. I was searching on google and found this website. I found it very informative, thanks for sharing good information!!!

    ReplyDelete
  2. I just wanted to add a comment here to mention thanks for you very nice ideas. Blogs are troublesome to run and time consuming thus I appreciate when I see well written material. Your time isn’t going to waste with your posts. Thanks so much and stick with it No doubt you will definitely reach your goals! have a great day!
    FFFM180P

    ReplyDelete
  3. Asslam o allaikum,JAZAKA ALLAH

    ReplyDelete
  4. Assalm-O-Alaikum
    Dear
    Its a very useful for new learner
    Thanks. PK

    ReplyDelete
  5. Hi every one, I'd like to do the universal IR remote controller can control almost IR's devices as TVs, DVDs, air conditioners ect, what's IR protocols I need integrate in MCU?

    ReplyDelete
  6. sir i think pic micro-controllers can not support crystals greater than 8MHz.
    You have used 16MHz crystal.
    plz correcgt me if i am wrong..

    ReplyDelete