You are on page 1of 10

COMPLEX ENGINEERING ACTIVITY

NAME
Bushra Batool (170811)
Bachelors of Electrical Engineering
(BEET-6-A)
Lab Engineer
SIR TOUSEEF
Designation

DEPARTMENT OF ELECTRICAL ENGINEERING

FACULTY OF ENGINEERING

AIR UNIVERSITY, ISLAMABAD


LAB#12
INTERFACING UART TO 80851 MICROCONTROLLER
OBJECTIVE:
 To implement the the quadrature phase shift keying(QPSK)
DISCUSSION:
In this complex engineering activity we implement the concept of qpsk modulation
,demodulation and analysis the BER performance of the qpsk

QPSK:
Quadrature Phase Shift Keying (QPSK) is a form of Phase Shift Keying in which two bits are
modulated at once, selecting one of four possible carrier phase shifts (0, 90, 180, or 270 degrees).
QPSK allows the signal to carry twice as much information as ordinary PSK using the same
bandwidth. QPSK is used for satellite transmission of MPEG2 video, cable modems,
videoconferencing, cellular phone systems, and other forms of digital communication over an RF
carrier.

QPSK MODULATION:
The QPSK Modulator uses a bit-splitter, two multipliers with local oscillator, a 2-bit serial to
parallel converter, and a summer circuit. Following is the block diagram for the same.At the
modulator’s input, the message signal’s even bits (i.e., 2nd bit, 4th bit, 6th bit, etc.) and odd bits
(i.e., 1st bit, 3rd bit, 5th bit, etc.) are separated by the bits splitter and are multiplied with the
same carrier to generate odd BPSK (called as PSKI) and even BPSK (called as PSKQ).
The PSKQ signal is anyhow phase shifted by 90° before being modulated.
The QPSK waveform for two-bits input is as follows, which shows the modulated result for
different instances of binary inputs.

QPSK DE-MODULATION:
The QPSK Demodulator uses two product demodulator circuits with local oscillator, two band
pass filters, two integrator circuits, and a 2-bit parallel to serial converter. Following is the
diagram for the same.The two product detectors at the input of demodulator simultaneously
demodulate the two BPSK signals. The pair of bits are recovered here from the original data.
These signals after processing, are passed to the parallel to serial converter.

APPLICATION:
 It is most robust modulation technique due to the fact that binary 1 and 0 are separated by
180 degree phase shift of the carrier.
 Due to this property, BPSK modulated data can travel longer distances when transmitted
from base station or subscriber stations

MATLAB CODE:
Message signal:
%qpsk modulation
clc;
clear all;
close all
T=1;
t=0:(T/100):T;
c1=sqrt(2/T)*cos(2*pi*1*t);
c2=sqrt(2/T)*sin(2*pi*1*t);
N=8;
x=randi([0 1],1,N);
x=2*x-1; %conveting them in to pNRZ
even_seq=x(1:2:length(x));
odd_seq=x(2:2:length(x));
t1=0;
t2=1

i=1;
m_s=2:2:length(x);
t_s=0:0.01:length(x);
for j=1:length(t_s)
if t_s(j)<=m_s(i)
even_ps(j)=even_seq(i); %pluse shaping up to 2tb
else
even_ps(j)=even_seq(i);
i=i+1;
end
end

i=1;
m_s=2:2:length(x);
for j=1:length(t_s)
if t_s(j)<=m_s(i)
odd_ps(j)=odd_seq(i);
else
odd_ps(j)=odd_seq(i);
i=i+1;
end
end
for i=1:2:(N-1)
t=[t1:(T/100):t2]
if x(i)>0.5
x(i)=1;
m=ones(1,length(t));
else
x(i)=0;
m=-1*ones(1,length(t));
end

x_odd(i,:)=c1.*m;
if x(i+1)>0.5
x(i+1)=1;
m=ones(1,length(t));
else
x(i+1)=0;
m=-1*ones(1,length(t));
end
even_x(i,:)=c2.*m;
qpsk=x_odd+even_x;

%plot(t,qpsk(i,:));
%title('QPSK xnal');
%hold on

t1=t1+(1+.01);
t2=t2+(1+.01);
end
%hold off

figure();
stem(x);
title('Original xnal');

% qpsk wave form


x=randi([0 1],1,10);
% two carriers generation
T_s=2;
sc1=sqrt(2/T_s)*cos(2*pi*1*t_s);
sc2=sqrt(2/T_s)*sin(2*pi*1*t_s);
figure();
plot(t_s,sc1);
title('Carrier xnal#1');
figure();
plot(t_s,sc2);
title('Carrier xnal#2');
% QBPSK
R1=even_ps.*sc1;
R2=odd_ps.*sc2;
qpsk1=R1-R2;
%plot(t_s,R1)
%plot(t_s,R2)
figure();
plot(t_s,qpsk1) %QPSK xnal
title('QPSK Modulated xnal');
%QPSK Demodulation
t1=0;t2=1;
for i=1:N-1
t=[t1:(1/100):t2]
a1=sum(c1.*qpsk(i,:));
b1=sum(c2.*qpsk(i,:));

if ((a1>0) && (b1>0))


D(i)=1;
D(i+1)=1;
elseif((a1>0) && (b1<0))
D(i)=1;
D(i+1)=0;
elseif((a1<0) && (b1<0))
D(i)=0;
D(i+1)=0;
elseif((a1<0) && (b1>0))
D(i)=0;
D(i+1)=1;
end
t1=t1+(1+.01);
t2=t2+(1+.01);
end
figure();
stem(D);
title('QPSK Demodulation');

Orthogonal carriers:

QPSK MODUALTED WAVE


BER CALCULATION IN QPSK:
N=10000;

yy=[];
y=0
x=randi([0 1],1,N);
for i=1:2:length(x)
if x(i)==0 && x(i+1)==0
y=cosd(255)+1j*sind(255);
elseif x(i)==0 && x(i+1)==1
y=cosd(135)+1j*sind(135);
elseif x(i)==1 && x(i+1)==0
y=cosd(315)+1j*sind(315)
elseif x(i)==1 && x(i+1)==1
y=cosd(45)+1j*sind(45);
end
yy=[yy y];
end
ber_simu=[];
M=4;
scatterplot(yy)
for EbN0dB= 0:15;
EbN0=10^(EbN0dB/10);
n=(1/sqrt(2))*(randn(1,length(yy))+(1j*randn(1,length(yy))));
sigma=sqrt(1/(log2(M)*EbN0));
r=yy+sigma*n;
scatterplot(r)
I=(real(r)>0);
q=(imag(r)>0);
x_cap=[];
for i=1:length(r)
x_cap=[x_cap I(i) q(i)];
end
%ber
ber_sim=sum(x~= x_cap)/N;
ber_simu=[ber_simu ber_sim];
end
EbN0dB=0:15;
semilogy(EbN0dB,ber_simu,'R-')

CONSTELLATION DIAGRAM:
CALCULATING THE BER FOR DIFFERENT VALUE OF BER:

BER OUPUT GRAPH:


LEARNIG OUTCOME OUTCOMES
In this complex engineering activity we implement modulation ,demodulation and analysis the
ber plot.it is simple in the sense that we take UNRZ line code and convert it in to the PNRZ line
code then we separate the even and odd bits which are the multiply with the two carriers that are
orthogonal to each other .At last we sub rat them to obtain the QPSK modulated signal .At
receiver end we divide the incoming signal in to 2Tb and then multiply them with carrier to
implement the correlator receiver and at last we got the detected output. For calculating the BER
graph we take large number of samples about 1000 then we modulate it and calculate the value
to plot the semi-logarithm graph.

You might also like