CSP Lab Manual 25.2.16
CSP Lab Manual 25.2.16
CSP Lab Manual 25.2.16
Page No: 1
Page No: 2
model:-
Jakes
popularized a model for Rayleigh fading based on summing sinusoids. Let the
scatterers be uniformly distributed around a circle at angles n with k rays emerging
from each scatterer. The Doppler shift on ray n is and, with M such scatterers, the
Rayleigh fading of the kth waveform over time t can be modeled as: .
Here, and the and are model parameters with usually set to zero, chosen so that
there is no cross-correlation between the real and imaginary parts of R(t): and used
to generate multiple waveforms. If a single-path channel is being modeled, so that
there is only one waveform then can be zero. If a multipath, frequency-selective
channel is being modeled so that multiple waveforms are needed, Jakes suggests that
uncorrelated waveforms are given by: .
In fact, it has been shown that the waveforms are correlated among themselves
they have non-zero cross-correlation except in special circumstances. The
model is also deterministic (it has no random element to it once the parameters are
chosen). A modified Jakes' model chooses slightly different spacing for the scatterers
and scales their waveforms using Walsh-Hadamard sequences to ensure zero crosscorrelation. Setting
And, Results in the following model, usually termed the Dent model or the modified
Jakes model:
Page No: 3
Page No: 4
Page No: 5
Developed
spectrum analysis for Clarkes model. Let P ()d denote the function of the total
incoming power with in d of the angle and let A denote the average received
power with respect to an isotropic antenna . As N, P () d approaches a
continuous, rather than a discrete ,distribution . If G ( ) is the azimuthal gain
pattern of the mobile antenna as a function of the angle of arrival, the received
power can be expressed as
Pr=A G( ) P()d
The spectrum is centred on the carrier frequency and is zero outside the limits
of
fcfm. Each of the arriving waves has its own carrier frequency (due to its
direction of arrival) which is slightly offset from the center frequency .For the case
of a vertical /4 antenna (G( )=1.5) and a uniform distribution P()=1/2 over 0 to
2 output spectrum is given by
SE (f)=
+ve
Sqrt (sE(f)).
Perform an IFFT on the resulting frequency domain signals from the in phase
and quadrature arms to get two N-length time series, and add the squares of
each signal point in time to create an N-point time series like under the radical
of equation
|E2(t)|=
=r(t)
Page No: 6
Take the square root of the sum obtained in step6 to obtain an N-point time
series of a simulated Rayleigh fading signal with the power Doppler spread and
time correlation.
Page No: 7
Result:Rayleigh Fading channel generated using Clarkes & Jakes Model for different
Doppler Spreads are simulated and verified.
Page No: 9
As MLS are periodic and shift registers cycle through every possible binary value
(with the exception of the zero vector), registers can be initialized to any state, with
the exception of the zero vector.
A Gold code, also known as Gold sequence, is a type of binary sequence, used
in telecommunication (CDMA) and satellite navigation (GPS). Gold codes are
named after Robert Gold. Gold codes have bounded small cross-correlations within
a set, which is useful when multiple devices are broadcasting in the same range. A
set of Gold code sequences consists of 2n 1 sequences each one with a period of
2n 1.
A set of Gold codes can be generated with the following steps. Pick two
maximum length sequences of the same length 2n 1 such that their absolute crosscorrelation is less than or equal to 2(n + 2) / 2, where n is the size of the LFSR used
to generate the maximum length sequence (Gold '67). The set of the 2n 1
exclusive-ors of the two sequences in their various phases (i.e. translated into all
relative positions) is a set of Gold codes. The highest absolute cross-correlation in
this set of codes is 2(n + 2) / 2 + 1 for even n and 2(n + 1) / 2 + 1 for odd n.
The exclusive or of two Gold codes from the same set is another Gold code in
some phase.
If l is odd, t = 2(l+1)/2 + 1, and
If l is even, t = 2(l+2)/2 + 1.
Thus, a Gold sequence formally is an arbitrary phase of a sequence in the set
G(u,v) defined by
G(u,v)= {u,v,u * v, u * Tv, u *T2 v, U * T(N-1) v}
Tk denotes the operator which shifts vectors cyclically to the left by k places, *
is the exclusive OR operator and u, v are m-sequences of period generated by
different primitive binary polynomials.
Program:clc;
clear all;
m=input('enter the size of shift registers m =');
N=2^m-1;
tt=-N+1:1:N;
x=ones(1,m);
x1=x;
taps1=input('enter the taps1 =');
taps2=input('enter the taps2 =');
for i=1:N
Page No: 10
end
disp(y1);
%%%Test-1
T1=sum(y1);
disp('total number of of 1s in maximalseq1 1s');
disp(T1);
if(T1==2^(m-1))
disp('maximal sequence is exist between the selected taps1');
else
disp('maximal sequence is NOT exist between the selected taps1');
end
%%%test2
sy1=2*y1-1;
s1=xcorr(sy1,sy1);
figure(1);
plot(s1);
title('Auto correlation of Maximal sequence1');
xlabel('no of samples---->');
ylabel('magnitude---->');
grid;
%%%2nd maximal sequences
for i=1:N
y2(i)=x(m);
x2=xor(x,taps2);
x=[x2 x(1:m)];
end
disp(y2);
%%%Test-1
T2=sum(y2);
disp('total number of of 1s in maximalseq2 1s');
disp(T2);
if(T2==2^(m-1))
disp('maximal sequence is exist between the selected taps2');
else
disp('maximal sequence is NOT exist between the selected taps2');
end
%%%test2
sy2=2*y2-1;
s2=xcorr(sy2,sy2);
figure(2);
plot(s2);
title('Auto correlation of Maximal sequence2');
xlabel('no of samples---->');
ylabel('magnitude---->')
grid;
if(T1==T2)
%module-2 of 2'maximalseq is given as gold sequences(y)
y=xor(y1,y2);
g1=2*y-1;
%%%to check 3-value cross correlation function
x=xcorr(sy1,sy2);
figure(3);
plot(x);
title('cross correlation of MLS1&MLS2');
xlabel('no of samples---->');
ylabel('magnitude---->')
grid;
%%% autocorrelation of gold sequences
Page No: 11
end
%%%gold sequence testing by find corss correlation function
c=input('enter the MLsequence1 or MLSequence2 c=');
if(c==1)
seq=sy1;
else
seq=sy2;
end
nn=input('enter the No shift we want nn=');
yz=2*y-1;
yz1=circshift(yz,[0,nn]);
Y=xcorr(seq,yz1);
disp(Y);
figure(5);
plot(Y);
title('3-value checking of goldsequence ');
xlabel('No of samples ');
ylabel('magnitude');
grid;
%xor sub function:
s=6;
z=xor(s,tt);
n=length(tt);
c(1)=xor(s(tt(1)),s(tt(2)));
for i=1:n-2
c(i+1)=xor(s(tt(i+2)),c(i));
end
z=c(length(c));
Page No: 12
Page No: 13
Page No: 14
Figure 1:-
Result:Simulation and verification of Maximal and Gold Sequence, has been verified.
Page No: 15
)=
Page No: 16
In the design of FIR filters using any window technique, the order can be
calculated using the formula given by
N=
Design of FIR filters using window Techniques:The Design frequency response Hd(
Where
)=
hd(n)=
dw
One possible way of obtaining FIR filter is to truncate the infinite Fourier series
at n=
, where N is the length of the desired sequence. But abrupt truncation of the
Fourier series results in oscillation in the pass band and stop band. There oscillations are
due to slow convergence of the Fourier services and this effect is known as the Gibbs
phenomenon.
To reduce these oscillations, the Fourier coefficients of the filter are modified by
multiplying the infinite impulse response with a finite weighting sequence w(n) called a
window where
w(n) = w(-n) 0 for |n|<=
w(n) = w(-n) =0
for |n|>
After multiplying window sequence w(n) with hd(n), we get a finite duration
sequence h(n) that satisfies the desired magnitude response.
H(n) = hd(n)w(n) for all |n|<=
=0
Page No: 17
) and w(
H(
= Hd(
Because both Hd(
)*w(
and w(
The central lobe of the frequency response of the window should contain most of
the energy and should be narrow.
The highest side lobe level of the frequency response should be small.
The side lobes of the frequency response should decrease in energy rapidly as w
tends to .
z=h;
%HANNING FUNCTION
function z=hann(l)
p=l-1;
n=0:1:p;
h=0.5-0.5*cos(2*pi*n/p);
z=h;
%BLACKMAN FUNCTION
function z=black(l)
p=l-1;
n=0:1:p;
h=0.42-0.5*cos(2*pi*n/p)+0.08*cos(4*pi*n/p);
z=h;
Program:% MATLAB program for FIR Low Pass Filter design
using rectangular window technique
%To find response of an FIR LPF using rectangular window.
clc; clear all; close all;
fc=input('Enter the cut off frequency:');
fs=input('Enter the sampling frequency:');
N=input('Enter the order of the filter:');
if(rem(N,2)~=0)
N=N+1;
end
wn=2*fc/fs;
wr=boxcar(N+1);
b=fir1(N,wn,wr);
freqz(b,1);
OUTPUTS:
Enter the cut off frequency:200
Enter the sampling frequency:1000
Enter the order of the filter:20
Page No: 19
OUTPUTS:
Enter the cut off frequency:200
Enter the sampling frequency:1000
Enter the order of the filter:20
Page No: 20
Page No: 21
OUTPUTS:
Enter the cut off frequency:200
Enter the sampling frequency:1000
Enter the order of the filter:20
Page No: 22
OUTPUTS:
Enter the cut off frequency:200
Enter the sampling frequency:1000
Enter the order of the filter:20
OUTPUTS:
Enter the cut off frequency:200
Enter the sampling frequency:1000
Enter the order of the filter:20
Page No: 23
Page No: 24
The most common technique used for designing IIR digital filters
known as indirect method, involves first designing analog filter and then
transforming to a digital filter. For the given specifications of a digital filter T/F
requires 3 steps.
Map the desired digital filter specification into those for an equivalent analog
filter.
Derive the analog transfer function for the analog prototype.
Transform the Transfer function of the analog prototype into an equivalent
digital filter transfer function.
Specifications of Magnitude response of a low pass filter is shown in fig:
Wp Pass band frequency in radians.
Ws Stop band Frequency in radians.
Wc 3-db cutoff frequency in radians.
- parameter specifying allowable pass band.
- parameter specifying allowable stop band.
Design of IIR filters from analog filters:There are several methods that can be used to design digital filters
having as infinite duration unit sample response. The techniques described are all
based on converting an analog filter into a digital filter. If the conversation
technique is to be effective, it should posses the following desirable properties.
1. The j-axis in the s-plane should map in to the unit circle in the z-plane. Thus
there will be a direct relationship between the two frequency variables in the two
domains.
2. The Left-half plane of the s-plane should map into the inside of the unit circle in
the z-plane. Thus a stable analog filter will be converted to a stable digital filter.
3. The four most widely used methods for digitizing the analog filter into a digital
filter include.
Page No: 25
1. Approximation of derivatives.
2. The impulse invariant transformation.
3. The bilinear transformation.
4. The matched z-transformation technique.
Design of IIR filter using Bilinear Transformation:The bilinear transformation is a conformal mapping that transforms the j axis
into the unit circle in the z-plane only once, thus avoiding aliasing of frequency
components. Furthermore, all points in the LHP of s are mapped inside the unit
circle in the z-plane and all points in the RHP of s are mapped into corresponding
points outside the unit circle in the z-plane.
Steps to design digital filter using bilinear transform technique:1. From the given specifications, find pre-warping analog frequencies using
formula
=2/T*tanw/2
2. Using the analog frequencies find H(s) of the analog filter.
3. Select the sampling rate of the digital filter, call it T seconds per sample.
4. Substitute s=
IIR filters
design -------- %
ripple....');
ripple....');
freq......');
freq......');
freq......');
filter 1.butterworth 2.chebyshev type-I
3. BPF 4.BSF:');
Page No: 26
end
if(d==3)
c=input('enter choice of filter 1. LPF 2. HPF
if(c==1)
[n,wn]=cheb2ord(w1,w2,rp,rs,'s');
[b,a]=cheby2(n,rp,wn,'low','s');
end
if(c==2)
[n,wn]=cheb2ord(w1,w2,rp,rs,'s');
[b,a]=cheby2(n,rp,wn,'high','s');
end
if(c==3)
[n]=cheb2ord(w1,w2,rp,rs,'s');
wn=[w1 w2];
[b,a]=cheby2(n,rp,wn,'bandpass','s');
end
if(c==4)
[n]=cheb2ord(w1,w2,rp,rs,'s');
wn=[w1 w2];
[b,a]=cheby2(n,rp,wn,'stop','s');
end
end
w=0:.01:pi;
[h,om]=freqs(b,a,w);
m=20*log10(abs(h));
an=angle(h);
figure,subplot(2,1,1);
plot(om/pi,m,'k','linewidth',2);
title('magnitude response of IIR filter is:');
xlabel('(a) Normalized freq. -->');
ylabel('Gain in dB-->');
subplot(2,1,2);
plot(om/pi,an,'k','linewidth',2);
title('phase response of IIR filter is:');
Page No: 27
Page No: 28
Page No: 29
Page No: 30
Page No: 31
Page No: 32
Result:Designing of IIR filter from analog has been simulated and verified.
Page No: 33
The channel Bandwidth depends on the Bit Rate or signaling rate fb.
If two or more bits are combined in some symbols then the signaling rate will be
possible with each symbol changing there exists the phase of the carrier changed
by /4 radians.
Generation of QPSK:
1s.
then multiplied by the carrier signal of sin(2fct) and cos(2fct). For even and
odd sequence.
Se(t) = be(t)*
sin(2fct)
So(t) = bo(t)*
cos(2fct)
Page No: 34
Then these two signals Se(t) and So(t) are added through adder.
S(t) = b(t)*
fct)+be(t)
fct)
Reception of QPSK:
In this Receiver section the QPSK signal is received at the Receiver and thus the
and cos(2fct) .
Then it is passed towards the Low pass filter to eliminate high freq: components
and finally the I and Q bits are arranged in order.
Probability of Error:-
The Pe is that the error probability that exists by this communication system.
Thus the Pe for QPSK is being defined by plotting Pe by Eb/No in dB on x-axis
through semilogaritham.
Page No: 35
Page No: 36
0.0293
0
0.0186
0.0112
0.0058
Page No: 37
Aim:- To evaluate the performance of QPSK System over Rayleigh Fading Channel.
Software Required:- Pc with MATLAB 7.5.0
Theory:The model simulates QPSK transmission over a multipath Rayleigh fading
channel. You can control transmission and channel parameters via workspace
variables.
The maximum Doppler shift is computed as v*f/c, where v is the mobile speed,
f is the carrier frequency, and c is the speed of light. For example, a maximum
Doppler shift of 200 Hz (as above) corresponds to a mobile speed of 65 mph (30
m/s) and a carrier frequency of 2 GHz.
By convention, the delay of the first path is typically set to zero. For subsequent
paths, a 1 microsecond delay corresponds to a 300 m difference in path length. In
some outdoor multipath environments, reflected paths can be up to several
kilometers longer than the shortest path. With the path delays specified above, the
last path is 3.6 km longer than the shortest path, and thus arrives 12 microseconds
later.
Together, the path delays and path gains specify the channel's average delay
profile. Typically, the average path gains decay exponentially with delay (i.e., the dB
values decay linearly), but the specific delay profile depends on the propagation
environment. In the delay profile specified above, we assume a 3 dB decrease in
average power for every 4 microseconds of path delay. We have also selected an
option in each channel block's mask dialog to normalize the average path gains so
that their collective gain is 0 dB.
Theoretical BER:BER =
where
Page No: 38
Page No: 39
for i=1:n
if(es(i)==d(i))
else
pe1=pe1+1;
end
end
disp('data');
disp(d);
disp('geting')
disp(es);
disp('error is')
for i=1:n
if(d(i)==es(i))
else
pe=pe+1;
end
end
%disp(pe);
%pe=pe+(sum(xor(d,es)));
end
% pe2(ii)=pe1;
% BER(ii)=pe2(ii)/(n*sp);
pe1(ii)=pe;
BER(ii)=pe1(ii)/(n*sp);
geta=mean(abs(w))*ii;
%geta=G*(sum(bfad.*bfadt)/sigmao^2);
qf4(ii)=0.5*(1-sqrt(geta/(1+geta)));
%qf4(ii)=2*qfunc(sqrt(snr));
end
%disp(pe2);
% disp(pe1);
disp('bit error rate is');
disp(BER);
%disp(ber);
semilogy(snrdb,BER,'-o',snrdb,qf4,'-+');
hold all;
axis([ 0 40 10e-7 10e-1 ]);
legend('BER','Q');
grid;
%Sub function for Jakes for Rayleigh Fading Channel Generation.
%z=jakes(h);
%clc
%clear all;
N0=8;
Page No: 40
Page No: 41
Page No: 42
Page No: 43
Rake receiver:If, in a mobile radio channel reflected waves arrive with small relative time
delays, self interference occurs. Direct Sequence (DS) Spread Spectrum is often
claimed to have particular properties that makes it less vulnerable to multipath
reception. In particular, the rake receiver architecture allows an optimal combining
of energy received over paths with different. It avoids wave cancellation (fades) if
delayed paths arrive with phase differences and appropriately weighs signals coming
in with different signal-to-noise ratios.
The rake receiver consists of multiple correlators, in which the receive signal is
multiplied by time-shifted versions of a locally generated code sequence. The
intention is to separate signals such that each finger only sees signals coming in over
a single (resolvable) path. The spreading code is chosen to have a very small
autocorrelation value for any nonzero time offset. This avoids crosstalk between
fingers. In practice, the situation is less ideal. It is not the full periodic
autocorrelation that determines the crosstalk between signals in different fingers, but
rather two partial correlations, with contributions from two consecutive bits or
symbols. It has been attempted to find sequences that have satisfactory partial
correlation values, but the crosstalk due to partial (non-periodic) correlations
remains substantially more difficult to reduce than the effects of periodic
correlations.
The rake receiver is designed to optimally detect a DS-CDMA signal
transmitted over a dispersive multipath channel. It is an extension of the concept of
the matched filter.
In a multipath channel, delayed reflections interfere with the direct signal.
However, a DS-CDMA signal suffering from multipath dispersion can be detected
Page No: 44
by a rake receiver. This receiver optimally combines signals received over multiple
paths.
Like a garden rake, the rake receiver gathers the energy received over the
various delayed propagation paths. According to the maximum ratio combining
principle, the SNR at the output is the sum of the SNRs in the individual branches,
provided that
we assume that only AWGN is present (no interference)
codes with a time offset are truly orthogonal
Program:%RAKE RECIVER OVER SLOW FADING CHANNEL PROG-7
clc;
clear all;
e=1;
snrdb=0:1:20;
n=1000;
L=length(snrdb);N=7;code=[1 1 1 -1 -1 1 -1];G=7;chipsperslot=7;
bfad=randn(1,10);%[0.1 -0.2 0.3];
bfadt=conj(fliplr(bfad));%[0.3 -0.2 0.1];
ts=100;
tb=200;
t=0:ts:((n*tb/2)-ts);
sp=10;
for ii=1:L
pe1=0;
snr=10^((ii-1)/10);
sigmao=sqrt(sum(bfad.*bfadt)*G/snr);
%%%data generater
d=rand(1,n)>.5;
d1=2*d-1;
%%%%SPREADING THE DATA
% out=conv(d1,code);
out=[];
for i=1:n
out=[out d1(i)*code];
end
K=length(bfad);
mfdata=conv(out,bfad);
%
%% AWGN CHANNEL
w=sigmao.*randn(1,length(mfdata));
rx=w+mfdata;
%
%%AT RECEIVER SIDE
%%%matched filter
mfdata1=conv(rx,conj(fliplr(bfad)));
%delay=length(code)+length(bfad);
getdata=mfdata1(3:length(mfdata1)-2);
%getdata=mfdata1(delay:delay+chipsperslot);
%getdata=getdata(K:length(code):length(getdata));
rdata=getdata;
for i=1:n
rdata(i)= getdata(((K)+(i-1)*N));
end
rd=rdata>0;
Page No: 45
end
disp(pe2);
disp(qf4);
disp('bit error rate is');
disp(BER);
semilogy(snrdb,BER,'-o',snrdb,qf4,'-+');
hold all;
%axis([0 14 10e-7 10e-1]);
legend(' praticalBER','theoreticalBER');
title('BER performance of RAKE Receiver')
xlabel('snrdb--->');
ylabel('Pe--->');
grid;
0.2040
0.2080
Page No: 46
Page No: 47