# Measurement Precision

 Designs Programming Freq Counter

The measurement period is subject to a ± 2 PIC cycle uncertainty.

To minimize the effect of this error, it is desirable to program CC to the largest possible value for a given frequency to minimizing the size of this error relative to the total measurement period.

For a given input frequency, programming the Timer Pre-load R21 and Frequency Pre-scale R22 registers to ensure the measurement period has a value of greater than 20,000 ensures the measurement error bound below 0.1 %.

# Maximizing Precision - unwrapping the period

The maximum unwrapped measurement period (MSP) is:

`MSP = 2^16 / FS`

which for a 25 MHz ADC clock is about 2.6 ms. Given the ± 2 PIC cycle measurement error this allows measurement precision of ± 0.03 %.

It is possible to extend precision even further.

By first making a measurement over a short cycle count to obtain the "ball park" frequency without exceeding the unwrapped measurement period, subsequent measurements may be made over longer cycle counts which result in the 16 bit sample address counter wrapping.

However, since the earlier measurements gave a rough estimate of the frequency under test, it is a simple matter to add back the appropriate number of `MSP` to unwrap the period measurement to determine its true value.

An alternative procedure would be to take the average of many lower precision measurements. In either case, the limiting factor in such measurements then becomes the accuracy of the ADC sample clock itself...

# Clock Accuracy and Precision

The ADC sample clock is the time-base against which all frequency measurements are made and its accuracy is the absolute limiting factor. The crystal used in BitScope has an accuracy of about 50 ppm. However, its precision at a operating temperature is much better; about 10 ppm.

If a standard frequency reference to this accuracy is available, it is possible to calibrate BitScope by using trace mode 8 in reverse to measure BitScope's crystal frequency to the accuracy of the reference using the period unwrapping described above.

Once determined, the precise crystal frequency may be programmed to the BitScope EEPROM for subsequent use by the host software when evaluating the frequency from the measured period.