Mini Frequency Counter
Colin Mitchell
Colin Mitchell
February 10, 2008
Make sure to subscribe to our newsletter and be the first to know the news.

Table Of Contents


This is a very handy piece of TEST EQUIPMENT to add to your workbench.
Talking Electronics has a range of different items of Test Equipment and these can be viewed HERE.
This Mini Frequency Counter is a simple design with an accuracy of about 1%.
It will detect frequencies from 1Hz to about 4MHz and has both a digital input for frequencies up to 4MHz and an analogue input for frequencies up to about 600kHz.
The single 7-segment display shows the digits one-at-a-time. The first digit is the millions and then a comma with a large tail. The next three digits are displayed then a standard comma, before the final three digits. This is how you know the value of the first digit.

It is designed to help you when producing multiplexed displays, to indicate the scanning frequency, and similar applications. It can also be used to determine the frequency of oscillator circuits, such as those using an inductor to produce a high voltage.
It can also be used in conjunction with a piece of test equipment called a Square Wave Oscillator, to determine the actual frequency being produced by the oscillator.



To achieve a stable recording-base for the microcontroller, the supply voltage must be stable and fixed.
Even though the internal oscillator for the micro is not a crystal, it has been found to be fairly stable, provided a warm-up time is allowed.
We have provided a stable supply by including a zener as a shunt regulator.
In other words, the zener is directly across the power rail and fed via a resistor so that a current flows through the zener and keeps it in conduction.
This is actually “wasted current” but it is simplest way to provide regulation.
Normally the current through the zener is worked out by a simple formula. The current required by the circuit is determined and a few milliamps is added and this is the current required to flow through the resistor feeding the zener.
The maximum number of drive lines that can be supplying LEDs at any one time is 4 and each set of LEDs is designed to take 25mA, making a total of 100mA, plus 1mA for the chip and1mA for the zener (to keep it in conduction). This means 101mA is flowing through the zener when the LEDs are not illuminated and when the LEDs are illuminated, the micro “robs” the current from the zener and it takes 1mA while the chip takes 101mA.
But this is a very wasteful arrangement as the circuit is taking 102mA all the time.
We can “cheat” a little by reducing the “bleed-current” to about 15mA. There is no scientific reasoning behind this but here is the reasoning:
When the circuit is taking a reading, it is consuming about 1mA and the zener is providing an accurate 5v1 for the micro.
When the chip supplies current to the LEDs, it draws say 25mA. If we take this in slow-motion, we can see what happens. As the current requirement for the chip increases, the first 15mA is “robed from the zener and the voltage will still be at 5v1. When the next mA is taken, the zener has nothing more to deliver and thus the current flow through the resistor and a slightly higher voltage is developed across the resistor. This is when the zener “drops out of regulation” and the voltage on the micro is slightly less than 5v1.
As the current increases to 102mA, and the voltage across the resistor will be about 0.47volt. Depending on the voltage of the 4 cells, the chip-voltage will be 0.47v less than the battery voltage and some of the LEDs will not be as bright as the others. In our prototype, this was not noticeable when using a 47R bleed resistor.

Now, when the circuit is turned on and the chip is not driving the LEDs,
The amount of current to flow through the zener is worked out by an unusual method.
As you will see from the circuit diagram, the chip drives some of the segments of the display when an output line is high and some when the lines are low.
In this way each line will drive two separate segments as the chip does not sufficient drive-lines to drive each segment individually.
When the chip is “driving a segment” (the output is HIGH) the current is coming from the power-rail of the chip. When the chip is “sinking a segment,” the current is coming from the power rail via the LEDs in the segment.
By quickly changing an output line from HIGH to LOW, we can drive two segments. Each output is capable of delivering 25mA, so if this current is being passed to one segment for 50% of the time, then another segment for 50% of the time, the average current for each segment is 12mA. This is sufficient for the LEDs we have used.

The chip will be able to supply current without the voltage dropping noticeably. There is no physics behind this. The resistor feeding the zener is tried until the set of LEDs being “sunk” by the micro is about the same brightness as the LEDs being “driven” by the chip.


The micro has one or two (depending on the type of chip) 8-bit registers called TIMERS or COUNTERS.
They are effectively binary dividers. A digital signal (meaning a signal that rises and falls rapidly and has an amplitude equal to the supply voltage) is applied to the LSB (least significant bit) and it “clocks” the counter. On the first rise-and-fall of the signal, the lowest bit contains a “1,” so the counter contains 0000 0001, on the next cycle it contains: 0000 0010, 0000 0011, 0000 0100, 0000 0101, 0000 0111, 0000 1000 etc.
After 255 cycles, the counter will contain 1111 1111 and a on the next cycle it will “roll over” to 0000 0000. During this process it will set a bit (called a flag) in the micro.
With one counter we can record up to 256Hz.
By joining two counters together (called cascading) we can get 256 x 256 = 65,536Hz and with 3 counters we can get over 16,000,000.
The micro we are using does not have two or three counters but we can get around this in very clever way.
The micro has a 8-bit register called a pre-scaler. It is exactly like a counter, except it cannot be “read,” so we take an initial reading to get the lowest

In the second stage to taking a frequency-reading, the pre-scaler is connected to the counter via an instruction and a “count” is taken.
Each time the counter overflows from FF to 00, a flag is et and this sends the micro to the Interrupt Service Routine, where a third file is incremented. Although this operation takes a few microseconds to perform, it is only done about 61 times for 4MHz, it is a known amount, and can be added to the final result.

These counters can be clocked at any frequency (up the the limit of the capability of the “flip-flops”) and the frequency has no relation to the frequency of operation of the micro.

Normally a micro can only do one thing at a time. But in our case it is doing two things at the same time.
When it is detecting a frequency, one of the input lines is connected to a counter with pre-scaler and the counters are being clocked. At the same time, the micro is executing a delay. This is called “gating.”
The gate (the input line) is open for a period determined by the length of the delay and the n it is closed. The count in the counters is then passed to a sub-routine for processing.
The actual start and stop for the counters is determined by clearing the counter then calling the delay. At the end of the delay, the counters are “read.”


One of the clever features of the circuit is the driving of the display. There are not sufficient drive-lines on the 8-pin chip to drive each segment individually.
But since each segment consists of two LEDs in series, this produces a characteristic voltage drop of about 3.4v to 4.6v, depending on the colour of the LED. When another set of LEDs is placed in series with the first two, the total voltage drop across them is higher than the supply voltage and thus they will not illuminate when the micro has each drive-line is configured as an input.
When a drive-line is configured as an output and taken LOW, the top segment will illuminate and when the drive-line is HIGH, the lower segment will illuminate.
By rapidly taking the drive-line HIGH, LOW, HIGH, LOW, both segments will appear to be illuminated.
Thus 8 segments can be illuminated in any combination, leaving two lines for other purposes.
We have used one of the extra lines as an input for reading frequencies and the last line is unused.


We have used a FET for the pre-amplifier.


The PIC micro we have chosen for this project is the smallest and best in the series. We have investigated all small micros from nearly all manufacturers and decided that PIC is the best choice.
Some of the other “Tiny Micro’s” are no longer being produced. In addition, the greatest amount of support-software and hardware is available for the PIC series.
That’s why we have chosen the PIC12F629. You can also use the PIC12F675 but you cannot use the MCV08A as this micro does not have and interrupt feature.


There is one point we must mention about readings above 1MHz. We have already stated the project is only accurate to about 1% and this corresponds to the first three figures of a reading. To produce a fairly stable display for frequencies 1Mz and higher, the last three digits are not accurate as the chip cannot produce the required accuracy. So we have taken a further reading with the prescaler added to the counter and it represents a frequency that changes by one unit for each 256 cycles change in detection.


The first ting you will want to do is calibrate the circuit. The pre-programmed chip that comes with the kit has been calibrated, but if you are building the project yourself, here is the process of calibration:
The calibration circuit is a crystal oscillator. You will need a crystal of any frequency and


Colin Mitchell

Colin Mitchell



Social Media


Related Posts

PIC Elmer 160
March 06, 2012
© 2021, All Rights Reserved.

Quick Links

Advertise with usAbout UsContact Us

Social Media