How can i count the no. of pulses that comes into pin of microcontroller 89s52?

Do you have a question? Post it now! No Registration Necessary

Translate This Thread From English to

Threaded View


A BRIEF DESCRIPTION ABOUT MY PROJECT
I am using a microcontroller 89S52 in my small project...My project is
to display ration of the amount of air exhaled in the 1st second and
also at the end of the forced expiration(normally 6 seconds ).For that
im using a small fan.. in one end there is an IR LED source and in the
other end there is an IR detector...so when the fan rotates due to the
air blown it cuts the IR light to the detector and hence we get pulses
as output..im trying to count that pulses using a counter of the
microcontroller..and for counting the pulses at the end of the 1st
second i have used a timer...How can i count the pulses at the end of
the 6th second of expiration?please explain...

Re: How can i count the no. of pulses that comes into pin of microcontroller 89s52?


Muhammed Shafi a écrit :
Quoted text here. Click to load it
Sorry, I'm not sure to understaind.

A person starts blowing.
Second 0 to 1 : You count the rotation of fan (for 1 second)
Second 1 to 5 : You do nothing
Second 5 to 6 : You count the rotation of fan (for 1 second)

It's that you want ?

--
Franssoa
débutant inside(c)

Re: How can i count the no. of pulses that comes into pin of microcontroller 89s52?


On Mon, 9 Mar 2009 23:58:19 -0700 (PDT), Muhammed Shafi

Quoted text here. Click to load it

Warning: I'm a software developer who dabbles in microcontrollers as a
hobby, not a pro as far as microcontrollers are concerned.

What you could do (if your hardware supports it) is set up an
interrupt that gets triggered by signal level or status change on your
pulse input. In that interrupt, increment the n-th location of an
array of ints.  Increment the index n every second (starting with
n=0), using e.g. your timer.

That's the basic idea - you'll have to make sure your counting is
correct, you initialize your array with all zeroes before counting,
your integer type can handle the maximum number of pulses per second,
your array is large enough to handle the maximum expected expiration
time (and you do something sensible if that is the case nevertheless)
but basically, you'd end up with

int pulses[MAX_SECONDS];

where

pulses[0] is the number of pulses in the first second,
pulses[1] is the number of pulses in the second second,
...
pulses[n] is the number of pulses in the last second

You could stop measuring once there's a couple seconds with 0 pulses.
(If that is your problem - you really need to explain more about what
you intend to measure exactly)

   Regards,
   Gilles.


Site Timeline