Generally, we all known about shift register, combinational circuits and the other important element in the digital electronics is a counter. The counter circuits are used for counting purposes, and it is also used for measuring the frequency and time. The counter circuits are designed especially for synchronous sequential circuits. The state of the counter is equal to the count held in the circuit by the flip flops. The counters will calculate the number that how many times an event occurred. The counters are the crucial hardware components and they are also known as timers and these are the best examples of the flip flops. These are also used to design programmable timers.
What is a Counter Circuit?
Generally, the counter circuits are constructed by using a number of flip-flops which are connected in cascade. The manufacturing of counter circuits is separate integrated circuits and it is inbuilt in the part of larger integrated circuits. The counter circuits are widely used in the digital circuits. There are different types of counter circuits like synchronous counters, asynchronous counters, decade counters, ring counters, and Johnson counters.
Pin Configuration of AVR Atmega8 Microcontroller
The AVR Atmega8 Microcontroller consists of 28 pins and all the pins of the microcontroller will support two signals except 5 pins. From the 28-pins of microcontroller the port B pins are 9,10,14,15,16,17,18,19, the port C pins are 23,24,25,26,27,28, &1, and the port D pins are 2,3,4,5,6,11,12. The following image shows the pin configuration of the AVR Atmega8 microcontroller and description of each pin is described below.
Pin-1: RESET pin. If we apply low-level signals for a longer time than the minimum pulse length will produce the RESET pin
Pin-2 & 3: A serial communication in the USART
Pin-4 & 5: An external interrupt. From these two pins, one of the pins is active when an interrupt flag bit of the status register is set and the other pin will be active as long as the intruder condition succeeds.
Pin-9 & 10: An external oscillator pins as well as timer counter oscillators. The crystal oscillator is associated with the two pins directly. The pin-10 is used for lower frequency crystal oscillators or the crystal oscillators.
Pin-19: Used for the SPI-channel as a Master CLK o/p, slave CLK i/p.
Pin-18: A CLK I/P, slave CLK O/P.
Pin-17: Used for the SPI-channel as a Master data o/p, slave data i/p. When it is allowed by the master, it is used as an i/p when it is improved by the slave & bidirectional. This pin can also be utilised as an o/p compare with match o/p, which helps as an external o/p for the timer/counter.
Pin-16: Used as a timer or counter1 comparatively by ranging the PB2-pin as an o/p. It is also used as a slave choice i/p.
Pin-15: Used as an external o/p of the timer or counter compare match A.
Pin-23 to 28 is used as an ADC channel. Pin-27 is used as a serial interface CLK and pin-28 is used as a serial interface data.
Pin-12 &13: Analog Comparator Inputs.
Pin-6 & 11: Timer/counter sources.
Frequency Counter Circuit By Using ATmega16
The following circuit shows frequency counter circuit using the ATmega16 microcontroller. This frequency meter or counter is used to measure the frequency up to 4MHz because we are using an 8MHz clock for the ATmega16 microcontroller. The working operation of this circuit is to count the number of pulses of a signal in one second is simply the frequency counter circuit.
To count the pulses of a signal, we are using the timer1 of the ATmega16 and it will measure the frequency by using the normal mode. When we are starting the count pulses it makes a delay of one second, then we stop the timer and read it in the register which contains the number of pulses. If the timer1 is made an overflow then we are enabling the overflow interrupt of timer1 then we are going to count the number of overflows which are which are made by the timer1. The overflow means the timer1 has made 2^16 count. Therefore, by using the following equation the number of pulses in one second can be calculated.
Frequency = i*2^16 + TCNT1
From the above equation
It is used to calculate the number of overflows in one second. Reading the frequency meter is updated for every second.
Digital Stop Watch Using Atmega8 Microcontroller
The following schematic diagram shows the digital stopwatch using an Atmega8 microcontroller. The operational principle of this circuit is, in the starting stage the stopwatch is in the STOP condition and it is identified by through the blinking display. Generally, the counting stats from 00:00, if we press the START button then the count starts. If the watch is in the running condition then the display will not blink and the display will be on.
It will start counting and the mini seconds are displayed. By pressing the halt key the digital stopwatch is stopped, in the halt state the counting freezes and the display starts blinking. By pressing again START key the digital stopwatch starts from the resume counting. The RESET key is used to reset the clock and the clock starts from 00:00 i.e. 0 minute and 0 Sec.
Applications of Counters
- The counters are used widely in the flip-flops.
- It is used in the cricket stadiums to count the number of people entering & leaving the stadium or room or auditorium.
- The operations of microwave ovens and washing machines are by using the counters
- The counters are used in the digital electronic devices like the digital clock, analogue to digital converts, and digital triangular wave generators.
The information in this article is about simple counter circuits AVR Atmega8 microcontroller. I hope by reading this article you have gained some basic information on the counter circuits. If you have any queries about this article or about the implementation of electrical and electronic projects, please feel free to comment in the below section. Here is the question for you, what is the function of the counter circuit?