Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Using a suitable simulation tool, execute the Least Mean Square weight adaptation
algorithm for updating the coefficients of FIR Adaptive filter. Analyze its
performance with different values of step size.
CHANNEL EQUALIZER DESIGN USING LMS ALGORITHM
EX.NO:
DATE :
AIM:
To simulate adaptive filters for noise cancellation using MATLAB.7.0.1.
EQUIPMENTS REQUIRED:
1) Personal computer
2) MATLAB.7.0.1 software.
THEORY:
A filter with adjustable parameter is called an adaptive filter, It is used to estimate
and ultimate a noise component in desired signal. We consider the sine signal as the signal to be
estimated. The noise sequences is generated randomly v1(n) and v2(n) are the sequences and
d(n) is the desired signal. Consider the noisy signal as r(n) and r(n)=d(n)+v(n).The reference
signal v2(n) is used to estimate v1(n) using a 12th order adaptive noise canceller with coefficient
that are updated using normalized LMS Algorithm the estimate of d(n) is produced with a step
size B=0.25.
ALGORITHM:
1. Initialize the filter length,delay and adaptive filter coefficient.
2. Initialize the stepsize = 0.25
3. Generate the desired signal and the input signal that is applied to the filter.
4. Initialize the converter (counter) to zero to the length of the input signal and repeat
the following step until the counter reaches the length of the input signal.
5. Shift the data for delay.
6. Update the buffer.
7. Calculate the enhanced signal.
8. Update the weight.
9. Finally get all the waveform and plot it.
FLOW CHART:
Start
For N=0 To
Length y(n)
Next
Stop
PROGRAM:
%adaptive filtering using LMS algorithm
%X delayed input data buffer
%y measured signal
% W coefficient vector
% E enhanced signal
clear all;
N=20;
%filter length
M=0;
%delay
w0=1;
%intial value of adaptive filter coefficient
SF=2048;
%factor for reducing the data samples-11 bits ADC command
mu=0.25;
x=zeros(N,1);
delay=zeros(1,M+1);
w=w0*ones(N,1);
signal=sin(2*pi*0.055*[0:1000-1]);
noise=randn(1,1000);
nfilt=fir1(12,0.25);
%11th order pass filter
fnoise=filter(nfilt,1,noise); %correlated noise data
d=signal+fnoise;
y=d/SF;
if w0==0
sf=SF;
%scaling factor for display
else
sf=SF/N/w0;
end;
for i=1:length(y)
if M>0
delay(2:M+1)=delay(1:M);
end;
delay(1)=y(i);
x(2:N)=x(1:N-1);
x(1)=delay(M+1);
%update buffer
E(i)=signal(i)-w'*x;
%enhanced signal
w=w+2*mu*E(i)*x;
%update the wgts
end;
figure(1);
subplot(3,1,1),plot(1:length(signal),signal*sf);
title('actual length');
xlabel('->time(sec)');
ylabel('->amp(v)');
subplot(3,1,3),plot(1:length(signal),noise*sf);
title('noise signal');
xlabel('->time(sec)');
ylabel('->amp(v)');
figure(2);
subplot(3,1,1),plot(1:length(y),y*sf);
title('input signal');
xlabel('->time(sec)');
ylabel('->amp(v)');
subplot(3,1,3),plot(1:length(E),E*sf);
title('enhanced signal');
xlabel('->time(sec)');
ylabel('->amp(v)');
OUTPUT:
->amp(v)
->amp(v)
FIG 1:
FIG 2:
actual length
200
0
-200
100
200
300
400
500
600
->time(sec)
700
800
900
1000
700
800
900
1000
noise signal
500
0
-500
100
200
300
400
500
600
->time(sec)
->amp(v)
->amp(v)
input signal
0.2
0
-0.2
100
200
300
400
500
600
->time(sec)
700
800
900
1000
700
800
900
1000
enhanced signal
200
0
-200
100
200
300
400
500
600
->time(sec)
RESULT:
Thus, the adaptive filters are simulated for noise cancellation.
9.Using a suitable simulation tool, execute the Recursive Least Square weight
adaptation algorithm for updating the coefficients of FIR Adaptive filter. Analyze its
performance with different values of step size.
PROGRAM:
%FIR:
clear all
close all
hold off
%no of system pts
N=2000;
inp=randn(N,1);
n=randn(N,1);
[b,a]=butter(2,0.25);
Gz=tf(b,a,-1);
h=[b -a(2:length(a))];
%channel system order fixed as we have 5 elements (3 in a and 2 in b)
inporder=3;
outorder=2;
sysorder=inporder+outorder;
y=lsim(Gz,inp);
%add some noise
n=n*std(y)/(15*std(n));
d=y+n;
totallength=size(d,1);
%take only 50 pts for training(N-inorder47=50-3)
N=50;
%begin of the alg
%forgetting factor
lambda=0.999;
%initial P matrix
delta=1e2;
P=delta*eye(sysorder);
w=zeros(sysorder,1);
for n=inporder:N
u=inp(n:-1:n-inporder+1);
outp=d(n-1:-1:n-outorder);
u=[u;outp];
phi=u'*P;
k=phi'/(lambda+phi*u);
y(n)=w'*u;
e(n)=d(n)-y(n);
w=w+k*e(n);
P=(P-k*phi)/lambda;
%just for plotting
Recordedw(1:sysorder,n)=w;
end
%check for results
for n=N+1:totallength
u=inp(n:-1:n-inporder+1);
outp=d(n-1:-1:n-outorder);
u=[u;outp];
y(n)=w'*u;
e(n)=d(n)-y(n);
end
hold on
plot(d)
plot(y,'r');
title('System output');
xlabel('samples');
ylabel('True and estimated output');
figure
semilogy((abs(e)));
title('Error curve');
xlabel('samples');
ylabel('Error value');
figure
plot(h,'r+');
hold on
plot(w,'.');
legend('Filter weights','Estimated filter weights',4);
title('Comparison of the filter weights and estimated weights');
figure
plot(Recordedw(1:sysorder,sysorder:N)');
title('Estimated weights convergence');
xlabel('Samples');
ylabel('Weights value');
axis([1 N-sysorder min(min(Recordedw(1:sysorder,sysorder:N)'))
max(max(Recordedw(1:sysorder,sysorder:N)'))]);
hold off
OUTPUT:
FIG1:
System output
2.5
2
1.5
1
0.5
0
-0.5
-1
-1.5
-2
200
400
600
800
1000 1200
samples
1400
1600
1800
2000
1800
2000
FIG2:
Error curve
10
-1
10
Error value
-2
10
1
-3
10
0.8
0.6
-4
10
0.4
-5
10
0.2 0
FIG 3:
200
400
600
800
1000 1200
samples
1400
1600
0
-0.2
-0.4
Filter weights
Estimated filter weights
1
1.5
2.5
3.5
4.5
FIG 4:
Estimated weights convergence
1
0.8
Weights value
0.6
0.4
0.2
0
-0.2
-0.4
10
15
20
25
30
Samples
35
40
45
50
RESULT:
Thus, the adaptive filters are simulated for noise cancellation
10.Analyze the BER performance of Direct Sequence spread spectrum CDMA system
The independence of the code distinguishes this from standard modulation schemes in which
the data modulation will always spread the spectrum somewhat.
3. The receiver synchronizes to the code to recover the data. The use of an independent code and
synchronous reception allows multiple users to access the same frequency band at the same time.
In order to protect the signal, the code used is pseudo-random. It appears random, but is actually
deterministic, so that the receiver can reconstruct the code for synchronous detection. This
pseudo-random code is also called pseudo-noise (PN).
DIRECT SEQUENCE SPREAD SPECTRUM:
CDMA is a Direct Sequence Spread Spectrum system. The CDMA system works directly
on 64 Kbit/sec digital signals. These signals can be digitized voice, ISDN channels, modem data,
etc.
Signal transmission consists of the following steps:
1. A pseudo-random code is generated, different for each channel and each successive
connection.
2. The Information data modulates the pseudo-random code (the Information data is spread).
3. The resulting signal modulates a carrier.
4. The modulated carrier is amplified and broadcast.
Signal reception consists of the following steps:
1. The carrier is received and amplified.
2. The received signal is mixed with a local carrier to recover the spread digital signal.
3. A pseudo-random code is generated, matching the anticipated signal.
4. The receiver acquires the received code and phase locks its own code to it.
5. The received signal is correlated with the generated code, extracting the Information data.
Advantages:
Improved call quality, with better and more consistent sound as compared to AMPS
systems
Simplified system planning through the use of the same frequency in every sector of
every cell
Enhanced privacy
Block Diagram:
Transmitter:
User1 spreading
code generation
(Orthogonal/Non
orthogonal/mixe
d codes)
Random
Data
generatio
n User1
Random
Data
generatio
n User2
QAM
Modulatio
n
Up
sampl
e
QAM
Modulatio
n
User2
Spreading
code
generation
(Orthogonal/N
o
orthogonal/mix
ed codes)
Receiver:
WindowT
Tx
Interfac
e
Down
sampl
e
Despread
User1
data
De-spread
User 2 Data
User 1
Data
User 2
Data
PROCEDURE:
QAM
Demo
d
QAM
Demod
BER
calculatio
n
BER
Calculatio
n
OUTPUT:
RESULT:
Thus the performance evaluation of Direct sequence spread spectrum CDMA system was
simulated using WICOMMT and its output was verified.
12. Using MATLAB simulink tool, simulate the OFDM transmitter model and plot the
necessary waveforms.
DESIGN PROCEDURE:
1) First, the N input complex symbols are padded with zeros to get Ns symbols that are
used to calculate the IFFT. The output of the IFFT is the basic OFDM symbol
2) Based on the delay spread of the multipath channel, a specific guard time must be
chosen (say Tg ) . Number of samples corresponding to this guard time must be taken
from the beginning of the OFDM symbol and appended at the end of the symbol.
Likewise, the same number of samples must be taken from the end of the OFDM
symbol and must be inserted at the beginning.
3) The OFDM symbol must be multiplied with the raised cosine window to remove the
power of the outofband subcarriers.
4) The windowed OFDM symbol is then added to the output of the previous OFDM
symbol with a delay of Tr, so that there is an overlap region of r Tb between each
symbol
The following are the most important design parameters of an OFDM system design
Bandwidth available.
In
Serial to
Parallel
IFFT`
Parallel to
Serial
Out
PROGRAM:
TRANSMITTER PROGRAM:
clear all;
close all;
clc;
%=================================================================
% OFDM System Parameters
N
= 64;
= 16;
numOfZeros = N/4+1;
% Implementations.
GI
BW
= 1/4;
= 20;
numOfSym
= 128;
EbNo = [0:20];
den = 1;
num = ones(16,1)/16;
%============================================================
% Main Program
%==============================================================
% data generation
randint txData = randint(N-numOfZeros,numOfSym,M,0);
% QAM modulation
txDataMod = qammod(txData,M);
mean(abs(txDataMod(:,2)).^2);
% zeros padding
txDataZpad =[txDataMod((N-numOfZeros+1)/2:end,:);...
zeros(numOfZeros,numOfSym);...
txDataMod(1:(N-numOfZeros-1)/2,:)];
% Note : in practice zero padding operation must be followed by a standard. Usually the
% last part of data frame shifts to the first part of zero padded frame.
%============================================================
% IFFT
txDataZpadIfft = sqrt(N)*ifft(txDataZpad,N);
%==============================================================
% Apply windowing function to each time domain waveform
for i = 1:64
txDataZpadIfft1(i,:) = txDataZpadIfft(i,:);
end
% Guard Interval Insertion
txDataZpadIfftGI =[txDataZpadIfft1((1-GI)*N+1:end,:);txDataZpadIfft];
OUTPUT:
10
OFDM
THEORY
-1
BER
10
-2
10
-3
10
-4
10
6
8
EbNo (dB)
10
12
14
RESULT:
Thus OFDM Transmitter Model was implemented by Matlab7.0 and its Output and BER
performance is plotted successfully
DESIGN PROCEDURE:
5) First, the N input complex symbols are padded with zeros to get Ns symbols that are
used to calculate the IFFT. The output of the IFFT is the basic OFDM symbol
6) Based on the delay spread of the multipath channel, a specific guard time must be
chosen (say Tg ) . Number of samples corresponding to this guard time must be taken
from the beginning of the OFDM symbol and appended at the end of the symbol.
Likewise, the same number of samples must be taken from the end of the OFDM
symbol and must be inserted at the beginning.
7) The OFDM symbol must be multiplied with the raised cosine window to remove the
power of the outofband subcarriers.
8) The windowed OFDM symbol is then added to the output of the previous OFDM
symbol with a delay of Tr, so that there is an overlap region of r Tb between each
symbol
The following are the most important design parameters of an OFDM system design
Bandwidth available.
In
Out
Serial to
Parallel
FFT`
Parallel to
Serial
PROGRAM:
RECEIVER PROGRAM:
% Guard Interval removal
rxDataZpadIfft = txDataZpadIfftGI(GI*N+1 :N+GI*N,:);
%==========================================================
% FFT operation
rxDataZpad
= 1/sqrt(N)*fft(rxDataZpadIfft,N);
%==============================================================
% zero removal and rearrangement
rxDataMod
=[rxDataZpad((N-(N-numOfZeros-1)/2+1):N,:);...
rxDataZpad(1:(N-numOfZeros+1)/2,:)];
%==============================================================
% Demodulation
rxData =qamdemod(rxDataMod*sqrt(10),M);
%Received Data
qamdemod(rxDataMod/mean(std(rxDataMod))*mean(std(txDataMod)),M);
%=============================================================
txDataZpadIfftGI1 = reshape(txDataMod,1,6016);
% you cannot use txDataZpadIfftGI or txDataSig those are zero paded and ifft/fft
%formed so you care only about qam modulated data whixh is txDataMod
rxDataMod1 = reshape(rxDataMod,1,6016);
ber1 =semianalytic(txDataZpadIfftGI1,rxDataMod1,'qam',M,numOfSym*12,EbNo);
%increase the sampling to be sufficient
% no need for num,den because it wouldnot work here
bertheory = berawgn(EbNo,'qam',M);
%=========================================================
figure(1)
semilogy(EbNo,ber1,'-b'); grid on; hold on;
semilogy(EbNo,bertheory,'-m');
title('BER for OFDM, and Theory');
axis([0 14 0.0001 1]);
xlabel('EbNo (dB)'); ylabel('BER');
legend('OFDM','THEORY');
hold off;
%==============================================================
OUTPUT:
10
OFDM
THEORY
-1
BER
10
-2
10
-3
10
-4
10
6
8
EbNo (dB)
10
12
14
RESULT:
Thus OFDM Transceiver Model was implemented by Matlab7.0 and its Output and BER
performance is plotted successfully
DESIGN PROCEDURE:
9) First, the N input complex symbols are padded with zeros to get Ns symbols that are
used to calculate the IFFT. The output of the IFFT is the basic OFDM symbol
10) Based on the delay spread of the multipath channel, a specific guard time must be
chosen (say Tg ) . Number of samples corresponding to this guard time must be taken
from the beginning of the OFDM symbol and appended at the end of the symbol.
Likewise, the same number of samples must be taken from the end of the OFDM
symbol and must be inserted at the beginning.
11) The OFDM symbol must be multiplied with the raised cosine window to remove the
power of the outofband subcarriers.
12) The windowed OFDM symbol is then added to the output of the previous OFDM
symbol with a delay of Tr, so that there is an overlap region of r Tb between each
symbol
The following are the most important design parameters of an OFDM system design
Bandwidth available.
PROGRAM:
TRANSMITTER PROGRAM:
clear all;
close all;
clc;
%=================================================================
% OFDM System Parameters
N
= 64;
= 16;
numOfZeros = N/4+1;
% Implementations.
GI
BW
= 1/4;
= 20;
numOfSym
= 128;
EbNo = [0:20];
den = 1;
num = ones(16,1)/16;
%============================================================
% Main Program
%==============================================================
% data generation
randint txData = randint(N-numOfZeros,numOfSym,M,0);
% QAM modulation
txDataMod = qammod(txData,M);
mean(abs(txDataMod(:,2)).^2);
% zeros padding
txDataZpad =[txDataMod((N-numOfZeros+1)/2:end,:);...
zeros(numOfZeros,numOfSym);...
txDataMod(1:(N-numOfZeros-1)/2,:)];
% Note : in practice zero padding operation must be followed by a standard. Usually the
% last part of data frame shifts to the first part of zero padded frame.
%============================================================
% IFFT
txDataZpadIfft = sqrt(N)*ifft(txDataZpad,N);
%==============================================================
% Apply windowing function to each time domain waveform
for i = 1:64
txDataZpadIfft1(i,:) = txDataZpadIfft(i,:);
end
% Guard Interval Insertion
txDataZpadIfftGI =[txDataZpadIfft1((1-GI)*N+1:end,:);txDataZpadIfft];
RECEIVER PROGRAM:
% Guard Interval removal
rxDataZpadIfft = txDataZpadIfftGI(GI*N+1 :N+GI*N,:);
%==========================================================
% FFT operation
rxDataZpad
= 1/sqrt(N)*fft(rxDataZpadIfft,N);
%==============================================================
% zero removal and rearrangement
rxDataMod
=[rxDataZpad((N-(N-numOfZeros-1)/2+1):N,:);...
rxDataZpad(1:(N-numOfZeros+1)/2,:)];
%==============================================================
% Demodulation
rxData =qamdemod(rxDataMod*sqrt(10),M);
%Received Data
qamdemod(rxDataMod/mean(std(rxDataMod))*mean(std(txDataMod)),M);
%=============================================================
txDataZpadIfftGI1 = reshape(txDataMod,1,6016);
% you cannot use txDataZpadIfftGI or txDataSig those are zero paded and ifft/fft
%formed so you care only about qam modulated data whixh is txDataMod
rxDataMod1 = reshape(rxDataMod,1,6016);
ber1 =semianalytic(txDataZpadIfftGI1,rxDataMod1,'qam',M,numOfSym*12,EbNo);
%increase the sampling to be sufficient
% no need for num,den because it wouldnot work here
bertheory = berawgn(EbNo,'qam',M);
%=========================================================
figure(1)
semilogy(EbNo,ber1,'-b'); grid on; hold on;
semilogy(EbNo,bertheory,'-m');
title('BER for OFDM, and Theory');
axis([0 14 0.0001 1]);
xlabel('EbNo (dB)'); ylabel('BER');
legend('OFDM','THEORY');
hold off;
%==============================================================
OUTPUT:
10
OFDM
THEORY
-1
BER
10
-2
10
-3
10
-4
10
6
8
EbNo (dB)
10
12
14
RESULT:
Thus OFDM Transceiver Model was implemented by Matlab7.0 and its Output and BER
performance is plotted successfully
The radiating patches may square, rectangular, circular, and elliptical or any other configuration.
Square, rectangular, and circular shapes are the most common because of ease of analysis and
fabrication .Some of the advantages of the microstrip antennas compared to convectional
microwave antennas are
1) Low weight, low volume,
2) Low fabrication cost,
3) Easy mass production,
4) Linear and circular polarization is possible with simple feed,
5) Easily integrated with MIC,
6) Feed
lines
and
matching
networks
can
be
fabricated
simultaneously
with
antenna structure.
Patch antennas find a variety of application starting from military to commercial, because
of there ease of design and fabrication. Patch arrays are
Extensively used in phased array radar application and in applications requiring high directivity
and narrow beam width.
DESIGN:
1) Select an appropriate substrate of thickness (h) and dielectric constant ( ) for the design of
the patch antenna.
2) Calculate the physical parameters of the patch antenna as shown in the geometry in fig 2
using the given formula.
patch is given by
Go to the EM >> Simulation setup and click on the substrate. Now click new to accept
the 25 mil Alumina template. Define the substrate as below, modify the default substrate
height, dielectric constant, TanD and conductor height and define it as copper by click on
technology >> Material definitions ( select it from add from data base list).
Changing the name of the dielectric is optional as it has no bearing on the simulation.
Click on cond and change it intrude into substrate and enter the height as 35 micron.
In EM >> Simulation setup >>frequency plan, set the simulation frequency range as
2.1GHz
to
2.7
Click on S Parameter >>simulate, observe the simulation results in the data display.
For far field antenna pattern, EM >> post processing>> far field, and select the desired
frequency 2.4 GHz , impedance real- 50 ohm and click on apply and compute.
\
For far field computation will be done and results will be displayed in post processing
window.
We can use window >> tile and go to plot properties (from the bottom tabs) and then
select far field cut.
We can use window >> tile and go to plot properties (from the bottom tabs) and then
select far field >> antenna parameters >> ok >> Display antenna parameters to see
the required data.
RESULT:
Thus Microstrip Patch Antenna parameters were simulated and estimated successfully.