# Digital Frequency Counter

First of all, if you like this project, please vote for me in the Hurricane Laser Competition and the LED Contest!

Have you ever needed to find out how quickly something is oscillating? For things like hamster wheels and ocean waves, this is easy. You just count how many times the wheel goes around in a certain amount of time, then do some math, and you have the frequency. But what if you're dealing with something a little less tangible like audio waves or electronic signals? That's where digital electronics saves the day.

This Instructable will show you how to build a digital frequency counter capable of measuring events up to 250kHz and will attempt to explain some of the electronics theory behind it. The project costs about \$30US, assuming you already have all the tools and equipment required.

This is actually my term project in a Digital Electronics course at the University of Oregon. It's intended as an addition to my term project from the winter term, which was a Function Generator I also posted to this site.
Remove these ads by Signing Up

## Step 1: Description

A frequency counter is a device that measures a periodic signal and determines its frequency in Hertz (Hz or s-1). But how does it do it? If you were trying to determine the frequency of a wheel manually, you might follow this operation:
1. Mark a spot on the wheel, then let it spin.
2. Start a timer.
3. Count how many times the spot on the wheel reaches the top.
4. Stop the timer.
5. Divide the number of rotations by the amount of time that passed while you were counting.

The result of the division would be the frequency of rotation of the wheel. This build actually follows the same steps, but it does all the operations automatically, repetitively, and it doesn't actually do any math. The math is built into the way the frequency counter counts.

This frequency counter actually follows these steps:
1. Generate a stable, known, reference time period.
2. Count the number of periods of the signal you're measuring.
3. At the end of the reference time period, display the number of counts and reset the count to zero.

These steps can be completed very quickly and repetitively using digital electronics methods. It's a very "dumb" process. The accuracy of the output frequency depends wholly on the accuracy of the reference time period and the speed of the counting chips. Using quartz crystal oscillators, we can generate reference periods with an error of about 20ppm, or 0.002%. Digital electronics can typically handle up to 30MHz signals, so this project is actually quite accurate.

The key to keeping any math out of the device is to make the reference periods base ten (decimal). Digital electronics is all base two (binary) so we need some chips that let us do some decimal conversion. What would be really nice is to just have a 1 second reference period. Then we could just count the number of pulses from the measurement in one second and display that and we'd automatically have Hz. That's actually what's going on.

But there are only three digits for display. How do we keep the display from rolling over? Let's say we have a frequency of 1,234Hz that we want to measure. If we counted for one second, the display would show 234 since it would roll over once. That's no good. But what if we only count for 1/10th of a second? Then we would get a count of 123 since 1234Hz * 0.1s = 123.4 (the .4 gets rounded, digital only deals in integers). If we KNOW we're only counting for a tenth of a second, we just multiply this count by 10 to get 1230Hz. This works for higher frequencies too. If you know the order of magnitude of the reference period, you can just do some easy 10^n multiplication and get a three-significant-digit result.
trickx181 month ago

boycecat3 months ago

would it be possible to modify this to measure a low frequency (50Hz) accurately? I am guessing any rounding errors would be more of a problem? Thank you

laserjocky (author)  boycecat2 months ago

Sorry for the slow reply. For this you could increase the counting time to 10 seconds to gain some accuracy in the form of a tenths place. You would need to modify the circuit. There's already an extra BCD counter on the board so it would be a matter of wiring it up to generate a 10 second reference period.

dalexdisuja4 months ago

hi all of my friend i get very good article on digital frequency meter at the link

http://www.nbcafe.in/digital-frequency-meter-by-pi...

they write very elaboretly which is very helpful you may see that.

laserjocky (author)  dalexdisuja4 months ago

Thanks for the link! Of course, I wasn't allowed to use anything near the complexity of a micro controller for this project. If you want to do things easily, use an MC. If you want to understand how something works, start at the lowest level.

nigelj10 months ago

this might sound silly.....but how to use it for measuring audio from microphone?

laserjocky (author)  nigelj10 months ago

This counter can really only handle a single frequency. There may be a way to measure a string of short pulses from a mic, but if you're trying to separate out individual frequencies then you'll need something much more complicated than this build.

What this counter would do on its own when given a microphone input is count half the number of times the audio wave crossed over zero. There wouldn't be a way to determine which frequency components were contributing to the final count.

10 months ago

Can you suggest me a circuit that can measure frequency of sound produced in real world environment? like human voice, tuning fork etc?Is it difficult to do? I have come across many such circuits but none of them specify if it will work with real world sounds.

laserjocky (author)  nigelj10 months ago

This build might be able to handle a tuning fork input because it is a single frequency. But a human voice is composed of many frequencies mixed together with different amplitudes for each. In order to decompose these frequencies you will need a circuit that performs a Fourier analysis. Fourier analysis is a pretty complicated thing for a homebuilt circuit to do accurately. It's probably best to use a computer running Fast Fourier Transform software. That would tell you exactly how much of each frequency was included in your sound wave.

If all you want is to find the lowest frequency component (the fundamental frequency) of a human voice, then you might be able to get away with placing a low-pass filter on the front end of this circuit. Or even better, if you can find a very low bandwidth band-pass circuit whose center frequency can be adjusted, you could sweep the center frequency back and forth until you selected out a single frequency of the human voice. The output of the band-pass would be fed to the counter. But band pass filters aren't perfect, they just lower the amplitude of frequencies outside their set range, and those low amplitude waves could still affect the counter.

Ok final idea: You could make a circuit that contains several band pass filters with different ranges, say one that passes 10-100Hz, 100-500Hz, 500-1kHz, 1kHz-5kHz, etc, etc. Then you would need a circuit on each output that determined the amplitude of the waves. Like an op-amp going to a diode-capacitor-resistor circuit that fed into an analog to digital converter which converted the voltage to a pattern that lights up an LED bar or something. With this circuit you'd be able to tell roughly which frequencies were in a sound wave, but it wouldn't be very accurate.

10 months ago

Thanks for the input. I didnt know human voice were this complicated....anyway I'm planning to do a frequency meter ( in Hz ) using PIC and LCD to output for college project. About tuning fork......can i use mic to input tuning fork sound and measure the frequency? Also i guess it can be used for setting frequency of musical intruments right?

laserjocky (author)  nigelj10 months ago

Yes, you could use a tuning fork and mic to measure the tuning fork's frequency with this circuit, but you would need a pre-amp for the microphone. There should be plenty of simple circuits for that online. I haven't worked much with audio amplification.

Setting the frequency of musical instruments will have the same issues as the human voice. The reason instruments sound different is because each one contains it's own distinct combination of frequencies other than the fundamental you hear. When a piano plays an A, the majority frequency is 440Hz. But there are actually many overtones in the note you can't quite hear with your ear. Those overtone frequencies are what makes the piano sound different from a trumpet or guitar. Those frequencies are what would make it difficult to use this counter to measure audio frequencies. A tuning fork might be ok, but that's only because tuning forks have essentially no overtones. They are pretty much the purest sound you can get. Another instrument you might be able to measure is a flute. Flutes and tuning forks both have almost no overtones.

If you're using a PIC or other micro controller, you may be able to program it to do a fast fourier transform of an incoming wave. That's beyond what I'm able to help with, but maybe there is an instruct able about it.

10 months ago

Hi,
It's me again. I need your suggestion.The digital frequency meter in this instructable is able to measure upto 250 kHz.Do you know how to increase the measuring range, like in the Mhz range? I'm doing a similar project using 8051 and according to it's specs, it can measure upto 12 Mhz, but the circuit I have can do only upto 250 kHz. Do you know how I can modify the circuit to increase the measurement range?

laserjocky (author)  nigelj10 months ago

The frequency for this device isn't determined by the digital electronics I used. Digital chips usually work up to at least several MHz. You can look up the data sheets for each chip and see for yourself. 10-30MHz is pretty standard for all of these. I think (and I stress THINK) that the frequency is being limited by stray impedance in the circuit. Each wire, solder joint, IC connection, etc, acts as a very small combination of a capacitor and inductor (often called impedance, for both in general). Stray impedance is death for high frequencies. When you add up all those small impedances, the incoming signal ends up being garbled. The stray impedance of this circuit is probably huge because of the wire wrapping method.

I think the best way to improve frequency response for this circuit is to order a nice, professionally etched PCB. PCB's keep all connections in the same plane, use small wires, minimal connection length, etc, and that really does wonders for minimizing stray impedance.

10 months ago

FFT sounds too complicated for us to implement now but I will be incorporating that on the next version of our project ( final year project )

Thanks :)

cglaw20131 year ago
awesome
donkeyknee1 year ago
good
steveastrouk1 year ago
Unless they gave you a precision limit, it would have been funny to do a frequency to voltage converter and a voltmeter as the output...
laserjocky (author)  steveastrouk1 year ago
The thought had crossed my mind, but for this class I'm pretty sure that would have been cheating :)
amandaghassaei2 years ago
nice project! and great documentation. do you think you will make a pcb for this?
laserjocky (author)  amandaghassaei2 years ago
Thanks! I probably won't be making a PCB for this project, even though it would likely improve the frequency response by a very significant amount. The biggest limitation for that in this project is probably stray inductance. EagleCAD does relatively good auto-routing for free if you want to go that route. You'd pretty much have to get the PCB etched professionally though (probably >\$100) since there will be so many traces and vias.
2 years ago
Hi, it's always great to find someone who doesn't use microcontrollers for everything. If you want to find some ideas for simple frequency counters capable of measuring high frequencies, look there:

http://pa2ohh.com/

http://www.hanssummers.com/sfreq.html
pfred22 years ago
Not many are still making circuits like this anymore. I'm glad to see someone other than me does. I'd like to see more decoupling capacitors to improve circuit stability but the logic design looks nice.

One thing I'd never do making a circuit like this is try to complete it before powering it up. I build one section at a time, test it, debug it, and move on only when I get proper operation from the circuit section I am working on.

Your build it and hope it works method is too optimistic for me. Doing that only lands me in a place I never want to be. Trying to debug a circuit with more than the minimum of possible variables. To me that just adds up to extra work.
laserjocky (author)  pfred22 years ago
It's true, almost no one uses logic chips in this way anymore. I've seen a few others on Instructables. For me, it was just a great way to build something complex from extremely simple components. I love how modular the old digital chips are. Unfortunately, the course I made this for was mostly a theory course, and they didn't go into things like decoupling capacitors at all. I know the general idea, but do you have any pointers for me for the future? Where should they typically be added, just on the power lines near each IC?

Normally I'd agree with you about the testing. That was the method my PI taught us to use in the lab. Build and test in reasonable chunks. It's hard for me because I haven't invested in an actual oscilloscope for my home yet. I did test the essential portions of the circuit on a breadboard in the lab first, even though those have issues at high speeds, and it seemed to work ok. By the time I was actually loading chips into the protoboard, I knew the circuit pretty much by heart. It worked the first time I powered it up. I had many more issues with the analog sections of the function generator. As it happens, I had those issues with it because I took the same "build it and hope it works" method... Hmm, area for improvement noted.
switch622 years ago
Well done. It's nice to see a digital design that uses actual logic chips. Now a days it's just throw in a microprocessor and do it all in software.
Mind you micro's make the development and design simpler.
laserjocky (author)  switch622 years ago
Yeah, a microcontroller design would have actually been cheaper too. With the upper limit for frequency counting for this board, the microcontroller's clock speed wouldn't have limited it at all. But this was for a digital electronics class and we weren't allowed to use those.