This action might not be possible to undo. Are you sure you want to continue?

# 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

interpolator(osfFilt. you can set the ResetBeforeFiltering property of the equalizer object to 0. rolloff).Constellation). For this channel.mathworks. end % Run link simulation in a loop chan = ChannelType: InputSamplePeriod: DopplerSpectrum: MaxDopplerShift: PathDelays: AvgPathGaindB: NormalizePathGains: StoreHistory: StorePathGains: PathGains: ChannelFilterDelay: ResetBeforeFiltering: NumSamplesProcessed: 'Rayleigh' 2. The script commadapteqloop.) simName = 'Linear equalization for frequency-flat fading'. 4/13/2011 .html?file=/products/demos/s.. 'N.m displays the initial properties of the channel and equalizer objects.6486 . (The HTML version of this demo shows the last state of the visualizations. Each run corresponds to a transmission block.. In the "Weights" plot.m runs multiple times. % Maximum Doppler shift (Hz) chan = rayleighchan(Tsamp. pskmodObj. 'Square Root Raised Cosine'.jakes] 30 0 0 1 0 0 -0. osfFilt.Beta'.ResetBeforeFiltering = 0. % Signal-to-noise ratio per sample (dB) Simulation 1: Linear Equalization for Frequency-flat Fading Begin with single-path. which implements automatic gain and phase control. . hDRxFilt. The red circles in the signal constellation plots correspond to symbol errors. hDTxFilt. the receiver uses a simple 1-tap LMS (least mean square) equalizer. % Used to label % Multipath channel fd = 30. commadapteqloop. % Ratio of symbol energy to noise power spectral density (dB) snrdB = EsNodB . EsNodB = 20. hRxFilt = fdesign. orderFilt. t % Equalizer objec % Link simulation nBlocks = 50.. (To retain state from one block to the next.0000 . frequency-flat fading. . alg. http://www. % Single weight stepSize = 0.1000 1 0 0 1 'Linear Equalizer' 'LMS' 1 1 1 [1 0. a MATLAB figure shows signal processing visualizations.. fd).0000 + 1. commadapteqloop. % Number of transmission blocks in simulation for block = 1:nBlocks.. orderFilt.com/products/communications/demos.1.Beta'. % Adaptive algorithm object eqObj = lineareq(nWeights. chan. rolloff). 'Square Root Raised Cosine'. blue and magenta lines correspond to real and imaginary parts.) Before the first run..10*log10(osfFilt).0.PersistentMemory = true. respectively.0000i -0. figure window. osfFilt. hDTxFilt = design(hTxFilt). For each run. % Step size for LMS algorithm alg = lms(stepSize). % Allow state retention across blocks.PersistentMemory = true.decimator(osfFilt.Adaptive Equalizer Simulation Demo Page 2 of 6 hTxFilt = fdesign.0000 + 0. Additive White Gaussian Noise Set signal-to-noise ratio parameter for additive white Gaussian noise. % Create channel object.1. 'N.0000i -1. hDRxFilt = design(hRxFilt).5000e-007 [1x1 doppler. % Adaptive equalizer nWeights = 1.Communications System Toolbox .9202i 0 0 0 eqObj = EqType: AlgType: nWeights: nSampPerSym: RefTap: SigConst: 0000i] StepSize: LeakageFactor: Weights: WeightInputs: ResetBeforeFiltering: 0. The equalizer resets its state and weight every transmission block.

99.0499i 0. pskmodObj.0000e-007 1.9138 + 0.303 eqObj = EqType: AlgType: nWeights: nSampPerSym: RefTap: 'Linear Equalizer' 'RLS' 8 1 3 http://www. simName = 'Linear equalization for frequency-selective fading'. % RLS algorithm object eqObj = lineareq(nWeights.RefTap = 3.3942i 0. but with modified properties.PathDelays = [0 0. alg.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). % Reference tap % Equalizer objec % Link simulation.AvgPathGaindB = [0 -3 -6]. % RLS algorithm forgetting factor alg = rls(forgetFactor). The simulation uses the channel object from Simulation 1..com/products/communications/demos. % Preallocate storage for block = 1:nBlocks.5947 . 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.2294 + 0.. % Average path gain vector (dB) % Adaptive equalizer nWeights = 8. Store BER values.5000e-007 [1x1 doppler. BERvect(block) = BER. 4/13/2011 .5]*Tsym.mathworks.0. commadapteqloop.Constellation). % Path delay vector (s) chan.jakes] 30 [0 9.9 1. forgetFactor = 0. BERvect = zeros(1.html?file=/products/demos/s. % Multipath channel chan. The receiver uses an 8-tap linear RLS (recursive least squares) equalizer with symbol-spaced taps.5000e-006] [0 -3 -6] 1 0 0 [-0.Communications System Toolbox .nBlocks). t eqObj.

9900 0. % Two samples per symbol at equalizer input hRxFilt = fdesign.5000e-006] [0 -3 -6] 1 0 0 http://www.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. 'N. rolloff). nFbkWeights. end avgBER3 = mean(BERvect) chan = ChannelType: InputSamplePeriod: DopplerSpectrum: MaxDopplerShift: PathDelays: AvgPathGaindB: NormalizePathGains: StoreHistory: StorePathGains: 'Rayleigh' 2. % Reference tap for block = 1:nBlocks.PersistentMemory = true. % Adaptive equalizer nFwdWeights = 6. orderFilt. BERvect(block)=BER.jakes] 30 [0 9.0000 . % Number of feedback filter weights eqObj = dfe(nFwdWeights. % Number of feedforward equalizer weights nFbkWeights = 2. 0000i] ForgetFactor: InvCorrInit: InvCorrMatrix: Weights: WeightInputs: ResetBeforeFiltering: NumSamplesProcessed: 0.html?file=/products/demos/s.Communications System Toolbox .. . hDRxFilt.Beta'.1. alg.com/products/communications/demos. 4/13/2011 .mathworks. The DFE uses the same RLS algorithm as in Simulation 2...0000i -0. commadapteqloop.. eqObj. pskmodObj.5000e-007 [1x1 doppler. hDRxFilt = design(hRxFilt).0000i -1.RefTap = 3. simName = 'Decision feedback equalization (DFE) for frequency-selective fadi ng'.0000 + 0.1000 [8x8 double] [0 0 0 0 0 0 0 0] [0 0 0 0 0 0 0 0] 1 0 avgBER2 = 0.0000 + 1. 'Square Root Raised Cosine'.Constellation. The receive filter structure is reconstructed to account for the increased number of samples per symbol.Adaptive Equalizer Simulation Demo Page 4 of 6 SigConst: [1 0. nSamp). % Receive filter nSamp = 2. osfFilt/2.0000e-007 1.decimator(osfFilt/2. This simulation uses the same channel object as in Simulation 2.

com/products/communications/demos.0.0.0000e-004 Summary This demo showed the relative performance of linear and decision feedback equalizers in both frequency-flat and frequency-selective fading channels.1383 .3656 .0000 .0000i -1.m http://www.2033i -0. but that a frequency-selective channel requires an equalizer with multiple taps. 4/13/2011 ..m commadapteq_checkvars.0000 + 0.Adaptive Equalizer Simulation Demo Page 5 of 6 PathGains: [0.1.Communications System Toolbox .0000i -0.0.html?file=/products/demos/s.mathworks. It showed how a one-tap equalizer is sufficient to compensate for a frequency-flat channel. 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. avgBER3 = 1. Finally.28 22i] ChannelFilterDelay: 4 ResetBeforeFiltering: 0 NumSamplesProcessed: 104000 eqObj = EqType: AlgType: nWeights: nSampPerSym: RefTap: SigConst: 0000i] ForgetFactor: InvCorrInit: InvCorrMatrix: Weights: WeightInputs: ResetBeforeFiltering: NumSamplesProcessed: 0.0000 + 1.1031i -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.m commadapteq_pskdetect..6437 .9900 0.

.Adaptive Equalizer Simulation Demo Page 6 of 6 commadapteq_graphics..m © 1994-2011 The MathWorks.mathworks. Site Help Patents Trademarks Privacy Policy Preventing Piracy http://www. Inc. 4/13/2011 .com/products/communications/demos.Communications System Toolbox .html?file=/products/demos/s.

a script that runs link simulations for ideal and imperfect MLSE equalizers eqber_siggen . Type "edit eqber_graphics" at the MATLAB® command line to view this file. (See section 10. 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.a function that generates and updates plots showing the performance of the linear. 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. the MLSE traceback length. % nBits = 2048. Finally. Proakis. then processes it through the channel and adds noise eqber_graphics . the error in estimated channel length. the number of equalizer tap weights. Use BPSK without any pulse shaping. indicating that at low BERs. Contents Code Structure Signal and Channel Parameters Adaptive Equalizer Parameters MLSE Equalizer and Channel Estimation Parameters. % System simulation Fs = 1.a script that generates a binary phase shift keying (BPSK) signal with no pulse shaping.) Set initial states of data and noise generators. and Initial Visualization Construct RLS and LMS Linear and DFE Equalizer Objects Linear Equalizer Decision Feedback Equalizer Ideal MLSE Equalizer. for more details on the channel.. it shows and dynamically updates the estimated channel response. and a 5-tap real-valued symmetric channel impulse response. and MLSE equalizers. it updates a BER plot for comparative analysis between the equalization methods. DFE.. you can change such parameters as the channel impulse response.. It also shows the relative burstiness of the errors. 4th Ed.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.2. Open eqberdemo. As the simulation progresses. It also initializes and invokes a maximum likelihood sequence estimation (MLSE) equalizer.3 of Digital Communications by J. It also shows the signal spectra of the linearly equalized and DFE equalized signals. % 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 . The MLSE equalizer is first invoked with perfect channel knowledge. the DFE error performance is burstier with detected bits fed back than with correct bits fed back. then with a straightforward but imperfect channel estimation technique. the least mean square (LMS) step size. To experiment with this demo. % maxErrs = 50. during the "imperfect" MLSE portion of the simulation. The script constructs and implements a linear equalizer object and a decision feedback equalizer (DFE) object. and the maximum number of errors collected at each Eb/No value. both the MLSE algorithm and the DFE algorithm suffer from error bursts.a script that runs link simulations for linear and DFE equalizers eqber_mlse . In particular. Signal and Channel Parameters Set parameters related to the signal and channel. the recursive least squares (RLS) forgetting factor. These files are as follows: eqber_adaptive . Set the Eb/No range.BER Performance of Different Equalizers file:///C:/Program%20Files/MATLAB/R2009a/toolbox/comm/commdem.

460 0. const = get(modem. Initialize the equalizer states. idealBER = berawgn(EbNo. % cyclic prefix length = 1. mlseInputs] = deal([]). idealBER...227 0. % number of trellis states [mlseMetric. hDfeFig] = eqber_graphics('init'. hText2. hLinFig. Use the least mean square (LMS) algorithm thereafter to ensure rapid execution speed. % parameter of LMS algorithm % DFE parameters . . hLinSpec. legendString. in samples % in dB % initialize values % initial state of noise generator % Initialize the graphics for the simulation. Use the recursive least squares (RLS) algorithm for the first block of data to ensure rapid tap convergence.688 chnlLen = length(chnl). Use a traceback length of six times the length of the channel impulse response. 'psk'. % number of feedback weights MLSE Equalizer and Channel Estimation Parameters.use same update algorithms as linear equalizer nFwdWts = 15. hEstPlot.00001. % parameter of RLS algorithm algType2 = 'lms'.460 0. % signal constellation mlseType = 'ideal'.227]'.BER Performance of Different Equalizers file:///C:/Program%20Files/MATLAB/R2009a/toolbox/comm/commdem. and the BER of an ideal BPSK system.pskmod(M). % bit rate dataState = 999983. % channel impulse response % channel length.. EbNo. BER = zeros(size(EbNo)). and a DFE with 15 feedforward and feedback taps. % perfect channel estimates at first mlseMode = 'cont'. hFit. % no MLSE resets % Channel chnlEst = prefixLen excessEst estimation parameters chnl. noiseState = 999917. [hBER. EbNo = 0:14. M. % RLS algorithm for first data block at each Eb/No forgetFactor = 0.. chnl. nBits). % Linear equalizer parameters nWts = 31. to enable seamless equalization over multiple blocks of data. 2 of 10 5/5/2011 3:30 AM . and Initial Visualization Set the parameters of the MLSE equalizer.. Adaptive Equalizer Parameters Set parameter values for the linear and DFE equalizers. % MLSE equalizer traceback length numStates = M^(chnlLen-1).. 'nondiff'). % initial state of data generator % Channel parameters chnl = [0. % perfect estimation initially = 2*chnlLen. Use a cyclic prefix in the channel estimation technique. hFig. mlseStates. Plot the unequalized channel % frequency response. % length of estimated channel impulse response % beyond the true length 0. hText1. hDfeSpec. hLegend. % number of weights algType1 = 'rls'. % order of modulation Rs = Fs. % maximum number of symbols at each Eb/No % Modulated signal parameters M = 2. % samples per symbol Rb = Rs * log2(M). % symbol rate nSamp = Fs/Rs. maxBits = 1e8. 'Constellation'). Use a 31-tap linear equalizer. % LMS algorithm for remaining data blocks stepSize = 0. % number of feedforward weights nFbkWts = 15. and set the length of the prefix. hErrs. Assume that the estimated length of the channel impulse response is one sample longer than the actual length. Set the equalization mode to "continuous".999999. % MLSE equalizer parameters tbLen = 30..

3 of 10 5/5/2011 3:30 AM .. alg1 = eval([algType1 '(' num2str(forgetFactor) ')']). alg2). [linEq1.. alg1). linEq2. nFbkWts.RefTap] = ...BER Performance of Different Equalizers file:///C:/Program%20Files/MATLAB/R2009a/toolbox/comm/commdem.RefTap.ResetBeforeFiltering. deal(round(nWts/2)). alg1).. deal(0).. and the LMS algorithm is used thereafter for speed purposes. linEq2. Construct RLS and LMS Linear and DFE Equalizer Objects The RLS update algorithm is used to initially set the weights. % Set reference tap to center tap [linEq1. alg2 = eval([algType2 '(' num2str(stepSize) ')']). linEq2 = lineareq(nWts.ResetBeforeFiltering] = . linEq1 = lineareq(nWts. % Maintain continuity between iterations dfeEq1 = dfe(nFwdWts.

% flag to ensure known initial states for noise and data eqType = 'linear'.m for a listing of the simulation code for the adaptive equalizers. dfeEq2. eqber_adaptive... deal(0). which is to be expected at such a high error rate. 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.. [dfeEq1.ResetBeforeFiltering] = . deal(round(nFwdWts/2)). 4 of 10 5/5/2011 3:30 AM .ResetBeforeFiltering. dfeEq2 = dfe(nFwdWts. and plot the equalized signal spectrum. % Set reference tap to center forward tap [dfeEq1. dfeEq2. Note that as the Eb/No increases.RefTap] = . and the burst error performance for each data block..BER Performance of Different Equalizers file:///C:/Program%20Files/MATLAB/R2009a/toolbox/comm/commdem.. the linearly equalized signal spectrum has a progressively deeper null. See eqber_adaptive. the BER. firstRun = true. alg2)..RefTap. % Maintain continuity between iterations Linear Equalizer Run the linear equalizer. nFbkWts.

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

eqber_adaptive.BER Performance of Different Equalizers file:///C:/Program%20Files/MATLAB/R2009a/toolbox/comm/commdem. 6 of 10 5/5/2011 3:30 AM . close(hFig(ishandle(hFig)))... eqType = 'dfe'.

Ideal MLSE Equalizer. with Perfect Channel Knowledge Run the MLSE equalizer with a perfect channel estimate.. Note that the errors occur in an extremely bursty fashion. eqType = 'mlse'. hDfeFig(ishandle(hDfeFig))). and plot the BER and the burst error performance for each data block.BER Performance of Different Equalizers file:///C:/Program%20Files/MATLAB/R2009a/toolbox/comm/commdem. mlseType = 'ideal'. 7 of 10 5/5/2011 3:30 AM . See eqber_mlse. close(hLinFig(ishandle(hLinFig)). Observe.. eqber_mlse.m for a listing of the simulation code for the MLSE equalizers. that the overwhelming percentage of errors occur with an inter-error interval of one or two bits. particularly at low BERs.

. See eqber_mlse. mlseType = 'imperfect'. and plot the BER and the burst error performance for each data block. 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. MLSE Equalizer with an Imperfect Channel Estimate Run the MLSE equalizer with an imperfect channel estimate.. eqber_mlse.m for a listing of the simulation code for the MLSE equalizers.BER Performance of Different Equalizers file:///C:/Program%20Files/MATLAB/R2009a/toolbox/comm/commdem. (The channel estimation algorithm is highly dependent on the data. These results align fairly closely with the ideal MLSE results. 8 of 10 5/5/2011 3:30 AM .

. 9 of 10 5/5/2011 3:30 AM .BER Performance of Different Equalizers file:///C:/Program%20Files/MATLAB/R2009a/toolbox/comm/commdem..

8 MATLAB and Simulink are registered trademarks of The MathWorks. Copyright 1996-2007 The MathWorks. Inc. 10 of 10 5/5/2011 3:30 AM .mathworks.com/trademarks for a list of other trademarks owned by The MathWorks.BER Performance of Different Equalizers file:///C:/Program%20Files/MATLAB/R2009a/toolbox/comm/commdem. Inc.. Published with MATLAB® 7. Please see www. Other product or brand names are trademarks or registered trademarks of their respective owners.. Inc.