- This topic has 10 replies, 5 voices, and was last updated 11 years, 11 months ago by .
Viewing 11 posts - 1 through 11 (of 11 total)
Viewing 11 posts - 1 through 11 (of 11 total)
- You must be logged in to reply to this topic.
|
Microcontroller › 8051 › counter help
Hi everyone,
I am fairly new to the 8051. I am building a heart beat monitor and I built a sensor having an digital output. (pulses) now i need to use the 8051 to count these pulses. any help on how i have to do this?
thanks
The timers, timer0 and timer1 in 8051 can be used for counting the pulses fed into microcontroller. you initialize the microcontroller’s timer in the counter mode and fed pulses into it to be counted.
regards
but do i have to use both timer0 and timer1?
you can use either timer0 or timer1 for counting purpose.
I’ve done a similar project. I’ll explain the method which I’ve used.
Normall we need hart beats/minute. So take the heart beat count for ten seconds and multiply it with 6.
Connect the input of HB sensor to any one of the input pin. Increment a count each time the pin become high from low. Generate a delay of 10 seconds by setting any one of the timer. (I hope you know the technique, using static variables for large delays). When it becomes 10 seconds, stop incrementing the count, read the count and multiply it with 6 and display.
Great! that helps a lot! I will do some research about how to use the timer to make the 10 second dely as you said because i dont know how!
THANKS
Do you happen to have any sample code i can find very helpful?
Thanks
Hi Fred,
I’ve done it on a totaly different microcontroller called RENESAS. You won’t get anything useful from the code.
I can give you a rough idea only,
Inside your ISR,
{
static int count = 0;
if ( count < max_count )
{
count ++;
wait_variable = 1;
}
else
{
stop_timer ();
wait_variable = 0;
}
Inside your main code,
while ( wait_variable ); // will wait till wait_variable become 0;
Hello everyone.
I want to make conveyor belt object counter and i m using p89v51rd2 for that purpose..
can anyone help me to know that how to increment a counter.
I will be pleased if anyone can help me in c coding for that.
Hi Akash,
Share more details about your project so that others can help you.
Also suggest you to post your query as a seperate topic in this forum.