# Measuring signal phase difference between receivers

I am working on a project which aims to locate a transmitter.

I consider doing this using several receivers and measuring the phase differnces between them.

My problem is that arduino measures once every ca $dt=10^{-6}$ seconds, and therefore, to notice a phase difference, the distance between two receivers must be at least $c\cdot dt$ which is ~300 m.

I know that there are methods of finding the phase difference in much smaller systems, but I can't figure out how to solve that problem.

So, how can I measure the phase difference without placing the receivers that far away from one another?

## Preface

First of all: Arduino might really not be the tool of choice here; with a 1MS/s max, and some something-in-between-8-and-16-effective-bits ADC, there's hard limits on what you can detect. I will explain the theory of how to do better estimation than just sample-wise, but I won't address these limits here.

Furtherore, I assume you

• do real-valued sampling with the built-in ADC (because that is not a simultaneous two-channel/IQ ADC), meaning that you probably have some IF receivers that convert a RF bandpass signal to a directly sample-able IF signal (or one that you can undersample)
• keep true to the filtering requirement of Nyquist's sampling theorem,
• use the actual received signals, and not just e.g. the time of their amplitude peak, and
• have knowledge of DSP basics and some understanding of the DFT.

So, your 300m calculation is correct if you can only compare two sample streams only by shifting one of them integer amounts of samples. And with this, I assume you compare using a cross-correlation function (ie. you find the product of one reception and the other, shifted by all reasonable full-sample delays, and look for a maximum).

But you don't have to do that; you can either

• interpolate in time domain and calculate the cross-correllation in time domain, and find the argmax of that
• compare the two sequences in frequency domain and estimate the time difference directly.

## Interpolation in Time Domain

Since we know that you've adhered to Nyquist sampling theorem (you did, didn't you?), we want to keep it that way. To properly interpolate by a factor of $N$, you just pad every sample you get with $N-1$ zeros, and then low-pass filter the result to the original band (ie. apply an $\frac 1N$th band-filter). That gives you a $N$ times higher resolution.

However, it also means that your correlation just went in complexity from $L^2$ ($L$ being the length of your sample sequence) to $N^2L^2$, which is really unfortunate on an Arduino. So you'd have to do that on a PC, probably.

## Frequency Domain Techniques

You're probably aware of the time-shift property of the Fourier or the Discrete Fourier Transform (DFT). For the latter it states that

$$\mathcal F\{x[t-\tau]\}(f) = e^{-j\frac{2\pi}{L} \tau f} F\{x[t]\}(f)$$

So let's name the signal that the "closer" receiversees $x_0$, and let's define the other receiver sees, $x_1$, to be $\tau$ "late"; it directly follows that \begin{align} \mathcal F\{x_1[t]\}(f) &= \mathcal F\{x_0[t-\tau]\}(f) \\ &= e^{-j\frac{2\pi}{L} \tau f} F\{x_0\}(f) \\ &\implies\\ \frac{\mathcal F\{x_1[t]\}(f)}{\mathcal F\{x_0[t]\}(f)} &=e^{-j\frac{2\pi}{L} \tau f}\\ &=: \varphi(f) \end{align}

I introduced the "auxillary" function $\varphi(x)$ here – so if you look at that,

$$\varphi(x)=e^{-j\frac{2\pi}{L} \tau x}\text,$$

you'll notice that it's a complex sinusoid with frequency $\tau$!

So, by estimating the frequency of that, you get $\tau$, your time delay. Notice that the variance of a frequency estimate reduces with the number of samples you observe – in other words, the longer your DFT (you'd probably use an FFT), the higher your frequency resolution, and the smaller your delay granularity, and the better your Time-Difference of Arrival estimate.

## Remarks

Sampling Rate of $\frac1{1\text{ µs}}= 1\text{ MHz}$: That sounds too high, actually. Where did you get that number? I ask because I have my doubts: what are you going to do with that amount of data inside an Arduino? Spit it out via the serial port? Certainly not, that's much slower. Process it on-Arduino? Don't think so, unless I underestimate the processing power of an ATMega seriously. Store it in RAM and use it later? Well, at 1MS/s, how long will your RAM last?

Correlation in time Domain is seldom done directly, but often by (conjugate) multiplying the DFTs of the sequences, and then reverting back to time domaind – an FFT has a complexity of $\mathcal O(N\log N)$, and thus the whole "transform both sequences – multiply – inverse transform" has complexity of about $\mathcal O(3N\log N+ N) "<" \mathcal O(N^2)$.
When you write the fast correlation down, you'll notice similarities to the frequency-domain approach above, if you apply the shift theorem.

Variance of the $\tau$-estimator can't be pushed down indefinitely with real-world signals, since well... real-world signals do have finite length.