I try to locate a mobile device using multilateration. The mobile device acts as the receiver and in the room I have three speakers. To calculate the position I need the time difference of arrival (TDOA) values for each speaker signal. I am using MATLAB and xcorr for this. The (simplified) code looks like this:

[signal1, fs] = audioread('speaker1_signal.wav');
[rx_signal, fs] = audioread('received_signal.wav');
[R, lags] = xcorr(signal1, rx_signal);
[v, i] = max(R);
lag = lags(i);
% for each speaker signal

Calculating the time difference is not difficult. I calculate the lag value for each speaker, set one as 'fixed' and substract the other values from the fixed one. So far, so good.

My problem: it seems that the maximum value of the xcorr is not always the best value. Looking at the following plot (real data) we can see the problem:

example plot

The max values for Signal1 and Signal2 are placed around 18k; However, the value for Signal3 (yellow) is placed around 15k. This results in huge time differences (that results to wrong positions). I would like to know if there are any solutions for detecting the ''best'' peak value or how I can solve my problem?


My signal is linear frequency modulated (each speaker has a bandwith of $1\textrm{ kHz}$) and I am using FDMA and the ultrasonic range (17-21k) due to hardware limitations. The receiver is a Smartphone; on a measurement microphone this problem doesn't occur very often. But the final product should run on a smartphone as well.

  • $\begingroup$ Do the speakers emit a linear sweep at different frequency ranges? Please note that the room will modulate the speaker signal until it hits the mic, so, you might need to do a bit of equalisation before cross-correlation, or somehow take the envelope into account. Can you please try reducing the amplitude of the speakers and give it another try? (I.e. try to minimise the impact of reflections on the signal. I am implying walls here but If you are in the supersonic range, other objects will give strong reflections too) $\endgroup$
    – A_A
    Jul 18 '16 at 10:14
  • $\begingroup$ @A_A Yes they emit at different ranges. Speaker1 from 17k to 18k; speaker2 from 18k to 19k and speaker3 from 19k to 20k. I will try what you've suggested but it will take some time 'cause I don't have access to the room each day. But I think I can recreate the problem in another room. (Both ''normal offices'') Since the room modulates the signal I assume the signal length could have an impact as well? The results above were achieved with a length of 100ms. $\endgroup$
    – Philipp
    Jul 18 '16 at 10:49
  • $\begingroup$ Thanks for letting me know. You cannot do much with the signal length in this scenario. Sound does a km in ~3 sec. To avoid reflections in a room you would have to create very short bursts and use higher sampling frequencies which might quickly become a problem for your processing on the smartphone. $\endgroup$
    – A_A
    Jul 18 '16 at 11:17
  • $\begingroup$ Try to do the processing in baseband. $\endgroup$
    – ThP
    Jul 18 '16 at 20:13
  • $\begingroup$ @ThP could you please explain this a little bit. I am pretty new to DSP. $\endgroup$
    – Philipp
    Jul 23 '16 at 11:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.