counting pulses on a 18f

Status
Not open for further replies.

jay543_uk

New Member
iv got a square wave pulse from a anomemeter that i want to display on a lcd, it pulses 6 times to one rotation of the anomemter.

i believe that the maximum frequancy i need to measure is about 150hz

what is the best way to count this with a micro pic, trying to use a 18f with mlab c18 compiler.

i was thinking of setting up a tmr0 timer and count the pulses till it overflows and then see how many pulse there are in that set time, does this sound right or should i do it another way.

with no rotation of the anomemter the output sits high (5v) and pulses down to 0v when rotated

thanks for any help
jason
 
hi,
I would set up another timer for a 1 second interrupt, use timer0 to count the pulses.
Read the value of timer0 on interrupt, this will give a direct reading of frequency.
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…