This device can be used to remotely control the speed of an AC fan and to switch
it on or off. The remote control is a cheap NEC
Format remote
, usually supplied with small DVD players. Three buttons are
used to command the circuit. The UP key increase the fan’s speed while the DOWN
key decrease it. The ENTER key is used to switch on or off the fan. The unit
provides 10 way speed control from 0 to 9. The current speed is displayed in
a seven segment display. The yellow LED on the PCB indicates the power status
of the load. If the load is switched off using the R/C then the LED will also
be switched off.

In the Video below you can check out the project in action.

The main parts of the circuit is labeled below.

  1. The seven
    segment display
    used to show the current speed level.
  2. The TSOP1738
    sensor is used to pick up commands from remote control.
  3. The Yellow LED indicates the power status of the load.
  4. OUT – Here the AC load is connected in series. Tested on 220v 50Hz AC line.
  5. IN – Power supply from a 12-0-12 transformer is applied here.
  6. MCU – ATmega8
    AVR 8 bit Microcontroller.
  7. SWITCH – Manual Switch used to operate the unit without the remote control.
remote controlled ac fan regulator

Fig.: Atmel AVR Based Remote Controlled Fan Regulator.

 

remote controlled fan regulator wiring diagram

Fig.: Remote Controlled Fan Regulator Wiring Diagram.

 

transformer

Fig.: Transformer with plug.

 

Construction of Remote Controlled Fan Regulator.

You can make the circuit as per the schematic on any general purpose PCB. To
ease your job we are giving the PCB Layouts too, so that you can make the PCB
at your home using the Etching
Method
. You may also have the PCBs made from any fabrication house too. To further
easy the job and save your money we have already made the PCBs from a good fabrication
house and they are available for purchase at very low cost.

Start assembly process by first soldering the jumper1. Then you can mount the
resistors. After that solder the diodes, remember to properly orient the diodes.
They are polar and don’t work if installed other way round. Then solder the
IC U4 and U2, this time too take care of the orientation. The small round circle
on the IC package marks the PIN number 1.

IC

Fig.: Proper IC Installation.

After that you can solder the ceramic disk capacitors, the 16MHz crystal, 7805,
Triac, TSOP Sensor, Display. Finally Connect the 12-0-12 Transformer and apply
power. The display should show ’0′. Then you can press the up/down key in remote
control to adjust the speed. The display should change accordingly. This ensures
that the circuit is running properly.

Its time to connect a real AC load. Connect a 220V 100W incandescent lamp (NO
CFL Please). As shown in the above wiring diagram. Replace the fan with bulb
because its easier to test.

WARNING !!!
Never Touch any part of the circuit when
AC load is connected. It can give you a fatal shock !!!

Now you can can use the remote control to increase/decrease the lamp’s brightness
using the remote control. You can also switch it on and off using the ENTER
key.

Troubleshooting

If the unit does not respond to the remote control signals then look for the
following.

  1. AVR ATmega8′s Fuse BIT is programmed to
    • HIGH=0xC9 LOW=0xFF
  2. AVR is clocked with 16MHz crystal (other value won’t work)
  3. Remote Control is NEC Format Only (Chinese DVD/CD player remote works good,
    TV Remote Generally do not work as these are RC5 coded)
  4. Remote Key codes has been feed to rckey.h file. Build and
    run this
    demo
    and press UP,DOWN and ENTER keys to get their keycode and put them
    in rckeys.h file. All remotes available in market has random
    keycode, so This part is very important. After editing the rckeys.h file the
    project must be Rebuild. (I hope you know what does that means).
  5. IR sensor is of good quality and must be labeled TSOP1738 (other values
    won’t work).
  6. If you get a KIT
    from us then most of the problem do not arise.
hobby remote control

Fig.: This Hobby Remote Control Works Great!

Hobby
Remote Control (NEC)
is available from our online store.

Part list for Remote Controlled Fan Regulator.

Part List
01 330 ohm resistor (9 Nos) R2-R9, R14
02 4k7 Resistor (2 Nos) R1,R11
03 1K Resistor R12
04 39 ohm Resistor R13
05 1K5 Resistor R15
06 22pF Ceramic Disk Capacitor (2 Nos) C1,C2
07 0.1uF Ceramic Disk Capacitor 250V(1 Nos) C3
08 0.1uF Ceramic Disk Capacitor (2 Nos) C5,C6
09 470uF 50v Electrolytic Capacitor C4
10 16
MHz Crystal
Half Size
X1
11 1N4007 Diode (6 Nos) D2,D3,D4,D5,D6,D7
12 LED
5mm Any Colour
D1
13 MCT2E Opto Coupler U4
14 MOC3021 Opto Triac Driver U2
15 ATmega8-16PU
General purpose 8 bit MCU
U1
16 Triac BT136 U3
17 7805
Voltage Regulator
U5
18 Common
Anode Display
DISP11
19 TSOP1738
IR Sensor
X2
20 220V AC to 12-0-12 Center Tapped Transformer 500mA minimum.  
21 Hobby
Remote Control (NEC)
 

Buy
Remote Controlled Fan Regulator Kit.

Schematic

remote controlled fan regulator schematic

Fig.: Schematic (Click To Enlarge/Print).

PCB For Remote Controlled Fan Regulator.

PCBs can be purchased from PCB
section of our online shop
.

remote controlled fan regulator pcb

Fig.: Remote Controlled Fan Regulator PCB.

 

avr-gcc C Source Code.


/*

Remote Controlled Fan Regulator.

********************************

Compiler: avr-gcc (WinAVR-20090313)
Project Manager/IDE: AVR Studio 4.17 Build 666
Other Lib: eXtreme NEC Decoder.

Hardware:
   INT0 - IR Receiver
   INT1 - Zero Crossing Detector.

   PD5 - Triac Control.
   PB2 - Manual Switch

For
   ATmega8 @ 16MHz

Fuse: 
   HIGH=0xC9 LOW=0xFF

   Copyright (c) 2008-2010
   eXtreme Electronics, India

                                     NOTICE
                           --------
NO PART OF THIS WORK CAN BE COPIED, DISTRIBUTED OR PUBLISHED WITHOUT A
WRITTEN PERMISSION FROM EXTREME ELECTRONICS INDIA. THE LIBRARY, NOR ANY PART

OF IT CAN BE USED IN COMMERCIAL APPLICATIONS. IT IS INTENDED TO BE USED FOR
HOBBY, LEARNING AND EDUCATIONAL PURPOSE ONLY. IF YOU WANT TO USE THEM IN 
COMMERCIAL APPLICATION PLEASE WRITE TO THE AUTHOR.

*/


#include <avr/io.h>
#include <util/delay_basic.h>

#include <avr/interrupt.h>

#include "remote.h"
#include "rckeys.h"

#define FAN_POWER_LED_PORT PORTD
#define FAN_POWER_LED_DDR DDRD
#define FAN_POWER_LED_BIT 7

#define POWER_LED_ON()  FAN_POWER_LED_PORT&=(~(1<<FAN_POWER_LED_BIT))
#define POWER_LED_OFF() FAN_POWER_LED_PORT|=(1<<FAN_POWER_LED_BIT)

uint8_t table[10]={141,125,109,94,78,62,47,31,16,1};

uint8_t speed=0;
uint8_t fan_on=0;


void Initialize()
{
   FAN_POWER_LED_DDR|=0B10000000;

   POWER_LED_OFF();

   DDRC|=0b00111111; //Seven segment
   DDRB|=0b00000010; //Middle segment G

   Display(0);

   RemoteInit();

   //Initialize the zero crossing detector INT(1)

   MCUCR|=((1<<ISC11)|(1<<ISC10));     //INT in Rising edge
   GICR|=(1<<INT1);              //Enable INT1

   //Output

   DDRD|=(1<<PD5);
   PORTD|=(1<<PD5);  //High = TRIAC Off


   //Set Timer 2
   TCCR2|=(1<<WGM21);   //CTC

   TIMSK|=(1<<OCIE2);   //Enable OCI2

   sei();

}
/*

Zero Crossing Detect.

*/

ISR(INT1_vect)
{
   if(!fan_on)
   {
      PORTD|=(1<<PD5);  //High = TRIAC Off
      return;
   }

   if(speed==9)
   {
      PORTD&=(~(1<<PD5)); //low = TRIAC ON

      return;
   }

   PORTD|=(1<<PD5);  //High = TRIAC Off

   OCR2=table[speed];

   TCNT2=0x00;

   TCCR2|=((1<<CS22)|(1<<CS21)|(1<<CS20));   //Start Timer prescaler =1024

}

/*

Timer2 Compare ISR

*/
ISR(TIMER2_COMP_vect)
{
   PORTD&=(~(1<<PD5)); //low = TRIAC ON

   TCCR2&=(~((1<<CS22)|(1<<CS21)|(1<<CS20)));   //Stop Timer
}

/*

Simple Wait Function

*/
void Wait()
{
   char i;

   for(i=0;i<100;i++)
      _delay_loop_2(0);
}


/*

Displays a number in Seven Seg Display

*/
void Display(uint8_t num)
{
   if(num>9)
      return;

   switch (num)
   {
      case 0:
         PORTC=0B00000000;
         PORTB|=0B00000010;
         break;
      case 1:
          //      xxfedcba

         PORTC=0B00111001;
         PORTB|=0B00000010;
         break;
      case 2:
         //      xxfedcba
         PORTC=0B00100100;
         PORTB&=(~(0B00000010));
         break;
      case 3:
         //      xxfedcba

         PORTC=0B00110000;
         PORTB&=(~(0B00000010));
         break;
         break;
      case 4:
         //      xxfedcba

         PORTC=0B00011001;
         PORTB&=(~(0B00000010));
         break;
      case 5:
         //      xxfedcba
         PORTC=0B00010010;
         PORTB&=(~(0B00000010));
         break;
      case 6:
         //      xxfedcba

         PORTC=0B00000010;
         PORTB&=(~(0B00000010));
         break;
      case 7:
         //      xxfedcba
         PORTC=0B00111000;
         PORTB|=0B00000010;
         break;
      case 8:
         //      xxfedcba

         PORTC=0B00000000;
         PORTB&=(~(0B00000010));
         break;
      case 9:
         //      xxfedcba
         PORTC=0B00010000;
         PORTB&=(~(0B00000010));
         break;
   }
}


void main()
{

   uint8_t cmd; //Command received from remote

   Initialize();

   while(1)
   {
      //Get Command For the Remote Control
      cmd=GetRemoteCmd(1);

      //Now process the command

      //UP Key
      if(cmd==RC_UP)
      {
         if(speed<9)
            speed++;

      }

      //DOWN Key
      if(cmd==RC_DOWN)
      {
         if(speed>0)
            speed--;
      }

      //Enter Key

      if(cmd==RC_ENTER)
      {
         if(fan_on)
         {
            POWER_LED_OFF();
            fan_on=0;   //Turn Off
         }
         else
         {
            POWER_LED_ON();
            fan_on=1;   //Turn On

         }
      }

      Display(speed);

   }
}

Note: Other files that are part of the eXtreme NEC decoder
must also be added to the project. They can be downloaded from links given below.

Downloads

Buy Kit

Buy complete kit including PCB, Parts, Programmed MCU, Transformer and Matching IR Remote
Control Unit.

Buy
Remote Controlled Fan Regulator Kit.

Related Post

By

Avinash Gupta

www.AvinashGupta.com

me@avinashgupta.com