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

2mhz Freq Maeasurement

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
2mhz Freq Maeasurement
Guest







2mhz Freq Maeasurement
PostPosted: Fri Sep 24, 2004 2:17 pm     Reply with quote

Is it possible to detect the period of a 2mhz signal ?
SherpaDoug



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

View user's profile Send private message

PostPosted: Fri Sep 24, 2004 2:42 pm     Reply with quote

First, are you talking about 2 megahertz (MHz) or are you really talking about 2 millihertz (mHz). 2 millihertz has a period of about 9 minutes and such waves are used in deep earth seismography, some obscure submarine hunting operations, maybe temperature oscillations in large ovens, and a few other places. A PIC can easily measure time spans near 9 minutes.
If you really mean 2 megahertz the answer is yes... sort of. The hardware timers generally run about as fast as the CPU clock which for the right PIC could be as high as 40MHz, but is 10 to 20MHz for most PICs. So if you run the timer at 20MHz and your signal is 2MHz you will get about 5 counts per cycle or 2.5 counts per half cycle. Yes you get a measurement but the resolution is very coarse.
You are much better off using a prescaler before the PIC to divide the signal down in frequency for better measurement.
_________________
The search for better is endless. Instead simply find very good and get the job done.
2mhz Freq Measurement
Guest







2mhz Freq Measurement
PostPosted: Fri Sep 24, 2004 3:35 pm     Reply with quote

I would like to place a / by on the input the problem is I will need to detect a delta of 100HZ.

(The input is Mhz)

What is I run the CPU Freq > 20Mhz/

_THX
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Fri Sep 24, 2004 8:51 pm     Reply with quote

Please be more specific, maybe you can describe your application? Right now it sounds like something the PIC can do, but it might be difficult. Knowing your application easer solutions might pop up.

For example, how much time do you have for measuring the frequency? Suppose, you have 1 second, then you could count the number of pulses in this second with one of the hardware counters and you will have an exact result. The longer the time you have for measuring, the more accurate you can make the measurement.

Hardware limitations for a PIC18 Timer0 counter are around 50MHz.
2mhz Freq Measurement
Guest







2mhz Freq Measurement
PostPosted: Mon Sep 27, 2004 12:14 pm     Reply with quote

The app is a sensor that produces a 2Mhz signal. The output could move +/- 100hz with respect to the sensor measurement.

I wanted to measure the period and convert to Freq.


-THX
SherpaDoug



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

View user's profile Send private message

PostPosted: Mon Sep 27, 2004 1:30 pm     Reply with quote

If you search this board for "frequency counter" you should be able to find something that will count the cycles over a period of time. If you count for 10ms then a 100Hz frequency shift will give you a 1 count difference. If you can afford to count for 100ms you will get a 10 count difference which will be more immune to noise. At 2MHz it is much easier to measure frequency than period.
_________________
The search for better is endless. Instead simply find very good and get the job done.
2mhz Freq Maeasurement
Guest







2mhz Freq Maeasurement
PostPosted: Mon Sep 27, 2004 1:45 pm     Reply with quote

Should I use B0 and count INT's
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