+ Post New Thread
Results 1 to 4 of 4
  1. #1
    Newbie level 2
    Points: 20, Level: 1

    Join Date
    Mar 2017
    Posts
    2
    Helped
    0 / 0
    Points
    20
    Level
    1

    A little problem~ The Buzzer doesnt stops buzzing (AT89c2051 Microcontroller)

    I am making a college project which is a blind walking stick using Micr AT89c2051 interfaced with Ultrasonic Sensor (HC-SR04).
    I did all the coding part and did burn the code in the Micr. +ve pin of the buzzer is connected to Vcc ...and the other one to the port pin...
    I am giving '1' to that pin, ...
    but after i start on the power, the micr doesnt checks the condition to be true and starts buzzing the buzzer.
    -----------
    *should i use a npn transistor OR
    *should i try giving '0' to that pin OR
    *somethng else?

    -----------
    This is the atual Schematic of our project.
    Attachment 137404
    -----------
    This is the Code used

    Code:
    #include<reg51.h>
    void t0m1delay(void);
    sbit trig= P3^0;
    sbit echo= P3^1;
    sbit buzz= P1^7;
    sbit water= P3^7;
    void msdelay(unsigned char);
    void main (void)
    {
    water=1;
    echo=1;
    while(1)
    {
    trig=0;
    msdelay(2);
    trig=1;
    t0m1delay();
    trig=0;
    msdelay(8);
    if(echo==1)
    buzz=1;
    
    if(water==1)
    {
    buzz=1;
    msdelay(256);
    msdelay(256);
    buzz=0;
    msdelay(256);
    msdelay(256);
    }
    }
    }
    void t0m1delay(void)
    {
    TMOD=0x01;
    TL0=0x0f6;
    TH0=0x0ff;
    TR0=0;
    TF0=0;
    }
    void msdelay (unsigned int itime)
    {
    unsigned int i,j;
    for(i=0; i<itime; i++)
    for(j=0; j<1275; j++);
    }
    -----------

    The working is

    *A Trigger signal of at least 10microseconds will be generated on pin 2 of the microcontroller.
    *This signal will make the ultrasonic module to transmit 8 40 kHz waves from the transmitter.
    *The received signal would be automatically decoded by the module. And results would be sent on pin 3 of the microcontroller via echo pin.
    *Meanwhile, pin 11 will be used to sense water. It will be done by the simple principal of ‘salt water conduction’.
    *A dc signal will be sent to the lower side of the stick via wires.
    *If no water is sensed, the circuit would be open, and no o/p would be given to the buzzer.
    *If water is sensed, the circuit will be a closed circuit. And buzzer output would be given.

    ----------

    any help would be very much appreciated..

    •   Alt28th March 2017, 15:46

      advertising

        
       

  2. #2
    Super Moderator
    Points: 24,309, Level: 37
    andre_teprom's Avatar
    Join Date
    Nov 2006
    Location
    Portugal
    Posts
    7,297
    Helped
    911 / 911
    Points
    24,309
    Level
    37
    Blog Entries
    5

    Re: A little problem~ The Buzzer doesnt stops buzzing (AT89c2051 Microcontroller)

    You are perhaps with a high RC time constant at the Reset pin.

    • Try to reduce it to the minimal possible, OR
    • As you said, invert the logic that control this pin ( keep in mind that in the 51 architecture most I/Os has built-in pullup resistors)
    --------------------------------------------------------------------------------------------------
    Part of the world that you live in, You are the part that you're giving ( Renaissance )


    1 members found this post helpful.

    •   Alt28th March 2017, 15:57

      advertising

        
       

  3. #3
    Member level 5
    Points: 618, Level: 5

    Join Date
    Aug 2016
    Posts
    83
    Helped
    14 / 14
    Points
    618
    Level
    5

    Re: A little problem~ The Buzzer doesnt stops buzzing (AT89c2051 Microcontroller)

    Hi,

    In your code, you initialized water with '1' and echo with '1'. Then you always check echo to ring buzzer if echo is one. You also always check water to ring buzzer if water is '1'.

    I think you should initialize water with '0' and echo with '0'.

    I may be wrong but I'm learning MCU and C at the moment.
    -------------
    --Akanimo.



    •   Alt28th March 2017, 17:49

      advertising

        
       

  4. #4
    Newbie level 2
    Points: 20, Level: 1

    Join Date
    Mar 2017
    Posts
    2
    Helped
    0 / 0
    Points
    20
    Level
    1

    Re: A little problem~ The Buzzer doesnt stops buzzing (AT89c2051 Microcontroller)

    atually the '1' was to initialize those pins as input pins... as per what i have learnt,



--[[ ]]--