You are on page 1of 49

International University of Ho Chi Minh City

School of Computer Science & Engineering

DIGITAL SIGNAL
PROCESSING

Instructor: HUYNH KHA TU, MEng.


Email: hktu@hcmiu.edu.vn
Cellphone: 0916656656
Digital Signal Processing

Code of module: IT07IU


Credits: 3
Pre-requisite: Signals & Systems,
DLD
Assessment:
Assignment : 20%
Mid-term test : 20%
Final examination : 60%
Digital Signal Processing

References:
2. John G.Proakis, Dimitris
G.Manolakis, “Digital Signal
Processing: Principles, Algorithms
and Application”, Prentice Hall
1996, Upper Saddle River, New
Jersey 07458, ISBN-0133737624.

4. Lecture notes
Digital Signal Processing
Contents:
1. Sampling, Quantization and
Reconstruction
2. D/A and A/D converters
3. Discrete-time systems
4. Finite-impulse response and
convolution
5. Z-transform
Chapter 1:
Sampling, Quantization and Reconstruction

 Introduction
 Overview of Analog signal
 Analog to digital conversion
 Digital to analog conversion
1.1. Introduction

1.1.1. Signals, systems and Digital signal


processing
A signal is defined as any physical quantity that
varies with time, space, or any other independen
variable or variables.
Mathematically, we describe a signal as a functio
of one or more independent variables.
1.1. Introduction
precisely
For example: defined
s1(t) = 9t ;
s2(t) = 20t2 ;
s3(x,y) = 3x + 2xy + 10y2

or

image, speech, electrocardiogram (ECG),


electroencephalogram (EEG) signals, …
1.1. Introduction
A system is defined as a physical device
that performs an operation or software
realizations of operations on a signal.
Passing a signal through a system we
have processed the signal.
This course consider the processing of signal by
digital means

Digital signal processing


1.2. Basic elements of a DSP
systems

Analog Digital Analog


input A/D Signal D/A output
signal Converter Processo Converter signal
r

Digital Digital
input output
signal signal

A large programmable digital computer;


a small microprocessor; hardwired digital processo
or software
1.1.3. Advantages of Digital over
Analog Signal Processing

Flexibility in configuring
Accuracy requirements
The easy storage
Ability to implement sophisticated signal
processing algorithms
The low cost
1.2. Overview of Analog
signal

n analog signal is represented in term of a functio


time, for example, x(t).

he frequency spectrum of x(t) is:


+∞
X ( Ω) = ∫ x ( t )e − jΩt
dt
−∞

Ω : the radian frequency [rad/s]; Ω = 2πf


1.2. Overview of Analog
signal

Consider the response of a linear system

y(t)
x(t)
Linear system h(t) output
input

is system is characterized by the impulse response h(t)



( )( )
y ( t ) = ∫ h t − t ' x t ' dt or Y(Ω) = H(Ω).X(Ω)
−∞
1.2. Overview of Analog
signal
H(Ω) is the frequency response of the system

H ( Ω ) = ∫ h( t ) e − jΩt
dt
−∞

* If input is a sinusoid

x(t) = e jΩt y(t) = H(Ω).ejΩt


Linear system H(Ω)
input output

H(Ω) = |H(Ω)|.ejargH(Ω)
1.2. Overview of Analog
signal
The function of the Linear filter:
In time-domain:

x( t ) = e j Ωt
⇒ y( t ) = H ( Ω ) e j Ωt
= H ( Ω) e jΩt + j arg H ( Ω )

If x( t ) = A1 .e jΩ1t
+ A2 .e jΩ 2 t
+ ... + An .e jΩ n t

After passing through the filter


y ( t ) = A1 .H ( Ω ).e jΩ1t + A2 .H ( Ω ).e jΩ2t + ... + An .H ( Ω ).e jΩnt
The filter changes the magnitudes only,
not the frequencies of the signal.
1.2. Overview of Analog
signal
In frequency domain:
X ( Ω ) = 2πA1δ ( Ω − Ω1 ) + 2πA2δ ( Ω − Ω 2 ) + ... + 2πAnδ ( Ω − Ω n )
H(Ω).X(Ω)
X(Ω)
A1 A2 H(Ω) An
A1Ḥ(Ω1)
A2Ḥ̣(Ω2)

AnH(Ωn)

Ω Ω
Ω1 Ω2 Ωn Ω1 Ω2 Ωn
Y ( Ω ) = H ( Ω ). X ( Ω ) = H ( Ω ).[ 2πA1δ ( Ω − Ω1 ) + 2πA2δ ( Ω − Ω 2 ) + ... + 2πAnδ ( Ω − Ω n ) ]
Y ( Ω ) = 2πA1 H ( Ω1 )δ ( Ω − Ω1 ) + 2πA2 H ( Ω 2 )δ ( Ω − Ω 2 ) + ... + 2πAn H ( Ω n )δ ( Ω − Ω n )
1.3. Analog to digital
conversion

A/D
Converter

x(t) Sampler x(nT) Quantize xq(nT) Coder 01011…


r

Analog Discrete Quantize Digital


signal -time d signal signal
signal
1.3. Analog to digital
conversion
Sampling: convert a continuous-time signal into
a discrete-time signal.
x(t) → x(nT) ≡ x(n) ;
T: sampling interval
Quantization: the conversion of a discrete-time
ntinuous valued signal into a discrete-time discre
lued (digital) signal.

Coding: each discrete value xq(n) is represented


a b-bit binary sequence.
1.3.1. Sampling process
Ideal
sampler

x x(nT
(t) )
Analog Sample
signal d signal
x(t) x(nT)

t t
T
T: sampling period
fs = 1/T : the sampling rate
1.3.1. Sampling process

riodic sampling establishes a relationship betwee


e time variables t and n of continuous-time and
screte-time signals:

n
t = nT =
fs
x(t) → x(nT)
1.3.2. The sampling
Theorem

With an analog signal x(t) having maximum


frequency fmax, the sampling rate is selected
so that
fs ≥ 2.fmax

The sampling rate fs = 2.fmax : the Nyquist rate.

fs/2 : Nyquist frequency or folding frequency.


1.3.2. The sampling
Theorem

Example:
Consider the analog signal:
xa(t) = 3Cos50πt + 100Sin300πt – Cos100πt
What is the Nyquist rate for this signal?

Nyquist rate is: 300Hz.


1.3.2. The sampling
Theorem

However, in practical, most signals is not limited


n a band, they are often passed a low-pass filter
before sampling. The use of the filter here can
avoid the spectrum aliasing.

x(t) Analog x(t) Sampler and x(nT)


quantizer To DSP
lowpass filter
Analog Analog
signal signal
Bandlimite
d signal
1.3.2. The sampling
Theorem
There are two kind of anti-aliasing pre-filters:
ideal and practical pre-filter.
Ideal anti-aliasing pre-filter:

+ Its cut-off frequency is fs/2.

+ Omit all frequencies beyond fs/2.


+ H(f) = 1 (or H(Ω) = 1) for all f ∈[-fs/2 ;
fs/2]
(or Ω ∈ [-Ω/2; Ω/2])
1.3.2. The sampling
Theorem
Practical anti-aliasing pre-filter:

+ Can not omit all frequencies beyond fs/2.


⇒ There are aliases.

⇒ Design a suitable filter can reduce the aliase


to minimum.
+ Consider the attenuation.
1.3.2. The sampling
Theorem

he attenuation A dB means H(f) decreases 10-A/20


or example, from the border of folding frequency fs/2
(f) decreases A dB means:

H( f )
= 10 − A / 20
H ( f s / 2)

We often assume that |H(fs/2)| = 1 and


gnore the effect of the phase response of the filte
1.3.2. The sampling
Theorem

What happens if fs <


2.fmax?
1.3.2. The sampling
Theorem

xample:
onsider the analog signal:
a(t) = 3Cos2000πt + 5Sin6000πt + 10Cos12000π

. What is the Nyquist rate for this signal?


. If fs = 5000, find the disctere-time signal
obtained after sampling?
. Find the signal ya(t) after reconstructing.
1.3.2. The sampling
Theorem

sed on the sampling theory, we can use


ideal re-constructor to recover the original signa

Ideal re-
constructor
x(t) x(nT) x(t)
Ideal
sampler
Analog Analog
-fs/2 fs/2
signal signal
Rate fs
1.3.2. The sampling
Theorem

The ideal re-constructor:

A low-pass filter with cut-off frequency equal to f

Cancel the frequency components outside


s/2 ; fs/2] of signal x(nT)

Keep only the frequency components belonging


s/2 ; fs/2]
1.3.2. The sampling
Theorem
From a set of frequency [ f , f ± fs , f ± 2fs , … ],
there is only one frequency fa belonging to
[-fs/2 ; fs/2].
How to find fa?
Calculate fa=f mod (fs) until fa ∈ [-fs/2 ; fs/2].
+ fa = f if and only if f ∈ [-fs/2 ; fs/2]
+ If f ∉ [-fs/2 ; fs/2] ⇒ fa ≠ f
⇒ xa(t) ≠ x(t)
although xa(nT) = x(nT)
1.3.2. The sampling
Theorem
xample:
onsider the sinusoidal xa(t) = A Cos20t [Hz].
When sampling xa(t) with fs = 14Hz, the sampled
gnal xa(nT) will cover periodic frequencies
0 + m.14Hz, but only fa=10mod14 = -4 ∈ Nyquist
terval [-7 ; 7]
f = -4 ⇒ xa(t) = ACos(-8πt) ≠ ACos20t.
If we choose fs = 22Hz ≥2.f = 20Hz
we will have the reconstructed signal with 10Hz
1.3.2. The sampling
Theorem

Example:
Consider the signal:
x(t) = 4 + 3Cosπt + 2Cos2πt + Cos3πt t[ms]
a. Find fs so that there is no alias.
b. Supposing that x(t) is sampled with fs equal a
half of Nyquist rate, find xa(t) which is alias of x(t
1.3.2. The sampling
Theorem
onsider the following sound wave, where t is in millisecond
x(t) = Sin(20πt) + Sin(30πt) + Sin(80πt).
his is pre-filtered by an analog anti-aliasing pre-filter H(f)
nd then sampled at frequency rate fs = 40KHz. The resultin
amples are immediately reconstructed using an ideal
e-constructor. Determine the output ya(t) of the re-constru
the following cases and compare it with the original x(t).
1. When there is no pre-filter (H(f) = 1).
2. When H(f) is an ideal pre-filter with cut off of
20KHz.
3. When H(f) is a practical pre-filter that has a flat
pass-band up to 20KHz and attenuates at a rate
of 48dB/octave beyond 20KHz. Ignore the effects
1.3.3. Quantization

e process of converting a discrete-time continuo


mplitude signal into a digital signal by expressing
ch sample value as a finite (instead of an infinite
mber of digits, is called quantization.

xq(n) = Q[x(n)]

xq(n): the sequence of quantized samples at the


output of the quantizer.
eq(n) = xq(n) – x(n) : quantization error.
1.3.3. Quantization
Example:
Consider the analog exponential signal
xa(t) = (0.9)t , t ≥ 0.
Sampling xa(t) at the sampling frequency fs = 1H
we have: T = 1/fs = 1.
⇒ x(nT) = x(n) = (0.9)n ; n ≥ 0.
1.3.3. Quantization
1.3.3. Quantization
Consider the first 10 samples of x(n).
Numerical Illustration of Quantization with one significant digit using
truncation or rounding

x(n) xq(n) xq(n) eq(n) = xq(n) – x(n)


n
Discrete-time signal (Truncation) (Rounding) (Rounding)
0 1 1.0 1.0 0.0
1 0.9 0.9 0.9 0.0
2 0.81 0.8 0.8 -0.01
3 0.729 0.7 0.7 -0.029
4 0.6561 0.6 0.7 0.0439
5 0.59049 0.5 0.6 0.00951
6 0.531441 0.5 0.5 -0.031441
7 0.4782969 0.4 0.5 0.0217031
8 0.43046721 0.4 0.4 -0.03046721
9 0.387420489 0.3 0.4 0.012579511
1.3.3. Quantization
1.3.3. Quantization

+ The value allowed in the digital signal are called


the quantization levels.
+ The distance ∆ between two successive
quantization levels is called the quantization
step size or resolution.
+ The quantization error eq(n)

∆ ∆
− ≤ eq ( n ) ≤
2 2
1.3.3. Quantization

Quantization of sinusoidal signals


Consider an analog sinusoid signal
xa(t) = ACosΩot ⇒x(n) = xa(nT)
1.3.3. Quantization
1.3.3. Quantization
1.3.3. Quantization

The quantization error: eq(t) = xq(t) – xa(t)

The mean-square error power Pq is:


τ τ
1 1 2
Pq = ∫ eq ( t ) dt = ∫ eq ( t ) dt
2

2τ −τ τ0

with τ: the time that xa(t) stays within the


quantization levels.
τ 2
∆ 1 ∆ 2 ∆2
Since eq ( t ) = t , − τ ≤ t ≤ τ ⇒ Pq = ∫   t dt =
2τ τ 0  2τ  12
1.3.3. Quantization
The root mean-square error erms is:

erms =
12
If the quantizer has b bits of accuracy and the
quantizer covers the entire range 2A,
the quantization step is:
2A
∆= b
2
2
A 1
⇒ Pq = . 2b
3 2
1.3.3. Quantization

The average power of the signal xa(t) is:

Tp
1 A2
Px =
Tp ∫0 ( ACosΩ o t )dt = 2
1.3.3. Quantization

The quality of the output of the A/D converter


s usually measured by the signal-to-quantization
noise ratio (SQNR)
Px 3 2b
SQNR = = .2
Pq 2
Expressed in decibels (dB)

SQNR (dB ) = 10 log10 SQNR = 1.76 + 6.02b


1.3.3. Quantization

he dynamic range of the quantizer (in dB)


he full scale range R of a A/D converter is divided
ually to 2b quantization levels. The quantization step
R R
∆= b =2 b

2 ∆
R
20 log10   = 20 log10 ( 2b ) = b.20 log10 2 = 6.b
∆

6.b is the dynamic range in dB


1.3.4. Coding of Quantized
samples

The coding process in an A/D converter assigns


a unique binary number to each quantization leve

If we have L levels, we need at least L different


binary numbers. With a word length of b bits,
we can create 2b different binary numbers.

⇒ 2b ≥ L or b ≥ log2L.
1.4. Digital to analog
conversion

This is the process converting a digital signal in


an analog signal.

All D/A converters connect the dots in a digital


signal by performing some kind of interpolation
whose accuracy depends on the quality of the
D/A conversion process.