Microcontroller › 8051 › counter help
- This topic has 10 replies, 5 voices, and was last updated 13 years, 1 month ago by
AJISH ALFRED.
-
AuthorPosts
-
May 22, 2012 at 6:29 pm #1813
Fred
ParticipantHi 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
May 23, 2012 at 12:43 am #7876Mehtab Ali
ParticipantThe 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
May 23, 2012 at 6:32 am #7878Fred
Participantbut do i have to use both timer0 and timer1?
May 23, 2012 at 5:04 pm #7881Mehtab Ali
Participantyou can use either timer0 or timer1 for counting purpose.
May 23, 2012 at 5:59 pm #7884AJISH ALFRED
ParticipantI’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.
May 23, 2012 at 7:15 pm #7886Fred
ParticipantGreat! 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
May 24, 2012 at 8:51 pm #7899Fred
ParticipantDo you happen to have any sample code i can find very helpful?
Thanks
May 25, 2012 at 5:15 pm #7904Anonymous
GuestHi Fred,
I’ve done it on a totaly different microcontroller called RENESAS. You won’t get anything useful from the code.
May 28, 2012 at 6:32 pm #7925AJISH ALFRED
ParticipantI 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;
November 24, 2012 at 4:09 am #8785Akash
ParticipantHello 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.
November 24, 2012 at 6:02 pm #8789AJISH ALFRED
ParticipantHi 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.
-
AuthorPosts
- You must be logged in to reply to this topic.