Docstoc

Remote fan regulator

Document Sample
Remote fan regulator Powered By Docstoc
					                    I 




Remote Fan Regulator With 
         Timer 
                     
                     
            Aruna Rubasinghe 
                8/11/2009 




         




                                aruna.rubasinghe@gmail.com
                                070412d@ent.mrt.ac.lk
                                http://aruna1.web44.net
                                University of Moratuwa
                                Sri Lanka
                                           Remote Fan Regulator With Timer    2




Features
 
    1.   5 speed fan regulator
    2.   Digital display
    3.   Timer
    4.   Low temperature shutdown switch
    5. Buzzer 
 
 
    http://aruna1.web44.net/electronics/
                              
                                                    Fan Regulat
                                             Remote F                  Timer 
                                                              tor With T                  3




 
     o
How to Operate


As IR pu
       ulses receive, circuit will count up an increase f speed.fa speed can be controlle
                                 l           nd         fan      an                     ed
                    ection is disp
from 0-5.current sele                        ven     t
                                 played on sev segment display.
0-5th posi            r          trolling
         itions are for speed cont
6th positio is for tim mode
          on         mer


Timer mode:
To enter timer mode go to 6th pos
                                sition.
Wait rou
       ughly about 5 seconds un you here a beep. A green LED will also tu on and th
                              ntil     e                                urn       he
        gment displa will go to zero.
seven seg          ay
                   ou        ered timer m
Once this is done yo have ente                    you                              me,
                                        mode. Now y have to set the time. To set tim
give IR s            cuit     will                  om        you       e           ch
        signal to circ and it w begin to count up fro zero as y press the button. Eac
                    r          that means we can set minimum 30 minute to maximum
digit is a multiplier of 30min.t                   t                            m
4.5hours.


Example: timer digit =3
                    30min=90mi
            Time= 3*3        in=1.5hours


        u          me        ut        s          ED        n         ou
After you select tim wait abou 3 seconds and red LE will turn on and yo will hear a
       ow                     d.         n           n           conds will ca
beep. No the timer is activated Staying on a selection about 3 sec                        to
                                                                             ause circuit t
         timer with se
activate t                       t.                     n           er         g            an
                     elected digit So make your selection quick. Afte activating the timer fa
                                 ero.     will                  d.
speed will automatically set to ze So you w have to set fan speed


        urn       timer?
How to tu off the t
To turn o the timer after it is a
        off       r                          mply go to 0th position a wait abo 5 second
                                activated, sim                       and      out      ds
        ou                                  bled.
there. Yo will hear a beep and timer is disab


Note: O          i                        et        d         rature of su
      Once timer is activated circuit is se to depend on temper                      In
                                                                         urrounding. I
                     set       off                  ure      elow 28C. (So I will no
       default it is s to turn o the fan if temperatu drops be         (           ot
        reeze and di while sleeping.).This value can only be cha
       fr          ie                    s                               difying the C
                                                               ange by mod
        rogram. (voi read_temp )
       pr          id        p()
                                      Remote Fan Regulator With Timer         4




To bypass this temperature controller simply push bypass button once on regulator
(not in remote) and temperature sensor will turn off (don’t blame me if you got
freeze). Push it again and sensor will turn on. This button works only if you have
activated the timer and you will hear a beep as you press the button.
                                            1N4001 x 4
 ~
                      T1                                            D2                                       U5
                                             D1                   1N4148                                   78L05                          +5V
                             9V                                                                            IN     OUT
230V 50Hz                                                                          IMP 2
                                                          IMP 1                                                 COM               C4




                                                                                  +
                                                                                      C2            C3
                                                                                                                                  0.33uF
                                                                                  220uF             0.1uF
 ~
                                                                                                                                                   R7
                                                                                                                                                330 ohm

                                                                                                                                                                                R17
                                                                                                                                                                               330 ohm
                                                                                                                                           bicolour led                                                                                         ~
                                                                                                                                                                                                                                      ACfan
                                         Temperature                                                                                                   12F675                                             OPTOISO
                                                                                                                                   R9
                                         Sensor                     Infrared reciever                                              1k                                                              R1                 R2        R3
                                                                                                                                                   1              8                             100 ohm             180 ohm    2.2k
                                                  LM35                                                                                             2              7
                                                                            TSOP1738                                                               3              6
                                                OUT VIN            R15                                              D4                                                            R6     1k                           2W        2W
                                                                                VIN OUT                                                            4              5                                                                       Q1
                                                   GND            100 ohm                                                                          .                                                                                    BT137   230V 50Hz
                                                                                                                    1N4148        IMP 4                                                IMP 5
                                                                                  GND                IMP 3                                                                                                 MOC3022
                                           S2




                                                                            +
                                                                                               +
                  LM35 bypass                                         C5                           C6
                  switch                                                                                                                                                                                                       C1
                                                                    4.7uF                      4.7uF                                                                                                                          0.1uF
                                                                                                                        D5                                                                                                    400V
                                                                    R16                        TSOP1738               1N4148
                                                                                                   VIN OUT                                                                                                                                      ~
                                                                  100 ohm                                                                              cd4026
                                           R10




                                                                                           +
                                                                                                                      +
                                         100 ohm                                                     GND
                R11                                                                         C7                             C8                                                                  R4
               100k                                                                                                       4.7uF                    1              16                           1M
                                                                                           4.7uF                                                   2              15
                                                                                                                                                   3              14
                                                                                                                                                   4              13
                                                                                                                                                   5              12
      R12                                                                                                                                          6              11
      1M                                                                                                                                           7              10
                       R14                                                                                                                         8              9                            R5
                       1k                                                                                                                                                                      1M
                                         2N3906
                                                                                                            R18
                                                                                                                            S1
                      2N3904                                                                                  10k
         R13
        100k                 1.5nF
                                                                                                                          R20                          .gfedcba
                                                                                                        R19
                                                                                                         1k               10k
                                                                                                                                                                      RED CC




                                     +
                                                                                                                                                          Gnd
                                            HCM1206




                                     -
                                                                                                 Q3                                                          R8
                                                                                               BC547A
                           buzzer(motherboard)                                                                                                              220 ohm


                                                                                                                                                 common cathode
                                                                                                                                                 7-Segment display
                                   Remote Fan Regulator With Timer    6




Circuit Diagram-Transmitter




Equation for frequency

                .
                              Hz

R1=1500 ohm
C1=0.01uF
F=38000 Hz
                                  Remote Fan Regulator With Timer    7




Circuit Diagram-Transmitter (Alternative)




Equation for the frequency

For 74HC14


                  .
For 74HCT14



              .
For 38 kHz and 74HC14

C1=0.01uF
R1=3289.5 ohm
                                   Remote Fan Regulator With Timer    8




Required Parts:
Part                               Amount
230v to 9v step-down transformer   1
1N4001                             4
1N4148                             3
220uF                              1
4.7uF                              4
0.1uF                              1
0.33uF                             1
1.5nF                              1
0.1uF (400V)                       1
0.01uF                             1
15 ohm                             1
56 ohm                             1
100 ohm                            5
220 ohm                            1
330 ohm                            3
1k                                 4
1.5k                               1
2k preset                          1
5k preset                          1
10k                                3
100k                               2
1M                                 3
180 ohm (2W)                       1
2.2K (2W)                          1
2N3904                             1
2N3906                             1
BC547 (any npn general purpose)    2
D400                               1
BT137                              1
                                              Remote Fan Regulator With Timer               9



Push to on buttons                           3
TSOP1738(or equivalent)                      2
MOC3022 (MOC 304X will not work)             1
Bi-color LED (or two normal LEDs)            1
IR LED                                       1
Red LED                                      1
Buzzer                                       1
Common cathode 7 segment display             1
LM35                                         1
CD4026                                       1
PIC 12F675                                   1
74HC14                                       1
7805                                         1




Note: this list include parts for both transmitters, so buy stuff relevant for your selection
                                                    Fan Regulat
                                             Remote F                  Timer 
                                                              tor With T                 10




     tant Points
Import         s
        cuit     C        f         chip and CD
This circ uses PIC 12F675 from Microc                  cade Counte
                                              D4026 (Dec         ers/Dividers +
      d                     tputs) from T
Decoded 7 Segment Display Out                       ments.
                                        Texas Instrum
        e          mportant poin that shou pay spec attention in this circ
There are several im           nts       uld      cial      n                        re
                                                                         cuit. They ar
       ith       symbol on th
noted wi special s          he              c
                                            circuit. Relev descrip
                                                         vant                 llowing:
                                                                 ptions are fol


                           pattern of v
             IMP 1: Signal p                     this point i a full wave rectifie
                                      voltage at t          is       w           ed
             unsmo         eform. This pattern contains zero v
                 oothed wave                                 voltage point (Zero cross
                                                                         ts
                  s)        ed          pt         IC         upted every t
             points which use to interrup the PIC.PI is interru                       cts
                                                                          time it detec
                  t
             an H to L edge.




                                            points
                                 Zero cross p




                 2:       F                      s          mooth DC sig
             IMP 2 C2 220uF smoothing capacitor is used to sm                     ut
                                                                       gnal. Withou
                   apacitor we can’t get 5V from 7805 regulator. H
             this ca                      V         5            However thi capacitor is
                                                                           is
                  d           ode      r                      smoothing e
             placed after a dio in order to reduce capacitors s                     ro
                                                                        effect on zer
             cross points.




                              o           s
                             No zero points here
                                Remote Fan Regulator With Timer            11




IMP 3: C6 and C8 4.7uF capacitors are used to remove false signal generated
by IR receiver due to environmental interferences.


IMP 4: This is a simple diode-resistor AND logic. It is used to add more than
one IR receiver to input pin.TSOP1738 receivers used here temporarily lowers
its output voltage when they receive a 38 kHz IR signal. Therefore AND gate
is used to add two receivers.




IMP 5: This is the simplest zero cross detector. Though it is not accurate it is
enough for this one.R6 1k resistor works as a current limiter while R4 and R5
1M resistors used as a pull down resistors. If you need more accuracy you can
use transistor ZCD (zero cross detector) or a more advanced op-amp ZCD.
                                               Remote Fan Regulator With Timer             12




Tricks:
Due to lack of I/O ports available in 12F675 I had to do some tricks to do more than one
operation from available pins.
   •   You can see that pin 6 of PIC is used to drive a bi
       color led. These bi-color LEDs’ change their color
       as polarity changes. Here the color of the LED is
       selected by making pin 6 output high or low.R7 and
       R17 resistors are used as a voltage divider to supply
       negative (when output is high) or positive
       polarity(when output is low) to the LED. In order to
       turn off the led pin6 is configured as an input. So
       instead of using two pins to turn 2 LEDs same operation is obtained using single pin
       and a bi-color LED.
   •   In CD4026 decade counter/seven segment driver IC pin 1 is used to increment counter
       and pin 15 is used to reset the counter. By placing a rising edge on pin 1, counter can
       be incremented by one and by placing rising edge on pin 15, counter can be reset.
       Instead of using two I/O ports for both count and reset, only one pin of the PIC is
       used.
       This is achieved by using a tri state switch. A simple transistor arrangement is used to
       design this tri state switch. Pin 2 of PIC is connected to base of transistor Q3 and to
       pin 15(reset) of CD4026.collector of the Q3 is connected to pin 1(count) of CD4026.
       When pin 2 of PIC is at output low node A in following diagram goes low and node B
       goes high which generates rising edge on pin 1 of CD4026 there for counter
       increments by one.
       When pin 2 of PIC is at output high node A in following diagram goes high and node
       B goes low which generates rising edge on pin 15 of CD4026 there for counter resets.
       When pin 2 of PIC is set to input mode both pin 1 an 15 of CD4016 disconnect from
       PIC




                                  A




                                           B
                                     Remote Fan Regulator With Timer             13




•   Pin 3 of PIC is used as both input and output pin. By setting pin 3 to output high
    buzzer can be operated, by setting pin 3 to analogue input temperature reading
    from LM35 can be processed. Here why I was able to use pin 3 as both input and
    output without temperature reading is that LM35 generates mV range voltage (at
    25 C 250mV) as output. Since buzzer circuit’s R10 resistor work as an isolation
    resistor to isolate buzzer from LM35 when reading output of LM35 output value
    is not affected by the buzzer.
                                               Remote Fan Regulator With Timer             14




Theory of operation:


Theory used here is similar to normal SCR based light dimmers. This circuit basically uses
phase control dimmer technique.
Using PWM will not work because after triac is triggered at its minimum voltage or higher
voltage it will not turn off until voltage between MT and MT2 comes to below minimum
holding value. Therefore once triggered it will not be re-triggered even though you switch
opto coupler continuously.




                                    Zero cross points
ZCD circuit is used to detect zero cross points of waveform and PIC is interrupted as Zero
cross point occurs. Therefore PIC is interrupted 100 times per second. Once interrupted PIC
checks selected speed and then waits few milliseconds according to the selected speed and
then triggers the triac through opto-coupler. This waiting period is below 10ms and above
1ms because time period is 10ms and triac has a minimum voltage requirement between MT1
and MT2 in order to establish a connection. If triac triggers at zero cross point triac will not
turn on.




           2.5 5 7.5
           ms ms ms
                                                  Fan Regulat
                                           Remote F                  Timer 
                                                            tor With T                 15




                 g
Hints on selecting parts


      Opto couple used here is a “rando phase op isolator” These iso
   1. O         er                    om       pto       ”.                    be
                                                                   olators can b
       triggered at any phase of AC signal. MOC304X series isolat will not work as the
       t            a          f                  X             tors     t           ey
       a “zero cro isolators They onl allow to tr
       are       oss       s”.      ly                      triac at a zer cross poin
                                                rigger opto t            ro         nt
       of        m.
       o wave form Special Z
                           ZCD circuit is included in this typ of isolato Therefor
                                     t           d           pe         ors.     re
       even you tur on emitte of isolator it will not trigger the detector unt it detects a
       e          rn        er          r                                    til
       zero cross point. If you are going to use this ty then you may need to change th
       z                                   o           ype      u                     he
       c          t                       ss         d           peed by ski
       code so that it will count zero cros points and controls sp                    ral
                                                                           ipping sever
       zero cross po
       z                      ding to requir speed. I have includ this as sp
                   oints accord            red                  ded                    er
                                                                           peed 1 trigge
       m          will       the                                                       an
       method. It w triggers t triac at every 5 zero cross points. And make sure they ca
       handle above 230V.
       h          e




      IR         used here is TSOP 1738
   2. I receiver u                                          e           her      cy
                                      8.any 38 kHz compatible (or any oth frequenc
       depending on your IR tr
       d                                  n            ransmitter is 38 kHz) IR receiver ca
                             ransmitter, in this case tr           s          R           an
       b used here
       be        e.
      Ex:    00,               etc
      E HRM380 SCH0038, VS1838 e


   3. T          d                     ximum power requireme
      Triac should be able to handle max                   ents of the fan. In here I
       used BT137 which has 8A rating a I used a stand fan in tastings. ( don’t know
       u                              and                               (I
       w will ha
       what                             s            ng
               appen after I connect this to my ceilin fan)


      1k         is        this circuit a current li
   4. 1 resistor i used in t            as                               D.        ue
                                                   imiting resistor of ZCD This valu
       s          hange accord
       should be ch                                  r          e.         se
                             dingly to the transformer you choose (In my cas its 9V)


   5. A                     ven      o                                  ve        Cs
      Always use IC bases (ev for opto coupler).It will help you to remov burned IC

       easily if you screw up so
       e           u           omething.              ly        opto coupler)
                                              (Speciall PIC and o           )


      c        oad    atics and so
  You can downlo schema                   e           s         s
                                 ource code + hex files from my site below

                               p://aruna1.w
                            http                      ectronics/
                                          web44.net/ele
                                   Remote Fan Regulator With Timer    16




C Source Code
Coded using CCS compiler
Version 4.084
(You may need to adjust timings in firing)




#include "C:\Documents and Settings\Aruna\My Documents\fan project\final
code\main.h"


/* pin designations
 A5 - count / reset
 A4 - buzzer / SWITCH 2
 A3 - IR / SWITCH 1
 A2 - zero cross detection
 A1 - bi color LED
 A0 - optoisolator
*/
int speed=0;
int count=0;
int timer0_on=0;
int timer_setup_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 first_INT_done=0;
int zero_cross_count=0;
int temp=0;
int timer_reset_mode=0;
                                          Remote Fan Regulator With Timer             17



int temp_bypass=0;
void set_timer();
void finalize_timer();
void chk_ir();
void beep(INT times,int length);
void bi_led(char mode,INT times,int length);
void read_temp();
void fire(INT delay);
void reset_timer1();


#INT_EXT


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


    read_temp ();


    IF (speed == 0)
    {


        output_low (PIN_A0);
        zero_cross_count = 0;
    }


    else IF (speed == 1)
    {
        IF (zero_cross_count == 5) // fire at every 5 zero crossings
        {
            delay_ms (1); //wait till waveform rises pass minimum triac holding voltage
            output_high (PIN_A0);
            zero_cross_count = 0;
                                           Remote Fan Regulator With Timer    18



            delay_ms (1); //hold until triac make connection
            output_low (PIN_A0);
        }
    }




    else IF (speed == 2)
    {
        fire (6);
    }


    else IF (speed == 3)
    {
        fire (4);
    }


    else IF (speed == 4)
    {
        fire (2);
    }


    else IF (speed == 5)
    {


        {
            delay_ms (1);
            output_high (PIN_A0);
            delay_ms (1);
            output_FLOAT (PIN_A0);
        }
    }
}


#INT_TIMER1
                                          Remote Fan Regulator With Timer    19




void TIMER1_isr(VOID)
{
    //timer interrupt runs at every 256ms
    quater_mili++;
    bi_led ('r', 0, 0) ;


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


        IF (second == 60)
        {
            second = 0;
            minute++;


            IF (minute % 30 == 0) //beep after end of every 30min
            {
                beep (5, 50) ;
            }


            IF (minute == time_min) //real thing
            {
                output_low (PIN_A0);
                beep (1, 1000) ;
                bi_led ('o', 0, 0) ;
                reset_cpu ();
                minute = 0;
                time_min = 0;
                disable_interrupts (INT_TIMER1);
            }
        }
    }
                                         Remote Fan Regulator With Timer    20



}


#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_setup_mode = 1;


            disable_interrupts (INT_TIMER0);


            timer0_count = 0;
            first_INT_done = 1;
        }
    }


    IF (timer_set_mode == 1)
    {
        IF (timer0_count < 3000)
        {
            timer0_count++;
        }


        else IF (timer0_count >= 3000)
        {
                                         Remote Fan Regulator With Timer    21




            disable_interrupts (INT_TIMER0);
            timer0_count = 0;
            finalize_timer ();
        }
    }


    IF (timer_reset_mode == 1)
    {
        IF (timer0_count < 5000)
        {
            timer0_count++;
        }


        else IF (timer0_count >= 5000)
        {
            reset_timer1 ();
        }
    }
}


void count_up()
{
    output_low (PIN_A5);
    delay_ms (1);
    output_FLOAT (PIN_A5);
}


void reset()
{
    output_high (PIN_A5);
    delay_ms (1);
    output_FLOAT (PIN_A5);
}
                                   Remote Fan Regulator With Timer    22




void reset_timer1()
{
    disable_interrupts (INT_TIMER0);
    timer0_count = 0;
    disable_interrupts (INT_TIMER1);
    timer_set = 0;
    bi_led ('o', 0, 0) ;
    beep (1, 50) ;
    delay_ms (50);
    beep (1, 100) ;
    delay_ms (50);
    beep (1, 50) ;
    reset_cpu ();
}


void beep(INT8 times,int length)
{
    INT i = 0;


    FOR (i = 1; i <= times; i++)
    {
        output_high (PIN_A4);
        delay_ms (length);
        output_FLOAT (PIN_A4);


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


void bi_led(char mode,INT times,int length)
                                           Remote Fan Regulator With Timer    23



{
    IF (length == 0)//default
    {
        length = 50;
    }


    IF (mode == 'o') //turn off
    {
        output_FLOAT (PIN_A1);
    }


    else IF (mode == 'r') //red
    {
        INT i = 0;
        output_FLOAT (PIN_A1);


        IF (times == 0)
        {
            output_high (PIN_A1);
        }


        ELSE
        {
            FOR (i = 1; i <= times; i++)
            {
                output_high (PIN_A1);
                delay_ms (length);
                output_FLOAT (PIN_A1);
                delay_ms (length);
            }
        }
    }


    else IF (mode == 'g') //green
                                           Remote Fan Regulator With Timer    24



    {
        INT i = 0;
        output_FLOAT (PIN_A1);


        IF (times == 0)
        {
            output_low (PIN_A1);
        }


        ELSE
        {
            FOR (i = 1; i <= times; i++)
            {
                output_low (PIN_A1);
                delay_ms (length);
                output_FLOAT (PIN_A1);
                delay_ms (length);
            }
        }
    }
}


void finalize_timer()
{
    bi_led ('r', 0, 0) ;
    beep (3, 50) ;
    reset ();
    speed = 0;
    count = 0;
    timer_setup_mode = 0;
    timer_set = 1;
    timer_set_mode = 0;
    enable_interrupts (INT_TIMER1);
    enable_interrupts (INT_EXT);
                                           Remote Fan Regulator With Timer          25



}


void set_timer()
{
    disable_interrupts (INT_EXT);
    timer_det_mode = 0;


    beep (2, 50) ;
    reset ();
    bi_led ('r', 2, 50) ;
    bi_led ('g', 0, 0) ;
    timer0_count = 0;
    timer_set_mode = 1;
    enable_interrupts (INT_TIMER0); // enabling for second time
    time_min = 0;


    WHILE ( ! timer_set)
    {
        IF (! input (PIN_A3) &&time_min <= 270) //max time = 9*30 = 270min
        {
            beep (1, 100) ;
            delay_ms (1000);//debouncing
            bi_led ('r', 0, 0) ;
            delay_ms (50);
            bi_led ('g', 0, 0) ;
            timer0_count = 0;
            time_min = time_min + 30;
            count_up ();
        }


        else IF (! input (PIN_A3) &&time_min > 270) //if time is too large go to zero
        {
            delay_ms (1000);
            beep (1, 100) ;
                                        Remote Fan Regulator With Timer    26



            bi_led ('r', 0, 0) ;
            delay_ms (50);
            bi_led ('g', 0, 0) ;
            timer0_count = 0;
            time_min = 0;
            reset ();
        }
    }
}


VOID chk_ir ()
{
    IF ( ! input (PIN_A3))
    {
        count++;
        delay_ms (500);//switch deboncing
        beep (1, 50) ;


        IF (timer_reset_mode == 1)
        {
            disable_interrupts (INT_TIMER0);
            timer_reset_mode = 0;
        }




        IF (speed != 5 &&count <= 5)
        {
            count_up ();
            speed++;
        }


        else IF (count == 6&&timer_set == 0)
        {
            speed = 0;
                                          Remote Fan Regulator With Timer    27




            timer_det_mode = 1;
            enable_interrupts (INT_TIMER0); //eneabling for first time;
            count_up ();


            timer0_on = 1;
            bi_led ('g', 0, 0); //green
        }


        else IF (count >= 7||timer_set == 1)
        {
            speed = 0;
            count = 0;


            IF (timer_setup_mode == 0)
            {
                bi_led ('o', 0, 0) ;
                disable_interrupts (INT_TIMER0);
                first_INT_done = 0;
                reset ();
                speed = 0;
            }


            IF (timer_set == 1)
            {
                enable_interrupts (INT_TIMER0);
                timer_reset_mode = 1;
                reset ();
                speed = 0;
                count = 0;
            }
        }
    }
}
                                         Remote Fan Regulator With Timer         28




void read_temp()
{
    output_FLOAT (PIN_A4);
    setup_adc_ports (sAN3|VSS_VDD);
    setup_adc (ADC_CLOCK_INTERNAL); //turn on adc
    set_adc_channel (3);
    delay_us (10);
    temp = read_adc (); //read value
    delay_us (10);
    setup_adc_ports (NO_ANALOGS|VSS_VDD); //turn off
    setup_adc (ADC_OFF);


    IF (temp < 10) //button press - s2
    {
        delay_ms (1000); //for debouncing and to avoid buzzer SHORT circuiting
        beep (3, 30) ;


        IF (temp_bypass == 0&&timer_set == 1) //
        {
            temp_bypass = 1; //deactivate the LM35
        }


        ELSE IF (temp_bypass == 1&&timer_set == 1)
        {
            temp_bypass = 0; //activate the LM35
        }
    }




    IF (temp_bypass == 1&&timer_set == 1)
    {
        bi_led ('g', 2, 50) ; //led signal FOR deactivated LM35
        bi_led ('r', 2, 50) ;
                                           Remote Fan Regulator With Timer         29



    }


    else IF (temp_bypass == 0&&timer_set == 1)
    {
        bi_led ('r', 0, 50) ;
    }


    IF (temp_bypass == 0&&timer_set == 1)
    {
        IF (temp >= 10&&temp <= 57) //10mv of out put = 1Ctherefore 28C =
280mV.since this is 10 bit adc
        {
            //calculate value using (1024 * tempreture * 10) / 5000
            beep (1, 500) ; //FOR 28C--- > (1024 * 28 * 10) / 5000 = 57.344 = 57
            delay_ms (100);
            beep (3, 50) ;
            reset_cpu ();
        }
    }
}


void fire(INT delay)
{
    delay_ms (delay);
    output_high (PIN_A0);
    delay_ms (1);
    output_FLOAT (PIN_A0);
}


void main()
{
    setup_adc_ports (NO_ANALOGS|VSS_VDD);
    setup_adc (ADC_OFF);
    setup_timer_0 (RTCC_INTERNAL|RTCC_DIV_4);
                                   Remote Fan Regulator With Timer    30



    setup_timer_1 (T1_INTERNAL|T1_DIV_BY_4);
    setup_comparator (NC_NC);
    setup_vref (FALSE);


    output_FLOAT (PIN_A4);
    output_FLOAT (PIN_A1);
    output_FLOAT (PIN_A5);




    reset (); //initial reset
    delay_ms (1000);


    enable_interrupts (INT_EXT);
    disable_interrupts (INT_TIMER1);
    disable_interrupts (INT_TIMER0);
    enable_interrupts (GLOBAL);




    WHILE (1)
    {
        chk_ir ();


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

				
DOCUMENT INFO
Shared By:
Stats:
views:4290
posted:2/13/2010
language:English
pages:30
Description: this is a microcontroller project to make a remote controlled fan regulator