# [time-nuts] Frequency counter questions

Chris Albertson albertson.chris at gmail.com
Sun Apr 23 12:22:07 EDT 2017

``` Assuming you are counting every cycle with no pre-scaler and can't measure
the period, the answer is easy.

If you want to measure Hz then the gate needs to be 1 second.  If you want
to measure too 0.1 Hz then you need a 10 second gate.  In your case 0.001
Hz you need to count for 1,000 seconds.

If you use a prescaler let's say it is a "divide by N" then you multiply
the gate time by N.

If the frequency is high and you want to measure to .001 Hz then you need a
really large maximum count and will overflow a 32 bit integer  You want 12
digits so you need to use a 64 bit integer counter.

The STM32 has some pre-scalers built in and a built in counter too, I
think.  I don't know what their maximum speed is.   You don't need the
compute power is an STM32 but "why not" as they cost only \$12, I use the
Nucleo boards and mbed.

The problem with counting to 12 digits is that you are only measuring the
average frequency over a very long interval.  The signal is likely not that
stable.   Lets say during that 10 second gate the signal was DC or zero Hz
for 5 seconds then went to 2 MHz.  You meter would read 1.000 MHz but the
signal was NEVER 1 MHz.

The OTHER way to measure frequency is harder but faster.  You measure the
period.   A perfect meter could mere the unknown frequency in one cycle.
It would not be an average.   But there are no perfect meters.

On Sun, Apr 23, 2017 at 12:14 AM, Jerry Hancock <jerry at hanler.com> wrote:

> Hello,  I would like to find a person that would be able to answer some
> frequency counter questions I have.
>
> Basically, I am thinking of building my own using one of the high end
> STM32F7 boards as the counter.  I would like it to count reliably to 12
> digits (e.g. 30,000,000.001x hz).  I am not worried about input
> conditioning as I have a circuit that is suitable for my needs.  Most of my
> questions have to do with using a prescaler on the front (divide by N where
> what is N) to get to the desired resolution when using multiples of the PPS
> coming from my GPSDO.  Gate times could be as long as needed to get the
> resolution.  So what prescaler do I need and what gate time is required are
> the first two questions.  I suggest if someone is willing to help that they
> either reply here with an email address or send a note to meters at hanler
> dot com.  This is for my own non-commercial use.
>
> Thanks!
>
> Jerry
> _______________________________________________
> time-nuts mailing list -- time-nuts at febo.com
> To unsubscribe, go to https://www.febo.com/cgi-bin/
> mailman/listinfo/time-nuts
> and follow the instructions there.
>

--

Chris Albertson
Redondo Beach, California
```