Sie sind auf Seite 1von 47

Lab Report

IMPLIMENTAION OF MODULATION AND DEMODULATION


SCHEMES OF BPSK,QPSK AND DPSK

AIM

Impliment the modulation and demodulation schemes of bpsk,qpsk and dpsk

THEORY

Binary Phase Shift Keying (BPSK)

(a) BPSK Modulation


In BPSK modulation, the phase of the RF carrier is shifted 180 degree in accordance
with a digital bit stream. A one causes a phase transition, and a zero does not produce
a transition. In BPSK modulator, phase of carrier is varied represent binary 1 or 0. Both
peak amplitude remains constant as phase changes. For example, if we start a phase of o
degree to represent binary 1, then we can change the phase to 180 degree to send
binary 0.figure shows below the generation of BPSK withclock signal .pattern or
baseband data, 1bit encoded.Normal sine wave or carrier is transmitted for logic 1 .As
shown in the waveform and block diagram

b)BPSK demodulation

ECE Department 1 MEA Engineering College


Lab Report

The incoming modulated BPSK signal is multiplied with carrier signal generated from
the carrier generator. The output of the multiplier contents high frequency and low
frequency components. The integrator blocks integrate multiplier output. With help of
comparator by comparing threshold values input data is received.

Quadrature Phase Shift Keying

In QPSK, the data bits to be modulated are grouped into symbols, each containing two bits, and
each symbol can take on one of four possible values: 00, 01, 10, or 11. During each symbol
interval, the modulator shifts the carrier to one of four possible phases corresponding to the four
possible values of the input symbol. In the ideal case, the phases are each 90 degrees apart, and
these phases are usually selected such that the signal constellation matches the configuration
shown in Figure 9.1. Practical QPSK modulators are often implemented using structures similar
to the one shown in Figure 9.2. This structure uses the trigonometric identity

I cos ct + Q sin ct = R cos(ct + )

where

R = sqrtroot( I 2 + Q2)

= tan1( Q/ I)

a) QPSK modulation

The binary bit stream or massage signal is pass through line coding like bipolar NRZ signal
represent at binary values 0 and 1 respectively then multiplied with two term real and
imaginary carrier signal carry the information bit stream. Phase can be changes accordance
with binary bit 1 and 0 respectively such way modulation signal is phase changes

b) QPSK demodulation

We want get our original bit stream thatsModulated signal multiplier with high frequency
and low frequencies component and passing through the integrator carrier signal and
Integrate signal to desired which in form of original information content signal then pass

ECE Department 2 MEA Engineering College


Lab Report

through comparator with upper limit set at 1 and lower limit set to 0. It compare with output
of integrator blocks. And get original information

Differential phase-shift keying (DPSK)

Differential phase shift keying (DPSK) is a common form of phase modulation that conveys data
by changing the phase of the carrier wave. As mentioned for BPSK and QPSK there is an
ambiguity of phase if the constellation is rotated by some effect in the communications
channel through which the signal passes. This problem can be overcome by using the data
to change rather than set the phase.

For example, in differentially encoded BPSK a binary '1' may be transmitted by adding 180 to
the current phase and a binary '0' by adding 0 to the current phase. Another variant of DPSK is
Symmetric Differential Phase Shift keying, SDPSK, where encoding would be +90 for a '1' and
90 for a '0'.

In differentially encoded QPSK (DQPSK), the phase-shifts are 0, 90, 180, 90 corresponding
to data '00', '01', '11', '10'. This kind of encoding may be demodulated in the same way as for
non-differential PSK but the phase ambiguities can be ignored. Thus, each received symbol is
demodulated to one of the points in the constellation and a comparator then computes the
difference in phase between this received signal and the preceding one. The difference encodes
the data as described above. Symmetric Differential Quadrature Phase Shift Keying (SDQPSK)
is like DQPSK, but encoding is symmetric, using phase shift values of 135, 45, +45 and
+135.

The modulated signal is shown below for both DBPSK and DQPSK as described above. In the
figure, it is assumed that the signal starts with zero phase, and so there is a phase shift in both
signals at .Analysis shows that differential encoding approximately doubles the error rate
compared to ordinary -PSK but this may be overcome by only a small increase in . Furthermore,
this analysis (and the graphical results below) are based on a system in which the only corruption
is additive white Gaussian noise (AWGN). However, there will also be a physical channel
between the transmitter and receiver in the communication system. This channel will, in general,

ECE Department 3 MEA Engineering College


Lab Report

introduce an unknown phase-shift to the PSK signal; in these cases the differential schemes can
yield a better error-rate than the ordinary schemes which rely on precise phase information.

PROGRAM

clc
clear all;

N=10^6;
T=1;
os=5;
fs=5/T;
Eb_NO_dB = [0:10];
for ii=1:length(Eb_NO_dB)

ip= rand(1,N)>0.5;
s=2*ip-1;
sU=[s;zeros(os-1,length(s))];
sU=sU(:).';
sFilt=1/sqrt(os)*conv(sU,ones(1,os));
sFilt=sFilt(1:N*os);
n=1/sqrt(2)*[randn(1,N*os)+1i*randn(1,N*os)];

y=sFilt + 10^(-Eb_NO_dB(ii)/20)*n;
yFlit=conv(y,ones(1,os));
ysamp=yFlit(os:os:N*os);

ipHat=real(ysamp)>0;
nErr(ii)=size(find([ip-ipHat]),2)

ECE Department 4 MEA Engineering College


Lab Report

end

simBer=nErr/N;
theoryBer=0.5*erfc(sqrt(10.^(Eb_NO_dB/10)));

close all
figure
semilogy(Eb_NO_dB,theoryBer,'bs-','linewidth',1);
hold on
semilogy(Eb_NO_dB,simBer,'mx-','linewidth',2);
axis([0 10 10^-5 0.5])
grid on
legend('theory','sim-(matched filter )');
xlabel('Eb/No,dB');
ylabel('bit error rate');
title('bit error probability curve for bpsk modulatio');

ECE Department 5 MEA Engineering College


Lab Report

OBSERVATION

RESULT

Designed and implemented bpsk and obtained the bit error curve for bpsk modulation

ECE Department 6 MEA Engineering College


Lab Report

COMMUNICATION THROUGH FADING CHANNEL

AIM

1. To design communication through a Rayleigh fading channel

2. To plot and compare theoretical and simulated BER v/s SNR curve for BPSK modulation.

THEORY

In wireless communications, fading is variation of the attenuation of a signal with various


variables. These variables include time, geographical position, and radio frequency. Fading is
often modeled as a random process. A fading channel is a communication channel that
experiences fading. In wireless systems, fading may either be due to multipath propagation,
referred to as multipath induced fading, or due to shadowing from obstacles affecting the wave
propagation, sometimes referred to as shadow fading.

Rayleigh and Rician fading channels are useful models of real-world phenomena in
wireless communications. These phenomena include multipath scattering effects, time
dispersion, and Doppler shifts that arise from relative motion between the transmitter and
receiver.

The figure below depicts direct and major reflected paths between a stationary radio
transmitter and a moving receiver. The shaded shapes represent reflectors such as buildings.

The major paths result in the arrival of delayed versions of the signal at the receiver. In
addition, the radio signal undergoes scattering on a local scale for each major path. Such local
scattering is typically characterized by a large number of reflections by objects near the mobile.

ECE Department 7 MEA Engineering College


Lab Report

These irresolvable components combine at the receiver and give rise to the phenomenon known
as multipath fading. Due to this phenomenon, each major path behaves as a discrete fading path.
Typically, the fading process is characterized by a Rayleigh distribution for a nonline-of-sight
path and a Rician distribution for a line-of-sight path.

The relative motion between the transmitter and receiver causes Doppler shifts. Local
scattering typically comes from many angles around the mobile. This scenario causes a range of
Doppler shifts, known as the Doppler spectrum. The maximum Doppler shift corresponds to the
local scattering components whose direction exactly opposes the mobile's trajectory.

The performance (Eb/N0 Vs BER) of BPSK modulation (with coherent detection) over
Rayleigh Fading channel and its comparison over AWGN channel is simulated here. The
received signal y can be represented as

y=hx+n

where n is the noise contributed by AWGN which is Gaussian distributed with zero mean
and unit variance and h is the Rayleigh Fading response with zero mean and unit variance. (For a
simple AWGN channel without Rayleigh Fading the received signal is represented as y=x+n).

Non coherent detection of the BPSK signaling is not a suitable method


of detection especially in a Fading environment. In coherent detection, the
receiver has sufficient knowledge about the channel impulse
response.Techniques like pilot transmissions are used to estimate the channel
impulse response at the receiver, before the actual data transmission could
begin. Lets consider that the channel impulse response estimate at receiver is
known and is perfect & accurate.The transmitted symbols (x) can be obtained
from the received signal (y) by the process of equalization as given below.

y^=y/h=(hx+n)/h=x+z

here z is still an AWGN noise except for the scaling factor 1/h. Now the detection of x can be
performed in a manner similar to the detection in AWGN channels.

ECE Department 8 MEA Engineering College


Lab Report

The input binary bits to the BPSK modulation system are detected as

r=real(y^)=real(x+z)

d^=1,if r>0

d^=0,if r<0

Theoretical BER:

The theoretical BER for BPSK modulation scheme over Rayleigh fading channel (with AWGN
noise) is given by

The theoretical BER for BPSK modulation scheme over an AWGN channel is given here for
comparison

The following model is used for the simulation of BPSK over Rayleigh Fading channel and its
comparison with AWGN channel

ECE Department 9 MEA Engineering College


Lab Report

BPSK Modulation over Rayleigh and AWGN channel

ALGORITHM

Step 1: Define Frame Length and range of snr over which to simulate.

Step 2: Generate some random bits.

Step 3: BPSK modulator is designed.

Step 4 : Insertion of white gaussian noise and Rayleigh channel

Step 6: BPSK demodulator at the Receiver

Step 7 :Calculate Bit Error Rate

Step 8: Finally plot the BER Vs. SNR(dB) Curve on logarithmic scale.

PROGRAM

clear all;
clc;
close all

ECE Department 10 MEA Engineering College


Lab Report

N = 10^4; % number of bits or symbols

% Transmitter
ip = rand(1,N)>0.5; % generating 0,1 with equal probability
s = 2*ip-1; % BPSK modulation 0 -> -1; 1 -> 0

Eb_N0_dB = [-3:35]; % multiple Eb/N0(Signal to ratio) values

for ii = 1:length(Eb_N0_dB)

n = 1/sqrt(2)*[randn(1,N) + j*randn(1,N)]; % white gaussian noise, 0dB variance


h = 1/sqrt(2)*[randn(1,N) + j*randn(1,N)]; % Rayleigh channel

% Channel and noise Noise addition


y = h.*s + 10^(-Eb_N0_dB(ii)/20)*n;

% equalization
yHat = y./h;

% receiver - hard decision decoding


ipHat = real(yHat)>0;

% counting the errors


nErr(ii) = size(find([ip- ipHat]),2);

end

simBer = nErr/N; % simulated ber


theoryBerAWGN = 0.5*erfc(sqrt(10.^(Eb_N0_dB/10))); % theoretical ber
EbN0Lin = 10.^(Eb_N0_dB/10);
theoryBer = 0.5.*(1-sqrt(EbN0Lin./(EbN0Lin+1)));

ECE Department 11 MEA Engineering College


Lab Report

% plot
close all
figure
semilogy(Eb_N0_dB,theoryBerAWGN,'cd-','LineWidth',2);
hold on
semilogy(Eb_N0_dB,theoryBer,'bp-','LineWidth',2);
semilogy(Eb_N0_dB,simBer,'mx-','LineWidth',2);
axis([-3 35 10^-5 0.5])
grid on
legend('AWGN-Theory','Rayleigh-Theory', 'Rayleigh-Simulation');
xlabel('Eb/No, dB');
ylabel('Bit Error Rate');
title('BER for BPSK modulation in Rayleigh channel');

OBSERVATION

ECE Department 12 MEA Engineering College


Lab Report

RESULT

Design and plotted communication through a fading channel. Curves for theoretical and
simulated results of Rayleigh fading channel is obtained.

CDMA TRANSMITTER AND RECEIVER

AIM

To design and plot spreaded data and despreaded data for three users in same communication
channel using CDMA technology.

THEORY

ECE Department 13 MEA Engineering College


Lab Report

Code division multiple access (CDMA) is a channel access method used by


various radio communication technologies. CDMA is an example of multiple access, where
several transmitters can send information simultaneously over a single communication channel.
This allows several users to share a band of frequencies. To permit this without undue
interference between the users, CDMA employs spread-spectrum technology and a special
coding scheme (where each transmitter is assigned a code).

Direct-sequence spread spectrum for CDMA involves multiplying the data to be transmitted by a
pseudo-random sequence of -1's and 1's. This spreads the original signal into a much wider band,
hence the term spread-spectrum. The original data can be restored by the receiver using a de-
spreading technique. This involves de-spreading the received signal with the pseudo-random
sequence respective to the original signal. To do this, the transmitted and received sequences
must be synchronized.
CDMA uses orthogonal coding to allow multiple users to access a channel simultaneously. An
advantage of CDMA is that it is possible to keep increasing the number of users for a system.
The limiting factor of CDMA is the error rate, which increases with each added user. Each user
has a pseudo-random noise (PN) sequence that is orthogonal to other users' PN sequences. Their
cross-correlation is close to 0. The orthogonality of the codes ensures that each signal's
transmitter-receiver pair will only deal with its corresponding signal; in other words, the receiver

ECE Department 14 MEA Engineering College


Lab Report

for a particular signal will see any other signal going through the channel as simply noise, and
this will eliminate multiple-access interference.
In direct sequence spread spectrum, there are two types of spreading sequences: short and long.
In short spreading sequences, the spreading sequence is periodic with a period equal to the
processing gain. As a result, the same short sequence is used to modulate each symbol which is
transmitted. Examples of short spreading sequences are Walsh Codes and Gold Codes. In long
spreading sequences, the spreading sequence is either a periodic or has a period which is much
longer than the processing gain.

ALGORITHM

The FIR filter design process via window functions can be split into several steps:

Step 1: Defining the data and the pseudo code for three different users.

Step 2: Specifying the length of data and pseudo code.

Step 3: Obtain the spreaded data by XOR the data and the pseudo code.

Step 4: Plot the data, spreading sequence and spreaded data for three users.

Step 5: Obtain the despreaded data by XOR the spreaded data and the pseudo code.

Step 6: Plot the despreaded data.

PROGRAM
clc;
clear all;
close all;
spread=[];
data=[1 0 0 0;0 0 0 0;1 1 1 1];
pseudo_code=[1 0 1 0;0 1 1 1; 1 1 1 1];
k=1;
[r,c]=size(data);
[r1,c1]=size(pseudo_code);

ECE Department 15 MEA Engineering College


Lab Report

for l=1:r
k=1;
for i=1:c
for j=1:c1
spread(l,k)=xor(data(1,i),pseudo_code(1,j))
k=k+1;
end
end
end
figure;
subplot(431)
stem(data(1,:));
title('orginal data of 1');
subplot(432)
stem(pseudo_code(1,:));
title('spreading sequence 1');
subplot(433)
stem(spread(1,:));
title('spreaded sequence 1');

subplot(434)
stem(data(2,:));
title('orginal data of 2');
subplot(435)
stem(pseudo_code(2,:));
title('spreading sequence 2');
subplot(436)
stem(spread(2,:));
title('spreaded sequence 2');
subplot(437)
stem(data(3,:));

ECE Department 16 MEA Engineering College


Lab Report

title('orginal data of 3');


subplot(438)
stem(pseudo_code(3,:));
title('spreading sequence 3');
subplot(439)
stem(spread(3,:));
title('spreaded sequence 3');

%demodulator%
i=1;
k=1;
los=length(spread);
while k<los
s=0;
for j=1:c1
temp(1,j)=xor(spread(1,k),pseudo_code(1,j));
k=k+1;
s=s+temp(1,j);
end
if (s==0)
h2(1,i)=0;
else
h2(1,i)=1;
end
i=i+1;
end
despreaded_signal=h2;
%plotting despreaded signal%
subplot(414)
stem(despreaded_signal);
title('despreaded signal')

ECE Department 17 MEA Engineering College


Lab Report

OBSERVATIONS

RESULT
Designed and plotted spreaded data and despreaded data for three users in same communication
channel using CDMA technology.

ECE Department 18 MEA Engineering College


Lab Report

IMPLEMENTATION OF MATCHED FILTER

AIM

1. Implementation of matched filter.


2. Obtain bit error probability curve for BPSK.

THEORY

In signal processing, a matched filter is obtained by correlating a known signal, or template,


with an unknown signal to detect the presence of the template in the unknown signal. This is
equivalent to convolving the unknown signal with a conjugated time-reversed version of the
template. The matched filter is the optimal linear filter for maximizing the signal to noise
ratio (SNR) in the presence of additive stochastic noise. Matched filters are commonly used
in radar, in which a known signal is sent out, and the reflected signal is examined for common
elements of the out-going signal. Pulse compression is an example of matched filtering. It is so
called because impulse response is matched to input pulse signals. Two-dimensional matched
filters are commonly used in image processing, e.g., to improve SNR for X-ray. Matched
filtering is a demodulation technique with LTI (linear time invariant) filters to maximize SNR. It
was originally also known as a North filter.

With h as the impulse response and x and y input and output signals. The matched filter is
nothing else than a correlator that correlates with a given signal pattern.It has a impulse response
which is just the time reverse of the signal pattern.So by the way: If signal pattern have
measured, reverse it and set this as impulse response of a FIR filter. There is no need to do this in
the frequency domain if you have measurement in the time domain (both approaches are
equivalent but one is more error prone than the other).

ECE Department 19 MEA Engineering College


Lab Report


y (t )= x ( t ) .h (t+ )dt

ALGORITHM

(a) Generate random binary sequence of +1s and -1s.

(b) Upsample by inserting zeros and the convolve with rectangular filter

(c) Add white Gaussian noise.

(d) Convolve the received samples with matched filter, and extract output at time T

(e) Perform hard decision decoding and count the bit errors

(f) Repeat for multiple values of and plot the simulation and theoretical results.

ECE Department 20 MEA Engineering College


Lab Report

PROGRAM

clc;
clear all;
close all;
N=10^5;
T=1;
os=5;
fs=5/T;
Eb_NO_dB=[0:10];
for i1=1:length(Eb_NO_dB)

%transmitter%

ip=rand(1,N)>0.5;
s=2*ip-1;

%upsampling the signal for transmition

sU=[s;zeros(os-1,length(s))];
sU=sU(:).';
sFilt=1/sqrt(os)*conv(sU,ones(1,os));
sFilt=sFilt(1:N*os);
n=1/sqrt(2)*[randn(1,N*os)+j*randn(1,N*os)];

%noise addition

y=sFilt+10^(-Eb_NO_dB(i1)/20)*n;

%matched filter

yFilt=conv(y,ones(1,os));

ECE Department 21 MEA Engineering College


Lab Report

ySamp=yFilt(os:os:N*os);

%RECIEVER-hard decision coding

ipHat=real(ySamp)>0;
nErr(i1)=size(find([ip-ipHat]),2);
end
simBer=nErr/N;
theoryBer=0.5*erfc(sqrt(10.^(Eb_NO_dB/10)));
%plot
close all;
figure
semilogy(Eb_NO_dB,theoryBer,'bs-','linewidth',1);
hold on
semilogy(Eb_NO_dB,simBer,'mx-','linewidth',2);
axis([0 10 10^-5 0.5])
grid on
legend('theory','sim-(matched filter)');
xlabel('Eb/NO,dB');
ylabel('bit error rate');
title('bit error rate probability for bpsk');

ECE Department 22 MEA Engineering College


Lab Report

OBSERVATION

RESULT

Matched Filter is designed. Bit error rate vs Eb/NO is observed.

ECE Department 23 MEA Engineering College


Lab Report

OFDM TRANSEIVER

AIM

To implement ofdm transmitter and receiver using

THEORY

Orthogonal Frequency Division Multiplexing (OFDM) is a multicarrier modulation technique.


Multicarrier transmission is a method devised to deal with frequency selective channels. In
frequency selective channels different frequencies experience disparate degrees of fading. The
problem of variation in fading levels among different frequency components is especially
aggravated for high data rate systems due to the fact that in a typical single carrier transmission
the occupied bandwidth is inversely proportional to the symbol period. The basic principle of
multicarrier transmission is to translate high rate serial data stream into several slower parallel
streams such that the channel on each of slow parallel streams can be considered flat. Parallel
streams are modulated on subcarriers. In addition to that, by making symbol period longer on
parallel streams the effect of the delay spread of the multipath channel, namely inter-symbol
interference (ISI), is greatly reduced. In multipath channels multiple copies of the transmitted
signal with different delays, which depend on characteristics of the material from which the
transmitted signal has been reflected, are received at the receiver. The delay spread of a channel
is a measure of degree of multipath effect - it is equal to the difference between arrival times of
the first and the last multipath components. Due to the fact the length of the symbol period of
each parallel stream scales proportionally to the number of subcarriers used the percentage of
overlap between two adjacent symbols due to delay spread and resulting from it inter-symbol
interference (ISI) also decreases proportionally to the number of subcarriers

Advantages of orthogonal frequency division multiplexing (ofdm)

In early multicarrier transmission systems subcarriers were non-overlapping to prevent inter-


carrier interference which can greatly degrade performance of a system. Individual subcarriers
were separated by guard bands which constituted wasted bandwidth. The reason why Orthogonal
Frequency Division Multiplexing (OFDM) has become the most popular technique of

ECE Department 24 MEA Engineering College


Lab Report

multicarrier transmission is that subcarriers overlap in frequency and 8 therefore bandwidth


utilization increases by up to 50%. Overlapping subcarriers is allowed because in OFDM
modulation subcarriers are orthogonal to each other. Moreover, OFDM modulation/demodulation
takes form of inverse DFT/DFT which can be efficiently implemented in hardware using Fast-
Fourier Transform algorithm.

Ofdm modulation

In OFDM transmitter N complex-value source symbols Xk k=0,1,...N-1, which can come from
any constellation, such as QPSK or QAM, are modulated onto N orthogonal subcarriers - inverse
Fourier-Transform complex exponentials evaluated at subcarrier frequencies fk :

In a digital transmitter t=nTs where Ts is the sampling period. Subcarriers frequencies are
uniformly distributed:

Frequency spacing fs is equal to 1 in order to preserve orthogonality between subcarriers.


The final form of OFDM transmission takes a form of inverse-Fast-Fourier Transform:

N-sample long x sequence is called OFDM symbol and its duration is equal to N*Ts.

Ofdm demodulation

ADC at the receiver receives an analog signal which is a result of convolution of the transmitted
OFDM symbol x(t) with the channel impulse response plus noise:

ECE Department 25 MEA Engineering College


Lab Report

OFDM demodulation takes a form of Fast-Fourier Transform of the sampled received signal r(t)
(after removal of Ng samples of the guard interval):

since inter-carrier interference (ICI) is avoided by maintaining orthogonality between subcarriers


the channels (Hks) at subcarriers frequencies can be treated independently and the demodulated
OFDM symbol in a frequency domain can be written as:

After channel estimation which yields complex-valued channel attenuation factors Hk at each
subcarriers frequency the decoded k-th transmitted data symbol can be obtained through the
following transformation:

Block diagram of ofdm transceiver

ECE Department 26 MEA Engineering College


Lab Report

ALGORITHM

The ofdm transeiver design process can be split into several steps:

1. Generating and coding of data


2. Convolutionally encoding of data
3. Interleaving of coded data
4. Binary to decimal conversion
5. 16-QAM Modulation
6. Pilot insertion
7. Computing IFFT
8. Adding Cyclic Extension
9. Calculating SNR
10. Removing Cyclic Extension
11. Computing FFT
12. Pilot extraction
13. Demodulation of data
14. Decimal to binary conversion
15. De-Interleaving
16. Decoding data
17. Calculating BER
18. Time averaging for optimum results

ECE Department 27 MEA Engineering College


Lab Report

PROGRAM
% OFDM Code

close all
clear all
clc

%%
% Generating and coding data
t_data=randint(9600,1)';
x=1;
si=1; %for BER rows
%%
for d=1:100;
data=t_data(x:x+95);
x=x+96;
k=3;
n=6;
s1=size(data,2); % Size of input matrix
j=s1/k;

%%
% Convolutionally encoding data
constlen=7;
codegen = [171 133]; % Polynomial
trellis = poly2trellis(constlen, codegen);
codedata = convenc(data, trellis);

%%
%Interleaving coded data

ECE Department 28 MEA Engineering College


Lab Report

s2=size(codedata,2);
j=s2/4;
matrix=reshape(codedata,j,4);

intlvddata = matintrlv(matrix',2,2)'; % Interleave.


intlvddata=intlvddata';

%%
% Binary to decimal conversion
dec=bi2de(intlvddata','left-msb');

%%
%16-QAM Modulation

M=16;
y = qammod(dec,M);
% scatterplot(y);

%%
% Pilot insertion

lendata=length(y);
pilt=3+3j;
nofpits=4;

k=1;

for i=(1:13:52)

pilt_data1(i)=pilt;

ECE Department 29 MEA Engineering College


Lab Report

for j=(i+1:i+12);
pilt_data1(j)=y(k);
k=k+1;
end
end

pilt_data1=pilt_data1'; % size of pilt_data =52


pilt_data(1:52)=pilt_data1(1:52); % upsizing to 64
pilt_data(13:64)=pilt_data1(1:52); % upsizing to 64

for i=1:52

pilt_data(i+6)=pilt_data1(i);

end

%%
% IFFT

ifft_sig=ifft(pilt_data',64);

%%
% Adding Cyclic Extension

cext_data=zeros(80,1);
cext_data(1:16)=ifft_sig(49:64);
for i=1:64

ECE Department 30 MEA Engineering College


Lab Report

cext_data(i+16)=ifft_sig(i);

end

%%
% Channel

% SNR

o=1;
for snr=0:2:50

ofdm_sig=awgn(cext_data,snr,'measured'); % Adding white Gaussian Noise


% figure;
% index=1:80;
% plot(index,cext_data,'b',index,ofdm_sig,'r'); %plot both signals
% legend('Original Signal to be Transmitted','Signal with AWGN');

%%
% RECEIVER
%%
%Removing Cyclic Extension

for i=1:64

rxed_sig(i)=ofdm_sig(i+16);

end

ECE Department 31 MEA Engineering College


Lab Report

%%
% FFT

ff_sig=fft(rxed_sig,64);

%%
% Pilot Synch%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

for i=1:52
synched_sig1(i)=ff_sig(i+6);
end

k=1;

for i=(1:13:52)

for j=(i+1:i+12);
synched_sig(k)=synched_sig1(j);
k=k+1;
end
end

% scatterplot(synched_sig)

%%
% Demodulation
dem_data= qamdemod(synched_sig,16);

ECE Department 32 MEA Engineering College


Lab Report

%%
% Decimal to binary conversion

bin=de2bi(dem_data','left-msb');
bin=bin';

%%
% De-Interleaving

deintlvddata = matdeintrlv(bin,2,2); % De-Interleave


deintlvddata=deintlvddata';
deintlvddata=deintlvddata(:)';

%%
%Decoding data
n=6;
k=3;
decodedata =vitdec(deintlvddata,trellis,5,'trunc','hard'); % decoding datausing veterbi decoder
rxed_data=decodedata;

%%
% Calculating BER
rxed_data=rxed_data(:)';
errors=0;

ECE Department 33 MEA Engineering College


Lab Report

c=xor(data,rxed_data);
errors=nnz(c);

% for i=1:length(data)
%
%
% if rxed_data(i)~=data(i);
% errors=errors+1;
%
% end
% end

BER(si,o)=errors/length(data);
o=o+1;

end % SNR loop ends here


si=si+1;
end % main data loop

%%
% Time averaging for optimum results

for col=1:25; %%%change if SNR loop Changed


ber(1,col)=0;
for row=1:100;

ber(1,col)=ber(1,col)+BER(row,col);
end
end

ECE Department 34 MEA Engineering College


Lab Report

ber=ber./100;

%%
figure
i=0:2:48;
semilogy(i,ber);
title('BER vs SNR');
ylabel('BER');
xlabel('SNR (dB)');
grid on

OBSERVATIONS

RESULT

1.Designed OFDM transiever and plotted.

ECE Department 35 MEA Engineering College


Lab Report

IMPLEMENATION OF DIVERSITY TECHNIQUES USING MAT


LAB

AIM

Implementing Selection diversity of antenna design using mat lab.

THEORY

Diversity techniques can be used to improve system performance in fading channels. Instead of
transmitting and receiving the desired signal through one channel, L copies of the desired signal
through M different channels are received. There are several different types of diversity
techniques that are commonly used in wireless communication systems

Frequency diversity

The first approach to achieve diversity is to modulate an information signal by M different


carriers, Figure 1, where s(t) is the equivalent low-pass of the transmitted signal, and W is
weighting factor. Each carrier must be separated from the other one to achieve minimal
coherence between transmission bands (f)c, so that different copies of the signal are received as
independent fading. At the receiver, L independent fading copies are "optimally" combined to
give a statistical decision. Optimal manipulator is the maximum ratio of combination, which will
be described later. Frequency Diversity can be used to suppress frequency selective fading.

ECE Department 36 MEA Engineering College


Lab Report

Time diversity

Another approach to achieve diversity is to transmit the desired signal in M different time
periods, i.e., each symbol is transmitted M times, Figure 2, where s(t) is the equivalent lowpass
of the transmitted signal, and W is weighting factor. The intervals between the transmission of
the same symbol should be determined in such a way to achieve the least coherence of time
intervals (t)c so that different copies of the same symbols undergo independent fading. The
optimal combination can be obtained by the maximum ratio of combinations. We notice that
sending the same symbol M times is as applying the (M,1) repetition code. In fact, non-trivial
coding can be also used. Error control coding with interlacing can be an effective way to combat
time selective (fast) fading.

ECE Department 37 MEA Engineering College


Lab Report

Space diversity

The third method to achieve diversity is to use M antennas to receive M copies of transferred
signal, Figure 3. The antennas should be located far enough from each other to achieve that
received copies of the signal have independent fading. Unlike frequency diversity and time
diversity, it is not necessary to have additional processing at the end of transmission. It is not
necessary to reserve additional transmission band or additional transmission time.

DIVERSITY COMBINING METHODS

Diversity transmission is based on the principle of using multiple copies of the transmitted
signals that are statistically independent. The most commonly used techniques of combining
signals after application of diversity techniques are: Selection Combining, SC, (which means a
choice of branch with the best signal-to-noise ratio), Maximum Ratio Combining, MRC, (or
combining with a maximum signal-to-noise ratio), Equal Gain Combining, EGC, (combining
with the equal contribution of all branches), Switch and Stay Combining, SSC, (simple
combining by switching the signals), as well as various hybrid techniques of signal combining.

Selection Combining, SC

ECE Department 38 MEA Engineering College


Lab Report

SC is the simplest and most commonly used method for combining signals in Diversity system,
which is based on choosing the branch with the most favourable SNR, Figure 4.

Equal Gain Combining, EGC

When applying EGC technique of combining signals, phase-changes of signals in all diversity
branches are compensated, and then signals are summed, Figure 5

Maximal Ratio Combining, MRC

MRC is the optimal linear technique of signal combination in the Diversity system, which
provides the best statistical results in limiting the impact of fading. The signal in each of
Diversity branches is, before summarizing, multiplied by the matching weighting factor, thus
equating phases of all signals, and the branches with more favorable SNR are taken with greater
contribution, Figure 7. This ensures that the signal with more power has greater contribution in
the received sum of signals. Therefore, it is necessary to have measurement of SNR in all
branches.

ECE Department 39 MEA Engineering College


Lab Report

ALGORITHM

The Diversity design process can be split into several steps:

1. Generating and coding of data


2. Generating white Gaussian noise and Rayleigh channel
3. Adding channel noise
4. Finding the power of the channel on all receiver chain
5. Finding the maximum power
6. Selecting the chain with maximum power/ Equalization with equal gain combining/
Maximal ratio combining
7. Calculating Effective SNR

PROGRAM
%% Implementation of diversity techniques

Method1:
clc;
clear all;
close all;
N=10^4; % number of bits or symbols

%transmitter
ip=rand(1,N)>0.5; %generating 0,1 with equal probability
s=2*ip-1; % BPSK modulation 0->-1; 1->0
nRx=[1:20];

ECE Department 40 MEA Engineering College


Lab Report

Eb_N0_dB=[25]; %multiple Eb/N0 values

for jj=1:length(nRx)
n= 1/sqrt(2)*[randn(nRx(jj),N)+ 1i*randn(nRx(jj),N)]; %white guasian noice
h= 1/sqrt(2)*[randn(nRx(jj),N)+ 1i*randn(nRx(jj),N)]; %Rayleigh channel

%channel and noise noise addition


sD=kron(ones(nRx(jj),1),s);
y=h.*sD+10^(-Eb_N0_dB/20)*n;

%%finding the power of the channel on all rx chain


hPower=h.*conj(h);
%finding the maximum power
[hMaxVal ind]=max(hPower,[],1);
hMaxValMat=kron(ones(nRx(jj),1),hMaxVal);

%selecting the chain with max power


ySel=y(hPower==hMaxValMat);
hSel=h(hPower==hMaxValMat);

%effective SNR
EbN0EffSim(jj)=mean(hSel.*conj(hSel));
EbN0EffTheory(jj)=sum(1./[1:nRx(jj)]);

end

%plot
close all
figure
plot(nRx,10*log10(EbN0EffSim), 'bp-', 'Linewidth',2);
hold on

ECE Department 41 MEA Engineering College


Lab Report

plot(nRx,10*log10(EbN0EffTheory), 'gd-','linewidth',2);
axis([1 20 0 6])
grid on;
legend('theory','sim');
xlabel('no: of receive antenna');
ylabel('effective snr, dB');
title('snr improvement with selection compining')

OBSERVATION:-

Method 2:

%% Implementation of diversity techniques


clc;
clear all;
close all;

ECE Department 42 MEA Engineering College


Lab Report

N=10^4; % number of bits or symbols

%transmitter
ip=rand(1,N)>0.5; %generating 0,1 with equal probability
s=2*ip-1; % BPSK modulation 0->-1; 1->0
nRx=[1:20];
Eb_N0_dB=[25]; %multiple Eb/N0 values

for jj=1:length(nRx)
for ii=1:length(Eb_N0_dB)
n= 1/sqrt(2)*[randn(nRx(jj),N)+ j*randn(nRx(jj),N)]; %white guasian noice
h= 1/sqrt(2)*[randn(nRx(jj),N)+ j*randn(nRx(jj),N)]; %Rayleigh channel

%channel and noise noise addition


sD=kron(ones(nRx(jj),1),s);
y=h.*sD+10^(-Eb_N0_dB/20)*n;

%%Equalization with equal gain combining


yHat=y.*exp(-j*angle(h)); %removing the phase of the channel
yHat=sum(yHat,1); %adding values from all the receive chains

%effective SNR
EbN0EffSim(ii,jj)=mean(yHat.*conj(yHat))/nRx(jj);
EbN0EffTheory(ii,jj)=(1+(nRx(jj)-1)*pi/4);

end
end

%plot
close all

ECE Department 43 MEA Engineering College


Lab Report

figure
plot(nRx,10*log10(EbN0EffSim), 'gd-', 'Linewidth',2);
hold on
plot(nRx,10*log10(EbN0EffTheory), 'bp-','linewidth',2);
axis([1 20 0 14])
grid on;
legend('theory','sim');
xlabel('no: of receive antenna');
ylabel('SNR gain, dB');
title('snr improvement with selection compining')

OBSERVATION:-

Method 3:

ECE Department 44 MEA Engineering College


Lab Report

%% Implementation of diversity techniques


clc;
clear all;
close all;
N=10^4; % number of bits or symbols
%transmitter
ip=rand(1,N)>0.5; %generating 0,1 with equal probability
s=2*ip-1; % BPSK modulation 0->-1; 1->0
nRx=[1:20];
Eb_N0_dB=[25]; %multiple Eb/N0 values

for jj=1:length(nRx)
for ii=1:length(Eb_N0_dB)
n= 1/sqrt(2)*[randn(nRx(jj),N)+ j*randn(nRx(jj),N)]; %white guasian noice
h= 1/sqrt(2)*[randn(nRx(jj),N)+ j*randn(nRx(jj),N)]; %Rayleigh channel

%channel and noise noise addition


sD=kron(ones(nRx(jj),1),s); %sd=1;
y=h.*sD+10^(-Eb_N0_dB/20)*n;

%%Maximal ratio combining


yHat=sum(conj(h).*y,1);

%effective SNR
EbN0EffSim(ii,jj)=mean(abs(yHat));
EbN0EffTheory(ii,jj)=nRx(jj);

end
end

%plot

ECE Department 45 MEA Engineering College


Lab Report

close all
figure
plot(nRx,10*log10(EbN0EffTheory), 'bd-', 'Linewidth',2);
hold on
plot(nRx,10*log10(EbN0EffSim), 'mp-','linewidth',2);
axis([1 20 0 16])
grid on;
legend('theory','sim');
xlabel('no: of receive antenna');
ylabel('SNR gain, dB');
title('snr improvement with Ratio compining')

OBSERVATION:-

RESULT

ECE Department 46 MEA Engineering College


Lab Report

1.Designed and plotted the Selection diversity of antenna.

ECE Department 47 MEA Engineering College

Das könnte Ihnen auch gefallen