# Detect Phase Difference 360 Degrees

Let's say I have two sine waves that are both DC offset to have no negative values, the measurement I want is the phase difference between these waves. When researching I've only seen detectors that give the phase difference up to 180 degrees, saying that if you want a 360 degree range you just need to figure out the quadrant. What I mean is that if the difference is outputted as 180 degree max difference, I can get a 360 range simply by telling if I am in the negative or positive range of the signal (speaking abstractly considering it's a DC biased AC waveform). However, I am at a loss as to how to do this, any help would be greatly appreciated.

This is for a laser range finding application. I am utilizing multi-frequency phase shift measurements to determine the distance. That is, I am modulating the laser by a sine wave (varying frequencies depending on the distance, all in the MHz range) and then measuring the phase difference between my modulating waveform and the waveform received by the photodiode. I have a phase comparator now that gives a 0-180 range. I can work with a 0-180 degree range except for it limits my max distance calculation to half the modulating frequency wavelength (and less precision).

Also, I am aware a 2*pi shifted waveform is indistinguishable from the original, to clarify I suppose, I just need to know the full range of phase shift within a 360 degree range.

EDIT: After some research it seems my answer is a double balanced mixer operating as a phase comparator in saturated mode (limiter). This seems to indicate that an imbalance in the dB levels of the two signals are not as important (within reason). However, the output of such a setup is still a DC output ranging from 0-180 degrees. So, hopefully the answer lies in figuring out if it is possible to adapt or add to such a mixer setup that gives me further info as to which quadrant the phase is in so I can tell if it's -180 to 0 or 0 to +180.

• If you just have a picture of two sine waves, you can't tell which one is supposed to be the reference. If you have a physical instrument with two inputs, you can tell. We need to know more about how you are obtaining these signals. Sep 30, 2014 at 6:10
• I added to my question to give more details. Sep 30, 2014 at 13:58
• Can you post a schematic of your phase comparator? (or a link to something similar.) It should be possible to either change it for 0-360, or maybe give you a sign bit. (tell you which is leading or lagging.) What's the maximum modulation freq.? Sep 30, 2014 at 17:39
• I am using a phase frequency detector IC to try and simplify things. I am open to making my own solution, looked at making a diode ring mixer phase detector myself. However, in that case I am not sure how to deal with a varying DC offset that will occur given the fact that the amplitude of the photodiode output will vary with received light input (and thus distance). I would almost need to clamp both inputs to a predefined amplitude for a mixer approach to work I think. Oct 1, 2014 at 4:37

## Why bother with phase at all?

The original question poses the problem of phase disambiguation over the entire unit circle for a (sine-driven) frequency modulated laser. The core approach, as proposed, will never achieve the stated aim because you need more information to disambiguate phase over 360deg than you have in a single frequency reflection scheme (which is ultimately what the originally described modulated then demodulated and phase differenced system boils down to).

However, if you just want distance, why not use the conventional Frequency Modulated Continuous Wave LIDAR approach? To get there from your proposal, just change your sine wave to a saw-tooth wave and look at the frequency difference between transmit and received signals instead of the phase difference.

Like so:

The saw-tooth (or "chirp") driven frequency modulation maps propagation distance/delay into frequency shift. Multiple targets are now separated by the frequency of their return signals (3 reflecting targets shown in the figure). The dashed lines indicate echoes from reflecting objects in the environment. The dashing is not intended to indicate gaps in the spectrum.

## You need transmitter identity

If you insist on a phase-of-arrival (PoA) approach, a simple permutation to your original proposal would be to add a second laser and use phase-difference-of-arrival (PDoA) between them.

In order for a difference to be unambiguous over 360deg, you must be able to determine the transmitter's (e.g. reference signal's) identity (which laser transmitted the received reflection) in order to determine phase lag vs. lead. Without this, you get the problem that you and others have elucidated. Namely, that <0,-180deg> looks a lot like <+180deg,0>.

Fortunately, such a feat is achievable with modulation and careful design. I proposed one such approach as part of my dissertation work. For your consideration, ARI:

## Angle-of-Arrival-Assisted Relative Interferometry (ARI)

An ARI-based system consists of transmitting beacons and passive receive-only objects each of which is equipped with a directional antenna. The beacons and objects may be almost co-located and appear to an operator as a single piece of equipment as seems to be the case with your application.

Each of the beacons knows its location and orientation. Each beacon transmits a unique pair of frequencies creating a beat envelope in the transmitted signal which is not unique to any beacon. The receiver can then identify reflecting targets in the intermediate environment through the intersection of the vectors formed from the known beacon locations and the set of angles of the directional antennae.

An initial angular-intersection based estimate is then refined by searching in the volumetric space defined by the intersection of the beamwidths of each beacon using the relative distances between beacons to disambiguate. This difference in path length is known through the phase difference of arrival of the envelopes from each beacon (or time difference since the envelope frequency is common to all beacons).

Since, the transmitter's identity is known from the frequency components and all of the required transmitter timing information is encoded in the signal, an object’s receiver does not need to maintain phase coherence with the time source of any beacon. Further, the beacons are immune to phase coherence errors in their carrier needing only to maintain sync amongst beacons at the modest frequency of their beat envelope.

The identity-encoded and directive nature of ARI assists in disambiguating phase-based distance relationships which are, otherwise, only disambiguous for the region ⟨−π/2, π/2⟩ and, adding orientation knowledge, allows 3D localization from a mathematical minimum of just two beacons and one object.

## Why it works

The transmitted signal from each beacon consists of two frequencies – one that is unique to the beacon, fx1 , and one that is shared across all beacons, fcom. A Hartley modulator architecture may be used to produce the following signal over the air:

Algebraically we see that this resolves to just two frequencies: fc + fx1 and fc + fx1 + fcom. This is a Single Side Band-Suppressed Carrier (SSB-SC) transmission.

Since this is the absolute minimum amount of spectrum required to convey all of the information required for ARI we are as spectrally efficient as possible.

The distance information required to localize a target is encoded in the phase of the signal at fcom. However, two transmitters on the same frequency will interfere and obscure the identity and phase of each.

ARI supports multiple simultaneous transmissions without interference, because the common frequency information is actually present on multiple unique frequencies (fx2 = fx1 + fcom , for x = a, b, c...).

Accordingly, we designate fcom as the baseband signal and task the ARI receiver with recovering it from each beacon.

Although the transmitted signal is up-converted in quadrature, the received signal does not require down-conversion in quadrature – a single conversion super-heterodyne receiver is sufficient.

The spectrum of the resulting intermediate signal contains the identities of any beacons transmitting towards the object at its current look direction. Beacons may be identified by the presence of a signal at fa1, fb1, etc... and at each of these frequencies offset by fcom. As fx1 is unique to the transmitter and the frequency offset, fcom, is common to all transmitters, a second unique frequency, fx2 = fx1 + fcom, exists for each beacon.

## Implementation options

There are three basic implementation strategies: analog, digital time-domain filtration, and digital frequency domain filtration. Like so:

## You can use ARI to solve the proposed problem

In the case of your laser, it is not possible to make the laser emit multiple frequencies simultaneously. Rather, you can modulate the single frequency output. You can apply ARI to the two lasers system proposed above by building your ARI waveforms into the signal driving the modulator itself, like so:

In the figure, the dashed lines indicate echoes from reflecting objects in the environment. The dashing is not intended to indicate gaps in the spectrum.

In this manner, ARI is essentially acting as four FMCW LIDAR systems operated in a non-interfering time-synchronized manner. Conversion to an intermediate frequency allows ∆fn recovery more readily and the rest is as previously described.

So there you have it. ARI is one (of several possible) techniques for encoding transmitter identity in a phase difference of arrival based system.

There are a number of papers that I (and others) have written on this approach here.

– Ktc
Oct 5, 2014 at 8:10
• @Ktc -- Thanks! I'll try to explain how it's applicable in more detail. Oct 5, 2014 at 8:54
• I could have waited to see if anyone else answers, but I think you solved my problem. Indeed, I actually have never come across frequency modulated continuous wave RADAR before, the annoyance of needing to know what you're searching for to find it kind of thing. I believe that'll be the simplistic solution. I thank you very much! Edit: And don't think your writing on ARI will go to waste, I may not use it, but I'll certainly read up on it. Oct 6, 2014 at 1:40
• @JarrodChristman in my research and ambitions in creating my own LIDAR for small hobby robotics, I concluded that continuous wave phase shift was the cheapest and easiest of all the options, with the only downfall being the fact that the "range reading" resets as the wavelengths overlap - but that can be fixed by using two transmitters, one very long range used as a logic checker, and then the proper short range and higher resolution one for your actual distance readings Oct 7, 2014 at 23:17
• @KyranF, thanks for the tips. Currently this is just me building range finding out of curiosity, though I have experimented with a 2D planar rasterization depth scanning using galvanometer mirrors. I too would be interested in a true 3D LIDAR (rotating axis). It would seem my effort is largely in finding the easiest method to implement. I have a few thoughts to prevent "wrapping" of overlapping measurements, but I'll have to wait until I have a more effective model to test them. Oct 8, 2014 at 1:35

A sinewave shifted by 360° is indistinguishable from the original sineweave. Therefore, any phase measurement is going to be limited to a total range of 360°. Some methods will give you an answer between -180° and +180°, while other methods will give you an answer between 0° and +360°. You can convert between them by realizing that the range from -180° and 0° is identical to the range from +180° and +360° (since they're different by exactly 360°).

Phase detectors come in 2 types.
The first type is an exclusive OR. Assume you have 2 square waves (they have nice sharp edges & are easier to compare) and you feed them to this gate. The output will only be high when ONE input is high. See here.
Since the width of the output pulse depends on the phase difference, you can filter it and sample with an ADC (or just use as feedback in a PLL) to measure up to 180 degrees of phase difference.

Then comes the fun part: is your signal leading or lagging the reference?

Time for the second phase detector, type 2. This uses flip-flops, as seen here.
Now the edges of our signals are triggering flip-flops, which drive 2 transistors. By default, the output is floating. Depending which signal arrives first, you will get positive OR negative pulses on the output. Once filtered, you have a voltage that also includes phase.

Why have both? Assume you have an 18V supply. Type 1 output will vary by 0.1V per degree of phase. Type 2 will vary by 0.05V per degree. If you have a circuit that doesn't care about lead vs. lag the Type 1 will offer better resolution / noise immunity.

In your case, you are talking about 360 degree difference, so think the second type of detector is more appropriate.

• perhaps you could explain how a digital phase comparator could possibly answer a question about calculating the phase between two sinusoids for laser ranging? Sep 30, 2014 at 14:45
• @placeholder, he could square up the sines with a comparator. The square waves give a nice linear signal with phase difference whereas an analog one (multiplier or +/-1 gain thing) gives a term that goes as cosine^2. Not so good when the phase shift is small. Sep 30, 2014 at 17:27
• I forgot to thank you for your answer. I would like to see if there are any other methods that can work directly with sine waves (just out of curiosity and to compare the pros and cons of the different methods). If I don't get any others then I'll try your method. Oct 4, 2014 at 23:20
• @JarrodChristman, you could try simply feeding 2 sine waves to a comparator (op amp). The peak difference will be proportional to the phase diff, as the signals pass through zero volts. BUT- which is leading? Oct 6, 2014 at 0:39