To recalibrate my ageing HP 3850A spectrum analyser I needed a 6 digit frequency counter. After looking at buying a used device I realised that the purchase and calibration would cost me £300 plus, and constant recalibration would be required.
I had a STM32F407 controller laying around, and a MBLOX GPS module, and wondered if the PPS (pulse per second) signal could be used to provide an accurate frequency reference and I could create a decent frequency counter based on this?
Using a 32 bit counter synchronised by the PPS GPS signal, we can get an accurately calibrated count. Using clever software we can use the initial count value, and could average readings to further improve accuracy.
From the MBLOX data sheet the PPS signal is accurate to 30nS, this is 0.06 parts per million (ppm) giving a good 7 digits accuracy.
The two measurement techniques are:
- Use a calibrated counter and trigger reading on rising/falling edge of incoming signal, for frequencies below a suitable break point (TBD).
- Count incoming pulses and use PPS to get count, the upper frequency is limited to the maximum counter speed.
Triggering on edge of incoming signal
Measuring a 20KHz signal using with a 80MHz counter clock would give a count of 4,000 initially, giving 3.5 digits accuracy, but averaging over 100 counts would give 4,000.00, 6 digits accuracy. This would only take a 1/200th of a second. Averaging over 1000 counts would happen in a 1/20th of a seconds giving 4000.000 6.5 digits accuracy.
40KHz would give a count of 2,000, but if counting for 1 second we got 40,000 in a second, which is far slower. The averaging technique can be used, resetting if there is a significant frequency change up to about 50 KHz.
Choice of board
STM32F407 on the STM disc-1 development board has a LCD display and USB, and two 32 bit counters. TIM 2 and TIM 5. These have a maximum clock of about 80MHz. The touch display would allow user input configuration to be trivial. I picked up my development board for £32 – bargain. All that would be required is a small case, input filtering and buffering of the measured source and attachment of the GPS receiver.
It may be necessary to use an external GPS antenna TBD. See part 2…