Escolar Documentos
Profissional Documentos
Cultura Documentos
Page 1 of 6
Solutions
Academia
Support
User Community
Company
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
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
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.)
% 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
Page 3 of 6
NumSamplesProcessed: 0
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
http://www.mathworks.com/products/communications/demos.html?file=/products/demos/s... 4/13/2011
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
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
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
Page 6 of 6
commadapteq_graphics.m
Site Help
Patents
Trademarks
Privacy Policy
Preventing Piracy
http://www.mathworks.com/products/communications/demos.html?file=/products/demos/s... 4/13/2011
file:///C:/Program%20Files/MATLAB/R2009a/toolbox/comm/commdem...
1 of 10
5/5/2011 3:30 AM
file:///C:/Program%20Files/MATLAB/R2009a/toolbox/comm/commdem...
maxBits = 1e8;
% 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
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
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
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
file:///C:/Program%20Files/MATLAB/R2009a/toolbox/comm/commdem...
6 of 10
5/5/2011 3:30 AM
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
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
file:///C:/Program%20Files/MATLAB/R2009a/toolbox/comm/commdem...
9 of 10
5/5/2011 3:30 AM
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