Experiment 02 - Study of Pulse Code Modulations
Experiment 02 - Study of Pulse Code Modulations
Lab-02
Study of Pulse Code Modulation
The objective of this lab is to be familiarized with Pulse Code Modulation. Students
are expected to write Matlab code, that will help them to understand the fundamentals of
PCM.
Pulse Code Modulation is a method of convert an analog signal into a digital Signal.
Analog signal is characterized by the fact that its amplitude can take on any value over a
continuous range. This means that it can take on an infinite number of values. But,
digital signal amplitude can take only finite number of values.
In PCM an analog signal is first sampled at a rate higher than the Nyquist rate, and
then the samples are quantized. It is assumed that the analog signal is distributed on an
interval denoted by [-xmax, xmax], and the number of quantization levels is large. The
quantization levels can be equal (Uniform PCM) unequal (Non-uniform PCM). In this
lab we will only consider the uniform PCM.
In uniform PCM the interval [-xmax,xmax] of length 2xmax is divided into equal
subintervals, each of length del=2xmax/N. If N is a power of 2 or N=2v, then v bits are
required for representation of each level
1. Signal Generation and Sampling operation
n=input('Enter n value for n-bit PCM system : ');
n1=input('Enter number of samples in a period : ');
L=2^n;
x=0:2*pi/n1:4*pi; % n1 number of samples
s=8*sin(x); % Amplitude Of signal is 8v
subplot(3,1,1);
plot(s);
subplot(3,1,2);
stem(s);
2. Quantization process
vmax=8;
vmin=-vmax;
del=(vmax-vmin)/L;
part=vmin:del:vmax; % level are between vmin and vmax
code=vmin-(del/2):del:vmax+(del/2); % Quantized valuses
[ind,q]=quantiz(s,part,code); % Quantization process
11=length(ind);
l2=length(q);
for i=1:l1
if(ind(i)~=0) % 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)) % quantize value in between the level
q(i)=vmin+(del/2);
end
end
subplot(3,1,3);
stem(q);
3. Encoding process
figure
code=de2bi(ind,'left-msb'); % Cnvert the decimal to binary
k=1;
for i=1:l1
for j=1:n
coded(k)=code(i,j); %convert code matrix to row vector
j=j+1;
k=k+1;
end
i=i+1;
end
subplot(2,1,1); grid on;
stairs(coded); % Display the encoded signal
DISCUSSION:- How do the quantized levels effect the PCM. (use suitable plots)