0% found this document useful (0 votes)
5 views12 pages

DSP Lab: Sampling and Quantization Study

The document outlines the DSP Lab EEE 312 course at Bangladesh University of Engineering and Technology, focusing on the study of sampling, quantization, and encoding of analog signals. It details the processes of converting analog signals to digital through sampling, quantization, and coding, along with MATLAB applications for practical experiments. The lab work includes tasks related to signal generation, sampling, quantization, and analysis of quantization errors and signal-to-quantization noise ratios.

Uploaded by

kowshikroy089
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views12 pages

DSP Lab: Sampling and Quantization Study

The document outlines the DSP Lab EEE 312 course at Bangladesh University of Engineering and Technology, focusing on the study of sampling, quantization, and encoding of analog signals. It details the processes of converting analog signals to digital through sampling, quantization, and coding, along with MATLAB applications for practical experiments. The lab work includes tasks related to signal generation, sampling, quantization, and analysis of quantization errors and signal-to-quantization noise ratios.

Uploaded by

kowshikroy089
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

DSP Lab EEE 312

BANGLADESH UNIVERSITY OF ENGINEERING AND TECHNOLOGY


DEPARTMENT OF ELECTRICAL AND ELECTRONIC ENGINEERING,
DHAKA-1000, BANGLADESH.

COURSE NO.: EEE 312

Experiment No. 1
Study of Sampling, Quantization and Encoding
Most signals of practical interest, such as speech, biological signals, communication
signals etc. are analog. These signals must be processed for different purposes. Digital
signal processing of an analog signal is preferable to processing the signals directly in the
analog domain because of its flexibility in reconfiguration, better accuracy in control,
better storing capability and cost effectiveness. That’s why the analog signals are to be
converted into corresponding digital domain for the purpose of processing. The analog
signals are converted into digital signals through sampling, quantization and encoding.

PRELAB WORK:
ƒ Read this laboratory tutorial carefully before coming to the
laboratory class, so that you know what is required.
ƒ Try to follow the lecture notes of EEE 311.
ƒ Familiarize yourself with relevant MATLAB functions and codes necessary for
this experiment.
ƒ Do not bring any prepared MATLAB code in the lab with any
portable device.

THEORY:

xa(t) x(n) xq(n)


Sampler Quantizer Coder
Analog signal Discrete time Quantized Digital signal
signal signal

©Dept. of EEE, BUET 2


DSP Lab EEE 312

Analog to digital conversion process


Sampling:

In this section, a continuous time signal is converted into a discrete time signal by taking
samples at discrete time instants.

Ideal Sampler

Analog x (t ) x a (nT )
Discrete time
signal sampled signal

Sampling Process
The analog signal is sampled once every T seconds, resulting in a sampled data sequence.
The sampler is assumed to be ideal in that the value of the signal at an instant (an
infinitely small time) is taken. The most important parameter in the sampling process is
the sampling period T, or the sampling frequency or sampling rate f s , which is defined as
1
f s = . Sampling frequency is given in units of ‘samples per second’ or ‘hertz’.
T

A sinusoidal Signal

©Dept. of EEE, BUET 3


DSP Lab EEE 312

Sampling operation is being performed

Sampled version of the sinusoidal signal


If the sampling is too frequent, then the DSP processor will have to process a large
amount of data in a much shorter time frame. If the sampling is too sparse, then important
information might be missing in the sampled signal. The choice is governed by sampling
theorem.

Sampling Theorem:

The sampling theorem specifies the minimum-sampling rate at which a continuous-time


signal needs to be uniformly sampled so that the original signal can be completely
recovered or reconstructed by these samples alone. The reconstruction of a sampled
signal is done by simple low pass filtering. For successful reconstruction of the sampled
signal, the sampling frequency must be equal to or greater than the twice time of the
highest frequency component of the original signal. Otherwise the signal cannot be
successfully recovered.

If a continuous time signal contains no frequency components higher than W Hz, then it
can be completely determined by uniform samples taken at a rate samples f s per second

©Dept. of EEE, BUET 4


DSP Lab EEE 312

where f s ≥ 2W ,
1
or, in terms of sampling period, T≤ .
2W

In MATLAB, the signals obtained before and after sampling look like –

Original sinusoidal Signal


1

0.8

0.6

0.4

0.2

-0.2

-0.4

-0.6

-0.8

-1
0 10 20 30 40 50 60 70 80 90 100

S
a
m
p
l
i
n
g

Sampled Signal with 100Hz sampling frequency


1

0.8

0.6

0.4

0.2

-0.2

-0.4

-0.6

-0.8

-1
0 1 2 3 4 5 6 7 8 9 10

©Dept. of EEE, BUET 5


DSP Lab EEE 312

Quantization:

In this section, a discrete time continuous-valued signal is converted into a discrete-time


discrete-valued (digital) signal. The value of each signal sample is represented by a value
selected from a finite set of possible values. The quantizer assigns each sample of x(n) to
the nearest quantization level by either rounding or truncation.

Quantization by rounding:

3 ∆ /2

2

1
Quantization
0 t process is being done
by rounding
-1

-2

-3

In the case of rounding, the step size is divided into upper and lower halves. The value in
the upper half are stepped into the next level and the value in the lower half remains in
that level.

0 t

-1

-2

-3

Quantized signal

©Dept. of EEE, BUET 6


DSP Lab EEE 312

Quantization by truncation:

3

2

1 Quantization
process is being done
0 t
by truncation

-1

-2

-3

In the case of truncation, the extended value for a particular level is cut down and the
sampled point stays at that particular level.

0 t

-1

-2

-3

Quantized signal

©Dept. of EEE, BUET 7


DSP Lab EEE 312

In MATLAB, the sampled signals obtained before and after quantized sampling look like
- Sampled Signal with 100Hz sampling frequency

1
0.8

0.6

0.4

0.2

-0.2

-0.4

-0.6

-0.8

-1

-2 0 2 4 6 8 10
Q
u
a
n
t
i
z
a
t
i
o
n

Quantized Signal with 8 quantization level


1

0.8

0.6

0.4

0.2

-0.2

-0.4

-0.6

-0.8

-1

-2 0 2 4 6 8 10

©Dept. of EEE, BUET 8


DSP Lab EEE 312

Performing the quantization operation on x(n) , the quantized output x q (n) is obtained.
The difference between unquantized sample x(n) and quantized output x q (n) is called
quantization error, e q (n) . The finite set of possible values are called quantization levels.
The distance ∆, between two successive quantization levels is called the quantization step
size or resolution.

The quantization error e q (n) in rounding is limited to

−∆ to ∆ ,
2 2

i.e. − ∆ ≤ e q (n) ≤ ∆
2 2

If x min and x max represent the minimum and maximum value of x(n) and L is the
number of the quantization levels, then

x max − x min
∆=
L −1

If x max = +V and x min = −V , and if b is the number of bits then


2V
∆= b
2 −1

The quantization error is then given by –

e( n) = x Q ( n ) − x ( n)

The mean-square value of the error is given by –

1 ∆2 2 ∆2
∆ ∫− ∆ 2
σ e2 = e ( n ) de ( n ) =
12

The performance of the A/D converter is characterized by SQNR, defined as

σ x2
SQNR = 2 ------------------------------------ (A)
σe

SQNRdB = 10 log 10 SQNR = 10 log 10 σ x2 − 10 log 10 σ e2

©Dept. of EEE, BUET 9


DSP Lab EEE 312

σ x2 σ x2 12σ x2 12σ x2 (2 b − 1) 2 σ x2 b
So, SQNR = 2 = 2 = 2 = = 3 2 (2 − 1) 2
σe ∆ ∆ (2V ) 2
V
12
⎛ σ x2 ⎞
and SQNR dB = 10 log 10 3 + 10 log 10 ⎜⎜ 2 ⎟ + 10 log 10 (2 b − 1) 2

⎝V ⎠

For higher values of b like 8, 10 or 12, we can approximate, 2 b − 1 ≅ 2 b

⎛σ 2 ⎞
SQNRdB ≅ 10 log 10 3 + 10 log 10 ⎜⎜ x2 ⎟⎟ + 10 log 10 2 2b
⎝V ⎠
⎛σ 2 ⎞
= 4.77 + 10 log 10 ⎜⎜ x2 ⎟⎟ + 6b
⎝V ⎠

Thus for each bit added to the A/D converter, the SQNR is improved by approximately 6
dB. For sine wave input with amplitude = 1 volt,

=0
SQNRdB = 4.77 + 10 log 10 σ − 10 log 10 V 2 + 6b
2
x

= 1.76 + 6b ------------------------------------ (B)


where, b= Number of bits

Coding:

The coding process in an A/D converter assigns a unique binary number to each
quantization level. If L is the number of levels, then L levels can be represented by b bits
where 2 b = L or b = log 2 L .

LAB WORKS :
ƒ Familiarize yourself with the MATLAB commands that will be required for this
lab.
ƒ You may require the following MATLAB built-in functions for this experiment –

sin(), interp1(), length(), max(), min(), stem(), plot(),find(), ones(), ceil(), dec2bin()

©Dept. of EEE, BUET 10


DSP Lab EEE 312

Part – A
Sampling of an analog signal and reconstruction of the sampled signal.

1. Generate a signal, x(t ) = sin(2π 10t + 0 0 )

2. Take the samples of this signal at a sampling rate of 20 Hz.

3. Reconstruct the analog signal by interpolation. [Use interp1() function]

4. Repeat steps 2 and 3 at a sampling rate of 50 Hz, 100 Hz and 10 Hz.

5. Generate another signal, y (t ) = sin(2π 10t ) + sin(2π 50t ) + sin(2π 100t )

6. For successful reconstruction of the signal, what should be its sampling frequency?
Verify it though the program.

Comment on the obtained results in step – 4 and 6. Explain the results.

Part – B
Study of quantization and quantization error.
1. Write a MATLAB source code that will realize the uniform quantizer .

2. Take the signal of step – 5 in Part – A and sample it by 200 Hz sampling frequency.

3. Quantize the signal by a 3 bit uniform quantizer.

4. Obtain the quantization noise power.

5. Obtain SQNR from equations (A) and (B) which are described in the theory part.

6. Reconstruct the original signal by interpolation. [Use interp1() function]

7. Repeat steps 3 to 6 for 4 and 6 bit uniform quantizer.

Comment on the obtained results in step - 6. Explain the result.

Part C

©Dept. of EEE, BUET 11


DSP Lab EEE 312

Encoding of the quantized sequence.


In the next stage of quantization, the sampled data will be converted into binary data. For
this, first you have to represent the quantization levels into decimal value and then have
to convert it into binary data.

• Obtain a sampled quantized data sequence.

• Represent each level by a definite binary number. The number of digits


b = log 2 L , where L is the quantized level.

Home tasks
Theory:
An important application of this experiment is in Pulse Code Modulation (PCM) system.
PCM is a method for sampling and quantizing an analog signal for the purpose of
transmitting or storing the signal in digital form. It is widely used for speech transmission
in telephone communications and for telemetry systems that employ radio transmission.

Speech signals have the characteristics that small signal amplitudes occur more
frequently than large signal amplitudes. A uniform quantizer provides the same spacing
between successive levels throughout the entire dynamic range of the signal. A better
approach is to use a non uniform quantizer, which provides more closely spaced levels at
the low signal amplitudes and more widely spaced levels at the large signal amplitudes. A
non uniform quantizer characteristic is usually obtained by passing the signal through a
non linear device that compresses the signal amplitudes, followed by a uniform quantizer.
With the use of non – uniform quantizer prior to a uniform one, quantization noise is
greatly reduced.
Non – uniform quantizer are of two types –
• U.S. and Canadian standard
• European standard
U.S. and Canadian telecommunication systems use µ - law compressor, which has the
input – output characteristics of the form –
ln(1 + µ s )
y= sgn( s ) s ≤ 1, y ≤1
ln(1 + µ )
where s is the normalized input, y is the normalized output, sgn(.) is the sign function and
µ is a parameter that is selected to give the desired compression characteristics. This
system adopted µ =255 for encoding of speech waveforms.

European telecommunication systems use A - law compressor, which has the input –
output characteristics of the form –

©Dept. of EEE, BUET 12


DSP Lab EEE 312

⎧1 + ln( A s ) 1
⎪ sgn( s ), ≤ s ≤1
⎪ 1 + ln A A
y=⎨
⎪ A s sgn( s ), 0≤ s ≤
1
⎪⎩1 + ln A A

where A is chosen as 87.56.

[See Chapter 10 of the 2nd reference]

Simulate the following system with MATLAB –

Quantized
Generate a µ - law Uniform Signal
Sampler
sinusoidal signal compressor Quantizer

Process the sinusoidal signal through the above sampler, µ law compressor and
uniform quantizer. As a part of processing, you have to do the following -

- Write MATLAB codes for each section


- Show the waveshapes for each section
- Compute the signal to quantization-noise ratio (of the quantized signal) with the
given formulae(for signal in step 5 part A).

References:
1) Proakis & Manolakis, “Digital Signal Processing: Principles, Algorithms and
Applications.”, Chapter 1, 3rd Edition , Prentice Hall Ltd.

2) Ingle & Proakis, “ Digital Signal Processing using MATLAB ”, Edition 2000
Thomson-Brooks/Cole Co Ltd.
-----------------------------------------------------------------------------------------------------------
The laboratory tutorial of this experiment is prepared by –
Imtiaz Ahmed
Lecturer, Dept. of EEE, BUET.

Under the supervision of –


Dr. Md. Kamrul Hasan
Professor, Dept. of EEE, BUET.

June 9, 2007

©Dept. of EEE, BUET 13

You might also like