Posted on Wednesday, July 8, 2009 • Category:
Counters / Frequency Meters
An AVR controller can be used as a counter, although it is a bit more involved than with a PIC. The reason is that a PIC (at least the 16F84) has an asynchronous counter input. This input will handle frequencies up to app. 40 MHz. AVR's have a synchronous counter input which is sampled with the clock frequency, so it cannot measure frequencies over half the clock frequency. So, when using a 4 MHz clock, input frequencies must be lower than 2 MHz. Use 40% of the clock frequency to be on the safe side.
The input frequency can be measured by starting an AVR counter. Wait some predetermined time and then stop the counter. Read the counter register, account for the measurement time, and you know the frequency. This sounds simple enough. Things get a little more complicated if you use an external (to the AVR) prescaler to measure higher frequencies. A prescaler can be seen as a counter itself, that produces an output pulse for every n counts of input pulses. Even if this external prescaler has not counted up to its limit, you will want to know this count value, because it adds to the AVR count value to get a resulting counter with more bits.
An example: the AVR internal counter is 16 bits. It can count up to 65536 before overflowing to 0. If you use an external 14-bit counter (a 4020) as prescaler, it will increment the internal AVR counter at every 16384th input pulse. If you know the value of the 14-bit counter after the measurement time, you have effectively a 30-bit counter:
2.5 GHz Frequency Counter
10Hz - 60MHz Frequency Meter / Counter Kit
1 GHz Frequency Counter Circuit-Zone.com © 2007-2025. All Rights Reserved.