Frequency counter circuit

Simple Frequency Counter

You may have already seen various projects over many websites named Frequency counter, Digital Frequency Counter etc. I’m posting just another of them. Showing the use of timer/counter of AVR micro controller (Atmega8) in one of it’s form. This circuit can be used as a simple micro controller project for your engineering courses. Frequency of a periodic signal is the number of cycles it repeats per second!   So If we count the number of cycles recorded in a second it will directly read the frequency. So what we are going to make is a frequency counter circuit, which can also be called as a frequency meter.

Frequency counter circuit

To make this frequency meter 1) we need a signal (whose frequency has to be counted) 2) Atmega8 micro controller from Avr 3) An LCD to display the counted frequency. I assume that you are familiar with Avr Atmega8 and you know how to program it. You also need to know – How to interface LCD with Avr

Now let’s get into the details of the project – Simple Frequency Counter or otherwise Frequency Meter!

Take a look at the circuit diagram given below and also skim through the program given towards the end of this article.

Description of circuit:-

So what I have done here is; Set the counter to zero, waited for 1S, and read  the counter again. But remember,you need to read the value immediately after the delay loop ends. It is simple. Just assign a variable and copy the count to that. The data type of the variable is essentially an unsigned integer. You can try floating point data type too! But here you need to typecast it! That’s all!  To read about floating point conversion in Avr – read this article carefully – String Formatting of Avr

And yes! It’s better that you apply a conditioned signal for counting the frequency. i.e. a square wave or a trail of pulses. You may use a suitable signal conditioning circuit like Comparator;   Schmitt trigger, sine wave to square wave converter, whatever suits you. If the signal is of low power, then use a conditioning circuit . You can get lots of signal conditioning circuits in this website – check here – Signal Conditioner Circuits

Now here is the Technical details of my project. I hope you’ll have not much problem to make this.

The program [Embedded C, AVR Studio]:

#define F_CPU 1000000
#include
#define SMP 1

int main(void)
{ unsigned int i;
stdout=&lcd_str;
initLCD();

_delay_ms(50);

while(1)
{ TCNT1 =0;
_delay_ms(1000/SMP);
i=TCNT1;
LCDcmd(0x01);
printf(“Freq:%uHz”,i*SMP);
_delay_ms(500);
}
return 0;
}

Read more: Frequency counter circuit


About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:
LinkedinTwitter

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top