Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

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

Status
Not open for further replies.

Navgun

Newbie level 2
Joined
Mar 28, 2017
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
26
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.
**broken link removed**
-----------
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.. :-(
 

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)
 
  • Like
Reactions: Navgun

    Navgun

    Points: 2
    Helpful Answer Positive Rating
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.
 

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

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top