Skip to main content

IR remotes

As part of my home automation project, I also wanted to control my home entertainment system. The controller can be a web interface or an app on android phone, or even a universal remote. Which means, I have to be able to send IR signals from the arduino board that my TV, amplifier and set-top box can understand. For this I will first have to read the signal coming from the remotes, store the various signals and replay them from the arduino board depending on my needs.

Before going too far into the details of receiving and sending IR signals, it would help to understand how a remote control actually works. There is already a lot of material on the internet on how remotes work. So I will try to keep it short and simple.

The IR transmission from remote to your device works on a really simple protocol. The transmitter which is just an LED that emits light in the infrared spectrum, pulses the light in a quick succession and the receiver which is a phototransistor, converts the light signal back to electric pulses. Now to transmit information, the transmitter should send a bunch of 0s and 1s. Normally one would expect (at least I thought), a 1 would be represented by the LED being on and 0 would be represented by the LED being off. However all the data would then have to start with a 1 because only then will the receiver be able to start "listening" to the data.


One way to solve the dilemma of data always having to start with 1, is to have some kind of start signal (the header), to let the receiver know that the data is about to start, and that it should prepare for listening to the data.


Now what happens if there are more than 1 consecutive 0s or 1s? If we know that the pulse width is certain milliseconds then we can identify the consecutive 1s or 0s. But the problem however is the timing. The receiver's and the transmitter's timers should be perfectly synchronized. Otherwise 4 consecutive 1's from the transmitter could be mistaken for only 3 consecutive 1s, if the timers drift a little bit.


So to solve the problem, the IR transmitters and receivers actually use a combination of high and low to represent either a 1 or 0. The 1 is usually represented by longer high and smaller low. While a 0 is represented by smaller high and low. For example in the following drawing the 1 is represented by 1200 milliseconds of high and 600 milliseconds of low. A 0 is represented by 600 ms of high and 600 ms of low. The header is represented by 2400 ms of high and 600 ms of low.


This is the Sony protocol, used by all Sony remotes. Other remotes may have slightly different timings for 1s and 0s, but that is generally how most remotes work. Now there is just one more twist. The IR signal is finally modulated with a high frequency signal, usually between 38kHz and 40kHz. An IR signal modulated with 40kHz looks like this.


Finally, most remotes repeat the same signal at least 2 times. The sony protocol specified that it should be repeated at least 3 times, and the signal should repeat every 45ms.


That is all we need to know to get things started with automating home entertainment systems!

Comments

Popular posts from this blog

Attesting General Power of Attorney in SF

Recently I had to go through the motions of getting a General Power of Attorney (GPA) document attested in San Francisco. I am an Indian by birth. My parents were trying to buy a house back in India for me. Since I did not want to travel to India they needed a GPA so that they can act on my behalf to sign all the documents required to buy the house. The problem however is that they needed it urgently because the seller lives in UK and wants to get all the things done quickly so he can go back. My parents send me a GPA document that they obtained from a lawyer. This is a document that will give the power to my parents to buy the said property in the document on my behalf. The lawyer said that I will have to get the document attested at an Indian Consulate in USA. The closest one for me is in SF and I can drive there in about an hour from where I live. So I though it will be like a day's work to get all the things done. I looked up at their  website  for the procedure t...

XBMC / Boxee remote control android app

I have been writing a few android apps over weekends at home and during 20% time at Google. However I never actually released any of them in the android market mainly because they were quick and dirty apps that fit my needs but perhaps would not be appealing to the general public. One such app that I quickly wrote over a couple of weekends is a XBMC remote. The media center that I use at home is XBMC and I have always wanted to have more control and faster access to my media. Using my remote to navigate through the menus is not as fast. Especially when I wanted to queue a lot of music it is very slow. So I wrote this nice little app called "XBMC remote" for my android phone to control XBMC from anywhere :). Give it a try. Search for "xbmc" in android market and install it if you use XBMC as your media center. When you first launch the app you will start with this screen. You will have to setup your web server address, username and password (if required) by ...

gtkdocize not found

If you are ever configuring an app and see the message "gtkdocize not found" in Gentoo, then you need to emerge gtk-doc. I had some hard time figuring this out so I am writing it in my blog for the next time. When I saw that error message I did an "emerge -s gtkdocize". Usually it is that simple in Gentoo. But not this time. The emerge command returned no results at all. Then I searched for gtkdoc and still no luck. After searching in Google, I still did not have a solution. After thinking for a while I decided to try to search for gtk-doc. Bingo! That worked! Interestingly, this is my first post from my Virtual machine :-)