Become a subscriber (Free)

Join 29,000 other subscribers to receive subscriber sale discounts and other free resources.
:
:
Don't worry -- youre-mail address is totally secure. I promise to use it only to send you MicroZine.

There are Two Fundamental Types of Frequency Counter

Did you know there are two types of frequency counter?  

The method you'll probably think of first is to count the input edges of the signal you want to measure and time a precise delay e.g. 1s then the frequency you measure will be in Hz.

There is another method called reciprocal counting where you count the edges of the internal clock instead (used in commercial counters). 

Normal direct frequency counting

The obvious method is to feed the measurement signal into a counter chip which is turned on for a set period e.g. 1 second.  

The counter value is actually the frequency measurement since:

f = events/time = counter value/1 second = counter value in Hz.

The problem with this method is that the resolution of the counter is 1Hz and the number of digits displayed is dependent on the input frequency:

A 1Hz input  gives 1 digit
A 100Hz input  gives 3 digits etc.

The resolution is in Hz (dependent on the gate time -which must be a multiple (or sub-multiple) of a second) - this is why the reciprocal counting method is better as it gives a resolution in terms of the master clock frequency inside the unit that is not dependent on gate time and the number of digits is also not dependent on the input frequency.

Reciprocal frequency counting

The second method is reciprocal counting where instead of counting the input signal you count periods of a master clock and instead of counting the input signal edges you let the input signal start and stop the counter.

For example the counter is started at the rising edge of the input signal and stopped at the next rising edge.  Now the counter reading is actually the period of the input signal in multiples of the master clock.

Its called reciprocal counting since you have to work out:

f= 1.0 / period

...to work out the frequency.

A simple reciprocal counting example.

Lets say your internal counter runs at 1 MHz and you have an input signal that has a frequency of 1345Hz.

The number of 1MHz periods in 1345Hz is:

Tsig/Tmeas = (1/1345)/(1/1e6) or 1e6/1345 = 743.49

We lose the decimal point to get

743 counts of our 1MHz counter.

So in the microcontroller we have a value of 743 and to show the frequency on a display we need to calculate the following equation:

1/(743*(1.0/1e6)) = 1345.895 Hz

which can also be written as:

1e6/743 = 1345.895 Hz

...and the easiest way to do that is using a floating point library.

Note: Remember that floating point libraries are slow, slow, slow so consider using fixed point maths.

The reason for using reciprocal counting

Reciprocal counting is more difficult as you have to use floating point routines to work out the frequency but because the counter counts edges of a master clock the resolution is fixed in multiples of that master clock and not dependent on the input signal i.e. the frequency counter will show all digits regardless of the frequency of the input.

The resolution of the measurement is better since in a normal counter the count will be out by ±1 Hz count whereas the reciprocal counter will be out by ±1 master clock cycle.

Note: This does not mean that it is more accurate - accuracy depends on the clock stability of the unit.

Reciprocal counters are useful for period measurements and you will find for commercial counters that they usually have two inputs labeled A and B.  You can set up the frequency counter to just measure A frequency on A or on B but you can also do signal period measurements e.g. trigger on the rising edge of A to get the high period etc.

In addition you can do measurements between different signals e.g. rising edge of A and only after that has triggered stop the count on the rising edge of B - that would be useful for measuring timing characteristics for a peripheral e.g. RAM access time.

You can find a project for a normal Direct frequency counter here.

New! Comments

Have your say about what you just read! Leave me a comment in the box below.



Privacy Policy | Contact | About Me

Site Map | Terms of Use



Visit our Facebook Page:
To Visit Click Here


Recent Articles

  1. Arduino EEPROM - how it works and how to use it - with examples.

    Arduino EEPROM: How to use it and How to presrve the life of EEPROM. Two examples sketches to save multiple values to EEPROM.

    Read more

  2. How to use the ADS1115

    A tutorial on using the ADS1115 precision 16 bit ADC for low power use.

    Read more

  3. The TP4056: Lithium Ion/polymer Battery Charger IC

    Learn how to use the TP4056 properly. There's a right, and a wrong way, to use it to safely charge Lithium Ion batteries.

    Read more

  4. DW01A Battery Protector IC

    The DW01A chip is a Lithium Ion battery protector commonly used on TP4056 boards.  Find out Exactly how it works and how to use it the correct way.

    Read more

  5. Arduino String: How to read commands from the serial port.

    For Arduino string operations you can use Object Class Strings or C style strings but which should you use? Also find out how to decode commands and control variables in your programs using strings.

    Read more

  6. A Real Time Clock design (DS1307) with a PIC microcontroller

    Real Time Clock Design (FREE): A Free and Complete RTC design using the DS1307 and a PIC micro (16F88) also re-targetable. This PIC project uses an I2C Clock chip and 7-segment display to create a fou…

    Read more

Readers Comments

"I wanted to thank
you so so so much
for all the information
you have provided in
your site it's

SUPERB and FANTASTIC."

- Ranish Pottath

"This site really is
the best and my favorite.
I find here many useful
projects and tips."

- Milan

bursach<at>gmail.com<

"Awesome site,
very, very easy and nice
to navigate!"


- Matt
matt_tr<at>
wolf359.cjb.net


Learn Microcontrollers

"Interested in
Microcontrollers?"

Sign up for The
Free 7 day guide:

FREE GUIDE : CLICK HERE


"I am a newbie to PIC
and I wanted to say
 how great your
site has been for me."


- Dave

de_scott<at>bellsouth.net

"Your site is a great
and perfect work.
congratulations."


- Suresh

integratredinfosys<at>
yahoo.com

"I couldn't find the correct
words to define
yourweb site.

Very useful, uncovered,
honest and clear.

Thanks so much for
your time and works.
Regards."


- Anon

Back to Top