atmega8535 and door sensor and other sensor

Discussion in 'General Electronics Chat' started by getzme4u, Oct 24, 2011.

  1. getzme4u

    Thread Starter New Member

    Aug 12, 2011
    6
    0
    hello everyone
    i made a alarm system for my home. in that use
    atmega8535 and door sensor, motion sensor,and vibration sensor.

    problem: sometime it make false alarm

    how i made it:
    i have codevision avr for programmming
    controller pina.1 and pina.2 are initially equal to 1(one) and pulled up by 10 k resistor through +5 v dc supply
    there i made a function to check();
    check()
    {
    if( pina.1 ==1)
    alarm_bit=1;

    if(pina.2==1)
    alarm_bit=1;

    }
    ///////// main function start here
    main()
    {

    while()
    {
    if(alarm_bit==1)
    then start hooter;

    }



    }

    hardare : there are 2 zone
    in 1 zone input for door sensor is gnd supply and its output ==0 goes to controller and reads normal condition means no alarm condition
    because gnd i flowing then door are cloesed so contrller gets 0( zero)
    and this pulled up also by +5 supply


    then any door open then it open and it get +5 dc state alarm start


    this is ok working but mine problem it does sometime false alarming while all doors are closed properly
    please tell me the how i can make this in industrial or without false alarming
    _________________
    working at atmega32 nad modem and want to work with rf ,ir .
    i am to learn wireless and to make projects realted with that.
     
  2. hgmjr

    Moderator

    Jan 28, 2005
    9,030
    214
    Code ( (Unknown Language)):
    1. check(){
    2. if( pina.1 == 1)
    3. alarm_bit = 1;
    4.  
    5. if(pina.2 == 1)
    6. alarm_bit = 1;
    7.  
    8. }
    9.  
    10. ///////// main function start here
    11.  
    12. main(){
    13.  
    14. while()
    15. {
    16.     if(alarm_bit==1)
    17.     then start hooter;
    18.  
    19. }
    20.  
    21.  
    22.  
    23. }
    24.  
    25.  
    One thing that I notice is that there is no call to the function check() from within main().

    hgmjr
     
  3. hgmjr

    Moderator

    Jan 28, 2005
    9,030
    214
    Also missing is an initialization section. Perhaps you have only provided a snippet of your code.

    It would be more helpful if you could post your entire soruce code.

    hgmjr
     
  4. RiJoRI

    Well-Known Member

    Aug 15, 2007
    536
    26
    Don't feel too bad about false alarms. I write firmware for alarm systems, and a LOT of the code is in there to prevent false alarms!

    One method we use is debouncing. All zones (pina.1 or pina.2 in your system) are scanned periodically. If a zone is active, a counter for that zone is incremented.

    If the counter reaches a certain number, the alarm sequence (hooter in your case) is started. If the zone has NOT tripped, the counter for that zone is set to 0.

    Also, check your local laws. If your hooter is outside your dwelling, it may need to be shut off after a certain amount of time, or your local police will be giving YOU the ticket! :eek:

    AND you'll want to decide when your alarm clears -- will it be when the zone restores, or when you disarm the system?

    --Rich
     
Loading...