Calculating frequencies based on cycle counts
CASTalk.com Forum Index CASTalk.com
Discussion of DSP, FPGA, storage and embedded system.
 
 FAQFAQ   MemberlistMemberlist     RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Google
 
Web castalk.com
Calculating frequencies based on cycle counts

 
Post new topic   Reply to topic    CASTalk.com Forum Index -> DSP
Author Message
Guest






Posted: Thu Dec 09, 2004 12:57 am    Post subject: Calculating frequencies based on cycle counts Reply with quote

Hi

I hope I'm mailing this to the right group.

My company has a piece of hardware which, among other things, is
intended to provide measurements of the frequency of a clock signal
(typically a few MHz).
To do this, it will measure the number of rising clock edges in a
period of, say, 10us (which time period is measured using a system
clock running at a higher frequency - say 100MHz or so).
So, we will end up with the number of rising clock edges in every 10us,
and from this the clock frequency is to be calculated. The aim is also
to track the frequency as it changes over time.

My question is, what is the best way to calculate the clock frequency
at a particular point? Are there standard statistical/numerical methods
which can be used for this?

Obviously, you can get a rough measurement of the frequency over a
short time - the 10us. And you can get a more precise measurement over
a longer period of time, but then the time resolution is not very
accurate.

Are there techniques which can be used to calculate a value, with an
error range, for the frequency at any point in time?
So you could plot the frequency against time, with a given error.

Note also that there would also be an error in the system clock
measuring the 10us period, so this would also have to be taken into
account.

I'd note that I'm neither a hardware engineer, nor a mathematician, so
I hope what I've described above makes sense.
Thanks for your help!
Calum
Back to top
Ronald H. Nicholson Jr.
Guest





Posted: Thu Dec 09, 2004 12:57 am    Post subject: Re: Calculating frequencies based on cycle counts Reply with quote

In article <31p8j0F376p3gU1@individual.net>, Jerry Avins <jya@ieee.org> wrote:
Quote:
cnmaclean@hotmail.com wrote:
My company has a piece of hardware which, among other things, is
intended to provide measurements of the frequency of a clock signal
(typically a few MHz).
To do this, it will measure the number of rising clock edges in a
period of, say, 10us (which time period is measured using a system
clock running at a higher frequency - say 100MHz or so).
So, we will end up with the number of rising clock edges in every 10us,
and from this the clock frequency is to be calculated. The aim is also
to track the frequency as it changes over time.

My question is, what is the best way to calculate the clock frequency
at a particular point? Are there standard statistical/numerical methods
which can be used for this?

Obviously, you can get a rough measurement of the frequency over a
short time - the 10us. And you can get a more precise measurement over
a longer period of time, but then the time resolution is not very
accurate.

One can average multiple 10uS measurements, or run a low-pass filter
on a stream of 10uS measurements. If you can somehow overlap N 10uS
measurements you might be able to get more accuracy in less time than
by just taking a single longer measurement over (N*10)uS.


IMHO. YMMV.
--
Ron Nicholson rhn AT nicholson DOT com http://www.nicholson.com/rhn/
#include <canonical.disclaimer> // only my own opinions, etc.
Back to top
Jerry Avins
Guest





Posted: Thu Dec 09, 2004 2:04 am    Post subject: Re: Calculating frequencies based on cycle counts Reply with quote

cnmaclean@hotmail.com wrote:

Quote:
Hi

I hope I'm mailing this to the right group.

My company has a piece of hardware which, among other things, is
intended to provide measurements of the frequency of a clock signal
(typically a few MHz).
To do this, it will measure the number of rising clock edges in a
period of, say, 10us (which time period is measured using a system
clock running at a higher frequency - say 100MHz or so).
So, we will end up with the number of rising clock edges in every 10us,
and from this the clock frequency is to be calculated. The aim is also
to track the frequency as it changes over time.

My question is, what is the best way to calculate the clock frequency
at a particular point? Are there standard statistical/numerical methods
which can be used for this?

Obviously, you can get a rough measurement of the frequency over a
short time - the 10us. And you can get a more precise measurement over
a longer period of time, but then the time resolution is not very
accurate.

Are there techniques which can be used to calculate a value, with an
error range, for the frequency at any point in time?
So you could plot the frequency against time, with a given error.

Note also that there would also be an error in the system clock
measuring the 10us period, so this would also have to be taken into
account.

I'd note that I'm neither a hardware engineer, nor a mathematician, so
I hope what I've described above makes sense.
Thanks for your help!
Calum

The mechanics of counting don't involve deep mathematics. For any chosen
approach, the ratio of the accuracy of a measurement and the time
required to make it is relatively constant.

Counting zero crossings in a fixed time interval -- called a gate time
in hardware counters -- involves a deducible uncertainty. Suppose that a
crossing occurred infinitesimally before the gate opened and another,
infinitesimally after it closed. Then an infinitesimal shift of the gate
relative to the signal could produce an additional count, and an
infinitesimal lengthening of the gate might produce two extra. Gate
edges can be independently subject to timing jitter, and the
zero-crossing detector's threshold is subject to noise. Taken all
together, the best one can hope for is knowing the count plus/minus 1
(or +0,-2 depending on how you figure). Measuring the frequency of a
signal by counting whole cycles using a gate quantized to only ten times
it is very crude indeed. (+/- 10%) The longer the gate, the less the
impact of the indeterminacy of the count.

Another method times a fixed number of cycles of the waveform to be
measured, perhaps even a single one. The signal itself serves as the
gate -- via a counter if several cycles are to be measured -- and the
number of cycles of a higher frequency are accumulated in a counter that
is read after the gate closes. The same counting uncertainty applies,
which is why the accuracy increases when several cycles are included in
the count. It actually a period measurement, so converting to frequency
requires a division.

How much hardware can you devote to this? Some 8-bit microcontrollers
can co this without any additional hardware, but at lower frequencies
than you need. You can probably find 16-bit machines that can do it with
no more than a reference crystal oscillator and a simple program.

Jerry

--
Engineering is the art of making what you want from things you can get.
ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
Back to top
 
Post new topic   Reply to topic    CASTalk.com Forum Index -> DSP All times are GMT
Page 1 of 1

 
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




VoIP Electronics Powered by phpBB