CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Frequency meter 0Hz to 100Hz

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
jjacob



Joined: 08 Mar 2008
Posts: 54
Location: PORTUGAL (PORTO)

View user's profile Send private message

Frequency meter 0Hz to 100Hz
PostPosted: Thu Sep 25, 2008 12:32 pm     Reply with quote

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 Smile

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 Smile

Thank you in advance.
Jacob
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Sep 25, 2008 12:44 pm     Reply with quote

Tachometer code:
http://www.ccsinfo.com/forum/viewtopic.php?t=29963
There are two pages for that thread.

Filter code:
http://www.ccsinfo.com/forum/viewtopic.php?t=3462
SherpaDoug



Joined: 07 Sep 2003
Posts: 1640
Location: Cape Cod Mass USA

View user's profile Send private message

PostPosted: Thu Sep 25, 2008 12:52 pm     Reply with quote

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.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group