0% found this document useful (0 votes)
18 views

Lab02 (R)

This document contains an experiment report on pulse code modulation (PCM). It includes the objectives, introduction, and MATLAB simulation of PCM. The introduction explains the concepts of quantization, quantization noise, quantization SNR, and PCM encoding. It also provides the quantization model and relationship between bits per sample and SNR. The simulation section demonstrates quantizing a sampled sinusoidal signal using different quantization levels and observing the effect on SNR. It contains tasks to generate a message signal, quantize it for various SNR values, and observe the quantized signal and assigned PCM bits. The document concludes with a rubric for evaluating the lab report.
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views

Lab02 (R)

This document contains an experiment report on pulse code modulation (PCM). It includes the objectives, introduction, and MATLAB simulation of PCM. The introduction explains the concepts of quantization, quantization noise, quantization SNR, and PCM encoding. It also provides the quantization model and relationship between bits per sample and SNR. The simulation section demonstrates quantizing a sampled sinusoidal signal using different quantization levels and observing the effect on SNR. It contains tasks to generate a message signal, quantize it for various SNR values, and observe the quantized signal and assigned PCM bits. The document concludes with a rubric for evaluating the lab report.
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 10

Center of Advance Studies in Engineering,

Islamabad

EXPERIMENT # 02: PULSE CODE MODULATION (PCM)

Name of Student: …………………………………………………….

Roll No.: ……………………………………………………………….

Date of Experiment: ………………………………………………….

Report submitted on: ………………………………………………..

Marks obtained: ……………………………………

Remarks: ……………………………………………

Instructor’s Signature: ……………………………...

1. Objective
1.1 To understand the process of quantization
1.2 To compare the signal to quantization noise ratio for different quantization levels
1.3 To implement the PCM

After completing this lab you should be able to:

1) Perform simulation analysis on Quanitaztion of Analog signals while meeting the


specification requirements.

2) Perform simulation analysis on PCM and demodulation.

3) Understand the trade-off between the bandwith required and the distortion minimized.

2. Introduction
An analog source emits a message waveform x(t) that is first sampled while ensuring the Nyquist
criterion. These samples are then quantized in amplitude and encoded. One type of simple
encoding is to represent each discrete amplitude level by a sequence of binary digits.

Hence, if we have “N” levels, we need bits per level.

The process of quantization usually prevents the quantized output from being reconstructed
exactly into the analog values being quantized. Thus quantization inherently involves the
question of distortion - quantizing more finely typically reduces the distortion, but increases the
bandwidth required to represent the sampled signal. By “distortion” we mean some measure of
the difference between the actual source samples and the corresponding quantized values.

2.1 Quantization
Quantization is the process of approximating a continuous range of values (or a very large set
of possible discrete values) by a relatively-small set of discrete symbols or integer values. More
specifically, a signal can be multi-dimensional and quantization need not be applied to all
dimensions. Discrete signals (a common mathematical model) need not be quantized, which can
be a point of confusion.
A common use of quantization is in the conversion of a discrete signal (a sampled continuous
signal) into a digital signal by quantizing. Both of these steps (sampling and quantizing) are
performed in analog-to-digital converters with the quantization level specified in bits. A specific
example would be compact disc (CD) audio which is sampled at 44,100 Hz and quantized with
16 bits (2 bytes) which can be one of 65,536 (i.e. 216) possible values per sample.

2.2 Quantization Noise and SQNR

Digital Communications Lab (EE TC4406) 2


Suppose that the signal to be quantized has a peak-to-peak value of 2V and that the number
of bits in a quantization word is m. If there are 2^m quantization levels, then the quantization
step size is given by

The quantizer input is x[n] and the output is . The output can be expressed by the
following equation: = x[n] + e[n] where e[n] is termed the quantization noise or
quantization error. The noise sequence, e[n], is uncorrelated with the sequence x[n]. After
quantization, actual information about the noise is forgotten. However, the statistics of the noise
is known. The noise is between −Δ/2 and Δ/2 and is uniformly distributed. The probability
density function of the noise or error, e[n], is given by Fig. Below

Figure: Probability density function of the quantization noise e[n]

Now, let us show the relationship between the Signal to Quantization Noise ratio and the number
of bits per samples required. First of all we make a Quantization scale from Vmin to Vmax as
shown below: Next we divide them into quantization levels “N” determined from the system
specs.

Vmin
Vmax

Analog Digital

Where, is the Quantization step size


Quantization error should be, e[n] = x[n] -
Where,

Signal to Noise Ratio for Quantization:

Digital Communications Lab (EE TC4406) 3


Suppose our signal is a Sine wave then signal power is

Noise variance (power) is

2.3 Quantization SNRdB

Quantization SNR is around 6dB per bit

3. MATLAB Simulation

Digital Communications Lab (EE TC4406) 4


3.1 Sinusoidal Example
In this simulation the student will write the function for quantization of sampled signal and
then try to quantize different sampled signals using this function.
Write the following m-script in new m-file:

%U_PCM Uniform PCM encoding of a sequence.


% [SQNR,A_QUAN,CODE]=U_PCM(A,N)
% a=input sequence.
% n=number of quantization levels (even).
% sqnr=output SQNR (in dB).
% a_quan=quantized output before encoding.
% code=the encoded output.

amax=max(abs(a));
a_quan=a/amax;
b_quan=a_quan;
d=2/n;
q=d.*[0:n-1];
q=q-((n-1)/2)*d;
for i=1:n
a_quan(find((q(i)-d/2 <= a_quan) & (a_quan <= q(i)+d/2)))=...
q(i).*ones(1,length(find((q(i)-d/2 <= a_quan) & (a_quan <= q(i)+d/2))));
b_quan(find( a_quan==q(i) ))=(i-1).*ones(1,length(find( a_quan==q(i) )));
end
a_quan=a_quan*amax;
stem(a_quan);
nu=ceil(log2(n));
sqnr=10*log10(2^(2*nu));

Now generate different sampled signals and quantized them using u_pcm(x,n) function. Where
‘x’ is the input signal and ‘n’ represents the no. of quantization levels used.

For example,

Digital Communications Lab (EE TC4406) 5


In matlab command window write the following script,
t=0:0.01:2;f=1;
x=cos(2*pi*f*t);
plot (t,x);title('Sampled Signal')

you will see the following sampled signal

now quantized this signal using u_pcm(x,n) function and increase the no. of quantization levels
ans see the effect on SQNR.

Digital Communications Lab (EE TC4406) 6


Digital Communications Lab (EE TC4406) 7
4. Lab Work
Task # 01 Quantization of the Message Signal

In this task you are required to generate a message signal which is actually a Sinusoidal signal of
Fundamental Frequency defined by the user, sampled at 10 x (Fundamental Frequency) Samples
per sec.

1) Plot original sampled signal

2) Call the u_pcm function in main module and plot the quantized signal for different values of
quantization levels.

3) By increasing the number of quantization levels see the effect this on SQNR and write the
results in the given table below:

No. of Levels No. of bits SQNR


4
8
16
32
64
128
256
512
1024

Task # 02 QUANTIZATION

Now, input the Signal to Quantization Noise ratio value from the user and quantize the message
signal generated in the previous task.

1) Show the quantized Signal compared to the Original Signal and assign the PCM bits to the
sampled values.

2) Observe and show the PCM bits per sample value calculated along with the Quantization
model table to the instructors.

Digital Communications Lab (EE TC4406) 8


Center for Advance Studies in Engineering, Islamabad
Digital Communication
Lab # 02
Name: _____________________________ Roll No.: ____________________

Lab #02 Marks distribution:

ER1=30 ER7=30 ER9=20


Part-I 10 points 10 points 10 points
Part-II 20 points 20 points 10 points

Lab #02 Marks distribution:

ER1=30 ER7=30 ER9=20


Part-I
Part-II

Lab #XX Rubric Evaluation Guideline:


# Qualities & 0 < Poor <= 12 < 21 < Good <= 27 < Excellent
Criteria 12 Satisfactory <= 27 <= 30
21
ER1 Task No Tasks were Some tasks were Few tasks were All tasks
Completion completed/ completed. Could left to be completed in
minimal effort not justify the completed. due time. All
shown reasons for Provided goals achieved.
uncompleted tasks acceptable
and goals. justification for
the uncompleted
tasks and goals.
z# Qualities & 0 < Poor <= 12 < 21< Good <= 27 < Excellent
Criteria 12 Satisfactory <= 27 <= 30
21
ER7 Code No indentation Computationally Working code Good structure,
indentation, of code, no complex routine and good optimized code
optimization optimization with improper indentation or and good
and and no indentation and structure, but variable names
descriptive descriptive variable names not optimized and comments
variable variable names/ resulting in
name minimal effort unnecessary
shown computations
# Qualities & 0 < Poor <= 8 8 < Satisfactory 14 < Good <= 18 < Excellent
Criteria <= 14 18 <= 20
ER9 Results and Unable to Inaccurate plots Correct plots Good
Plots produce any and results without any presentation of
plots or necessary the correct plots

Digital Communications Lab (EE TC4406) 9


results /minimal identifying with proper
efforts shown features such as labels, captions
labels, captions & visibility
& visibility

Digital Communications Lab (EE TC4406) 10

You might also like