Find delay between two signals
Communications Toolbox / Utility Blocks
The Find Delay block finds the delay between a signal and a delayed, and possibly distorted, version of itself. This is useful when you want to compare a transmitted and received signal to find the bit error rate, but do not know the delay in the received signal. This block accepts a column vector or matrix input signal. For a matrix input, the block outputs a row vector, and finds the delay in each channel of the matrix independently. See Delays for more information about signal delays.
sRef — Reference signal
vector | matrix
Original reference signal, specified as a vector or matrix. Dimensions and sample times of sRef and sDel must match.
sDel — Delayed signal
vector | matrix
Delayed or distorted version of reference signal, specified as a vector or matrix. Dimensions and sample times of sRef and sDel must match.
delay — Delay output
scalar | vector
The output port labeled delay outputs the delay in units of samples.
For a matrix input, the output is a row vector, and finds the delay in each channel of the matrix independently
The delay output is a nonnegative integer less than the Correlation window length.
chg — Delay flag
The chg output port outputs
when there is a change from the delay computed at the previous sample,
0 when there is no change
This output port becomes visible only when
"change signal" output port is selected.
Correlation window length (samples) — Number of samples
200 (default) | positive integer
The number of samples the block uses to calculate the cross-correlations of the two signals.
As the Correlation window length is increased, the reliability of the computed delay also increases. However, the processing time to compute the delay increases as well.
Include "change signal" output port — Enable chg port
off (default) |
If you select this option, then the block has an extra output port that emits a value of 1 when the current computed delay differs from the previous computed delay and emits a value of 0 when there is no delay.
Disable recurring updates — Disable recurring updates
off (default) |
Selecting this option causes the block to stop computing the delay after it computes the same delay value for a specified number of samples.
Number of constant delay outputs to disable updates — Number of constant delay outputs to disable updates
3 (default) | positive integer
A positive integer specifying how many times the block must compute the same delay before ceasing to update.
This field becomes visible only when Disable recurring updates is selected.
Finding the Delay Before Calculating an Error Rate
A typical use of this block is to determine the correct Receive delay parameter in the Error Rate Calculation block. This is illustrated in Use the Find Delay Block. In that example, the modulation/demodulation operation introduces a computational delay into the received signal and the Find Delay block determines that the delay is 6 samples. This value of 6 becomes a parameter in the Error Rate Calculation block, which computes the bit error rate of the system.
Another example of this usage is in Delays.
Finding the Delay to Help Align Words
Another typical use of this block is to determine how to align the boundaries of frames with the boundaries of codewords or other types of data blocks. Delays describes when such alignment is necessary and also illustrates, in the Aligning Words of a Block Code discussion, how to use the Find Delay block to solve the problem.
Set Correlation window length sufficiently large so that the computed delay eventually stabilizes at a constant value. When this occurs, the signal from the optional
chgoutput port stabilizes at the constant value of zero. If the computed delay is not constant, you should increase Correlation window length. If the increased value of Correlation window length exceeds the duration of the simulation, then you should also increase the duration of the simulation accordingly. If you can roughly estimate the delay, then the Correlation window length will produce a stable delay estimate at four times that value.
If the cross-correlation between the two signals is broad, then the Correlation window length value should be much larger than the expected delay, or else the algorithm might stabilize at an incorrect value. For example, a CPM signal has a broad autocorrelation, so it has a broad cross-correlation with a delayed version of itself. In this case, the Correlation window length value should be much larger than the expected delay.
If the block calculates a delay that is greater than 75 percent of the Correlation window length, the signal
sRefis probably delayed relative to the signal
sDel. In this case, you should switch the signal lines leading into the two input ports.
You can make the Find Delay block stop updating the delay after it computes the same delay value for a specified number of samples. To do so, select Disable recurring updates, and enter a positive integer in the Number of constant delay outputs to disable updates field. For example, if you set Number of constant delay outputs to disable updates to
20, the block will stop recalculating and updating the delay after it calculates the same value
20times in succession. Disabling recurring updates causes the simulation to run faster after the target number of constant delays occurs.
The Find Delay block finds the delay by calculating the cross-correlations of the first signal with time-shifted versions of the second signal, and then finding the index at which the cross-correlation is maximized.