Professional Documents
Culture Documents
Adc Lab PGM PDF
Adc Lab PGM PDF
Aim: To generate and de111odulate quadrature phase shifted (QPSK) s1g11a1113111g MATLAB
Theory
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.
0 ., elsewhere
0 , else where
There are two 0111101101101‘111a1basis functions
c1 (t) : ’\r"2./T cos 2an. OS t 5Tb
10 W4 V’E/Z -\~"E;‘2
‘ X
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
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
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
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.
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
Program
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 --->');
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
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--—>