CMOS prescaler turns the ADALM1000 into MHz Frequency meter

Blog Post created by dmercer Employee on Aug 26, 2015

The idea is very simple and commonly used. Just divide the high frequency signal with a prescaler down to frequencies low enough to measure with the ALM1000. Then the measured frequency is multiplied by the prescaler value and... we have the frequency of the input signal.

Measurement principle and resolution

A conventional frequency counter counts the number of cycles of the input signal over a certain time say one second. The count would then be the number of cycles per second or Hz. The resolution of the measured frequency is directly related to how long you count. If you want 0.1 Hz resolution you need to count for 10 seconds. This frequency measurement scheme works differently. The exact time is measured over a certain number of periods. The number of periods divided by the time gives the frequency. The resolution of this time measurement depends on the sample rate of the ALM1000 and measuring the time over multiple input periods improves the effective resolution. The measured time is plus or minus 1 sample period or 10 uSec.

Trick to improve the resolution

With a square wave signal from the prescaler, we do not know where exactly between the two analog samples of the ALM1000 the “zero crossing” occurred. The first sample is close to 0 volts and the next sample close to +5 volts. So the resolution of the time measurement is never less than plus or minus 1 sample period or 10 uSec. If we could somehow calculate where exactly the zero crossing falls between the two samples, the resolution of the time measurement would be much better. That is possible to do when the slope of the square wave is reduced by means of an RC network. The analog input signal chain of the ALM1000 contains a built in RC filter to provide some degree of anti-alias filtering. The RC time constant is 1.5 uSec. This does not reduce the slope of an input square wave a lot but it is enough for the measured samples to contain some amplitude information at the transition and we can use that to determine the fraction in time between samples where the zero crossing falls. Of course an external RC filter with a time constant closer to one sample period could be added between the output of the prescaler and the input of the ALM1000.


Figure 1 Interpolating the zero crossing between time sample points

Figure 1 is a simplified diagram to explain the procedure. S0 through S3 are the measured time sample points along the input waveform. The dashed line represents the midpoint between the minimum and maximum of the waveform and is used as the “zero crossing” point. V1 and V2 represent how far sample points S1 and S2 are below or above the midpoint line. If V1 is smaller than V2, then the zero crossing is closer to S1 than to S2. And with the ratio V2:V1, we can approximate ( interpolate ) the fraction of a sample period between S1 and S2 where the zero crossing falls.

The Prescaler

To reduce the frequency of a MHz signal to within the measurement range of the ALM1000 a divider factor of up to a few thousand will be needed. Multi-stage dividers such as the CD4020 14 stage, CD4040 12 stage or CD4060 14 stage dividers would be a good place to start. The high supply voltage versions top out at right around 10 MHz when operated from +5 V. The 5 V only 74HC4020 etc. versions can, according to their datasheets, toggle at up to 90 MHz but a practical upper limit is probably closer to 30 MHz.

Input Preamplifier

If the signal to be measured is a 5 Volt TTL or CMOS logic level then you are generally good to go by just connecting directly to the input pin on the divider chip. If however the signal is smaller and or a sine wave, a high gain, high bandwidth preamplifier will be needed. Here are a couple of simple options.

A CMOS logic gate has considerable gain near its input threshold. If the input is biased at or near the threshold and the input signal were AC coupled to that point the CMOS input pin of the divider could serve as a sort of preamplifier. Figure 2 shows the typical input / output voltage transfer for an unbuffered CMOS inverter. The slope of the line is the gain and determines the width of the transition region. The width of the transition region determines how small an input signal will result in a full 0 to 5 V swing at the output. The center of the slope where Vout = Vin is the threshold point and is often near VDD/2 but not necessarily exactly.


Figure 2 CMOS inverter Input / Output transfer plot

Simply biasing the inverter input at VDD/2 such as in figure 3 will work but uncertainty in the divider ratio and inverter threshold voltage will increase the minimum input signal amplitude that can be detected.


Figure 3 CMOS inverter with input biased at VDD/2

However, if we have access to both the input and output of the inverter as we do in the 74HC4060 we can apply DC feedback around the inverter to bias the input at exactly the input threshold where Vin = Vout as shown in figure 4. Now the input bias will track device to device differences and variations in power supply and temperature. This will minimize the input signal amplitude that can be detected.


Figure 4 CMOS inverter with DC feedback to set input bias point

The Software

A simple Python demo program was written to show how the above technique could be implemented for the ALM1000.  A copy is attached to this blog. It is intended only for demonstration of the concept but the basic methods implemented could be used with any desired user interface.

The program makes use of the 4:1 multiplexer from here connected to the Channel B input to measure four different divider outputs from a CD4060 CMOS frequency divider. The interface allows for a different divider factor for each mux channel. The measured frequency and period is displayed for each channel. Figure 5 and 6 are screen shots of the displayed output with 1.000 MHz ( as marked on the outside of the can ) and 10.0 MHz metal can crystal oscillators connected to the input of the CD4060 divider ( as per figure 4 ).


Figure 5 measuring 1.000 MHz oscillator


Figure 6 measuring 10.0 MHz oscillator

The use of the analog input multiplexer is of course not a requirement but was used to show good agreement at different divider factors. The program reads 20,000 samples or 0.2 seconds worth of input signal from each mux channel. The program starts by finding the first rising edge within the beginning ¼ of the time record. It then counts rising edges till it runs out of samples. It calculates an interpolated crossing point for the first and last rising edge. Using all these calculations it comes up with a measured time for the N input periods it found. Using the provided divider factor for each channel it then displays the input frequency and period. From the results in figures 5 and 6 we are seeing around 5 figures of accuracy or maybe a little more.

In conclusion we now have a way to effectively measure the frequency of a signal well beyond the bandwidth and sample rate of the ALM1000 analog inputs.

As always I welcome comments and suggestions from the user community out there.