Hi Friends,

Welcome to my AVR tutorial Series. In this article I will describe my Infrared Remote Control Library. Hope you will enjoy it.

I was very much amazed my remote controls since long. The simple circuits described in magazine were just operated like a switch and can only switch on and off an application. That means only single channel. That was of not much use. What I wanted was access to each key on remote control. I wished I could decode the signals generated by common remotes controls found in our homes. This way I could make multi channel remote controls for any project. So I went on and after some web research, coding and debugging I finally succeeded !

Actually I completed that more than one and half year ago (in may 2007). And now I thought I should also make it available to others who are in need of it so that they can use it in their projects. So I went on to make it more "clean" and also to make it more "easily portable" so that it can be used with different devices operating at different frequency. And now the result is here, a very easy to use library that can add remote control feature in any of your AVR project !

Using a IR remote has many advantages over using push buttons, like

  1. Less I/O pins used. You only need to engage a single MCU pin and you get over 50 input buttons !!!
  2. A typical DVD player remote costs only Rs40 to Rs 80 in India ($1 to $2 !!!). Compare with this the cost of using push buttons soldered on verobord.
  3. At last its Wireless !!!

But the only problem is the "difficulty" involved but you don't need to care for that because you can use my library free of cost !

Specifications

This remote control decoding library decodes the remote signal encoded with NEC format which is also known as Japanese format also. This format is very popular in India I have tested it with my old "BPL" TV remote, Intex DVD player remote and other DVD player remotes that are available in electronic shops, all worked very fine. But there are other remote control formats too. Like RC5 which I think should be popular in US. My HP Pavilion Laptops remote control does not work with this library. It is because it uses RC6 encoding (I think so). So if this library does not work with your remote control it must be using other encodation technique.

Hardware Setup


The Sensor

This library requires minimum external hardware. To test the library I have also connected a 16x2 character LCD module which will be used for displaying the decoded value of the key press. The LCD is only required for testing and to note down the key code of the various keys on remote.

Connecting a TSOP1738 with AVR MCU

Fig - Connecting the sensor.

 

 

TSOP1738 infrared sensor module interface with AVR

Fig - A real TSOP1738 IR sensor module.

 

 

The LCD Module

We connect a LCD module to the AVR to run the test program. The display will be used to display the key code received from the remote. This demo will also help you know the key code of the various keys on your remote control. To learn more about LCD interface with AVRs see this. The connection is different for ATmega8 and ATmega16/32 so I am giving both below.

Fig - LCD module connection for ATmega8

 

 

 

Fig - LCD module connection for ATmega16 Or ATmega32

 

 

You can change the PINs that are used for interfacing the LCD with the MCU. For more information on how to do that see this. The N/C pins are not connected anywhere. The PIN names are printed on the back side of the LCD module. The project can be prototyped with any development board. Some easy to use development boards are.

  1. Home Made AVR Devboard
  2. xBoard™
  3. xBoard™ MINI

Software Setup


To make the library usable with different AVR MCU's efficiently I have two different version of the library one for ATmega8 and other for ATmega16 or 32. The library requires some accurate timing and thus cannot be used with any random clock frequency. But I have done my best to make it work with common clock frequency by using some c preprocessor tricks and conditional compilation. The supported frequencies are 8MHz,12Mhz and 16MHz. So before compiling don't forget to supply the F_CPU in either the makefile or AVR Studio Project. In AVR Studio go to Project->Configuration option and set the frequency.

To be continued ...

 

Subscribe to my feed powered by Feed Burner to get all latest AVR updates on you inbox!