Searching \ for 'Timing loop' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page:
Search entire site for: 'Timing loop'.

Truncated match.
PICList Thread
'Timing loop'
1997\02\20@172206 by rrose

I'm in the process of designing/building an anemometer.  To measure
the speed of the wind, I'm going to be counting the number of
revolutions the shaft makes.

My question is: can I just a timing loop approach to counting the
number of revoultions or should I use a timing interrupt from a
real-time clock?

In other words, would this appoarch give me acceptable results:
       For i = 1 to NumberOfLoops
               if revolution detected then
                       NoOfRevs = NoOfRevs + 1
       next i

where I have computed the amount of time it takes to do the loop.  Or
would I be better off if I do something like:

       wait for timing interrupt
       while no timing interrupt detected
               if revolution detected then
                       NoOfRevs = NoOfRevs + 1

Thanks in advance for you comments/suggestions/ideas,

Richard Rosenheim

1997\02\20@235558 by Steve Hardy

> From: Richard Rosenheim <>
> I'm in the process of designing/building an anemometer.  To measure
> the speed of the wind, I'm going to be counting the number of
> revolutions the shaft makes.

Do you want (A) average speed (over say 1 min) or (B) gust speed
for each revolution, or (C) both?

From your other email I assume you're using a 16C84 so I'll limit
the discussion to just TMR0 -- otherwise you could use the capture/
compare facility of the bigger processors.

{Quote hidden}

If I was you I would make the sensor interrupt the processor by
using port B bit 0.  This interrupts on falling edge if you set it
up right.

At the same time, use TMR0 as timekeeper.  It should also interrupt
the processor so you can keep 16 or 24 bits of timing resolution.

At each sensor interrupt, you save a new timestamp.  The mainline
code just keeps computing the 'instantaneous' speed by comparing
the latest and previous timestamps.  For the average speed, you
can get the interrupt routine to keep a separate count for sensor
pulses, and also set a flag when each minute (or whatever) expires.
The mainline code will poll for this flag and when it occurs it will
determine how many pulses occurred in that time.

Just for fun you could store the greatest gust and average speed
in the EEPROM!

Canberra, Australia

1997\02\24@061815 by eroen Ommering

Hi Richard,

At 13:08 20/02/97 -0800, you wrote:
{Quote hidden}

a far neater method is the following, using two timers in your PIC:

One of the timers is preloaded / prescaled such that it will generate an
interrupt every <n> ms. (input = OSC) This is your system's heartbeat.

Then to measure the number of revolutions, you start a counter that counts
the pulses read from the shaft (e.g. TMR1 in a 'C64). Depending on the pulse
frequency and the accuracy, you let it count for a certain time and read it
The time is of course a multiple of the <n> ms heartbeat.

The <n> ms depends on your OSC frequency. To give you an example, using a
2.4576 MHz Xtal and some presacling, I get a 5 ms heartbeat. The interrupt
routine counts the heartbeats and every 200 beats (1 sec), it stops + reads
the 16 bit TMR1, writes it to some variable and clears the TMR1 and starts
it again.

Your main program only has to read the variable whenever it wants.


>Thanks in advance for you comments/suggestions/ideas,
>Richard Rosenheim
| Jeroen Ommering                        Cordless Systems Development |
| Ericsson Business Mobile Networks BV                                |
| Institutenweg 25                                                    |
| P.O. Box 645, 7500 AP  Enschede        Tel:    +31 53 45 05 420     |
| The Netherlands                        Fax:    +31 53 45 05 148     |
|                                                                     |
| E-mail:                             |

More... (looser matching)
- Last day of these posts
- In 1997 , 1998 only
- Today
- New search...