How to Determine Sample Delay Between Two Signals?

Updated Mar 30, 2019

Reported In

Software

  • LabVIEW Full
  • LabVIEW Advanced Signal Processing Toolkit
  • LabVIEW Professional

Issue Details

I have two signals that are delayed, and I would like to determine the sample delay between them.

How can I do it?
 

Solution

It is possible to do it in many ways. In this KB we provide a solution using the cross-correlation function.

In signal processing, cross-correlation is a measure of similarity of two series as a function of the displacement of one relative to the other. This is very useful to determine the delay between two signals.

This example uses cross-correlation to determine the sample delay between two signals that are identical but have been shifted. 
 
  1. Generates a signal of 100 samples
  2. Make a copy of the signal and shift it by a user controlled number of samples
  3. Delete off the shifted number of samples from the back so both waveform are still the same size.
  4. Cross correlate the signals
  5. Find the peak of the cross correlated function
  6. Find the x-value of the peak amplitude
  7. Subtract the number of samples of one waveform minus one because of cross correlation math
If you calculated the cross-correlation between both signals, the maximum (or minimum if the signals are negatively correlated) of the cross-correlation function indicates the point in time where the signals are best aligned, i.e. the time delay between the two signals is determined by the argument of the maximum, or arg max of the cross-correlation. This is true for time continous signal.

In discrete system you must take into account that the time is substitute by samples so after calculating the maximum of the cross-correlation function (6) you must related him to where the cross-correlation is max, usually at the middle of the band. Thus, you must subtract to the position of the max the total number of samples of the signal minus 1 (zero indexed) in order to calculate the sample delay (7)


 

WAS THIS ARTICLE HELPFUL?

Not Helpful