Electrical – Counting signal frequency with binary counter

counterfrequency-measurement

I'm trying to count the frequency of an audio signal using a 393 binary counter which is read by an Arduino without using its ADC. If the reading is done once per second, should the counter be somehow stopped when the counter is READ in order to avoid additional counts before the output pins are read? Perhaps, keep the input signal high with a MOSFET? What is the canonical approach to reading binary counter outputs?

Best Answer

Am only going to address your question about reading the count output from a '393 counter. You have two problems to overcome.
This counter is asynchronous, which means that a clock input ripples through the individual flip-flops to its next count state. If you happen to read the count value on-the-fly very soon after a clock transition, you might get a really strange number, neither one less, nor one more than what you'd expect. This rippling occurs very quickly but nevertheless can cause errors.
The other problem occurs when you concatenate counter chips for extended count values. A microcontroller can read in eight bits at-a-time. To read in a count from two or more '393's, the microcontroller must read in eight bits from one chip and save that result into a register, then return and read in eight bits from the next chip. In the interval, the count value can change, leading to the possibility of a wrong result.

schematic

simulate this circuit – Schematic created using CircuitLab

One solution to both problems adds a "gate" to clock input. When the microcontroller wants to read the count value, the clock input is disabled, freezing the current count value. Then the microcontroller can read the count value, which is now frozen at some value.

A 74HC590 counter chip is more appropriate. Its counter flip-flops are arranged to make a synchronous counter, having no ripple-count problem. It also incorporates an internal gate. It also provides an internal counter latch that stores the current count value, while letting the counter flip-flops continue counting up. And it provides a tri-state output, so that a micrcontroller can read in its eight-bit value from the same port. This makes it very easy to concatenate these chips if your microcontroller has limited I/O pins.
However, most microcontrollers have versatile internal counters that can give similar results with no external chips.