# How accurate is a ripple counter (using D flip-flop) in measuring the frequency of a signal?

I have two oscillating signals S1 and S2 whose periods are always different by a very tiny amount (~10-50ps). Can I use a D-flip-flop ripple-counter to measure S1 and S2 individually, and then subtract the 2 measurements to find out what is the delay difference between S1 and S2? If yes, how accurate would the computed delay difference be compared to the actual delay difference?

• You're probably better to add a diagram or more details of what you're trying to achieve. If the signals start off in phase maybe an XOR gate would be better, are you trying to implement some sort of TDOA (time difference of arrival) system? – PeterJ Jan 10 '14 at 7:45
• What's the frequency of the signal? – Pete Kirkham Jan 10 '14 at 13:35
• What is the waveform, what is the frequency range and what the output will be (a pulse, a DC voltage, a frequency?) – GR Tech Jan 10 '14 at 18:39

## 2 Answers

I think what you are looking for is a phase-frequency detector (PFD). These circuits are quite often used in phase-locked-loops (PLLs) for producing a "clean" reference signal that is locked-on to a fairly noisy (or modulated) input signal. The heart of the PFD can be shown in the logic diagram on the picture below (extract taken from here): - The two outputs labelled "U" and "D" stand for up and down respectively and these two outputs can be combined with equal value resistors to produce an output voltage that represents the frequency/phase difference between two signals.

Wikipedia also provides some information about this type of circuit.

This Maxim article also shows how one can be implemented using D type flip-flops: - How accurate would the computed delay difference be compared to the actual delay difference?

This is a difficult question to answer directly but I will say that PFD circuits, when used as the heart of a PLL, can achieve sub milli-hertz accuracy on locking an oscillator to an unknown input frequency of hundreds if not thousands of mega-hertz. Your two signals will begin in phase at some point and, due to the frequency difference between the two signals will drift to being completely out of phase - this will result in a cyclical output of the PFD which should be easily seen using an oscilloscope. Given that you then know how often the phases align, it is a trivial matter to compute what the average phase (or time delay) difference is per cycle.

• A PFD would seem to only be workable as an analog device; as a digital pulse it would generate "runt" pulses which would cause all sorts of metastability problems. Depending upon the input frequencies, if one wants digital measurements, it would seem easier to put both inputs through ripple counters to scale them by some amount (e.g. 65,536:1) and then time them; a 10ps difference multiplied by 65,536 would be 655.36ns, which should be large enough to measure using conventional techniques. – supercat Jan 10 '14 at 17:52
• @supercat The output will be an analogue signal in make-up but the fact that the two signals will move in and out of complete phase at a particular rate will give all the OP needs to calculate the average phase drift per cycle between the two frequencies. – Andy aka Jan 10 '14 at 18:52
• @supercat, normally the output of this kind of PFD is put through a low-pass filter to generate a "dc" analog signal proportional to the duty-cycle of the PFD output, which in turn is proportional to the delay between the input signals. – The Photon Jan 10 '14 at 19:58
• @ThePhoton: I guess I'm not quite clear whether the fact that the periods are different implies that the frequencies are different, or that there's cycle-to-cycle variation in period but the frequencies are the same, or what. – supercat Jan 10 '14 at 20:05
• @supercat, I agree, the question is not clear on that. If the frequencies are different, you could probably solve this with just an AND gate instead of a PFD. – The Photon Jan 10 '14 at 20:08

(sorry, too long for a comment) Your text contains some misunderstandings, or maybe bad wordings.

• What is a frequency difference of 10-50ps?
• A ripple counter does not measure, it counts. To use it to measure a frequency you must reset it, let it run for some time, stop it, and then the outputs indicate the frequency.
• First you state that your oscillators differ in frequency, later you talk about a delay difference. What is it?