remote Fan controller help

Thread Starter

aruna1

Joined Dec 20, 2008
46
I was making a remote fan controller.circuit and programming is finished but there is only one last problem remains.

sometimes circuit some how change speed(increase count on 7 segment and increases speed) without giving any IR signal.
its like IR receiver virtually received a IR signal.I'm driving a stand fan.I'm not sure this is because fan is a inductive load and i have no idea where is the problem

I removed ir sensor and replaced it with push button.with push button i don't have this problem.it seems IR module is generating signals some how.so i replaced it with a new one but it didn't solved the problem.

circuit responds to IR signal properly

I have attached my schematic here.

I use zero cross detector interrupt pic. IR signal is checked using polling.

can someone point me the error and show me a solution?

thanks.

this is the only problem I'm having to finalize my project
 

Attachments

jj_alukkas

Joined Jan 8, 2009
753
Are any high frequency light sources falling on the IR reciever?? A CFL lamp or direct sunlight causes these problems. Turn it away from them. Tube lights are also responsible. This is a general precaution to be known when dealing with IR controls..

Also adding a 1-33uF 16V capacitor between Vout and GND of TSOP 1738 sometimes helps prevent false triggering. You will have to test for the right value. 1uF would be sufficient.
 
Last edited:

Thread Starter

aruna1

Joined Dec 20, 2008
46
Are any high frequency light sources falling on the IR reciever?? A CFL lamp or direct sunlight causes these problems. Turn it away from them. Tube lights are also responsible. This is a general precaution to be known when dealing with IR controls..

Also adding a 1-33uF 16V capacitor between Vout and GND of TSOP 1738 sometimes helps prevent false triggering. You will have to test for the right value. 1uF would be sufficient.
no bulbs or cfl ,tubelights,direct sunlights alling on IR reciver.i will try adding a cap.

Could you give the source code in ASM and hex??
i dont have it in ASM.i wrote it in C.
i'll post it here.code is not finished yet.only basic parts are done.and need lot of cleaning

Rich (BB code):
#include "C:\Documents and Settings\Aruna\My Documents\fan project\adding timer\main.h"

int speed=0;
int count=0;
int k=0;
int timer0_on=0;
int timer_mode=0;
int16 timer0_count=0;
int timer_set=0;
int time_min=0;
int timer_det_mode = 0;
int timer_set_mode = 0;
int second=0;
int minute=0;
int quater_mili=0;
int x=0;
int first_INT_done=0;
int zero_cross_count=0;

void set_timer();
void finalize_timer();
void chk_ir();
void beep(INT times,int length);

#INT_EXT

void  EXT_isr(VOID) 
{
   chk_ir ();
   output_low (PIN_A0);
   zero_cross_count++;

   IF (speed == 0)
   {
      
      output_low (PIN_A0);
   }

   else IF (speed == 1)
   {
      IF (zero_cross_count == 5)
      {
         delay_ms (1);
         output_high (PIN_A0);
         zero_cross_count = 0;
         delay_ms (1);
         output_low (PIN_A0);
      }
      //delay_ms (8);
      //output_high (PIN_A0);
   }

   else IF (speed == 2)
   {
      
      delay_ms (6);
      output_high (PIN_A0);
   }

   else IF (speed == 3)
   {
      delay_ms (4);
      output_high (PIN_A0);
   }

   else IF (speed == 4)
   {
      
      delay_ms (2);
      output_high (PIN_A0);
   }

   else IF (speed == 5)
   {
   
      {
         delay_ms (1);
         output_high (PIN_A0);
         zero_cross_count = 0;
         delay_ms (1);
         output_low (PIN_A0);
      }
      
      //delay_us (1500);
      //output_high (PIN_A0);
   }
}

#INT_TIMER1

void  TIMER1_isr(VOID) 
{
   quater_mili++;

   IF (quater_mili == 4)
   {
      quater_mili = 0;
      second++;

      IF (second == 60)
      {
         second = 0;
         minute++;
         
         IF (minute == 1)
         {
            disable_interrupts (INT_EXT);
            output_low (PIN_A0);
            //speed=0;
            
            beep (2, 50) ;
            /* output_high (PIN_A5);
            delay_ms (50);
            output_low (PIN_A5);
            delay_ms (50);
            output_high (PIN_A5);
            delay_ms (50);
            output_low (PIN_A5);
            
            output_high (PIN_A4);
            delay_us (100);
            output_low (PIN_A4); */
            
            minute = 0;
            time_min = 0;
            disable_interrupts (INT_TIMER1);
         }

         /* IF (minute == time_min)
         {
            output_low (PIN_A0);
            minute = 0;
            time_min = 0;
            disable_interrupts (INT_TIMER1);
         }*/
      }
   }
}

#INT_TIMER0

void  TIMER0_isr(VOID) 
{
   IF (timer_det_mode == 1)
   {
      IF (timer0_count < 5000)
      {
         timer0_count++;
      }

      else IF (timer0_count >= 5000)
      {
         //timer mode on
         timer_mode = 1;
         
         disable_interrupts (INT_TIMER0);
         
         timer0_count = 0;
         first_INT_done = 1;
         //set_timer ();
      }
   }

   IF (timer_set_mode == 1)
   {
      output_low (PIN_A1);
      //delay_ms (50);

      IF (timer0_count < 3000)
      {
         timer0_count++;
      }

      else IF (timer0_count >= 3000)
      {
         
         disable_interrupts (INT_TIMER0);
         timer0_count = 0;
         finalize_timer ();
         
         
         //set_timer ();
      }
   }
}

void beep(INT8 times,int length)
{
   INT8 i = 0;
   FOR (i = 1; i <= times; i++)
   {
      output_high (PIN_A5);
      delay_ms (length);
      output_low (PIN_A5);

      IF (i != times)
      {
         delay_ms (length);
      }
   }

   
   
   output_high (PIN_A4);
   delay_us (100);
   output_low (PIN_A4);
}

void finalize_timer() // this code does not run
{
   beep (3, 50) ;
   timer_mode = 0;
   timer_set = 1;
   timer_set_mode = 0;
   enable_interrupts (INT_TIMER1);
   enable_interrupts (INT_EXT);
}

void set_timer() // this code runs
{
   disable_interrupts (INT_EXT);
   timer_det_mode = 0;
   
   beep (2, 50) ;
   timer0_count = 0;
   timer_set_mode = 1;
   x = 1;
   enable_interrupts (INT_TIMER0); // eneabling for second time
   time_min = 0;
   
   WHILE ( ! timer_set)
   {
      
      output_high (PIN_A1);

      IF (! input (PIN_A3) &&time_min <= 270) //time_min should be < 270----- need to add
      {
         delay_ms (1000);
         output_low (PIN_A1);
         timer0_count = 0;
         time_min = time_min + 30;
         output_high (PIN_A5);
         delay_ms (50);
         output_low (PIN_A5);
      }
   }
}

VOID chk_ir  ()
{
   IF ( ! input (PIN_A3))
   {
      count++;
      delay_ms (500);
      
      
      if(speed==0)
      {
      }
      
      IF (speed != 5 &&count <= 5)
      {
         output_low (PIN_A1);
         output_high (PIN_A5);
         delay_ms (100);
         output_low (PIN_A5);
         speed++;
      }

      
      else IF (count == 6)
      {
         speed = 0;
         
         timer_det_mode = 1;
         enable_interrupts (INT_TIMER0); //eneabling for first time;
         timer0_on = 1;
         output_high (PIN_A1);
         delay_ms(50);
         output_low (PIN_A1);
         delay_ms(50);
         output_high (PIN_A1);
         delay_ms(50);
         output_low (PIN_A1);
         delay_ms(50);
         output_high (PIN_A1);
      }

      else IF (count >= 7)
      {
         count = 0;

         IF (timer_mode == 0)
         {
            output_low (PIN_A1);
            disable_interrupts (INT_TIMER0);
            first_INT_done = 0;
            output_high (PIN_A4);
            delay_us (100);
            output_low (PIN_A4);
            speed = 0;
         }
      }
      delay_ms (500);
   }
}

void main()
{
   setup_adc_ports (NO_ANALOGS|VSS_VDD);
   setup_adc (ADC_OFF);
   setup_timer_0 (RTCC_INTERNAL|RTCC_DIV_4);
   setup_timer_1 (T1_INTERNAL|T1_DIV_BY_4);
   setup_comparator (NC_NC);
   setup_vref (FALSE);
   
   output_low (PIN_A5);
   output_high (PIN_A4);
   delay_ms (10);
   output_low (PIN_A4);
   delay_ms (1000);
   
   enable_interrupts (INT_EXT);
   disable_interrupts (INT_TIMER1);
   disable_interrupts (INT_TIMER0);
   enable_interrupts (GLOBAL);

   // TODO: USER CODE!!
   
   
   WHILE (1)
   {
      chk_ir ();

      if (first_INT_done == 1)
      {
         first_INT_done = 0;
         set_timer ();
      }
   }
}
 

Attachments

Top