View previous topic :: View next topic |
Author |
Message |
2mhz Freq Maeasurement Guest
|
2mhz Freq Maeasurement |
Posted: Fri Sep 24, 2004 2:17 pm |
|
|
Is it possible to detect the period of a 2mhz signal ? |
|
|
SherpaDoug
Joined: 07 Sep 2003 Posts: 1640 Location: Cape Cod Mass USA
|
|
Posted: Fri Sep 24, 2004 2:42 pm |
|
|
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 |
Posted: Fri Sep 24, 2004 3:35 pm |
|
|
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
|
|
Posted: Fri Sep 24, 2004 8:51 pm |
|
|
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 |
Posted: Mon Sep 27, 2004 12:14 pm |
|
|
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
|
|
Posted: Mon Sep 27, 2004 1:30 pm |
|
|
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 |
Posted: Mon Sep 27, 2004 1:45 pm |
|
|
Should I use B0 and count INT's |
|
|
|