National Institute of Technology: Communication Engineering Lab II
National Institute of Technology: Communication Engineering Lab II
National Institute of Technology: Communication Engineering Lab II
CALICUT
SUBMITTED BY : GROUP B6
1 MIRIYALA KISHAN B181030EC miriyala_b181030ec@nitc.ac.in
1
Problem Statement :
Simulate using MATLAB a digital communication system that employs
PCM to convert an analog n signal to a bit stream and subsequently uses
BPSK modulation to transmit it over an Additive White Gaussian Noise
Channel.
Input the analog signal 5+5.cos(2πf0 t), t ϵ [0,30/f 0 ]
Sample the signal at rate fs .Denote the number of quantization levels as l.
Assume that f 0 =1 KHz. At the receiver, reconstruct the analog signal from
the demodulated bit
stream.
(i) Calculate the Mean Squared Error (MSE) between the original analog
signal and the reconstructed signal.
(ii) Plot the MSE v/s f for f s = f0, 2f0 , 4f0 , 8f0 , 16f0 , 32f0 for all l (values
s
given below)
(iii) Plot the MSE v/s l, l= 4, 8, 16,…, 32 for all fs .
Repeat the experiment using DPCM. Compare the performance of PCM and
DPCM.
Theory
Pulse coded modulation (PCM)
A PCM stream has two basic properties that determine the stream's
fidelity to the original analog signal: the sampling rate, which is the
number of times per second that samples are taken; and the bit depth,
which determines the number of possible digital values that can be used
to represent each sample.
Differential Pulse Code Modulation (DPCM)
The input given to the decoder is processed and that output is summed
up with the output of the predictor, to obtain a better output.
Transmitter
Receiver
for i=1:1:5
for u=1:1:5
B(i,u)=MSE(Fs(i),N(u));
end
end
figure(4)
for i =1:1:4
hold on
la=num2str(2^N(i));
lab=strcat("L=",la);
plot(Fs,A(i,:),'DisplayName',lab)
title('MSE vs fs')
legend
end
figure(5)
for i =1:1:5
hold on
la2=num2str(Fs(i));
lab2=strcat("fs=",la2);
plot(N,B(i,:),'DisplayName',lab2)
title('MSE vs number of Quantization Levels')
legend
end
function out=MSE(fs_,l)
f=1000;
fs=fs_*f;
n=l;
t=[0:1/(fs*10) :2];
x=5*cos(2*pi*f*t);
x1=x+5;
%quantisation
%q=round(x1);
maxsig=max(x1); %signal max
interv=maxsig/(2^n-1);
u=maxsig+interv/2;
partition = [0:interv:maxsig];
codebook = [0-interv/2:interv:u];
[q,quants] = quantiz(x1,partition,codebook);
enc=de2bi(q,'left-msb');
h=length(enc);
bpsk_=reshape(enc,1,h*n);
bpsk(bpsk_==1)=1;
bpsk(bpsk_ ==0)=-1;
SNR=10.^(14/10);
No=1/SNR;
N=sqrt(No/2)*randn(1,h*n);
BPSK_AWGN=bpsk+N;
detected=zeros(1,h*n);
for i = 1:1:length(BPSK_AWGN)
if(BPSK_AWGN(i)>0)
detected(i) = 1;
else
detected(i) = -1;
end
end
detected_(detected==1)=1;
detected_(detected==-1)=0;
rec=reshape(detected_,h,n);
dec=bi2de(rec,'left-msb');
x_re=dec*interv;
y=lowpass(x_re,1000.001,30000);
y=reshape(y,1,length(y));
out=immse(y,x1);
global ct
if fs_== 2 && ct==1
ct=0;
figure(1);
subplot(3,1,1);
plot(t,x1,'r');
title('Original Signal')
xlim([0.001 0.003])
subplot(3,1,2);
stem(t,x1);
title('Sampled Signal')
xlim([0.001 0.003])
subplot(3,1,3);
plot(t,q);
title('Quantized Signal')
xlim([0.001 0.003])
figure(2);
subplot(3,1,1);
stem(bpsk)
title('BPSK modulated')
xlim([0 90])
subplot(3,1,2);
stem(BPSK_AWGN)
title('BPSK in AWGN')
xlim([0 90])
subplot(3,1,3);
plot(t,x_re,t,y);
title('Recovered Signal')
xlim([0.001 0.003])
figure(3);
plot(t,y)
xlim([0.001 0.003])
title('Reconstructed Signal')
end
end
Plots And Waveforms:
Plots And Waveforms:
Observations and Inferences