Find delay between two signals
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 input port receives the original
signal, while the
sDel input port receives the
delayed version of the signal. The two input signals must have the
same dimensions and sample times.
The output port labeled
delay outputs the
delay in units of samples. If you select
signal" output port, then an output port labeled
chg output port outputs 1 when there is a change
from the delay computed at the previous sample, and 0 when there is
no change. The
delay output port outputs signals
of type double, and the
chg output port outputs
signals of type boolean.
The block's Correlation window length parameter specifies how many samples of the signals the block uses to calculate the cross-correlation. The delay output is a nonnegative integer less than the Correlation window length.
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.
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
the block will stop recalculating and updating the delay after it
calculates the same value 20 times in succession. Disabling recurring
updates causes the simulation to run faster after the target number
of constant delays occurs.
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
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 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,
sRef is probably delayed relative to
sDel. In this case, you should switch
the signal lines leading into the two input ports.
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 and Align Signals Blocks. 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.
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.
The next example illustrates how to tell when the Correlation window length is not sufficiently large. Load this model by typing doc_find_delay_example at the command prompt.
The model uses a Delay block to
delay a signal by 10 samples. The Find Delay block
compares the original signal with the delayed version. In this model,
the Input processing parameter of the Delay block
is set to
Columns as channels. The model
then displays the output of the Find Delay block in a scope. If the Correlation
window length is
15, the scope shows
that the calculated delay is not constant over time, as you can see
in the following image.
This result tells you to increase the Correlation
window length. If you increase it to
the calculated delay stabilizes at 10, as shown below.
The number of samples the block uses to calculate the cross-correlations of the two signals.
If you select this option, then the block has an extra output port that emits an impulse when the current computed delay differs from the previous computed delay.
Selecting this option causes the block to stop computing the delay after it computes the same delay value for a specified number of samples.
A positive integer specifying how many times the block must compute the same delay before ceasing to update. This field appears only if Disable recurring updates is selected.
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.