You are on page 1of 10

QITADRATITRE PHASE SHIFT KEYING

Aim: To generate and de111odulate quadrature phase shifted (QPSK) s1g11a1113111g MATLAB

Theory

Generation of Quadrature phase shift keyed (QPSK) signal

QPSK 15 also known as quatetualy PSK, quad1‘1phase PSK. 4-PSK. 01‘ 4-QAM. It is a phase
modulation techniquethatt1'a11s1111ts two bits 111 f0111‘1110dulat1011 states.

Phase of the ca11‘1e1‘ takes 011 one of four equally spaced values such as W4. 371/4, 571.1"4

311d7711-‘4.

31(1) = 121311 cos {2 rrfct+ (21— 1) 1:14} , 051:1

0 ., elsewhere

Where 1 = 1213141 & E: Tx signal energy per symbol


T= symbol duration
Each of the possible Value of phase €011esponds to a pair of bits called d1b1ts.
Thus the g1ay encoded set of d1b1ts:100001 11
Si (t)
— \ZET005 [(21 , 1)]1'4] cos (271fct)- \2ET5111 [(21 1) 71.4)] 3111 (271fct) 0< t <Tb

0 , else where
There are two 0111101101101‘111a1basis functions
c1 (t) : ’\r"2./T cos 2an. OS t 5Tb

c; (t) = '\r"2./T sin 2nfct, OS t 5Tb


There are f0111‘111essage points

111131" debits Phase of Co-ordinates of message


QPSK signals
signal S1 S2

10 W4 V’E/Z -\~"E;‘2

00 31:54 —V’E.s'2 451512


5 If4 -‘\1E;“2 +'\“{E;“2
01

11 77:14 +v'E12 +6512


Block diagram of QPSK Transmitter
131(1) fl

‘ X

fit) + QPSK signal


binary b (t) —>
bits Demux

The 1.11) binary sequence MI) is represented 111 polar from with symbols 1 & 0 represented as
—\"VE12 and 4115/2. This binary wave is den111t1p1exed into two separate binary waves
consisting of odd & even numbered L’P bits denoted by 111 (t) & b; (t). b1 (1) & 1130) are
used to modulate a pair ofquadrattn‘e can‘iet. The result is two PSK waves These two binary
PSK waves are added to produce the desired QPSK signal

QPSK Receiver:

( : ) fdt x1 Decision _
01(t) “ Device

1
—p QPSK signal Multiplexer _,
I . ,
1 Emmy ofp
_, fdt x2 Decision
C, (t. ‘ Device —>

QPSK receiver consists of a pair of co11‘e1ators with common If? & supplied with locally
generated signal c1 (t) & c; (t). The con‘elator output, x1, & x; are each compared With a
threshold of zero V'oltslf x1 ;:-: 0. decision is made 111 favour of symbol ‘1’ for upper Channel
and if x1 2> 0, decision is made 111 favour of symbol 0. Parallely if x; >01 decision is made 111
favour of symbol 1 for lower channel & if x; <20, decision is made 111 favour of symbol 0.
These two channels are combined 111a 111111t1plexe1‘ to get the original binary output.
Algorithm
Initialization couuuands
QPSK modulation

1. Generate quadrature caniers.


2. Start FOR 1001)
3. Generate binary data, message signal(b1polar fonn)
4. Multiply 0311161 1 With odd bits of message signal and canier 2 with even bits of message
signal
5. Pel‘fonn addition of odd and even modulated signals to get the QPSK modulated signal
6. Plot QPSK modulated signal.
7. End FOR loop.
8. Plot the binary data and carriers.

QPSK demo dulation

1. Start FOR 1001)


Petfonn c011'elatio11 0f QPSK modulated signal with quadrature carriers to get two decision
variables x1 and x2.
Make decision on x1 and x2 and multiplex to get demodulated b111a1y data.
1;)

If x1>02111d x22>0, choose ‘11’. Ifx1i1>0and x2<-‘i0. choose ‘10’. If x1<03nd X22‘->O. Choose ‘01. If
X1<10a11d x240, choose ‘00”.
4. End FOR loop
5. Plot demodulated data

Program

% QPSK hvlodulation
clc:
Clear all;
close all:
Q'bGENERATE QUADRATURE CARRIER SIGNAL
Tb:1:t=0:(Tb;‘"100):Tb:fc:1:
c1=sq1t(2/Tb)*cos(2 *p1*fc*t);
C2:sq1t(2 1"Tb)*sin(2 *pi*fc *t);
Q'tygeiiel'ate message signal
N=8 :111=1‘a11d(1 .N);
1120:122Tb
f01'1=1:2:(N-1)
t=[t1:(Tbx"100):t2]
if 111(i)i>0.5
111(1)=1 ;
111_s=011es(1,1e11gth(t)):
else
111(i)=();
111_s=-1 *011es(1,le11gth(t));
end
%odd bits modulated signal
oddisig(1,:):c1 .*11173;
if 111(1+1 )>0. 5
111(1+ 1 )2 1 :
111_s=011es(1,length(t));
else
111(1+1)=0:_
111_s:-1 *011es(1 ,length(t));
end
%even bits modulated signal
eV'e11isig(1_:)=02.*mis;
%q_psk signal
qpsk=0dd_sig+even_sig;
%P10t the QPSK modulated signal
subplot(3,2,4);p10t(t,qpsk(i,:)):
t1t1e('QPSK signal');x1abe1('t---->')gylabe1('s(t)'):grid 011; hold 011;
t1:t1+(Tb+.01):_ t2:t2+(Tb+.01);
end
hold off
%Plot the binaiy data bits and can‘ier signal
subplot(3 ,2 11);ste111(111);
t1t1e('binary data bits');X1abe1('11—--->');ylabel('b(n)');g1‘1d 011;
subplot(3,2,2);plot(t,c1);
t1t1e('can‘1e1‘ signal- 1 ');xlabel('t---->'):ylabe1('c 1 (t)');g1'1d 011:
subplot(3.2.3);plot(t.c2);
t1t1e('ca11‘ie1‘ signal-Z');xlahel('t---->');ylabe1('c2(t)');g1‘1d 011;
% QPSK Demodulation
11:0;12:Tb
for i=1 :N-l
F[t1:(Tb./100):t2]
9'6c011‘e1at01‘
x1=511111(cl.*qpsk(1,:));
X2=s11111(c2.*qpsk(11:));
%deeision device
if (x 1 i>0&&x2 >0)
de1110d(1)=1 ;
de1110d(1+1):1 ;
elseif (X1>O&&X2<0)
de1110d(1)=1 ;
de1110d( 1+ 1 )=0;
elseif (X1<O&&X2<0)
de1110d(1):0;
de1110d(1+1):0;
elseif (X1<0&&X2>0)
demod(1)=0;
den1od( 1+ 1 )=1 '.
end
t1:tl+(Tb+_01); t2:t2+(Tb+.01);
end
subplot(3.2,5);ste111(de1110d);
t1t1e('qpsk demodulated bits'):xlabe1('11—--->‘);ylabe1('b(n)‘);g1‘1d 011:
Modal Graphs

Result

The program for QPSK modulation and demodulation has been simulated in MATLAB and
necessary graphs are plotted.
BER Simulation of DPSK modulation

Aim: To simulate bit e11‘01‘1‘ate perfonnance 0f DPSK modulation using Matlab.

Theory

DPSK involves 2 basic operations at the transinitten differential encoding of the 1/p binary wave
and phase shift keying. hence the name DPSK. To send symbol 0 we phase advance the current
signal an‘efonn by 1800 and to send symbol 1 we leave the phase of the current signal
unchanged.
In the differential encoding at the transmitter input stem with an arbitrary first bit serving as
reference and thereafter the sequence is generated using

dk-l' previous value of differentially encoded digit.


bk' 1.11) binary digit at time ka.
dk-1 tbk' logical inversion.

Assuming reference bit added to {dk} is 3'1'. {dk} is thus generated and used to phase shift key a
can‘ier With phase angles 0 and 7.

BER -B1t E1101 Rate

In digital transmission, the number of bit errors is the number of received bits of a data stream over
a c01111n11111cat1011 channel that have been altered due to noise. interference, distortion 01‘ bit
syncln‘onization e11‘01‘s.The bit e11‘01‘ rate 01' bit e1101‘1‘at10 (BER) is the number of bit en‘ors divided
by the total number 0ft1'ansfe1'1'ed bits during a studied t11ne inteiV'al. BER is a unitless
performance measure, often expressed as a petcentageln a connnunication system, the receiver
side BER may be affected by transnnssion channel noise, interference. distortion. bit
syncln‘onization problems attenuation, wireless multipath fading etc.
The BER may be analyzed using stochastic computer sinmlations. If a simple
transmission channel model and data source model is assumed. the BER may also be calculated
using Binary symmetric channel (used 111 analysis of decoding en‘or probability 111 case of 11011-
bursty bit errors on the transmission channel) and Additive white gaussian noise (AWGN) channel
without fading.
Algorithm
Initialization commands

Generate the input data randomly


QV‘H‘P’NE

Implement differential encoding


Do BPSK modulation
Add AWGN noise
Calculate the no of bits in e11‘o1‘
Plot the BER graph

Program

N = 10/4 9/6 1111111be1‘ofb1ts 01' symbols


randCstate’, 100); % initializing the randO function
1'a11dn('state'.200);9/b initializing the tanan function
1p =1‘and(1.N)>0.5;9'i) generating 01 with equal probability

1pD = 1nod(filte1'(1,[1 -1],1p),2); 9/6 9’6diffe1'entialencoding y[n]=y[n-1]+x[n]


s = 2*1pD-1; ”/0 BPSK modulation 0 -> -1; 1 -> 0
11 = 11"sq1‘t(2)*[1‘and11(1.N) +j*randn(1,N)]; 9/1 white gaussian noise, OdB variance

Eb_N0_dB = [-3:10]; 9'21 multiple Ebs’NO values


for 11 = 1:1ength(Eb7N07dB)
y = s + 10"(-Eb_N0_dB(1i)/20)*n; 9:1) additive white gaussian noise

1pDHat_coh =1‘eal(y) : 0; 9:1) coherent demodulation


1pHaticoh = 1110d(f11te1‘([1 -1],111pDHaticoh).2); ledifferential decodinsJ
11E11‘_dbpsk_coh(11) = size(find([1p -1pHat_coh]).2); 9/0 counting the 11111nbe1‘of en‘ors
end
silnBeridbpskicoh = nEn'idbpskicoh/N:
the01yBe1‘_dbpsk_C011 = e1‘fc(sq11(10."(Eb_N0_dB,/'10))).*(1 - .5*e1‘fc(sq1t(10."(Eb_N0_dBf10))));

close all
figure
se1nilogy(Eb_N0_dB,theo1yBe1‘_dbpsk_coh.'b.-'):
hold 011
se111110gy(Eb_N0_dB,simBe1‘_dbpsk_coh,'1nx-');
axis([-2 1010A-6 05])
grid 011
legendCtheory'. 'sinntlation');
Xlabel(‘Eb/N0. dB')
ylabelCBit E1101 Rate')
t1t1e('B1t error probability curve for coherent demodulation of DBPSK’)
% Code for Pulse Code Modulation
Clc;
Close all;
Clear all;
n=1nput('Enter 11 value for n-bit PCM system : ');
n1=1nput('Enter number of samples in a period : ');
L=2An;

% % Signal Generation
% X=0:1/100:4*p1;
% y=8*sin(x); % Amplitude Of signal is 8V
% subplot(2,2,1);
% plot(x,y);grid on;
% Sampling Operation
X=0:2*p1/n1:4*p1; % n1 nuber of samples have tobe selected
s=8*s1n(x);
subplot(3,1,1);
PICKS);
t1t1e('Analog Signal');
ylabel('Amp11tude--->');
xlabel('T1me--->');
subplot(3,1,2);
stem(s);grid on; t1t1e('Samp1ed Sinal'); ylabe1('Amp11tude--->'); xlabel('T1me--->‘);

% Quantization Process
thax=8;
thin=-Vmax;
de1=(thaX-th1n)/L;
part:vm1n:del:vmax;%level are between vmin and vmax with difference of del
code=Vm1n-(del/2):del:vmax+(de]/2); % Contaion Quantized valuses
[1nd,q]=quant1z(s,part,code); % Quantization process
% 1nd contain index number and q contain quantized values
11 =length(1nd);
12=length(q);

for i=1:ll
if(ind(i)~=0) % To make index as binary decimal so staned from 0 to N
ind(i)=ind(i)— 1;
end
i=i+1;
end
for 1:1 :12
1f(q(1)==Vm1n—(de]i2)) % To make quantize value inbetween the levels
q(1)=Vm1n+(de]/2);
end
end
subplot(3,1,3);
stem(q);grid on; % Display the Quantize values
t1t1e('Quantized Signal');
ylabe1( 'Amp 11tude--- > ');
Xlabe1('T1me--- > ');
% Encoding Process
figure
C0de=de2b1(1nd,'1eft-msb'); % Cnvert the decimal to binary
k=1;
for 1:1 :11
for j=1zn
coded(k)=code(1,j); % convert code matrix to a coded row vector
1=1+1;
k=k+ 1 ;
end

1=1+1;
end
subplot(2,1,1); grid on;
stairs(coded); % Display the encoded signal
axis([0 100 -2 3]); t1t1e('Encoded Signal');
ylabel('Amp11tude--->');
xlabe1('T1m --->');

% Demodulation Of PCM signal

qunt=reshape(coded,n,1ength(coded)/n);
1ndex=b12de(qunt','left-msb'); % Getback the index in decimal form
q=del*1ndex+vm1n+(del/2); % getback Quantized values
subplot(2,1,2); grid on;
plot(q); % Plot Demodulated signal
t1t1e('Demodulated Signal');
ylabel('Amp11tude--->');
Xlabel(’T1me--->’);

Modal Graph:
Enter n value for n—hie PCM system : 8
Enter number of samules in a period : 8

Analog Signal Encoded SIgnal


A 10 1 1 1 1 1 1 1 1 3 , . , .

A 2- _
g 0- W _
E 1
E ,10 1 I I 1 I 1 1 I ‘3 1 ' '
0 2 4 6 s 10 12 14 16 13 g o
Time---> 3
SampledSinal < .1 _ _
41 10 . . 1 1
E]; T I I T 2 I 2 1 I I I 1 1 | 1 1
:00 G: :C C: :C 0102033405060703390100
EL 2 I (L (L (L 1 (L (L J) T1me---> .
( 40 1 I 1 I | 1 | 1 DemodulatedSIgnal
U 2 4 6 B 10 12 14 16 1B 10 1
Time--->
Quantized Signal /_1 5-
1 ‘° ' 1 1 1 1 1 ! 1 11
1111111:
g
211111:
a s 111 a a 111 s .5.
—-
( -1D | 1 1 1 1 1 1 1
0 2 4 6 B 10 12 14 16 18
» -10 1 1 1 1 1 1 1 1
TM) 0 2 4 6 a 10 12 14 16 1s
Time--—>

You might also like