Decoding Sony IR protocol with a pic16f628


Today I'm started to write the firmware to decode ir signals because many people asked for it. On this page I will explain how I'm doing it with a pic16f628. The code will be written in assembler. Maybe later when I have good reactions on this topic I will publish my code of the tinyserirchip for the Phillips RC5 code.

Because many newbies and also hardcore electronists don't like it to make inmediatly huge printed circuit boards, so I will keep the hardware to a minimum that you can start with a breadboard (the way I did it to test the firmware), experimental pcb's.

These are the steps to do:
So whats the minimum: Because we work with IR light we need an ir receiver. The easiest way to receive modulated IR signals from remote controls is with an integrated module like those ones from Vishay or Siemens. I have the best experiences with the TSOP serie from Vishay.
Like you can read on my Sony IR protocol page the carrier frequency is 40kHz this means I use a TSOP1840. The output of this component is TTL compatible and we can connect it directly on an input pin of the microcontroller.
To decode and translate the output datastream of the ir module we need a microcontroller, here I take a pic16f628. Because it's easy available for the hobbyist, very cheap (cheaper than the pic16f84) and I'm familar with programming pic chips. To make a visualisation when a valid ir code is received we need also a led. I toke a white led because i have many of them but when you change the resistor value you can take other colors. To do something with the received ir signals we need also outputs. The outputs are output pins of the microcontroller, we will use 8 of them to drive external power stages etc.

I will add also a function that sends the data to a computer. So it will be possible to control your pc with the received infrared code. Then with a program running on the pc it will be possible to control winamp or other programs. At this moment the program will decode the sony protocol. When you push a button from 1..8 on a remote control you toggle the bits 0..7 on portB. When you push button 0 all outputs will be cleared.

The circuit of the hardware



The component values are:
R1 if you use a white led 100ohm, if you use a normal led 270 ohm
C1 = 100nF
C2 = 10F /16V
IR receiver = TSOP1840
CN1 = 8 pins header

The power supply is not included in the circuit, do a google websearch with the keyword 7805 voltage regulator and you will find hundreds of circuits.

The sourcecode

Before you download the sourcecode I'm asking two little things:

I need to do still some work on the sourcecode, but the sourcecode is working, just I need to add code to send the received ir codes to a pc.
View the sourcecode:
Download the hexfile:

Many people asked me to change the code that it only responds to a specific address here you find this.
View the sourcecode:
Download the hexfile:

Below you can find a version for the pic16f84 you can activate also control the first four outputs and the last together with channel buttons.
With the volume buttons you toggle outputs 1,3,5,7 or 2,4,6,8.
View the sourcecode:
Download the hexfile:

Downloading the sourcecode and hexfile is free, but if you appreciate my work you can make a donation via paypal with the button below or take a look on the ads.


The pictures are send to by users who made this project, please send me your pictures to then I can publish them and encourage other people to build this nice project.

Ahmed Abd El-Rahman from Egypt his project.

Back to homepage
fraud click