because the TC’ occurs 256 pulses
early and I add one clock pulse for
synchronizing, so I add minus 256 plus
1 to the desired gate time. Because the
gate bank starts and stops exactly on a
clock pulse (because of the gate
synchronizer) and the delay through the
counter is very low, the gate timing is
very accurate. At the end of the gate
time, the PIC reads the count bank
outputs to get the frequency.
Making a period measurement
follows a similar path, except the gate
bank and count bank inputs are
reversed by U2. The PIC preloads the
gate bank with a value equal to minus
the number of input signal pulses minus
255. For example, to count 1,000 signal
pulses, the gate bank is loaded with
minus 1,255 (minus 1,000 minus 255).
Period measurements are a little more
complex since we have to pick the number of input signal
pulses (the 1,000 in this example).
The accuracy of the measurement depends on how
many internal reference clock counts are accumulated in
the count bank. If we use the 1,000 signal pulses
discussed here and the input signal is 1,000 Hz, then the
gate will be open for one second and the count bank will
record 10,000,000. This gives us our 7/8 digit accuracy.
However, if the input signal frequency is 100 kHz, the
gate will be open for .01 seconds and the count bank will
record 100,000 or 5/6 digit accuracy. On the other hand,
if the input signal frequency is 10 Hz, the gate will stay
open for 100 seconds. As we’ll see shortly, the software
(available at the article link) solves this problem nicely and
will force a gate time of close to one second (or whatever
value we want). Five more components complete the
1. The input signal amplifier.
2. The rotary switch input circuit.
3. The PIC16F886.
4. The display.
5. The internal 10 MHz frequency reference.
The input signal amplifier (Figure 4) is
used to take a low amplitude input signal with
a frequency range of 10 Hz to over 70 MHz
and convert it to a TTL voltage level. Every
frequency counter has some sort of input
amplifier and the Internet is full of designs
ranging from simple two-transistor FET
amplifiers to multi-component designs often
using the popular MC10116 ECL triple line
receiver.
The frequency range can be increased to the 300
MHz range, or even higher by using a prescaler. Again,
the Internet has many designs for this. The rotary switch
input circuit is simply a four-resistor voltage divider, with
the voltage taps connected to the switched terminals of a
rotary switch. The switch wiper terminal connects to RA0
on the PIC, and the PIC A/D converter determines the
switch position by simply reading the voltage on pin RA0.
1. Make high accuracy (7/8 digit) readings (top tap of
the switch). These take about 1.3 seconds per reading.
2. Make medium accuracy (6/7 digit) readings (center
tap). These take about . 6 seconds.
3. Make continuous (5/6 digit) readings (bottom tap).
These take about .1 seconds.
March 2015 25
■ FIGURE 4. Input amplifier schematic.
■ FIGURE 5. PIC schematic.