Time-dispersive channels can cause intersymbol interference (ISI), a form of distortion that causes symbols to overlap and become indistinguishable by the receiver. For example, in a multipath scattering environment, the receiver sees delayed versions of a symbol transmission, which can interfere with other symbol transmissions. An equalizer attempts to mitigate ISI and improve receiver performance. Communications System Toolbox™ provides equalization capabilities using one or more Simulink^{®} blocks, System objects, or MATLAB^{®} functions.
This product supports the following distinct classes of equalizers, each of which have a different overall structure:
Linear equalizers, a class that is further divided into these categories:
Symbol-spaced equalizers
Fractionally spaced equalizers (FSEs)
Decision-feedback equalizers (DFEs)
MLSE (Maximum-Likelihood Sequence Estimation) equalizers that uses the Viterbi algorithm. To learn how to use the MLSE equalizer capabilities, see MLSE Equalizers.
Linear and decision-feedback equalizers are adaptive equalizers that use an adaptive algorithm when operating. For each of the adaptive equalizer classes listed above, this toolbox supports these adaptive algorithms:
Least mean square (LMS)
Signed LMS, including these types: sign LMS, signed regressor LMS, and sign-sign LMS
Normalized LMS
Variable-step-size LMS
Recursive least squares (RLS)
Constant modulus algorithm (CMA)
Several blocks from the Equalizers library implement adaptive equalizers, differing in the equalizer structure and the type of adaptive algorithm that they use. In all cases, you specify information about the equalizer structure (such as the number of taps), the adaptive algorithm (such as the step size), and the signal constellation used by the modulator in your model. You also specify an initial set of weights for the taps of the equalizer; the block adaptively updates the weights throughout the simulation. For adaptive algorithms other than CMA, the equalizer can adapt the weights in two modes: training mode and decision-directed mode.
To learn how to use the adaptive equalizer capabilities, start with Adaptive Algorithms. For more detailed background material, see the works listed in Selected Bibliography for Equalizers.
Equalizing a signal using Communications System Toolbox software involves these steps:
Create an equalizer object that describes the equalizer class and the adaptive algorithm that you want to use. An equalizer object is a type of MATLAB variable that contains information about the equalizer, such as the name of the equalizer class, the name of the adaptive algorithm, and the values of the weights.
Adjust properties of the equalizer object, if necessary, to tailor it to your needs. For example, you can change the number of weights or the values of the weights.
Apply the equalizer object to the signal you want
to equalize, using the equalize
method of the
equalizer object.
This code briefly illustrates the steps in the basic procedure above.
% Build a set of test data. hMod = comm.BPSKModulator; % BPSKModulator System object x = step(hMod,randi([0 1],1000,1)); % BPSK symbols rxsig = conv(x,[1 0.8 0.3]); % Received signal % Create an equalizer object. eqlms = lineareq(8,lms(0.03)); % Change the reference tap index in the equalizer. eqlms.RefTap = 4; % Apply the equalizer object to a signal. y = equalize(eqlms,rxsig,x(1:200));
In this example, eqlms
is an equalizer object
that describes a linear LMS equalizer having eight weights and a step
size of 0.03. At first, the reference tap index in the equalizer has
a default value, but assigning a new value to the property eqlms.RefTap
changes
this index. Finally, the equalize
command uses
the eqlms
object to equalize the signal rxsig
using
the training sequence x(1:200)
.
A decision-feedback equalizer is a nonlinear equalizer that contains a forward filter and a feedback filter. The forward filter is similar to the linear equalizer described in Symbol-Spaced Equalizers, while the feedback filter contains a tapped delay line whose inputs are the decisions made on the equalized signal. The purpose of a DFE is to cancel intersymbol interference while minimizing noise enhancement. By contrast, noise enhancement is a typical problem with the linear equalizers described earlier.
The following schematic contains a fractionally spaced DFE with L forward weights and N-L feedback weights. The forward filter is at the top and the feedback filter is at the bottom. If K is 1, the result is a symbol-spaced DFE instead of a fractionally spaced DFE.
In each symbol period, the equalizer receives K input samples at the forward filter, as well as one decision or training sample at the feedback filter. The equalizer then outputs a weighted sum of the values in the forward and feedback delay lines, and updates the weights to prepare for the next symbol period.
Note: The algorithm for the Weight Setting block in the schematic jointly optimizes the forward and feedback weights. Joint optimization is especially important for the RLS algorithm. |
A symbol-spaced linear equalizer consists of a tapped delay line that stores samples from the input signal. Once per symbol period, the equalizer outputs a weighted sum of the values in the delay line and updates the weights to prepare for the next symbol period. This class of equalizer is called symbol-spaced because the sample rates of the input and output are equal.
Below is a schematic of a symbol-spaced linear equalizer with N weights, where the symbol period is T.
Updating the Set of Weights. The algorithms for the Weight Setting and Error Calculation blocks in the schematic are determined by the adaptive algorithm chosen from the list in Equalization Features. The new set of weights depends on these quantities:
The current set of weights
The input signal
The output signal
For adaptive algorithms other than CMA, a reference signal, d, whose characteristics depend on the operation mode of the equalizer
Reference Signal and Operation Modes. The table below briefly describes the nature of the reference signal for each of the two operation modes.
Operation Mode of Equalizer | Reference Signal |
---|---|
Training mode | Preset known transmitted sequence |
Decision-directed mode | Detected version of the output signal, denoted by y_{d} in the schematic |
In typical applications, the equalizer begins in training mode to gather information about the channel, and later switches to decision-directed mode.
Error Calculation. The error calculation operation produces a signal given by the expression below, where R is a constant related to the signal constellation.
$$e=\{\begin{array}{cc}d-y& \text{AlgorithmsotherthanCMA}\\ y(R-{\left|y\right|}^{2})& \text{CMA}\end{array}$$
A fractionally spaced equalizer is a linear equalizer that is similar to a symbol-spaced linear equalizer, as described in Symbol-Spaced Equalizers. By contrast, however, a fractionally spaced equalizer receives K input samples before it produces one output sample and updates the weights, where K is an integer. In many applications, K is 2. The output sample rate is 1/T, while the input sample rate is K/T. The weight-updating occurs at the output rate, which is the slower rate.
The following schematic illustrates a fractionally spaced equalizer.
This example illustrates the use of an LMS linear equalizer. The simulation transmits a 16-QAM signal, modeling the channel using an FIR filter followed by additive white Gaussian noise. The equalizer receives the signal from the channel and, as training symbols, a subset of the modulator's output. The equalizer operates in training mode at the beginning of each frame and switches to decision-directed mode when it runs out of training symbols. The example contrasts the signals before and after equalization to illustrate the effect of the equalizer.
To open this modelopen this model, enter doc_lmseq
at
the MATLAB command line.
To build the model, gather and configure these blocks:
Random Integer Generator, in the Random Data Sources sublibrary of the Comm Sources library
Set M-ary number to 16
.
Set Sample time to 1/1000
.
Select Frame-based outputs.
Set Samples per frame to 1000
.
Rectangular QAM Modulator Baseband, in the AM sublibrary of the Digital Baseband sublibrary of Modulation
Set Normalization method to Average
Power
.
Set Average power to 1
.
Discrete FIR Filter, in the DSP System Toolbox™ Filter Implementations sublibrary of Filtering
Set Filter structure to Direct
form transposed
.
Set Coefficients to [1
-.3 .1 .2j]
.
Submatrix, in the DSP System Toolbox Indexing sublibrary of Signal Management
Set Ending row to Index
.
Set Ending row index to 100
.
AWGN Channel, in the Channels library
Set Mode to Signal
to noise ratio (SNR)
.
Set SNR to 40
.
Set Number of taps to 6
.
Clear the Mode input port, Output error, and Output weights check boxes.
Two copies of Constellation Diagram, in the Comm Sinks library
Set Symbols to display to 400
in
each of the two copies.
Connect the blocks as in the figure. Running the simulation produces two scatter plots that display the signal before and after equalization, respectively.
Scatter Plots in the Example. Throughout the simulation, the signal before equalization deviates noticeably from a 16-QAM signal constellation, as below.
Early in the simulation, the equalizer does not appear to improve the scatter plot. In fact, the equalizer is busy trying to adapt its weights appropriately. The following figure shows the equalized signal very early in the simulation.
After some simulation time passes, the equalizer's weights work well on the received signal. As a result, the equalized signal looks far more like a 16-QAM signal constellation than the received signal does. The figure below shows the equalized signal in its steady state.
This section provides an overview of the process you typically use in the MATLAB environment to take advantage of the adaptive equalizer capabilities. The MLSE equalizer has a different interface, described in MLSE Equalizers.
Keeping the basic procedure in mind, read other portions of this chapter to learn more details about
How to create objects that represent different classes of adaptive equalizers and different adaptive algorithms
How to adjust properties of an adaptive equalizer or properties of an adaptive algorithm
How to equalize signals using an adaptive equalizer object
Choose an Adaptive Algorithm. Configuring an equalizer involves choosing an adaptive algorithm and indicating your choice when creating an equalizer object in the MATLAB environment.
Although the best choice of adaptive algorithm might depend on your individual situation, here are some generalizations that might influence your choice:
The LMS algorithm executes quickly but converges slowly, and its complexity grows linearly with the number of weights.
The RLS algorithm converges quickly, but its complexity grows with the square of the number of weights, roughly speaking. This algorithm can also be unstable when the number of weights is large.
The various types of signed LMS algorithms simplify hardware implementation.
The normalized LMS and variable-step-size LMS algorithms are more robust to variability of the input signal's statistics (such as power).
The constant modulus algorithm is useful when no training signal is available, and works best for constant modulus modulations such as PSK.
However, if CMA has no additional side information, it can introduce phase ambiguity. For example, CMA might find weights that produce a perfect QPSK constellation but might introduce a phase rotation of 90, 180, or 270 degrees. Alternatively, differential modulation can be used to avoid phase ambiguity.
Details about the adaptive algorithms are in the references listed in Selected Bibliography for Equalizers.
Indicating a Choice of Adaptive Algorithm. After you have chosen the adaptive algorithm you want to use, indicate your choice when creating the equalizer object mentioned in Equalize A Signal. The functions listed in the table below provide a way to indicate your choice of adaptive algorithm.
Adaptive Algorithm Function | Type of Adaptive Algorithm |
---|---|
lms | Least mean square (LMS) |
signlms | Signed LMS, signed regressor LMS, sign-sign LMS |
normlms | Normalized LMS |
varlms | Variable-step-size LMS |
rls | Recursive least squares (RLS) |
cma | Constant modulus algorithm (CMA) |
Two typical ways to use a function from the table are as follows:
Use the function in an inline expression when creating the equalizer object.
For example, the code below uses the lms
function
inline when creating an equalizer object.
eqlms = lineareq(10,lms(0.003));
Use the function to create a variable in the MATLAB workspace and then use that variable when creating the equalizer object. The variable is called an adaptive algorithm object.
For example, the code below creates an adaptive algorithm object
named alg
that represents the adaptive algorithm,
and then uses alg
when creating an equalizer object.
alg = lms(0.003); eqlms = lineareq(10,alg);
Note:
To create an adaptive algorithm object by duplicating an existing
one and then changing its properties, see the important note in Duplicating and Copying Objects about
the use of |
In practice, the two ways are equivalent when your goal is to create an equalizer object or to equalize a signal.
Access Properties of an Adaptive Algorithm. The adaptive algorithm functions not only provide a way to indicate
your choice of adaptive algorithm, but they also let you specify certain
properties of the algorithm. For information about what each property
of an adaptive algorithm object means, see the reference pages for
the lms
, signlms
, normlms
, varlms
, rls
, or cma
functions.
To view or change any properties of an adaptive algorithm, use the syntax described for channel objects in Display Object Properties and Change Object Properties.
Defining an Equalizer Object. To create an equalizer object, use one of the functions listed in the table below.
Function | Type of Equalizer |
---|---|
lineareq | Linear equalizer (symbol-spaced or fractionally spaced) |
dfe | Decision-feedback equalizer |
For example, the code below creates three equalizer objects: one representing a symbol-spaced linear RLS equalizer having 10 weights, one representing a fractionally spaced linear RLS equalizer having 10 weights and two samples per symbol, and one representing a decision-feedback RLS equalizer having three weights in the feedforward filter and two weights in the feedback filter.
% Create equalizer objects of different types. eqlin = lineareq(10,rls(0.3)); % Symbol-spaced linear eqfrac = lineareq(10,rls(0.3),[-1 1],2); % Fractionally spaced linear eqdfe = dfe(3,2,rls(0.3)); % DFE
Although the lineareq
and dfe
functions
have different syntaxes, they both require an input argument that
represents an adaptive algorithm. To learn how to represent an adaptive
algorithm or how to vary properties of the adaptive algorithm, see Specify an Adaptive Algorithm.
Each of the equalizer objects created above is a valid input
argument for the equalize
function. To learn
how to use the equalize
function to equalize
a signal, see Using Adaptive Equalizers.
Another way to create an object is to duplicate an existing
object and then adjust the properties of the new object, if necessary.
If you do this, it is important that you use a copy
command
such as
c2 = copy(c1); % Copy c1 to create an independent c2.
instead of c2 = c1
. The copy
command
creates a copy of c1
that is independent of c1
.
By contrast, the command c2 = c1
creates c2
as
merely a reference to c1
, so that c1
and c2
always
have indistinguishable content.
Accessing Properties of an Equalizer. An equalizer object has numerous properties that record information about the equalizer. Properties can be related to
The structure of the equalizer (for example, the number of weights).
The adaptive algorithm that the equalizer uses (for
example, the step size in the LMS algorithm). When you create the
equalizer object using lineareq
or dfe
,
the function copies certain properties from the algorithm object to
the equalizer object. However, the equalizer object does not retain
a connection to the algorithm object.
Information about the equalizer's current state (for
example, the values of the weights). The equalize
function
automatically updates these properties when it operates on a signal.
Instructions for operating on a signal (for example, whether the equalizer should reset itself before starting the equalization process).
For information about what each equalizer property means, see
the reference page for the lineareq
or dfe
function.
To view or change any properties of an equalizer object, use the syntax described for channel objects in Display Object Properties and Change Object Properties.
Linked Properties of an Equalizer Object.Some properties of an equalizer object are related to each other
such that when one property's value changes, another property's value
must adjust, or else the equalizer object fails to describe a valid
equalizer. For example, in a linear equalizer, the nWeights
property
is the number of weights, while the Weights
property
is the value of the weights. If you change the value of nWeights
,
the value of Weights
must adjust so that its vector
length is the new value of nWeights
.
To find out which properties are related and how MATLAB compensates
automatically when you make certain changes in property values, see
the reference page for lineareq
or dfe
.
The example below illustrates that when you change the value
of nWeights
, MATLAB automatically changes
the values of Weights
and WeightInputs
to
make their vector lengths consistent with the new value of nWeights
.
Because the example uses the variable-step-size LMS algorithm, StepSize
is
a vector (not a scalar) and MATLAB changes its vector length
to maintain consistency with the new value of nWeights
.
eqlvar = lineareq(10,varlms(0.01,0.01,0,1)) % Create equalizer object. eqlvar.nWeights = 8 % Change the number of weights from 10 to 8. % MATLAB automatically changes the sizes of eqlvar.Weights and % eqlvar.WeightInputs.
The output below displays all the properties of the equalizer
object before and after the change in the value of the nWeights
property.
In the second listing of properties, the nWeights
, Weights
, WeightInputs
,
and StepSize
properties all have different values
compared to the first listing of properties.
eqlvar = EqType: 'Linear Equalizer' AlgType: 'Variable Step Size LMS' nWeights: 10 nSampPerSym: 1 RefTap: 1 SigConst: [-1 1] InitStep: 0.0100 IncStep: 0.0100 MinStep: 0 MaxStep: 1 LeakageFactor: 1 StepSize: [1x10 double] Weights: [0 0 0 0 0 0 0 0 0 0] WeightInputs: [0 0 0 0 0 0 0 0 0 0] ResetBeforeFiltering: 1 NumSamplesProcessed: 0 eqlvar = EqType: 'Linear Equalizer' AlgType: 'Variable Step Size LMS' nWeights: 8 nSampPerSym: 1 RefTap: 1 SigConst: [-1 1] InitStep: 0.0100 IncStep: 0.0100 MinStep: 0 MaxStep: 1 LeakageFactor: 1 StepSize: [1x8 double] Weights: [0 0 0 0 0 0 0 0] WeightInputs: [0 0 0 0 0 0 0 0] ResetBeforeFiltering: 1 NumSamplesProcessed: 0
Equalize Using a Training Sequence in MATLAB. This section describes how to equalize a signal by using the equalize
function
to apply an adaptive equalizer object to the signal. The equalize
function
also updates the equalizer. This section assumes that you have already
created an adaptive equalizer object, as described in Specify an Adaptive Equalizer.
For an example that complements this section, see the Adaptive Equalization SimulationAdaptive Equalization Simulation.
In typical applications, an equalizer begins by using a known
sequence of transmitted symbols when adapting the equalizer weights.
The known sequence, called a training sequence,
enables the equalizer to gather information about the channel characteristics.
After the equalizer finishes processing the training sequence, it
adapts the equalizer weights in decision-directed mode using a detected
version of the output signal. To use a training sequence when invoking
the equalize
function, include the symbols of
the training sequence as an input vector.
Note: As an exception, CMA equalizers do not use a training sequence. If an equalizer object is based on CMA, you should not include a training sequence as an input vector. |
The following code illustrates
how to use equalize
with a training sequence.
The training sequence in this case is just the beginning of the transmitted
message.
% Set up parameters and signals. M = 4; % Alphabet size for modulation msg = randi([0 M-1],1500,1); % Random message hMod = comm.QPSKModulator('PhaseOffset',0); modmsg = step(hMod,msg); % Modulate using QPSK. trainlen = 500; % Length of training sequence chan = [.986; .845; .237; .123+.31i]; % Channel coefficients filtmsg = filter(chan,1,modmsg); % Introduce channel distortion. % Equalize the received signal. eq1 = lineareq(8, lms(0.01)); % Create an equalizer object. eq1.SigConst = step(hMod,(0:M-1)')'; % Set signal constellation. [symbolest,yd] = equalize(eq1,filtmsg,modmsg(1:trainlen)); % Equalize. % Plot signals. h = scatterplot(filtmsg,1,trainlen,'bx'); hold on; scatterplot(symbolest,1,trainlen,'g.',h); scatterplot(eq1.SigConst,1,0,'k*',h); legend('Filtered signal','Equalized signal',... 'Ideal signal constellation'); hold off; % Compute error rates with and without equalization. hDemod = comm.QPSKDemodulator('PhaseOffset',0); demodmsg_noeq = step(hDemod,filtmsg); % Demodulate unequalized signal. demodmsg = step(hDemod,yd); % Demodulate detected signal from equalizer. hErrorCalc = comm.ErrorRate; % ErrorRate calculator ser_noEq = step(hErrorCalc, ... msg(trainlen+1:end), demodmsg_noeq(trainlen+1:end)); reset(hErrorCalc) ser_Eq = step(hErrorCalc, msg(trainlen+1:end),demodmsg(trainlen+1:end)); disp('Symbol error rates with and without equalizer:') disp([ser_Eq(1) ser_noEq(1)])
The example goes on to determine how many errors occur in trying to recover the modulated message with and without the equalizer. The symbol error rates, below, show that the equalizer improves the performance significantly.
Symbol error rates with and without equalizer: 0 0.3410
The example also creates a scatter plot that shows the signal before and after equalization, as well as the signal constellation for QPSK modulation. Notice on the plot that the points of the equalized signal are clustered more closely around the points of the signal constellation.
Equalizing Using a Training Sequence in Simulink. To train a non-CMA equalizer block at the beginning of each frame throughout the simulation, follow these steps:
Clear the Mode input port check box.
Provide the training sequence at the input port labeled Desired
.
Valid training symbols are those listed in the Signal constellation vector.
The block operates in training mode at the beginning of each frame
and switches to decision-directed mode when it runs out of training
symbols.
Typically, the symbol periods of the Input
and Desired
inputs
match; that is, the sample time of the Desired
signal
is k times the sample time of the Input
signal,
where k is the Number of samples per symbol parameter
in the equalizer block. If your training sequence is constant throughout
the simulation, the Simulink Constant block is a convenient way to
specify the sequence without having to specify a sample time explicitly.
To train a non-CMA equalizer block only on selected frames during the simulation, see Equalize in Decision-Directed Mode Using MATLAB.
Equalize in Decision-Directed Mode Using MATLAB. Decision-directed mode means the equalizer uses a detected version of its output signal when adapting the weights. Adaptive equalizers typically start with a training sequence (as mentioned in Equalize Using a Training Sequence in MATLAB) and switch to decision-directed mode after exhausting all symbols in the training sequence. CMA equalizers are an exception, using neither training mode nor decision-directed mode.
For non-CMA equalizers, the equalize
function
operates in decision-directed mode when one of these conditions is
true:
The syntax does not include a training sequence.
The equalizer has exhausted all symbols in the training sequence and still has more input symbols to process.
The example in Controlling the Use of Training or Decision-Directed Mode uses training mode when
processing the first trainlen
symbols of the input
signal, and decision-directed mode thereafter. The example below discusses
another scenario.
If you invoke equalize
multiple times with
the same equalizer object to equalize a series of signal vectors,
you might use a training sequence the first time you call the function
and omit the training sequence in subsequent calls. Each iteration
of the equalize
function after the first one
operates completely in decision-directed mode. However, because the ResetBeforeFiltering
property
of the equalizer object is set to 0
, the equalize
function
uses the existing state information in the equalizer object when starting
each iteration's equalization operation. As a result, the training
affects all equalization operations, not just the first.
The code below illustrates this approach. Notice that the first
call to equalize
uses a training sequence as
an input argument, and the second call to equalize
omits
a training sequence.
M = 4; % Alphabet size for modulation msg = randi([0 M-1],1500,1); % Random message hMod = comm.QPSKModulator('PhaseOffset',0); modmsg = step(hMod,msg); % Modulate using QPSK. trainlen = 500; % Length of training sequence chan = [.986; .845; .237; .123+.31i]; % Channel coefficients filtmsg = filter(chan,1,modmsg); % Introduce channel distortion. % Set up equalizer. eqlms = lineareq(8, lms(0.01)); % Create an equalizer object. eqlms.SigConst = step(hMod,(0:M-1)')'; % Set signal constellation. % Maintain continuity between calls to equalize. eqlms.ResetBeforeFiltering = 0; % Equalize the received signal, in pieces. % 1. Process the training sequence. s1 = equalize(eqlms,filtmsg(1:trainlen),modmsg(1:trainlen)); % 2. Process some of the data in decision-directed mode. s2 = equalize(eqlms,filtmsg(trainlen+1:800)); % 3. Process the rest of the data in decision-directed mode. s3 = equalize(eqlms,filtmsg(801:end)); s = [s1; s2; s3]; % Full output of equalizer
Equalize in Decision-Directed Mode Using Simulink. Decision-directed mode means that the equalizer uses a detected version of its output signal when adapting the weights. Adaptive equalizers typically start with a training sequence (as mentioned in Equalizing Using a Training Sequence in Simulink) and switch to decision-directed mode after exhausting all symbols in the training sequence. CMA equalizers are an exception, using neither training mode nor decision-directed mode. The non-CMA equalizer blocks in this library operate in decision-directed mode when one of these conditions is true:
The equalizer started processing the current input frame in training mode, exhausted all symbols in the training sequence frame, and still has more input symbols to process.
The Mode input port check box
is selected and the Mode
input signal is 0
.
You can configure a non-CMA equalizer block so that it adapts in training mode for the beginning or the entirety of selected frames. To achieve this level of control over the equalizer's mode, follow these steps:
Enable the Mode
input port by checking
the Mode input port check box.
Send a binary-valued scalar signal to the Mode
input
port. The Mode
input enables you to toggle back
and forth between training mode and decision-directed mode. The significance
of this signal is as follows:
When the Mode
input is 0
,
the equalizer operates in decision-directed mode on the entire frame
and ignores the Desired
input.
When the Mode
input is 1
,
the equalizer operates in training mode at the beginning of the frame
until it exhausts the symbols in the Desired
input,
and operates in decision-directed mode afterwards. If the Mode
input
is 1
and the Desired
input has
as many symbols as the Input
signal has, then the
equalizer operates in training mode on the entire frame.
Delays from Equalization. For proper equalization using adaptive algorithms other than CMA, you should set the reference tap so that it exceeds the delay, in symbols, between the transmitter's modulator output and the equalizer input. When this condition is satisfied, the total delay between the modulator output and the equalizer output is equal to
(RefTap-1)/nSampPerSym
symbols. Because the channel delay is typically unknown, a common practice is to set the reference tap to the center tap in a linear equalizer, or the center tap of the forward filter in a decision-feedback equalizer.
For CMA equalizers, the expression above does not apply because
a CMA equalizer has no reference tap. If you need to know the delay,
you can find it empirically after the equalizer weights have converged.
Use the xcorr
function to examine
cross-correlations of the modulator output and the equalizer output.
Here are some typical ways to take a delay of D into account by padding or truncating data:
Pad your original data with D extra symbols at the end. Before comparing the original data with the received data, omit the first D symbols of the received data. In this approach, all the original data (not including the padding) is accounted for in the received data.
Before comparing the original data with the received data, omit the last D symbols of the original data and the first D symbols of the received data. In this approach, some of the original symbols are not accounted for in the received data.
The example below illustrates the latter approach. For an example that illustrates both approaches in the context of interleavers, see Delays of Convolutional Interleavers.
M = 2; % Use BPSK modulation for this example. msg = randi([0 M-1],1000,1); % Random data hMod = comm.BPSKModulator('PhaseOffset',0); modmsg = step(hMod,msg); % Modulate trainlen = 100; % Length of training sequence trainsig = modmsg(1:trainlen); % Training sequence % Define an equalizer and equalize the received signal. eqlin = lineareq(3,normlms(.0005,.0001),pskmod(0:M-1,M)); eqlin.RefTap = 2; % Set reference tap of equalizer. [eqsig,detsym] = equalize(eqlin,modmsg,trainsig); % Equalize. hDemod = comm.BPSKDemodulator('PhaseOffset',0); detmsg = step(hDemod,detsym); % Demodulate the detected signal. % Compute bit error rate while compensating for delay introduced by RefTap % and ignoring training sequence. D = (eqlin.RefTap -1)/eqlin.nSampPerSym; hErrorCalc = comm.ErrorRate('ReceiveDelay',D); berVec = step(hErrorCalc, msg(trainlen+1:end), detmsg(trainlen+1:end)); ber = berVec(1) numerrs = berVec(2)
The output is below.
numerrs = 0 ber = 0
Equalize Using a Loop. If your data is partitioned into a series of vectors (that you
process within a loop, for example), you can invoke the equalize
function
multiple times, saving the equalizer's internal state information
for use in a subsequent invocation. In particular, the final values
of the WeightInputs
and Weights
properties
in one equalization operation should be the initial values in the
next equalization operation. This section gives an example, followed
by more general procedures for equalizing
within a loop.
The example below illustrates how to use equalize
within
a loop, varying the equalizer between iterations. Because the example
is long, this discussion presents it in these steps:
If you want to equalize iteratively while potentially changing equalizers between iterations, see Changing the Equalizer Between Iterations for help generalizing from this example to other cases.
Initializing Variables.The beginning of the example defines parameters and creates three equalizer objects:
An RLS equalizer object.
An LMS equalizer object.
A variable, eq_current
, that points
to the equalizer object to use in the current iteration of the loop.
Initially, this points to the RLS equalizer object. After the second
iteration of the loop, eq_current
is redefined
to point to the LMS equalizer object.
% Set up parameters. M = 16; % Alphabet size for modulation sigconst = step(comm.RectangularQAMModulator(M),(0:M-1)'); % Signal constellation for 16-QAM chan = [1 0.45 0.3+0.2i]; % Channel coefficients hMod = comm.RectangularQAMModulator(M); % QAMModulator System object % Set up equalizers. eqrls = lineareq(6, rls(0.99,0.1)); % Create an RLS equalizer object. eqrls.SigConst = sigconst'; % Set signal constellation. eqrls.ResetBeforeFiltering = 0; % Maintain continuity between iterations. eqlms = lineareq(6, lms(0.003)); % Create an LMS equalizer object. eqlms.SigConst = sigconst'; % Set signal constellation. eqlms.ResetBeforeFiltering = 0; % Maintain continuity between iterations. eq_current = eqrls; % Point to RLS for first iteration.
The next portion of the example is a loop that
Generates a signal to transmit and selects a portion to use as a training sequence in the first iteration of the loop
Introduces channel distortion
Equalizes the distorted signal using the chosen equalizer for this iteration, retaining the final state and weights for later use
Plots the distorted and equalized signals, for comparison
Switches to an LMS equalizer between the second and third iterations
% Main loop for jj = 1:4 msg = randi([0 M-1],500,1); % Random message modmsg = step(hMod,msg); % Modulate using 16-QAM. % Set up training sequence for first iteration. if jj == 1 ltr = 200; trainsig = modmsg(1:ltr); else % Use decision-directed mode after first iteration. ltr = 0; trainsig = []; end % Introduce channel distortion. filtmsg = filter(chan,1,modmsg); % Equalize the received signal. s = equalize(eq_current,filtmsg,trainsig); % Plot signals. h = scatterplot(filtmsg(ltr+1:end),1,0,'bx'); hold on; scatterplot(s(ltr+1:end),1,0,'g.',h); scatterplot(sigconst,1,0,'k*',h); legend('Received signal','Equalized signal','Signal constellation'); title(['Iteration #' num2str(jj) ' (' eq_current.AlgType ')']); hold off; % Switch from RLS to LMS after second iteration. if jj == 2 eqlms.WeightInputs = eq_current.WeightInputs; % Copy final inputs. eqlms.Weights = eq_current.Weights; % Copy final weights. eq_current = eqlms; % Make eq_current point to eqlms. end end
The example produces one scatter plot for each iteration, indicating the iteration number and the adaptive algorithm in the title. A sample plot is below. Your plot might look different because this example uses random numbers.
Procedures for Equalizing Within a Loop.
This section describes two procedures for equalizing within a loop. The first procedure uses the same equalizer in each iteration, and the second is useful if you want to change the equalizer between iterations.
Using the Same Equalizer in Each Iteration.The typical procedure for using equalize
within
a loop is as follows:
Before the loop starts, create the equalizer object that you want to use in the first iteration of the loop.
Set the equalizer object's ResetBeforeFiltering
property
to 0
to maintain continuity between successive
invocations of equalize
.
Inside the loop, invoke equalize
using
a syntax like one of these:
y = equalize(eqz,x,trainsig); y = equalize(eqz,x);
equalize
function updates
the state and weights of the equalizer at the end of the current iteration.
In the next iteration, the function continues from where it finished
in the previous iteration because ResetBeforeFiltering
is
set to 0
.This procedure is similar to the one used in Example: Equalizing Multiple Times, Varying the Mode. That
example uses equalize
multiple times but not
within a loop.
In some applications, you might want to modify the adaptive algorithm between iterations. For example, you might use a CMA equalizer for the first iteration and an LMS or RLS equalizer in subsequent iterations. The procedure below gives one way to accomplish this, roughly following the example in Example: Adaptive Equalization Within a Loop:
Before the loop starts, create the different kinds of equalizer objects that you want to use during various iterations of the loop.
For example, create one CMA equalizer object, eqcma
,
and one LMS equalizer object, eqlms
.
For each equalizer object, set the ResetBeforeFiltering
property
to 0
to maintain continuity between successive
invocations of equalize
.
Create a variable eq_current
that
points to the equalizer object you want to use for the first iteration.
Use =
to establish the connection so that the two
objects get updated together:
eq_current = eqcma; % Point to eqcma.
The purpose of eq_current
is to represent
the equalizer used in each iteration, where you can switch equalizers
from one iteration to the next by using a command like eq_current
= eqlms
. The example illustrates
this approach near the end of its loop.
Inside the loop, perform these steps:
Invoke equalize
using a syntax
like one of these:
y = equalize(eq_current,x,trainsig); y = equalize(eq_current,x);
Copy the values of the WeightInputs
and Weights
properties
from eq_current
to the equalizer object that you
want to use for the next iteration. Use dot notation. For example,
eqlms.WeightInputs = eq_current.WeightInputs; eqlms.Weights = eq_current.Weights;
Redefine eq_current
to point to
the equalizer object that you want to use for the next iteration,
using =
. Now eq_current
is
set up for the next iteration, because it represents the new kind
of equalizer but retains the old values for the state and weights.
The reason for creating multiple equalizer objects and then copying the state and weights, instead of simply changing the equalizer class or adaptive algorithm in a single equalizer object, is that the class and adaptive algorithm properties of an equalizer object are fixed.
In Communications System Toolbox, the mlseeq
function
and MLSE Equalizer block use the Viterbi algorithm to equalize a
linearly modulated signal through a dispersive channel. Both the function
and the block output the maximum likelihood sequence estimate of the
signal, using an estimate of the channel modeled as a finite input
response (FIR) filter.
Decoding a received signal uses these steps:
Applies the FIR filter, corresponding to the channel estimate, to the symbols in the input signal.
Uses the Viterbi algorithm to compute the traceback paths and the state metric, which are the numbers assigned to the symbols at each step of the Viterbi algorithm. The metrics are based on Euclidean distance.
Outputs the maximum likelihood sequence estimate of the signal, as a sequence of complex numbers corresponding to the constellation points of the modulated signal.
An MLSE equalizer yields the best possible performance, in theory, but is computationally intensive.
For background material about MLSE equalizers, see the works listed in Selected Bibliography for Equalizers.
When using the MLSE Equalizer block, you specify the channel estimate and the signal constellation that the modulator in your model uses. If applicable, you can also specify a preamble and/or postamble that you expect to accompany your data. For full details on options, see the reference page for the MLSE Equalizer block.
In its simplest form, the mlseeq
function
equalizes a vector of modulated data when you specify the estimated
coefficients of the channel (modeled as an FIR filter), the signal
constellation for the modulation type, and the traceback depth that
you want the Viterbi algorithm to use. Larger values for the traceback
depth can improve the results from the equalizer but increase the
computation time.
An example of the basic syntax for mlseeq
is
below.
M = 4; hMod = comm.QPSKModulator; const = step(hMod,(0:M-1)'); % 4-PSK constellation msg = step(hMod,[1 2 2 0 3 1 3 3 2 1 0 2 3 0 1]'); % Modulated message chcoeffs = [.986; .845; .237; .12345+.31i]; % Channel coefficients filtmsg = filter(chcoeffs,1,msg); % Introduce channel distortion. tblen = 10; % Traceback depth for equalizer chanest = chcoeffs; % Assume the channel is known exactly. hMLSEE = comm.MLSEEqualizer('TracebackDepth',tblen,... 'Channel',chanest, 'Constellation',const); msgEq = step(hMLSEE,filtmsg); % Equalize.
The mlseeq
function has two operation modes:
Continuous operation mode enables you to process a
series of vectors using repeated calls to mlseeq
,
where the function saves its internal state information from one call
to the next. To learn more, see Equalizing in Continuous Operation Mode.
Reset operation mode enables you to specify a preamble and postamble that accompany your data. To learn more, see Use a Preamble or Postamble.
If you are not processing a series of vectors and do not need to specify a preamble or postamble, the operation modes are nearly identical. However, they differ in that continuous operation mode incurs a delay, while reset operation mode does not. The example above could have used either mode, except that substituting continuous operation mode would have produced a delay in the equalized output. To learn more about the delay in continuous operation mode, see Delays in Continuous Operation Mode.
If your data is partitioned into a series of vectors (that you
process within a loop, for example), continuous operation mode is
an appropriate way to use the mlseeq
function.
In continuous operation mode, mlseeq
can save
its internal state information for use in a subsequent invocation
and can initialize using previously stored state information. To choose
continuous operation mode, use 'cont'
as an input
argument when invoking mlseeq
.
Note: Continuous operation mode incurs a delay, as described in Delays in Continuous Operation Mode. Also, continuous operation mode cannot accommodate a preamble or postamble. |
Procedure for Continuous Operation Mode. The typical procedure for using continuous mode within a loop is as follows:
Before the loop starts, create three empty matrix
variables (for example, sm
, ts
, ti
)
that eventually store the state metrics, traceback states, and traceback
inputs for the equalizer.
Inside the loop, invoke mlseeq
using
a syntax like
[y,sm,ts,ti] = mlseeq(x,chcoeffs,const,tblen,'cont',nsamp,sm,ts,ti);
sm
, ts
,
and ti
as input arguments causes mlseeq
to
continue from where it finished in the previous iteration. Using sm
, ts
,
and ti
as output arguments causes mlseeq
to
update the state information at the end of the current iteration.
In the first iteration, sm
, ts
,
and ti
start as empty matrices, so the first invocation
of the mlseeq
function initializes the metrics
of all states to 0.Delays in Continuous Operation Mode. Continuous operation mode with a traceback depth of tblen
incurs
an output delay of tblen
symbols. This means that
the first tblen
output symbols are unrelated to
the input signal, while the last tblen
input symbols
are unrelated to the output signal. For example, the command below
uses a traceback depth of 3
, and the first 3 output
symbols are unrelated to the input signal of ones(1,10)
.
y = step(comm.MLSEEqualizer('Channel',1, 'Constellation',[-7:2:7], ... 'TracebackDepth',3,'TerminationMethod', 'Continuous'), ... complex(ones(10,1))) y = -7 -7 -7 1 1 1 1 1 1 1
Keeping track of delays from different portions of a communication system is important, especially if you compare signals to compute error rates. The example in Example: Continuous Operation Mode illustrates how to take the delay into account when computing an error rate.
Example: Continuous Operation Mode. The example below illustrates the procedure for using continuous operation mode within a loop. Because the example is long, this discussion presents it in multiple steps:
Initializing Variables.The beginning of the example defines parameters, initializes
the state variables sm
, ts
,
and ti
, and initializes variables that accumulate
results from each iteration of the loop.
n = 200; % Number of symbols in each iteration numiter = 25; % Number of iterations M = 4; % Use 4-PSK modulation. hMod = comm .QPSKModulator('PhaseOffset',0); const = step(hMod,(0:M-1)'); % PSK constellation chcoeffs = [1 ; 0.25]; % Channel coefficients chanest = chcoeffs; % Channel estimate tblen = 10; % Traceback depth for equalizer sm = []; ts = []; ti = []; % Initialize equalizer data. % Initialize cumulative results. fullmodmsg = []; fullfiltmsg = []; fullrx = []; hMLSEE = comm.MLSEEqualizer('TracebackDepth',tblen, 'Channel', chanest, ... 'Constellation',const, 'TerminationMethod', 'Continuous');
The middle portion of the example is a loop that generates random
data, modulates it using baseband PSK modulation, and filters it.
Finally, mlseeq
equalizes the filtered data.
The loop also updates the variables that accumulate results from each
iteration of the loop.
for jj = 1:numiter msg = randi([0 M-1],n,1); % Random signal vector modmsg = step(hMod,msg); % PSK-modulated signal filtmsg = filter(chcoeffs,1,modmsg); % Filtered signal rx = step(hMLSEE,filtmsg); % Equalize % Update vectors with cumulative results. fullmodmsg = [fullmodmsg; modmsg]; fullfiltmsg = [fullfiltmsg; filtmsg]; fullrx = [fullrx; rx]; end
The last portion of the example computes the symbol error rate
from all iterations of the loop. The symerr
function
compares selected portions of the received and transmitted signals,
not the entire signals. Because continuous operation mode incurs a
delay whose length in samples is the traceback depth (tblen
)
of the equalizer, it is necessary to exclude the first tblen
samples
from the received signal and the last tblen
samples
from the transmitted signal. Excluding samples that represent the
delay of the equalizer ensures that the symbol error rate calculation
compares samples from the received and transmitted signals that are
meaningful and that truly correspond to each other.
The example also plots the signal before and after equalization in a scatter plot. The points in the equalized signal coincide with the points of the ideal signal constellation for 4-PSK.
% Compute total number of symbol errors. Take the delay into account. hErrorCalc = comm.ErrorRate('ReceiveDelay',10); err = step(hErrorCalc, fullmodmsg, fullrx); numsymerrs = err(1) % Plot signal before and after equalization. h = scatterplot(fullfiltmsg); hold on; scatterplot(fullrx,1,0,'r*',h); legend('Filtered signal before equalization','Equalized signal',... 'Location','NorthOutside'); hold off;
The output and plot follow.
numsymerrs = 0
Some systems include a sequence of known symbols at the beginning
or end of a set of data. The known sequence at the beginning or end
is called a preamble or postamble,
respectively. The mlseeq
function can accommodate
a preamble and postamble that are already incorporated into its input
signal. When you invoke the function, you specify the preamble and
postamble as integer vectors that represent the sequence of known
symbols by indexing into the signal constellation vector. For example,
a preamble vector of [1 4 4]
and a 4-PSK signal
constellation of [1 j -1 -j]
indicate that the
modulated signal begins with [1 -j -j]
.
If your system uses a preamble without a postamble, use a postamble
vector of []
when invoking mlseeq
.
Similarly, if your system uses a postamble without a preamble, use
a preamble vector of []
.
Use a Preamble in MATLAB.
The example below illustrates how to accommodate a preamble
when using mlseeq
. The same preamble symbols
appear at the beginning of the message vector and in the syntax for mlseeq
.
If you want to use a postamble, you can append it to the message vector
and also include it as the last input argument for mlseeq
.
In this example, however, the postamble input in the mlseeq
syntax
is an empty vector because the system uses no postamble.
M = 4; hMod = comm.QPSKModulator;% Use 4-PSK modulation. const = step(hMod,(0:M-1)'); % PSK constellation tblen = 16; % Traceback depth for equalizer preamble = [3; 1]; % Expected preamble, as integers msgIdx = randi([0 M-1],98,1); % Random symbols msgIdx = [preamble; msgIdx]; % Include preamble at the beginning. msg = step(hMod,msgIdx); % Modulated message chcoeffs = [.623; .489+.234i; .398i; .21]; % Channel coefficients chanest = chcoeffs; % Channel estimate hMLSEE = comm.MLSEEqualizer('TracebackDepth',tblen,... 'Channel',chanest, 'Constellation',const, ... 'PreambleSource', 'Property', 'Preamble', preamble); filtmsg = filter(chcoeffs,1,msg); % Introduce channel distortion. d = step(hMLSEE,filtmsg); % Symbol error rate hErrorCalc = comm.ErrorRate; serVec = step(hErrorCalc, msg,d); ser = serVec(1) nsymerrs = serVec(2)
The output is below.
nsymerrs = 0 ser = 0
The MLSE Equalizer block uses the Viterbi algorithm to equalize a linearly modulated signal through a dispersive channel. The block outputs the maximum likelihood sequence estimate (MLSE) of the signal, using your estimate of the channel modeled as a finite input response (FIR) filter.
The block decodes the received signal using these steps:
Applies the FIR filter corresponding to the channel estimate to the symbols in the input signal.
Uses the Viterbi algorithm to compute the traceback paths and the state metric, which are the numbers assigned to the symbols at each step of the Viterbi algorithm.
Outputs the maximum likelihood sequence estimate of the signal, as a sequence of complex numbers corresponding to the constellation points of the modulated signal.
An MLSE equalizer yields the best possible performance, in theory, but is computationally intensive.
When using the MLSE Equalizer block, you specify the channel estimate and the signal constellation that the modulator in your model uses. If applicable, you can also specify a preamble and/or postamble that you expect to accompany your data. For full details on options, see the reference page for the MLSE Equalizer block.
[1] Farhang-Boroujeny, B., Adaptive Filters: Theory and Applications, Chichester, England, John Wiley & Sons, 1998.
[2] Haykin, Simon, Adaptive Filter Theory, Third Ed., Upper Saddle River, NJ, Prentice-Hall, 1996.
[3] Kurzweil, Jack, An Introduction to Digital Communications, New York, John Wiley & Sons, 2000.
[4] Proakis, John G., Digital Communications, Fourth Ed., New York, McGraw-Hill, 2001.
[5] Steele, Raymond, Ed., Mobile Radio Communications, Chichester, England, John Wiley & Sons, 1996.