image thumbnail

Quadrature Phase Shift Keying(QPSK)

by

 

09 Aug 2010 (Updated )

This code is meant for QPSK....simulation

QPSK_1.m
% % % % % % % % % % % % % % % % % % % % % Code for Quadrature Phase Shift Keying
% % % % % % % % % % % % % % % % % % % % % % % % Code By:- Debaraj Rana

% % % % % % % % % % % % % % % % % % % % % % % % mail- debaraj.rana@ymail.com
% % % % % % % % % % % % % % % % % % % % % % % % Dept. Of Electronics & Telecom. Engg
% % % % % % % % % % % % % % % % % % % % % % % % VSSUT, Burla,ORISSA

clc;clear all;close all;
% data input
d=input('ENTER INPUT THE BIT STREAMS   ');
ln=length(d);
x=0:1/100:ln*2*pi;
cc=cos(x);
cs=sin(x);
k=length(cc);
k1=k/ln;

% input data odd/even test
if(mod(ln,2)~=0)
    d(ln+1)=0;
    ln=ln+1;
end    
for i=1:ln
  if(d(i)==0)
    d(i)=-1;
    i=i+1;
  end   
end


% To make odd bit streams and even bit streams
i=1;j=1;
while (i<ln) && (j<ln)
    
    dd1(j)=d(i);
    dd1(j+1)=d(i);
    dd2(j)=d(i+1);
    dd2(j+1)=d(i+1);
    j=j+2;
    i=i+2;
end


% to make bit streams eqv to sinusoidal waveform
t=1;
for i=1:ln
    for j=1:k1
        dd(t)=d(i);
        d1(t)=dd1(i);
        d2(t)=dd2(i);
        t=t+1;
        j=j+1;
    end
    i=i+1;
end

subplot(3,1,1);
stairs(dd);
axis([0 t -2 2]);
title('INPUT BIT STREAMS');
ylabel('Amplitude--->');
xlabel('Time--->');
subplot(3,1,2);
stairs(d1);
axis([0 t -2 2]);
title('ODD BIT STREAMS WITH TWICE CLOCK PERIOD');
ylabel('Amplitude--->');
xlabel('Time--->');
subplot(3,1,3);
stairs(d2);
axis([0 t -2 2]);
title('EVEN BIT STREAMS WITH TWICE CLOCK PERIOD');
ylabel('Amplitude--->');
xlabel('Time--->');
figure
subplot(2,1,1);
plot(cc);
axis([0 k -2 2]);
title('COSINE WAVEFORM');
ylabel('Amplitude--->');
xlabel('Time--->');
subplot(2,1,2);
plot(cs);
axis([0 k -2 2]);
title('SINE WAVEFORM');
ylabel('Amplitude--->');
xlabel('Time--->');

len=length(d1);
if(k<len)
   len=k;
end


% odd streams multiplied with cosine waveform
% even streams multiplied with sine waveform
for i=1:len
    qcc(i)=cc(i)*d1(i);
    qcs(i)=cs(i)*d2(i);
    i=i+1;
end

figure
subplot(3,1,1);
plot(qcc);
axis([0 len -2 2]);
title('COSINE MULTIPLIED WITH ODD BIT STREAM WAVEFORM');
ylabel('Amplitude--->');
xlabel('Time--->');
subplot(3,1,2);
plot(qcs);
axis([0 len -2 2]);
title('SINE MULTIPLIED WITH EVEN BIT STREAM WAVEFORM');
ylabel('Amplitude--->');
xlabel('Time--->');


% QPSK output from summer
qp=qcc+qcs;
subplot(3,1,3);
plot(qp);
axis([0 len -2 2]);
title('QPSK WAVEFORM');
ylabel('Amplitude--->');
xlabel('Time--->');
        

Contact us