*Started 4th September 2018*

Can one measure distance by transmitting two frequencies and measuring the phase shift of the received signals.

Defining distance `d`, speed `c`, frequency `f`, wavelength `lambda`, period `T`. Typical values are for `c`, the speed of sound 340 ms^{−1}, frequency 40 kHz with wavelength 8.5 mm. and period 25 μs.

Using continuous waves it might well be feasible to measure received phase relative to transmitted with 1% accuracy, which would give distance to within 0.085 mm, however you can only measure phase within one cycle. So the 0.085 mm is in addition to N wavelengths where N is unknown.

The phase shift `phi` at the receiver relative to at the transmitter will be:

` phi = (2pi*d)/lambda = (2pi*d)/(c/f) = 2pi*(d/(c*T))`

Measuring the phase shifts at two frequencies gives:

`phi_1-phi_2 = 2pi*(d/c)*(1/T_1-1/T_2)`

From which the distance is:

` d = (phi_1-phi_2)/(2pi)*c*(T_1T_2)/(T_2-T_1)`

Typical values for the periods are 24 μs and 24.125 μs which give:

` d = (phi_1-phi_2)/(2pi)*1.57488`

Given one can only measure phase between 0 and `2pi` the maximum measurable distance is 1.57 m. A 1% resolution in phase here gives a distance resolution of 16 mm. Compared with the single wavelength case above the phase resolution here is multiplying a much larger value than the wavelength and the resolution is a lot less.

Writing the total phase as a sum of the measured phase and N complete cycles, phase in the range 0..1.

` d/lambda = phi+N`

Assume `T_2>T_1` then `lambda_2>lambda_1` and `phi_2<phi_1`

Assuming N is the same for the two wavelengths, solving for N:

` N=(lambda_1*phi_1-lambda_2*phi_2)/(lambda_2-lambda_1)`

N has to be an integer, and gives d from the original equation:

` d = lambda_1*(phi_1+N)`

or

` d = lambda_2*(phi_2+N)`

Ah but.

` N= "integer"(d/lambda_1) `

(with the operator "integer" returning the integer part of its argument) can be bigger than

` N= "integer"(d/lambda_2) `

For N to be the same for both frequencies one has to arrange for ` phi_1 ` to be in the range ` phi_2..phi_2+1 `. Sometimes the higher frequency will get in one more wavelength than the lower, and its phase will be smaller than the higher one and it is necessary to correct this by adding one cycles worth of phase..