Phase comparison

May 06, 2009 30 Replies

Hi there, I'd appreciate some comments on the following....



I want to compare the phase of two signals of the same frequency, frequency = 3 mhz.



Let's say I use a flip flop (HC series). Signal A is applied to the set input. Signal B is applied to the reset input. Then I low pass filter the FF output and hopefully get a voltage proportional to phase difference ?



What sort of resolution can I expect ? Does the output voltage vary linearly with phase ? Assuming the supply is 5v, it follows that measuring voltage down to 1 mv volt would measure phase with a 1/5000 resolution ?



If signal A sets the FF and 3 ns after that event signal B resets it can I expect the FF to produce a 3 ns pulse ? Or is there a minimum phase difference needed for the thing to give a meaningful result ?



If I had a scope I would built the circuit and just measure it, but since I don't I can only measure things using indirect means and the test wouldn't be very conclusive.


Thanks in advance !!


Depends which side of the FF you take it off of, and what the delays and such are. Of course the phase detector doesn't work around the entire circle, you have to give up a bit on the edges.

If A rises, then B rises, then if the gate connected to A changes state (I suppose it would), that change is delayed by propagation until the gate at B is able to make a decision. Ideally, both A and B are infinnitessimally narrow pulses, but in practice that doesn't work, so for small phase differences, you will get a race condition where both inputs are high at the same time. What then matters is, which pulse falls first? You'll need to make sure the pulses have the same duration (a variable duration on one might be a good calibration adjustment -- just a trimmer R plus stray C would be enough).

Another option is to bias the phase. If you can adjust the trigger point or phase-shift (or even easier, if the input is constant frequency, time-shift) on one signal, you can introduce an offset which moves the phase away from the detector's bad range.

Accuracy is analog domain, i.e., limited by noise, bandwidth, jitter (phase noise), etc. If the noise is low, you can easily measure milivolt offsets reliably, yes. I don't think there is anything inherently odd about, say, a 74HC02. I suppose storage and dielectric loss type effects may introduce a low order error, but I doubt anything like that is important even at the 0.1% range.

For ppb+ accuracy, of course, you'd hook up a time standard (at least an ovenized quartz crystal, preferrably a rubidium or cesium atomic clock) and count cycles one way or another to determine whatever timing characteristics you're after. Time is one thing that can be measured to insane precision, far more accurately than anything purely analog (the equivalent of measuring nanovolts on top of a megavolt transmission line).

Tim

Tim, thanks a lot for your reply.

I was thinking of building a homemade laser measuring tape, just to see if a bare bones implementation can achieve any sort of accuracy.

Right now I'm driving a cheap laser diode at 4 mhz. My photodiode+amp receiver is a bit deaf (or blind).

And I wasn't sure if an ordinary digital gate would work linearly. So, it does, except at the edges.

where >both inputs are high at the same time. What then matters is, which pulse falls >first?

Is that true for a device like a 74hc74 ? If both the set and reset inputs are asserted at the same time or almost the same time, a race condition will be triggered ?

start a counter with one pulse load a register with the count at the second pulse reset the counter. use a pulse synchronizer to detect the edges.

Bob

The standard technique is to just feed both signals into an XOR gate. The output duty cycle (and voltage after filtering) will be proportional to phase.

Dave.

The drawback to using a xor gate is, I think, that the output signal changes if the duty cycle of the inputs changes. Using an edge triggered flip flop avoids that. But don't take my word for it, I'm not an expert by any means !! =]

In order to do that I would need a very fast counter ? I'm not sure if that's an easy solution...

ond

This? Filter the output

formatting link
The XOR could be replaced by filters> inamp to give direction.

he

A lot depends on how you define phase. If you really care about time from one edge to another, a flip-flop is better. If you are after the center of the pulse the XOR is better

That will work, given a messy ambiguity near zero phase.

With a fast flipflop (like an AC-family CMOS, or maybe a superfast TinyLogic flop) and very good power supplies and such, 1 ns resolution might be possible, 1/3000 of 3 MHz. It would take a lot of care.

John

These days it's an easy solution, although a flip-flop may be easier.

Tim Wescott Wescott Design Services http://www.wescottdesign.com Do you need to implement control loops in software? "Applied Control Theory for Embedded Systems" was written for you. See details at http://www.wescottdesign.com/actfes/actfes.html

that >doesn't work, so for small phase differences, you will get a race condition where >both inputs are high at the same time. What then matters is, which pulse falls >first?

Yes. There are a number of clever techniques that have been used to avoid this, the simplest of which is "just don't do that". In your case you'd only get zero phase at even multiples of 50 meters (for 3MHz), so as long as you stay away from 0 meters and 50, you should be fine.

Tim Wescott Wescott Design Services http://www.wescottdesign.com Do you need to implement control loops in software? "Applied Control Theory for Embedded Systems" was written for you. See details at http://www.wescottdesign.com/actfes/actfes.html

Perhaps adapt a classic phase-frequency detector (PFD) from a PLL...

formatting link

...Jim Thompson

| James E.Thompson, P.E. | mens | | Analog Innovations, Inc. | et | | Analog/Mixed-Signal ASIC\'s and Discrete Systems | manus | | Phoenix, Arizona 85048 Skype: Contacts Only | | | Voice:(480)460-2350 Fax: Available upon request | Brass Rat | | E-mail Icon at http://www.analog-innovations.com | 1962 | Stormy on the East Coast today... due to Bush\'s failed policies.

Oops, 3 MHz is 300 ns, so 1 ns is 1/300. You could actually get sub-ns resolution, but probably not sub-ns accuracy.

John

You can easily do 0.1 degrees at 50 to 100 MHz by using a Mini-Circuits MPD-1 or RPD-1 diode bridge phase detector. (That's about 5 ps or so.) Nonlinearity arises when the edge transients of the LO and RF inputs overlap, but for good square waves it is very small otherwise.

The most accurate way to measure phase that I know of is to use a successive approximation technique to converge on the phase detector null, either in analogue with a DAC and phase shifter, or digitally by mixing the output of a divide-by-N pulse-swallowing counter with the clock frequency, using a sharp filter to pick just one sideband (at (1

+- 1/N)f_in). Hitting the pulse-swallowing line shifts the phase by 1/N cycles, and this can be very accurate if you control feedthrough well enough.

It's quite easy to tell if your isolation is good enough--sit on the pulse-swallowing line to shift the desired signal and use a spectrum analyzer to see if there's a spur at the operating frequency.

The DAC method is quick--you can get 100k points/second easily, because each point needs only about (log(N))**2 cycles--but it needs frequent calibration using the pulse-swallowing method. The pulse-swallowing method needs no calibration but takes N**2 input cycles per measurement

Cheers,

Phil Hobbs

Dr Philip C D Hobbs Principal ElectroOptical Innovations 55 Orchard Rd Briarcliff Manor NY 10510 845-480-2058 hobbs at electrooptical dot net http://electrooptical.net

hanks a lot guys for all your responses !! You are amazing !! Best, P.

"hanks" should read "Thanks" =P

Or buy the debugged version from Philips (NXP these days).

formatting link

The application notes spell it all out.

-- Bill Sloman, Nijmegen

Ayup. Under the right (wrong?) conditions, it's a good way to double the input frequency, which is probably not what you had in mind. ;^)

W . | ,. w , "Some people are alive only because \\|/ \\|/ it is illegal to kill them." Perna condita delenda est ---^----^---------------------------------------------------------------

What about an up-down counter (or the equivalent); signal A makes it count up, and signal B makes it count down. Works sort-of like a digital version of a FM discriminator. Still resolution problems at low phase differences.

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required