View previous topic :: View next topic |
Author |
Message |
jjacob
Joined: 08 Mar 2008 Posts: 54 Location: PORTUGAL (PORTO)
|
Frequency meter 0Hz to 100Hz |
Posted: Thu Sep 25, 2008 12:32 pm |
|
|
Hi.
I've already search in the forum ... but didn't find a answer.
I'm trying to measure a range of frequency and print it on serial port.
The printing part is the easy one
My problem is how to measure the frequency, because the range of frequencies are from 0Hz to 100Hz. Another additional problem is that the frequency source may not be constant.
My frequency source is an 'anemometer'. So the frequency depends on the wind velocity ...
I'm thinking to use interrupts to detect the rising edge of the anemometer.
Quote: | I have an 'opamp' to change the sinusoidal wave to a square wave with 0 to 5v amplitude, so i can connect directly to the PIC. |
And then get the time from one timer. But, in case of my second rising edge never appear (wind stops!!) ... how can i read the timer ? It will overflow a lot of times !
I can say that my system, will only read frequencies from 0.1Hz to 100Hz.
Not from zero (1/0=infinite!!). Even in this case, i'll have to way 10 seconds, to say that the output frequency is 0Hz.
Can anybody help me ?
If anybody knows a solutions different from this, feel free to say it
Thank you in advance.
Jacob |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
SherpaDoug
Joined: 07 Sep 2003 Posts: 1640 Location: Cape Cod Mass USA
|
|
Posted: Thu Sep 25, 2008 12:52 pm |
|
|
Generally I would choose a reading interval, say once per second. Then I would see how many rising edges occur in that interval. Zero edges means zero Hz. One edge means 1Hz. etc. You always get a reading with 1Hz resolution. No interrupts are required as long as the counter doesn't overflow.
A more complex way is at time zero, to start a fast clock to time when the first edge arrives. Then count edges until the reading interval is over. Then use the fast clock again to time one more edge. The edge clock gives Hz and the difference of the two fast clock readings gives fractional Hz. That takes a lot more thought, especially to make sure things don't blow up at less than 1Hz. _________________ The search for better is endless. Instead simply find very good and get the job done. |
|
|
|