ADVANCED COMMUNICATION LAB MANUAL (15ECL76) 2018
ADVANCED DIGITAL COMMUNICATION LAB
PART B
SIMULATION EXPERIMENTS USING MATLAB
1. SIMULATE NRZ, RZ, HALF SINUSOID AND GENERATE EYE DIAGRAM
FOR BINARY POLAR SIGNALING.
a. THIS PROGRAM GENERATE SINGLE RZ NRZ AND HALF SINE SINGLE
PULSE FOR A BIT PERIOD OF T=64.
b. THIS PROGRAM USES THE POLAR RETURN TO ZERO AND POLAR NON
RETURN TO ZERO PULSES TO GENERATE EYE DIAGRAMS.
2. SIMULATE THE PCM MODULATION AND DEMODULATION SYSTEM AND
DISPLAY THE WAVEFORMS.
3. SIMULATE THE QPSK TRANSMITTER AND RECEIVER. PLOT THE
SIGNALS.
4. TEST THE PERFORMANCE OF A BINARY DIFFERENTIAL PHASE SHIFT
KEYING SYSTEM BY SIMULATING THE NON-COHERENT DETECTION OF
BINARY DPSK.
Dept. of ECE, BIT, Bengaluru - 04 Page 1
ADVANCED COMMUNICATION LAB MANUAL (15ECL76) 2018
1. SIMULATE NRZ, RZ, HALF SINUSOID AND GENERATE EYE DIAGRAM FOR
BINARY POLAR SIGNALING.
a) THIS PROGRAM GENERATE SINGLE RZ NRZ AND HALF SINE SINGLE PULSE FOR A BIT
PERIOD OF T=64.
PROGRAM:
T=64
%To generate Return to zero square pulse
prz=[zeros(1,T/4) ones(1,T/2) zeros(1,T/4)]
subplot(3,1,1)
plot(prz)
title('plot of return to zero pulse of bit period T=64')
%To generate Non Return to zero square pulse
pnrz=[ones(1,T) zeros(1,T)];
subplot(3,1,2)
plot(pnrz)
title('plot of Non return to zero pulseof bit period T=64')
psine=sin(pi*(0:T-1)/T);
subplot(3,1,3)
plot(psine)
title('plot of half sinusoid of bit period T=64')
Dept. of ECE, BIT, Bengaluru - 04 Page 2
ADVANCED COMMUNICATION LAB MANUAL (15ECL76) 2018
OUTPUT:
plot of return to zero pulse of bit period T=64
1
0.5
0
0 10 20 30 40 50 60 70
plot of Non return to zero pulseof bit period T=64
1
0.5
0
0 20 40 60 80 100 120 140
plot of half sinusoid of bit period T=64
1
0.5
0
0 10 20 30 40 50 60 70
b) THIS PROGRAM USES THE POLAR RETURN TO ZERO AND POLAR NON RETURN TO
ZERO PULSES TO GENERATE EYE DIAGRAMS.
PROGRAM:
clc
data=sign(randn(1,400)); % generate 400 random bits
Tau=64; % define the symbol period
%for i=1:length(data)
%dataup((i-1)*64+1:i*64)=[data(i),zeros(1,63)];% Generate impluse train
%end
dataup=upsample(data,Tau);% Generate impluse train
prz=[zeros(1,Tau/4) ones(1,Tau/2) zeros(1,Tau)];
yrz=conv(dataup,prz);% Return to zero polar signal
yrz=yrz(1:end-Tau+1);
eye1=eyediagram(yrz,2*Tau,Tau,Tau/2);title('RZ eye diagram')
pnrz=ones(1,Tau);
ynrz=conv(dataup,pnrz(Tau));% Non-return to zero polar
ynrz=ynrz(1:end-Tau+1);
eye2=eyediagram(ynrz,2*Tau,Tau,Tau/2);title('NRZ eye-diagram');
Dept. of ECE, BIT, Bengaluru - 04 Page 3
ADVANCED COMMUNICATION LAB MANUAL (15ECL76) 2018
OUTPUT:
NRZ eye-diagram
1
0.8
0.6
0.4
0.2
Amplitude
-0.2
-0.4
-0.6
-0.8
-1
-30 -20 -10 0 10 20 30
Time
RZ eye diagram
1
0.8
0.6
0.4
0.2
Amplitude
-0.2
-0.4
-0.6
-0.8
-1
-30 -20 -10 0 10 20 30
Time
Dept. of ECE, BIT, Bengaluru - 04 Page 4
ADVANCED COMMUNICATION LAB MANUAL (15ECL76) 2018
2. SIMULATE THE PCM MODULATION AND DEMODULATION SYSTEM AND
DISPLAY THE WAVEFORMS.
PROGRAM:
%PCM Modulator
%generating analog signal (sinusoidal)
f=input('enter the freq'); %maximum frequency of the input signal
fs=40*f; %Nyquist sampling rate
t=0:1/fs:1; %time
a=input(' enter thepeak amplitude val') %Amplitude
x=a*sin(2*pi*f*t); %sinusoidal signal
%level shifting
x1=x+a;
%quantization
q_op=round(x1);
%decimal to binary conversion
enco=de2bi(q_op,'left-msb');
%PCM Demodulator
deco=bi2de(enco,'left-msb');
%shifting the amplitude level to the original value
xr=deco-a; %x reconstructed
%plotting
plot(t,x,'r-',t,xr,'b-');
xlabel('time');
ylabel('Amplitude');
legend('Original signal','Reconstructed signal');
Dept. of ECE, BIT, Bengaluru - 04 Page 5
ADVANCED COMMUNICATION LAB MANUAL (15ECL76) 2018
OUTPUT:
Dept. of ECE, BIT, Bengaluru - 04 Page 6
ADVANCED COMMUNICATION LAB MANUAL (15ECL76) 2018
3. SIMULATE THE QPSK TRANSMITTER AND RECEIVER. PLOT THE SIGNALS.
PROGRAM:
% QPSK Modulation
clc;
clear all;
close all;
%GENERATE QUADRATURE CARRIER SIGNAL
Tb=1;t=0:(Tb/100):Tb;fc=1;
c1=sqrt(2/Tb)*cos(2*pi*fc*t);
c2=sqrt(2/Tb)*sin(2*pi*fc*t);
%generate message signal
N=8;m=rand(1,N);
t1=0;t2=Tb
for i=1:2:(N-1)
t=[t1:(Tb/100):t2]
if m(i)>0.5
m(i)=1;
m_s=ones(1,length(t));
else
m(i)=0;
m_s=-1*ones(1,length(t));
end
%odd bits modulated signal
odd_sig(i,:)=c1.*m_s;
if m(i+1)>0.5
m(i+1)=1;
m_s=ones(1,length(t));
else
m(i+1)=0;
m_s=-1*ones(1,length(t));
end
Dept. of ECE, BIT, Bengaluru - 04 Page 7
ADVANCED COMMUNICATION LAB MANUAL (15ECL76) 2018
%even bits modulated signal
even_sig(i,:)=c2.*m_s;
%qpsk signal
qpsk=odd_sig+even_sig;
%Plot the QPSK modulated signal
subplot(3,2,4);plot(t,qpsk(i,:));
title('QPSK signal');xlabel('t---->');ylabel('s(t)');grid on; hold on;
t1=t1+(Tb+.01); t2=t2+(Tb+.01);
end
hold off
%Plot the binary data bits and carrier signal
subplot(3,2,1);stem(m);
title('binary data bits');xlabel('n---->');ylabel('b(n)');grid on;
subplot(3,2,2);plot(t,c1);
title('carrier signal-1');xlabel('t---->');ylabel('c1(t)');grid on;
subplot(3,2,3);plot(t,c2);
title('carrier signal-2');xlabel('t---->');ylabel('c2(t)');grid on;
% QPSK Demodulation
t1=0;t2=Tb
for i=1:N-1
t=[t1:(Tb/100):t2]
%correlator
x1=sum(c1.*qpsk(i,:));
x2=sum(c2.*qpsk(i,:));
%decision device
if (x1>0&&x2>0)
demod(i)=1;
demod(i+1)=1;
elseif (x1>0&&x2<0)
demod(i)=1;
demod(i+1)=0;
Dept. of ECE, BIT, Bengaluru - 04 Page 8
ADVANCED COMMUNICATION LAB MANUAL (15ECL76) 2018
elseif (x1<0&&x2<0)
demod(i)=0;
demod(i+1)=0;
elseif (x1<0&&x2>0)
demod(i)=0;
demod(i+1)=1;
end
t1=t1+(Tb+.01); t2=t2+(Tb+.01);
end
subplot(3,2,5);stem(demod);
title('qpsk demodulated bits');xlabel('n---->');ylabel('b(n)');grid on;
OUTPUT:
Dept. of ECE, BIT, Bengaluru - 04 Page 9
ADVANCED COMMUNICATION LAB MANUAL (15ECL76) 2018
4. TEST THE PERFORMANCE OF A BINARY DIFFERENTIAL PHASE SHIFT
KEYING SYSTEM BY SIMULATING THE NON-COHERENT DETECTION OF
BINARY DPSK.
PROGRAM:
N = 10^4 % number of bits or symbols
rand('state',100); % initializing the rand() function
randn('state',200);% initializing the randn() function
ip = rand(1,N)>0.5;% generating 0,1 with equal probability
ipD = mod(filter(1,[1 -1],ip),2); % %differential encoding y[n]=y[n-1]+x[n]
s = 2*ipD-1; % BPSK modulation 0 -> -1; 1 -> 0
n = 1/sqrt(2)*[randn(1,N) + j*randn(1,N)]; % white gaussian noise, 0dB variance
Eb_N0_dB = [-3:10]; % multiple Eb/N0 values
for ii = 1:length(Eb_N0_dB)
y = s + 10^(-Eb_N0_dB(ii)/20)*n; % additive white gaussian noise
ipDHat_coh = real(y) > 0; % coherent demodulation
ipHat_coh = mod(filter([1 -1],1,ipDHat_coh),2); %differential decoding
nErr_dbpsk_coh(ii) = size(find([ip - ipHat_coh]),2); % counting the number of errors
end
simBer_dbpsk_coh = nErr_dbpsk_coh/N;
theoryBer_dbpsk_coh = erfc(sqrt(10.^(Eb_N0_dB/10))).*(1 -
.5*erfc(sqrt(10.^(Eb_N0_dB/10))));
close all
figure
semilogy(Eb_N0_dB,theoryBer_dbpsk_coh,'b.-');
hold on
semilogy(Eb_N0_dB,simBer_dbpsk_coh,'mx-');
axis([-2 10 10^-6 0.5])
grid on
legend('theory', 'simulation');
xlabel('Eb/No, dB')
ylabel('Bit Error Rate')
Dept. of ECE, BIT, Bengaluru - 04 Page 10
ADVANCED COMMUNICATION LAB MANUAL (15ECL76) 2018
title('Bit error probability curve for coherent demodulation of DBPSK')
OUTPUT:
Dept. of ECE, BIT, Bengaluru - 04 Page 11