Pulse Code Modulation PC MM at Lab Code
Pulse Code Modulation PC MM at Lab Code
Page 1 of 6
Figure 2: Block Diagram of PCM System.
Low Pass Filter
This filter eliminates the high frequency components present in the input analog signal which
is greater than the highest frequency of the message signal, to avoid aliasing of the message
signal.
Sampler
This is the technique which helps to collect the sample data at instantaneous values of
message signal, so as to reconstruct the original signal. The sampling rate must be greater
than twice the highest frequency component W of the message signal, in accordance with
the sampling theorem.
Sampling is defined as, “The process of measuring the instantaneous values of
continuous-time signal in a discrete form.”
Sample is a piece of data taken from the whole data which is continuous in the
time domain.
When a source generates an analog signal and if that has to be digitized, having
1s and 0s i.e., High or Low, the signal has to be discretized in time. This
discretization of analog signal is called as Sampling.
Quantizer
Quantizing is a process of reducing the excessive bits and confining the data. The sampled
output when given to Quantizer, reduces the redundant bits and compresses the value.
The digitization of analog signals involves the rounding off of the values which are
approximately equal to the analog values. The method of sampling chooses a few
points on the analog signal and then these points are joined to round off the value
to a near stabilized value. Such a process is called as Quantization.
The analog-to-digital converters perform this type of function to create a series of
digital values out of the given analog signal. The following figure represents an
analog signal. This signal to get converted into digital, has to undergo sampling
and quantizing.
The quantizing of an analog signal is done by discretizing the signal with a number
of quantization levels. Quantization is representing the sampled values of the
amplitude by a finite set of levels, which means converting a continuous-
amplitude sample into a discrete-time signal.
Page 2 of 6
Encoder
The digitization of analog signal is done by the encoder. It designates each quantized level
by a binary code. The sampling done here is the sample-and-hold process. These three
sections LPF, Sampler, and Quantizer will act as an analog to digital converter. Encoding
minimizes the bandwidth used.
Regenerative Repeater
This section increases the signal strength. The output of the channel also has one
regenerative repeater circuit, to compensate the signal loss and reconstruct the signal, and
also to increase its strength.
Decoder
The decoder circuit decodes the pulse coded waveform to reproduce the original signal. This
circuit acts as the demodulator.
Reconstruction Filter
After the digital-to-analog conversion is done by the regenerative circuit and the decoder, a
low-pass filter is employed, called as the reconstruction filter to get back the original signal.
Hence, the Pulse Code Modulator circuit digitizes the given analog signal, codes it and samples
it, and then transmits it in an analog form. This whole process is repeated in a reverse pattern
to obtain the original signal.
Matlab Code
clc;
close all;
clear all;
n=input('Enter for n-bit PCM system : '); %Encodebook
Bit Length
n1=input('Enter Sampling Frequency : '); %Sampling
Frequency
L = 2^n; %Number of Quantisation Levels
%% Here we pllot the Analog Signal and its Sampled form
Vmax = 8;
x = 0:pi/n1:4*pi; %Construction of Signal
ActualSignl=Vmax*sin(x); %Actual input
subplot(3,1,1);
plot(ActualSignl);
title('Analog Signal');
subplot(3,1,2); %Sampled Version
stem(ActualSignl);grid on; title('Sampled Sinal');
%% Now perform the Quantization Process
Vmin=-Vmax; %Since the Signal is sine
StepSize=(Vmax-Vmin)/L; %
Diference between each quantisation level
QuantizationLevels=Vmin:StepSize:Vmax; %
Quantisation Levels - For comparison
codebook=Vmin-(StepSize/2):StepSize:Vmax+(StepSize/2); %
Quantisation Values - As Final Output of qunatiz
Page 3 of 6
[ind,q]=quantiz(ActualSignl,QuantizationLevels,codebook);
% Quantization process
NonZeroInd = find(ind ~= 0);
ind(NonZeroInd) = ind(NonZeroInd) - 1;
% MATLAB gives indexing from 1 to N.But we need
indexing from 0, to convert it into binary codebook
Page 4 of 6
Output
Page 5 of 6
Operation of PCM using MATLAB Simulink
Output
References:
1. https://www.tutorialspoint.com/digital_communication/digital_communication_pulse_
code_modulation.htm
2. https://www.mathworks.com/matlabcentral/fileexchange/73719-pulse-code-
modulation
Md. Humayun Kabir
Adjunct Lecturer
Dept. of Electronic and Telecommunication Engineering
International Islamic University Chittagong
Page 6 of 6