Download as pdf or txt
Download as pdf or txt
You are on page 1of 9

Digital Communication

Laboratory
EXPERIMENT – 02

Objective of the experiment:


To study pulse code modulation (PCM) signal transmission and
reception using hardware kit and MATLAB.

Software used:
Online MATLAB 2022a and Simulink

Theory:
PCM is used to digitally represent sampled analog signal. This can be
achieved with the help of quantizer and encoder (after sampling). Quantizer
rounds off a sample value to the closest quantization level.

Quantization:
Quantization is rounding off a sample value to closest quantization
level. A sample is approximated by the center of the interval in which it lies.
The quantizer basically provides a mapping of the continuous samples
m(nTs) to a set of discrete samples νl , for l = 1, 2, 3, . . . , L (the discrete
samples are center of the interval).
Consider maximum and minimum amplitudes permissible for a
quantizer are mp and −mp, respectively. The range (−mp, mp) is partitioned
into L equal subintervals, each of magnitude ∆ν = 2mp/L.

Encoding:
Each quantized sample can be represented in log2L number of bits (0’s
and 1’s).
The quantized signal is converted into 0’s and 1’ and transmitted in
pulse form.
To avoid aliasing we can use “Anti-aliasing filter” so that we can
make the input message signal band-limited signal. In this way we can avoid
overlapping of successive samples in frequency domain.

In the transmitter side:

Source encoding is done to utilize available resources by reducing bit


redundancy in the input digital data – data compression (Huffman coding,
etc.). Then we apply channel encoding to combat the channel noise by
introducing redundancy bits in the data bits (Hamming coding, convolution
coding, LDPC, turbo coding, etc.)

At the receiver side:

Regenerative repeater:
A regenerative repeater is put in work. It strengthens the the signal to
compensate the signal loss thet means it reconstruct the signal strength.

Decoder:
Decoder decodes the binary waveform to convert it into original input
waveform.
A decoder is used to covert regenerated pulses to PAM signal.
Decoder combines the code word (group of bits for a level) by providing
sufficient weight to each bit.
The finally it is passed through a (low pass) reconstruction filter to get
the analog signal.

The operations done at the transmitting end are done in the reverse
order at the receiver to get the digital data. The received signal is passed
through a pulse detector to get bits which is processed through channel
decoder and source decoder to get back the original bit-stream.
MATLAB code and Simulink:

clc;
close;
clear all;
%%
A=1;
n=16;
n1=100;
L=2^n;
str1='Sampled signal at fs = ';
str2='Hz';
str3='Quantized Signal at fs = ';
str4='Encoded Signal at fs = ';
str5='Demodulated Signal at fs = ';
fs=[100 20 10];
T=0:1/1000:1;
xt=A*sin(20*pi*T);
figure(1);
plot(T,xt),grid on,title('Analog siganl'), ylabel('Amplitude--->'); xlabel('Time--->');
for j=1:3
t=0:1/fs(j):1-1/fs(j); % n1 number of samples to be selected
s=A*sin(20*pi*t);
figure(2)
subplot(3,1,j);
stem(t,s);grid on; title([str1 num2str(fs(j)) str2]); ylabel('Amplitude--->'); xlabel('Time--->');
% Quantization
vmax=A;
vmin=-vmax;
del=(vmax-vmin)/L;
part=vmin:del:vmax; % level between vmin and vmax with difference of del
code=vmin-(del/2):del:vmax+(del/2); % Quantized valuses
[ind,q]=quantiz(s,part,code); % Quantization
% ind contains index number and q contains quantized values
l1=length(ind);
l2=length(q);
for i=1:l1
if(ind(i)~=0) % To make index as binary decimal so started from 0 to N
ind(i)=ind(i)-1;
end
i=i+1;
end
for i=1:l2
if(q(i)==vmin-(del/2)) % To make quantize value inbetween the levels
q(i)=vmin+(del/2);
end
end
figure(3);
subplot(3,1,j);
stem(t,q);grid on; % Display the Quantize values
title([str3 num2str(fs(j)) str2]);
ylabel('Amplitude--->');
xlabel('Time--->');
%%
% Encoding Process
figure(4)
code=de2bi(ind,'left-msb'); %decimal to binary
k=1;
for i=1:l1
for y=1:n
coded(k)=code(i,y); %code matrix to a coded row vector
y=y+1;
k=k+1;
end
i=i+1;
end
subplot(3,1,j); grid on;
stairs(coded);grid on; % Displaying the encoded signal
axis([0 100 -2 3]); title([str4 num2str(fs(j)) str2]);
ylabel('Amplitude--->');
xlabel('Time--->');

% Demodulation Of PCM signal


qunt=reshape(coded,n,length(coded)/n);
index=bi2de(qunt','left-msb'); % Getback the index into the decimal form
q=del*index+vmin+(del/2); % getback the Quantized values
figure(5);
subplot(3,1,j); grid on;
plot(q); % Plot Demodulated signal
title([str5 num2str(fs(j)) str2]);
ylabel('Amplitude--->');
xlabel('Time--->');
end

x(t)=sin(2*pi*10); ZOH sampling at ts=0.01s


Quantization at 16-bit Encoded Signal

Recovered Signal:
Result:
Discussion:
Reducing the quantization level by limiting the number of bits utilized
to represent a signal, create larger distortion in reconstructed signal. The
more quantization levels the better the recovery. Recovery of original signal
become impossible for sampling time greater than half the time period of the
signal.
Conclusion:
The input signal was PCM modulated and demodulated using 16-bit
quantization.

**********

- Naveen Nayak Dharavath


- 119EC0579

You might also like