# Ajantha College and School Students Science Projects materials

"In the name of Allah, most
Gracious, most Compassionate"

Phone

044 4213 1795

Mobile

+91 91764 16648   +91 9042 686793

#### 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.

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; } ```