Lab 4 Pulse Code Modulation
Lab 4 Pulse Code Modulation
1.0 OBJECTIVES
1.1 To generate sampled signal using SCILAB software.
1.2 To perform Pulse Code Modulation system using SCILAB.
2.0 EQUIPMENT/APPARATUS
SCILAB Software
3.0 THEORY
Pulse Code Modulation (PCM) is the digitally encoded modulation technique that
is commonly used for digital transmission. With PCM, the pulses are of fixed
length and fixed amplitude. PCM is a binary system where a pulse or lack of
pulse within a prescribed time slot represents either a logic 1 or a logic 0
condition.
1
TRANSMITTER
Digital Signal
Channel
Digital Signal
RECEIVER
3.2.1 Sampling
Sampling is the process of taking samples of the analog input signal at a
rate of Nyquist sampling frequency. The function of a sampling circuit in a
PCM transmitter is to periodically sample the continually changing analog
input voltage and convert those samples to a series of constant-amplitude
pulses that can more easily be converted to binary PCM code.
3.2.2 Quantization
Quantization is the process of converting an infinite number of amplitude
possibilities (analog signal samples) to a finite number of conditions (pre-
determined discrete levels). The number of quantization levels, L, depends
on the number of bits per sample, n, used to code the analog signal where
L = 2n (1)
The magnitude of the stepsize of the quantization levels is called resolution,
ΔV. The resolution depends on the maximum voltage, Vmax, and the
minimum voltage, Vmin, of the information signal, where
Vmax Vmin
V
L 1 (2)
2
3.2.3 Encoding
Encoding is a process where each quantized sample is digitally
encoded into n-bits codeword, where
n log 2 L (4.5)
3
EXAMPLE :
Consider a signal x(t) = sin 2π5t is to be quantized into 8 levels. The number of samples is
1000 . Write a command using Scilab to plot the following signal :
(i) Original signal
(ii) Quantized signal
Determine the encoding bit for each sample.
SOLUTION :
clc;
close;
t = 0:0.001:1;
x = sin(2*%pi*5*t);
L = 8;
//quantization
xmax = max(abs(x));
xq = x/xmax;
en_code = xq;
d = 2/L;
q = d*[0:L-1];
q = q-((L-1)/2)*d;
for i = 1:L
xq(find(((q(i)-d/2)<=
xq)&(xq<=(q(i)+d/2))))=q(i).*ones(1,length(find(((q(i)-
d/2)<=xq)&(xq<=(q(i)+d/2)))));
en_code(find(xq == q(i)))= (i-1).*ones(1,length(find(xq
== q(i))));
end
xq = xq*xmax;
plot2d2(t*2*%pi,x);
plot2d2(t*2*%pi,xq,5);
(iii) Encoding
n = log2(L);
c = zeros(length(x),n);
for i = 1:length(x)
for j = n:-1:0
if(fix(en_code(i)/(2^j))==1)
c(i,(n-j)) =1;
en_code(i) = en_code(i)-2^j;
end
end
end
disp(c)
4
EXERCISE
(c) Determine the voltage of input signal that represented by 010, 011, and 110.
1. Report