You are on page 1of 16

Communications System Toolbox - Adaptive Equalizer Simulation Demo

Page 1 of 6

Accelerating the pace of engineering and science

Products & Services

Solutions

Academia

Support

User Community

Company

Communications System Toolbox


Adaptive Equalizer Simulation
This demo simulates a communication link with PSK modulation, raised-cosine pulse shaping, multipath fading, and adaptive equalization. The demo sets up three equalization scenarios, and calls a separate script to execute the processing loop multiple times for each scenario. Each call corresponds to a transmission block. The pulse shaping and multipath fading channel retain state information from one block to the next. For visualizing the impact of channel fading on adaptive equalizer convergence, the simulation resets the equalizer state every block. To experiment with different simulation settings, you can edit the demo. For instance, you can set the ResetBeforeFiltering property of the equalizer object to 0, which will cause the equalizer to retain state from one block to the next.

Contents
Modulation and Transmission Block Transmit/Receive Filters Additive White Gaussian Noise Simulation 1: Linear Equalization for Frequency-flat Fading Simulation 2: Linear Equalization for Frequency-selective Fading Simulation 3: Decision feedback Equalization (DFE) for Frequency-selective Fading Summary Appendix

Modulation and Transmission Block


Set parameters related to PSK modulation and the transmission block. The block comprises three contiguous parts: training sequence, payload, and tail sequence. All use the same PSK scheme. The training and tail sequences are used for equalization. We create a local random stream with known state to be used by random number generators.

Tsym = 1e-6; % Symbol period (s) bitsPerSymbol = 2; % Number of bits per PSK symbol M = 2.^bitsPerSymbol; % PSK alphabet size (number of modulation levels) nPayload = 400; % Number of payload symbols nTrain = 100; % Number of training symbols nTail = 20; % Number of tail symbols pskmodObj = modem.pskmod(M); % Modulator object hStream = RandStream.create('mt19937ar', 'seed', 12345); % Training sequence symbols xTrainSym = randi(hStream, [0 M-1], 1, nTrain); % Modulated training sequence xTrain = modulate(pskmodObj, xTrainSym); % Tail sequence symbols xTailSym = randi(hStream, [0 M-1], 1, nTail); % Modulated tail sequence xTail = modulate(pskmodObj, xTailSym); Transmit/Receive Filters
Create interpolator and decimator filter objects containing information about the transmit and receive filters (hDTxFilt and hDRxFilt). Each filter has a square-root raised cosine frequency response, implemented with an FIR structure. The transmit and receive filters incorporate upsampling and downsampling, respectively, and both use an efficient polyphase scheme (see the script commadapteqloop.m for more information). These multirate filters retain state from one transmission block to the next, like the channel object (see Simulation 1: Linear Equalization for Frequency-flat Fading below). The peak value of the impulse response of the filter cascade is 1. The transmit filter uses a scale factor to ensure unit transmitted power. Filter parameters

nSymFilt = 8; % Number of symbol periods spanned by each filter osfFilt = 4; % Oversampling factor for filter (samples per symbol) rolloff = 0.25; % Rolloff factor Tsamp = Tsym/osfFilt; % TX signal sample period (s) orderFilt = nSymFilt*osfFilt; % Filter order (number of taps - 1) % Filter responses and structures

http://www.mathworks.com/products/communications/demos.html?file=/products/demos/s... 4/13/2011

Communications System Toolbox - Adaptive Equalizer Simulation Demo

Page 2 of 6

hTxFilt = fdesign.interpolator(osfFilt, 'Square Root Raised Cosine', ... osfFilt, 'N,Beta', orderFilt, rolloff); hRxFilt = fdesign.decimator(osfFilt, 'Square Root Raised Cosine', ... osfFilt, 'N,Beta', orderFilt, rolloff); hDTxFilt = design(hTxFilt); hDRxFilt = design(hRxFilt); hDTxFilt.PersistentMemory = true; hDRxFilt.PersistentMemory = true; Additive White Gaussian Noise
Set signal-to-noise ratio parameter for additive white Gaussian noise.

EsNodB = 20; % Ratio of symbol energy to noise power spectral density (dB) snrdB = EsNodB - 10*log10(osfFilt); % Signal-to-noise ratio per sample (dB) Simulation 1: Linear Equalization for Frequency-flat Fading
Begin with single-path, frequency-flat fading. For this channel, the receiver uses a simple 1-tap LMS (least mean square) equalizer, which implements automatic gain and phase control. The script commadapteqloop.m runs multiple times. Each run corresponds to a transmission block. The equalizer resets its state and weight every transmission block. (To retain state from one block to the next, you can set the ResetBeforeFiltering property of the equalizer object to 0.) Before the first run, commadapteqloop.m displays the initial properties of the channel and equalizer objects. For each run, a MATLAB figure shows signal processing visualizations. The red circles in the signal constellation plots correspond to symbol errors. In the "Weights" plot, blue and magenta lines correspond to real and imaginary parts, respectively. (The HTML version of this demo shows the last state of the visualizations.)

simName = 'Linear equalization for frequency-flat fading'; figure window.

% Used to label

% Multipath channel fd = 30; % Maximum Doppler shift (Hz) chan = rayleighchan(Tsamp, fd); % Create channel object. chan.ResetBeforeFiltering = 0; % Allow state retention across blocks. % Adaptive equalizer nWeights = 1; % Single weight stepSize = 0.1; % Step size for LMS algorithm alg = lms(stepSize); % Adaptive algorithm object eqObj = lineareq(nWeights, alg, pskmodObj.Constellation); t

% Equalizer objec

% Link simulation nBlocks = 50; % Number of transmission blocks in simulation for block = 1:nBlocks, commadapteqloop; end % Run link simulation in a loop
chan = ChannelType: InputSamplePeriod: DopplerSpectrum: MaxDopplerShift: PathDelays: AvgPathGaindB: NormalizePathGains: StoreHistory: StorePathGains: PathGains: ChannelFilterDelay: ResetBeforeFiltering: NumSamplesProcessed: 'Rayleigh' 2.5000e-007 [1x1 doppler.jakes] 30 0 0 1 0 0 -0.6486 - 0.9202i 0 0 0

eqObj = EqType: AlgType: nWeights: nSampPerSym: RefTap: SigConst: 0000i] StepSize: LeakageFactor: Weights: WeightInputs: ResetBeforeFiltering: 0.1000 1 0 0 1 'Linear Equalizer' 'LMS' 1 1 1 [1 0.0000 + 1.0000i -1.0000 + 0.0000i -0.0000 - 1.

http://www.mathworks.com/products/communications/demos.html?file=/products/demos/s... 4/13/2011

Communications System Toolbox - Adaptive Equalizer Simulation Demo

Page 3 of 6

NumSamplesProcessed: 0

Simulation 2: Linear Equalization for Frequency-selective Fading


Simulate a three-path fading channel (frequency-selective fading). The receiver uses an 8-tap linear RLS (recursive least squares) equalizer with symbol-spaced taps. The simulation uses the channel object from Simulation 1, but with modified properties.

simName = 'Linear equalization for frequency-selective fading'; % Multipath channel chan.PathDelays = [0 0.9 1.5]*Tsym; % Path delay vector (s) chan.AvgPathGaindB = [0 -3 -6]; % Average path gain vector (dB) % Adaptive equalizer nWeights = 8; forgetFactor = 0.99; % RLS algorithm forgetting factor alg = rls(forgetFactor); % RLS algorithm object eqObj = lineareq(nWeights, alg, pskmodObj.Constellation); t eqObj.RefTap = 3; % Reference tap

% Equalizer objec

% Link simulation. Store BER values. BERvect = zeros(1,nBlocks); % Preallocate storage for block = 1:nBlocks, commadapteqloop; BERvect(block) = BER; end avgBER2 = mean(BERvect) % Average BER over transmission blocks
chan = ChannelType: InputSamplePeriod: DopplerSpectrum: MaxDopplerShift: PathDelays: AvgPathGaindB: NormalizePathGains: StoreHistory: StorePathGains: PathGains: 1i] ChannelFilterDelay: 4 ResetBeforeFiltering: 0 NumSamplesProcessed: 0 'Rayleigh' 2.5000e-007 [1x1 doppler.jakes] 30 [0 9.0000e-007 1.5000e-006] [0 -3 -6] 1 0 0 [-0.5947 - 0.0499i 0.9138 + 0.3942i 0.2294 + 0.303

eqObj = EqType: AlgType: nWeights: nSampPerSym: RefTap: 'Linear Equalizer' 'RLS' 8 1 3

http://www.mathworks.com/products/communications/demos.html?file=/products/demos/s... 4/13/2011

Communications System Toolbox - Adaptive Equalizer Simulation Demo

Page 4 of 6

SigConst: [1 0.0000 + 1.0000i -1.0000 + 0.0000i -0.0000 - 1. 0000i] ForgetFactor: InvCorrInit: InvCorrMatrix: Weights: WeightInputs: ResetBeforeFiltering: NumSamplesProcessed: 0.9900 0.1000 [8x8 double] [0 0 0 0 0 0 0 0] [0 0 0 0 0 0 0 0] 1 0

avgBER2 = 0.0285

Simulation 3: Decision feedback Equalization (DFE) for Frequency-selective Fading


The receiver uses a DFE with a six-tap fractionally spaced forward filter (two samples per symbol) and two feedback weights. The DFE uses the same RLS algorithm as in Simulation 2. The receive filter structure is reconstructed to account for the increased number of samples per symbol. This simulation uses the same channel object as in Simulation 2.

simName = 'Decision feedback equalization (DFE) for frequency-selective fadi ng'; % Receive filter nSamp = 2; % Two samples per symbol at equalizer input hRxFilt = fdesign.decimator(osfFilt/2, 'Square Root Raised Cosine', ... osfFilt/2, 'N,Beta', orderFilt, rolloff); hDRxFilt = design(hRxFilt); hDRxFilt.PersistentMemory = true; % Adaptive equalizer nFwdWeights = 6; % Number of feedforward equalizer weights nFbkWeights = 2; % Number of feedback filter weights eqObj = dfe(nFwdWeights, nFbkWeights, alg, pskmodObj.Constellation, nSamp); eqObj.RefTap = 3; % Reference tap for block = 1:nBlocks, commadapteqloop; BERvect(block)=BER; end avgBER3 = mean(BERvect)
chan = ChannelType: InputSamplePeriod: DopplerSpectrum: MaxDopplerShift: PathDelays: AvgPathGaindB: NormalizePathGains: StoreHistory: StorePathGains: 'Rayleigh' 2.5000e-007 [1x1 doppler.jakes] 30 [0 9.0000e-007 1.5000e-006] [0 -3 -6] 1 0 0

http://www.mathworks.com/products/communications/demos.html?file=/products/demos/s... 4/13/2011

Communications System Toolbox - Adaptive Equalizer Simulation Demo

Page 5 of 6

PathGains: [0.6437 - 0.2033i -0.1383 - 0.1031i -0.3656 - 0.28 22i] ChannelFilterDelay: 4 ResetBeforeFiltering: 0 NumSamplesProcessed: 104000

eqObj = EqType: AlgType: nWeights: nSampPerSym: RefTap: SigConst: 0000i] ForgetFactor: InvCorrInit: InvCorrMatrix: Weights: WeightInputs: ResetBeforeFiltering: NumSamplesProcessed: 0.9900 0.1000 [8x8 double] [0 0 0 0 0 0 0 0] [0 0 0 0 0 0 0 0] 1 0 'Decision Feedback Equalizer' 'RLS' [6 2] 2 3 [1 0.0000 + 1.0000i -1.0000 + 0.0000i -0.0000 - 1.

avgBER3 = 1.0000e-004

Summary
This demo showed the relative performance of linear and decision feedback equalizers in both frequency-flat and frequency-selective fading channels. It showed how a one-tap equalizer is sufficient to compensate for a frequency-flat channel, but that a frequency-selective channel requires an equalizer with multiple taps. Finally, it showed that a decision feedback equalizer is superior to a linear equalizer in a frequencyselective channel.

Appendix
This demo uses the following script and helper functions: commadapteqloop.m commadapteq_checkvars.m commadapteq_pskdetect.m

http://www.mathworks.com/products/communications/demos.html?file=/products/demos/s... 4/13/2011

Communications System Toolbox - Adaptive Equalizer Simulation Demo

Page 6 of 6

commadapteq_graphics.m

1994-2011 The MathWorks, Inc.

Site Help

Patents

Trademarks

Privacy Policy

Preventing Piracy

http://www.mathworks.com/products/communications/demos.html?file=/products/demos/s... 4/13/2011

BER Performance of Different Equalizers

file:///C:/Program%20Files/MATLAB/R2009a/toolbox/comm/commdem...

Open eqberdemo.m in the Editor

Run in the Command Window

BER Performance of Different Equalizers


This script shows the BER performance of several types of equalizers in a static channel with a null in the passband. The script constructs and implements a linear equalizer object and a decision feedback equalizer (DFE) object. It also initializes and invokes a maximum likelihood sequence estimation (MLSE) equalizer. The MLSE equalizer is first invoked with perfect channel knowledge, then with a straightforward but imperfect channel estimation technique. As the simulation progresses, it updates a BER plot for comparative analysis between the equalization methods. It also shows the signal spectra of the linearly equalized and DFE equalized signals. It also shows the relative burstiness of the errors, indicating that at low BERs, both the MLSE algorithm and the DFE algorithm suffer from error bursts. In particular, the DFE error performance is burstier with detected bits fed back than with correct bits fed back. Finally, during the "imperfect" MLSE portion of the simulation, it shows and dynamically updates the estimated channel response. To experiment with this demo, you can change such parameters as the channel impulse response, the number of equalizer tap weights, the recursive least squares (RLS) forgetting factor, the least mean square (LMS) step size, the MLSE traceback length, the error in estimated channel length, and the maximum number of errors collected at each Eb/No value. Contents Code Structure Signal and Channel Parameters Adaptive Equalizer Parameters MLSE Equalizer and Channel Estimation Parameters, and Initial Visualization Construct RLS and LMS Linear and DFE Equalizer Objects Linear Equalizer Decision Feedback Equalizer Ideal MLSE Equalizer, with Perfect Channel Knowledge MLSE Equalizer with an Imperfect Channel Estimate Code Structure This script relies on several other scripts and functions to perform link simulations over a range of Eb/No values. These files are as follows: eqber_adaptive - a script that runs link simulations for linear and DFE equalizers eqber_mlse - a script that runs link simulations for ideal and imperfect MLSE equalizers eqber_siggen - a script that generates a binary phase shift keying (BPSK) signal with no pulse shaping, then processes it through the channel and adds noise eqber_graphics - a function that generates and updates plots showing the performance of the linear, DFE, and MLSE equalizers. Type "edit eqber_graphics" at the MATLAB command line to view this file. The scripts eqber_adaptive and eqber_mlse illustrate how to use adaptive and MLSE equalizers across multiple blocks of data such that state information is retained between data blocks. Signal and Channel Parameters Set parameters related to the signal and channel. Use BPSK without any pulse shaping, and a 5-tap real-valued symmetric channel impulse response. (See section 10.2.3 of Digital Communications by J. Proakis, 4th Ed., for more details on the channel.) Set initial states of data and noise generators. Set the Eb/No range. % System simulation Fs = 1; % nBits = 2048; % maxErrs = 50; % parameters sampling frequency (notional) number of BPSK symbols per vector target number of errors at each Eb/No

1 of 10

5/5/2011 3:30 AM

BER Performance of Different Equalizers

file:///C:/Program%20Files/MATLAB/R2009a/toolbox/comm/commdem...

maxBits = 1e8;

% maximum number of symbols at each Eb/No

% Modulated signal parameters M = 2; % order of modulation Rs = Fs; % symbol rate nSamp = Fs/Rs; % samples per symbol Rb = Rs * log2(M); % bit rate dataState = 999983; % initial state of data generator % Channel parameters chnl = [0.227 0.460 0.688 chnlLen = length(chnl); EbNo = 0:14; BER = zeros(size(EbNo)); noiseState = 999917; Adaptive Equalizer Parameters Set parameter values for the linear and DFE equalizers. Use a 31-tap linear equalizer, and a DFE with 15 feedforward and feedback taps. Use the recursive least squares (RLS) algorithm for the first block of data to ensure rapid tap convergence. Use the least mean square (LMS) algorithm thereafter to ensure rapid execution speed. % Linear equalizer parameters nWts = 31; % number of weights algType1 = 'rls'; % RLS algorithm for first data block at each Eb/No forgetFactor = 0.999999; % parameter of RLS algorithm algType2 = 'lms'; % LMS algorithm for remaining data blocks stepSize = 0.00001; % parameter of LMS algorithm % DFE parameters - use same update algorithms as linear equalizer nFwdWts = 15; % number of feedforward weights nFbkWts = 15; % number of feedback weights MLSE Equalizer and Channel Estimation Parameters, and Initial Visualization Set the parameters of the MLSE equalizer. Use a traceback length of six times the length of the channel impulse response. Initialize the equalizer states. Set the equalization mode to "continuous", to enable seamless equalization over multiple blocks of data. Use a cyclic prefix in the channel estimation technique, and set the length of the prefix. Assume that the estimated length of the channel impulse response is one sample longer than the actual length. % MLSE equalizer parameters tbLen = 30; % MLSE equalizer traceback length numStates = M^(chnlLen-1); % number of trellis states [mlseMetric, mlseStates, mlseInputs] = deal([]); const = get(modem.pskmod(M), 'Constellation'); % signal constellation mlseType = 'ideal'; % perfect channel estimates at first mlseMode = 'cont'; % no MLSE resets % Channel chnlEst = prefixLen excessEst estimation parameters chnl; % perfect estimation initially = 2*chnlLen; % cyclic prefix length = 1; % length of estimated channel impulse response % beyond the true length 0.460 0.227]'; % channel impulse response % channel length, in samples % in dB % initialize values % initial state of noise generator

% Initialize the graphics for the simulation. Plot the unequalized channel % frequency response, and the BER of an ideal BPSK system. idealBER = berawgn(EbNo, 'psk', M, 'nondiff'); [hBER, hLegend, legendString, hLinSpec, hDfeSpec, hErrs, hText1, hText2,... hFit, hEstPlot, hFig, hLinFig, hDfeFig] = eqber_graphics('init', chnl, ... EbNo, idealBER, nBits);

2 of 10

5/5/2011 3:30 AM

BER Performance of Different Equalizers

file:///C:/Program%20Files/MATLAB/R2009a/toolbox/comm/commdem...

Construct RLS and LMS Linear and DFE Equalizer Objects The RLS update algorithm is used to initially set the weights, and the LMS algorithm is used thereafter for speed purposes. alg1 = eval([algType1 '(' num2str(forgetFactor) ')']); linEq1 = lineareq(nWts, alg1); alg2 = eval([algType2 '(' num2str(stepSize) ')']); linEq2 = lineareq(nWts, alg2); [linEq1.RefTap, linEq2.RefTap] = ... deal(round(nWts/2)); % Set reference tap to center tap [linEq1.ResetBeforeFiltering, linEq2.ResetBeforeFiltering] = ... deal(0); % Maintain continuity between iterations dfeEq1 = dfe(nFwdWts, nFbkWts, alg1);

3 of 10

5/5/2011 3:30 AM

BER Performance of Different Equalizers

file:///C:/Program%20Files/MATLAB/R2009a/toolbox/comm/commdem...

dfeEq2 = dfe(nFwdWts, nFbkWts, alg2); [dfeEq1.RefTap, dfeEq2.RefTap] = ... deal(round(nFwdWts/2)); % Set reference tap to center forward tap [dfeEq1.ResetBeforeFiltering, dfeEq2.ResetBeforeFiltering] = ... deal(0); % Maintain continuity between iterations Linear Equalizer Run the linear equalizer, and plot the equalized signal spectrum, the BER, and the burst error performance for each data block. Note that as the Eb/No increases, the linearly equalized signal spectrum has a progressively deeper null. This highlights the fact that a linear equalizer must have many more taps to adequately equalize a channel with a deep null. Note also that the errors occur with small inter-error intervals, which is to be expected at such a high error rate. See eqber_adaptive.m for a listing of the simulation code for the adaptive equalizers. firstRun = true; % flag to ensure known initial states for noise and data eqType = 'linear'; eqber_adaptive;

4 of 10

5/5/2011 3:30 AM

BER Performance of Different Equalizers

file:///C:/Program%20Files/MATLAB/R2009a/toolbox/comm/commdem...

Decision Feedback Equalizer Run the DFE, and plot the equalized signal spectrum, the BER, and the burst error performance for each data block. Note that the DFE is much better able to mitigate the channel null than the linear equalizer, as shown in the spectral plot and the BER plot. The plotted BER points at a given Eb/No value are updated every data block, so they move up or down depending on the number of errors collected in that block. Note also that the DFE errors are somewhat bursty, due to the error propagation caused by feeding back detected bits instead of correct bits. The burst error plot shows that as the BER decreases, a significant number of errors occurs with an inter-error arrival of five bits or less. (If the DFE equalizer were run in training mode at all times, the errors would be far less bursty.) For every data block, the plot also indicates the average inter-error interval if those errors were randomly occurring. See eqber_adaptive.m for a listing of the simulation code for the adaptive equalizers.

5 of 10

5/5/2011 3:30 AM

BER Performance of Different Equalizers

file:///C:/Program%20Files/MATLAB/R2009a/toolbox/comm/commdem...

close(hFig(ishandle(hFig))); eqType = 'dfe'; eqber_adaptive;

6 of 10

5/5/2011 3:30 AM

BER Performance of Different Equalizers

file:///C:/Program%20Files/MATLAB/R2009a/toolbox/comm/commdem...

Ideal MLSE Equalizer, with Perfect Channel Knowledge Run the MLSE equalizer with a perfect channel estimate, and plot the BER and the burst error performance for each data block. Note that the errors occur in an extremely bursty fashion. Observe, particularly at low BERs, that the overwhelming percentage of errors occur with an inter-error interval of one or two bits. See eqber_mlse.m for a listing of the simulation code for the MLSE equalizers. close(hLinFig(ishandle(hLinFig)), hDfeFig(ishandle(hDfeFig))); eqType = 'mlse'; mlseType = 'ideal'; eqber_mlse;

7 of 10

5/5/2011 3:30 AM

BER Performance of Different Equalizers

file:///C:/Program%20Files/MATLAB/R2009a/toolbox/comm/commdem...

MLSE Equalizer with an Imperfect Channel Estimate Run the MLSE equalizer with an imperfect channel estimate, and plot the BER and the burst error performance for each data block. These results align fairly closely with the ideal MLSE results. (The channel estimation algorithm is highly dependent on the data, such that an FFT of a transmitted data block has no nulls.) Note how the estimated channel plots compare with the actual channel spectrum plot. See eqber_mlse.m for a listing of the simulation code for the MLSE equalizers. mlseType = 'imperfect'; eqber_mlse;

8 of 10

5/5/2011 3:30 AM

BER Performance of Different Equalizers

file:///C:/Program%20Files/MATLAB/R2009a/toolbox/comm/commdem...

9 of 10

5/5/2011 3:30 AM

BER Performance of Different Equalizers

file:///C:/Program%20Files/MATLAB/R2009a/toolbox/comm/commdem...

Copyright 1996-2007 The MathWorks, Inc. Published with MATLAB 7.8 MATLAB and Simulink are registered trademarks of The MathWorks, Inc. Please see www.mathworks.com/trademarks for a list of other trademarks owned by The MathWorks, Inc. Other product or brand names are trademarks or registered trademarks of their respective owners.

10 of 10

5/5/2011 3:30 AM

You might also like