Hi Friends,

Today I will present an easy to build Multi channel IR Remote control system. It can control heavy loads (Up to AC 220V 6 Amps or smaller) with a touch of remote control. A total of 5 devices can be controlled from a distance of up to 20 feet. We will be using a standard remote control protocol that is called the NEC format. The NEC format is common in remote controls used with Chinese made CD/DVD players. They are easily available in Indian Markets. They also come in variety of sizes from full to small 21 keys (used in car audio systems).

Our system is smart enough, so the user can set which key controls which load. Their are five load indicator LEDs which provide the state of five loads. When the device is powered on for the first time, the load LEDs start to blink one by one. That is the first load LED starts to blink, this means the system is waiting for the user to assign a key for that load. So you should press the key you want to use for that load. Once the system receives the key of your choice it stores it in internal EEPROM. From now on you can use that key to control that specific load. In this way all five loads are mapped to five keys on the remote control.

The above key mapping procedure is required only once. From the next time the system is started it does not goes through the key mapping procedure. Although if required the same key mapping can be initiated if user wants. This is done by pressing any key on remote control within 3 second of booting. If the system receives any key press during boot up (i.e. within 3 sec. of startup) it starts the key mapper.

Once the key mapping is done, user can switch on/off the loads by just pressing the keys on remote control.

Their are five power connectors (the green thing on the edge of the board), they are used to connect external load. They function like simple switch. That means the two contact are closed (connected) when relay is active. Other wise they are open (NOT connected).

Multichannel IR Remote using AVR ATmega8

Fig.: Multi channel IR Remote

 

Multichannel IR Remote using AVR ATmega8

Fig.: Multi channel IR Remote

 

Multichannel IR Remote using AVR ATmega8

Fig.: Multi channel IR Remote

 

Multichannel IR Remote using AVR ATmega8

Fig.: Multi channel IR Remote

Schematic for Multi channel IR Remote

AVR ATmega8 based Multichannel IR Remote

Fig.: Multi channel IR Remote. Click to Enlarge/Print.

avr-gcc Source Code for Multi channel IR Remote


/******************************************************************************

Title:

   ATmega8 Based Multi channel IR Remote.

Description:
   It can control heady loads (Up to AC 220V 6 Amps or smaller) with a touch 
   of remote control. A total of 5 devices can be controlled from a distance 
   of up to 20 feet. We will be using a standard remote control protocol 
   that is called the NEC format. The NEC format is common is remote 

   controls used with Chinese made CD/DVD players remote controls. They are 
   easily available in Indian Markets. They also come in variety of sizes 
   from full to small 21 keys (used in car audio systems) 

   For More information visit
   http://www.eXtremeElectronics.co.in

Author:
   Avinash Gupta.
   avinash@eXtremeElectronics.co.in

Copyright:
   eXtreme Electronics, India 2008- 2011

Notice:

   No part of this work can be copied or published in electronic or
   printed form without proper permission from the Original Creators.

   ONLY INTENDED FOR EDUCATIONAL, HOBBY AND PERSONAL USE.
   COMMERCIAL USE IS STRICTLY PROHIBITED.


Disclaimer of Warranty.

   THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
   EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER
   PARTIES PROVIDE THE PROGRAM “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER 
   EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 
   OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 

   THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. 
   SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY 
   SERVICING, REPAIR OR CORRECTION.

******************************************************************************/


#include <avr/io.h>

#include <util/delay.h>

#include "remote.h"
#include "eeprom.h"

void Wait()
{
   uint8_t i;
   for(i=0;i<4;i++)
      _delay_loop_2(0);
}


void main()
{
      //Main command received from remote.
   uint8_t cmd;

   //Set PORTB0 to 4 as output. Relays are connected here.
   DDRB|=0b00011111;

   //Initialize the IR Remote library.
      RemoteInit();

   //Key codes assigned to five loads.

   uint8_t KeyCodes[5];

   uint8_t i;

   //Wait for any key during boot up.
   //if any key is pressed we enter the keymapper.
   for(i=0;i<16;i++)
   {
      cmd=GetRemoteCmd(0);

      if(cmd!=RC_NONE)
      {
         //Reset the Key mapping

         //If eeprom address 0x0000 contains 0xFF
         //that means remote keys are NOT mapped.
         EEPROMWrite(0,0xFF);
         break;
      }

      Wait();
   }

   //Flush Remote Command Buffer
   while(GetRemoteCmd(0)!=RC_NONE);

   //Check if eeprom area 0x0000 contains 0xFF

   //if yes we start key mapper. Which assigns
   //keycodes to loads. Other wise we load
   //key mapping from eeprom (see else block)
   if(EEPROMRead(0)==0xFF)
   {
      //This is first Run, so Map keycodes

      uint8_t i;
      for(i=0;i<5;i++)
      {

         while(1)
         {
            PORTB&=~(1<<i);

            Wait();
            cmd=GetRemoteCmd(0);
            if(cmd!=RC_NONE)
            {
               KeyCodes[i]=cmd;
               EEPROMWrite(i+1,cmd);
               break;
            }

            PORTB|=(1<<i);

            Wait();
         }
      }
      EEPROMWrite(0,0);
   }
   else

   {
      //Load Key configuration from EEPROM
      uint8_t i;
      for(i=0;i<5;i++)
      {

         KeyCodes[i]=EEPROMRead(i+1);
      }
   }

   //Main program loop  
      while(1)
      {

      cmd=GetRemoteCmd(1);

      uint8_t i;

      for(i=0;i<5;i++)
      {
         if(cmd==KeyCodes[i])
         {
            PORTB^=(1<<i);//Toggle load

            break;
         }
      }

      _delay_loop_2(0);
      _delay_loop_2(0);


   }
}

Building from sources.

The above code requires the IR Remote Library and EEPROM Library in order to compile. The two library comes in four files.

  • IR Remote Library
    • remote.c
    • remote.h
  • EEPROM Library
    • eeprom.c
    • eeprom.h

You need AVR Studio and WinAVR compiler installed on system. Details on how to get and install these tools is described here.

The above four files must be copied to your project folder. Then added to the current project using the AVR Studios left hand side panel. The .c files must be added to the source files section and the .h files should be added to the header file section. Refer to the following image for details.

avr studio

Fig: Adding files to projects.

Finally when the project is ready, You can build the project using the "Build Active Configuration" button as shown below. You can also hit F7 button or Select Build from Build Menu.

AVR Studio Build Button

Fig.: AVR Studio Build Button

If everything works fine, the hex file (with same name as you gave to your project) will be created in default folder inside your main project folder. You can then burn this hex file to your target ATmega8 MCU using any AVR Programmer. You also need to set the two fuse bytes in the MCU to the following value.

  • High Fuse Byte = 0xC9
  • Low Fuse Byte = 0xFF

Important Notice: The project will NOT work at all if the Fuse bytes are NOT programmed.

Setting AVR Fuse Byte

Fig.: Setting the Fuse bytes.

PCB for Multi Channel IR Remote

PCB for Multi Channel IR Remote

Fig.: PCB for Multi Channel IR Remote.

 

PCB

Fig.: PCB for Multi Channel IR Remote.

 

You can download the PCB layouts from the download section at the end of article. That can be used to make PCBs at home. Other wise you can buy ready made PCBs from our online store. Our PCBs are made with high quality FR4 material complete with solder mask, silkscreen and tinning.

 

Videos

Coming soon!

Downloads

If you like our projects and tutorial please share it with your friends on social networks using the sharing buttons below.

Subscribe!

Don’t miss any article get them right in your inbox! Subscribe to our feeds powered by Feedburner.


Get New Articles Deliverd To Your Inbox!

Email address:

Delivered by FeedBurner



By

Avinash Gupta

www.AvinashGupta.com

me@avinashgupta.com