ZL2PD Simple LED Frequency Counter
This 5-digit frequency counter project is one of a series of 8051 based frequency counters which I designed over a period of about two years. I wanted a compact counter for use in a receiver project, and this was one of the early versions I developed.

In an attempt to use the smallest possible LED display, this counter uses a very small National Semiconductors 8 digit LED display which came from an old calculator. (For those interested, the display part number is NSA1488) I worked out the display common and segment pin connections of the display using a multimeter.

Actually, any modern common cathode LED display can be used instead of this display. I used these in a later 5-digit version of this same counter. I originally believed that this ex-calculator display would be ideal for the compact receiver I was building, but, as events transpired, the display ended up being just a few millimeters too large, and I had to keep looking for a set of even smaller LED displays.
This simple LED frequency counter uses a Philips 87C751 microprocessor to reach above 35 MHz.
The counter uses a Philips 87C751 microprocessor. This is an EPROM member of the 8051 family. It was, for a number of years, the smallest 8051 chip equipped with an I2C interface, although that feature was not used in this project. It also comes with 2k of EPROM and 64 bytes of RAM. This may appear limited, but it's actually plenty of memory for this sort of application.

Just a warning: The 87C751 chip is fairly hard to find now. However, I've described this project here because I imagine that a number exist in junkboxes here and there. I still have a couple floating about in my junkbox, left over from earlier projects. I'll get around to using them on something else one day, and this may be just the project for someone to resurrect their 87C751 from the junkbox.
One feature of the chip to watch out for is its unusual timer/counter arrangement - Well, it's a bit unusual within the 8051 family anyway. The 87C751 has two timer/counters; one 16 bit timer/counter and one 10 bit timer. The 16 bit timer/counter is configured in an auto-reload mode. Here, it's used in the main frequency counting routine. The 10 bit timer is normally dedicated to the I2C interface, but here it is used for a fixed rate background timer. Combined with interrupts, it drives the display digit multiplexing, with one digit being displayed each time the 10 bit background counter rolls over, once every 860 uS, and captures new counter data every 128 mS.
I built the counter on prototype board using point to point wiring. This design was never intended for mass production and so a PCB was not developed. Besides, most prototypes and one-off designs are faster and easier to build this way, I've found. I used a mixture of regular hookup wire, wire-wrap wire and solder-through wire. The latter wire is very thin and quite hard to see in the photos (It's only used on the underside of the board). Made years ago by Vero in England, it is coated with a thin but surprisingly tough layer of insulation which acts as a solder flux when the wire is soldered into place.

The counter display is wired in at one end of the board and supported by a pair of triangular shaped scraps of PCB. LED displays need for a fairly high drive current to light up the LEDs. Unfortunately, the 87C751 cannot drive these directly. As a result, there are a fair number of discrete transistors required for display drivers. However, they are cheap, so it's not all bad.

The overall current is kept down by multiplexing the displays. That means a pair of ports are used to drive each of the eight displays one by one. One port outputs the LED segment data for each display while the other port selects the required display. This requires a little more care when writing the code.

This multiplexed display method does generate some clock noise, and the counter may need to be mounted in a shielded box for some applications. I ended up using another version of this counter in the receiver so this one was put to use around the bench for some time, and the multiplexer noise was rarely noted.
The counter is powered directly from a 5V supply, and needs less than 100mA. It covers frequencies from 500 Hz to above 30 MHz. The preamplifier circuit is one commonly found in frequency counters, and operates from a 5V rail. It uses a commonly available FET (MPF102 or J310 etc) and a pair of RF transistors. I used MPHS11 devices, but other versions I tried used the more commonly available 2N2222 transistors. The display driver transistors are all general purpose NPN and PNP devices. Examples include BC547 (NPN) and BC557 (PNP) devices.

Note that two pullup resistors are required on the I2C port lines on the 87C751.

The preamplifier feeds a 74HC4040 divider, which divides the input frequency by 64 to ensure the maximum frequency limitations of the 8051 family are not exceeded. The maximum input frequency is defined as 1/24th of the oscillator frequency. So, with a clock of 14.3 MHz, the maximum input frequency is 600 kHz. Since the 4040 stage divides the input by 64, the maximum frequency which can be counted is 38.4 MHz.

The 87C751 clock crystal is the reference for the counter, and the code allows fine tuning to ensure reasonable accuracy. Comments in the source code (below) describe all of the details. I used a 14.3 MHz crystal from an old 8086 PC motherboard, but the code can be modified for use with other crystals.

There are a couple of test points to be seen on the counter. These were used during code debugging to externally flag when sections of the code were exited. I don't have an in-circuit emulator for the 87C751, so the development was all done using the well proven (but tedious) "crash and burn" method. For those readers unfamiliar with this process, the term refers to the experience encountered during the often highly repetitive code development cycle. The designer writes some code, programs (burns) the code into the EPRM in the chip, then watches the new code crash in some spectacularly new and novel manner as yet another error is encountered in the program. Fortunately, this project wasn't too bad in that regard.

When the counter is powered up, the display will briefly show "HF2000A". This was the model number I gave to my new receiver. Feel free to change the source code so your version of the counter either displays nothing or something more appropriate. The data for this sign-on display is located, along with other display related data, towards the very end of the source code.

Aside from the expected numeric frequency information, the display may also show "BadCount". BadCount indicates the counter is attempting to display a frequency in excess of 65,535 MHz. It is held briefly to show the over-range count before the normal frequency counting routine continues again.
Click here to see the circuit diagram:
Files Available to Download:
Intel HEX file - Clicking on this link will allow you to download a zipped HEX format file (1 kB) for programming an 87C751 chip for use in this counter
Source File - Clicking on this link will allow you to download a zipped Metalink compatible ASCII TEXT format source file (5 kB) for this counter. This will allow the code to be modified by experienced 8051 programmers who may wish to use the code with another type of 8051 chip or add more features.
Hosting by WebRing.