Digital Signal Processing & Filter Design
Concept of Digital
Frequency
Prof. Md. Kamrul Hasan
Department of Electrical and
Electronic Engineering
BUET
A Chinese proverb
“We firmly believe that there is enormous value in hands-on-experience. Indeed,
software tools such as MATLAB allow students to implement sophisticated
signal processing systems on their own personal computers, and we feel that
there is great benefit to this once the student is confident of the fundamentals
and is capable of sorting out programming mistakes from conceptual errors.”
Oppenheim, Schafer & Buck
What is Signal Processing?
Signal processing is the analysis, interpretation
and manipulation of signals.
Signals of interest include sound, images, biological signals
such as ECG, radar signals, and many others.
Processing of such signals includes storage and
reconstruction, separation of information from noise (e.g.,
aircraft identification by radar, extracting speech from noise),
compression (e.g., image compression), and
feature extraction (e.g., ECG interpretation, speaker
identification).
What is a Signal?
In the fields of communications, signal processing, and in
electrical engineering more generally, a signal is any physical
quantity that varies with time, space or any other independent
variable, e.g. ECG, speech etc.
Signals are often scalar-valued functions of time (waveforms), but may
be vector valued and may be functions of any other relevant
independent variable.
The concept is broad, and hard to define precisely. Definitions
specific to subfields are common. For example, in information theory
, a signal is a codified message, that is, the sequence of states in a
communication channel that encodes a message. In a
communication system, a transmitter encodes a message into a
signal, which is carried to a receiver by the communications
channel. For example, the words "Mary had a little lamb" might be
the message spoken into a telephone. The telephone transmitter
converts the sounds into an electrical voltage signal. The signal is
transmitted to the receiving telephone by wires; and at the receiver it
is reconverted into sounds.
What is a system?
A system is a device that performs an
operation on an input signal.
System may be a hardware
System may be a software
For example, a FILTER is a SYSTEM which acts as a frequency attenuator
in the following example.
x(n) A sin(2 f1n) B sin(2 f 2 n) y (n) A sin(2 f1n)
Freq. Shaping
FILTER
Frequency component f2 is attenuated
Noise
In physics, the term noise has the following meanings:
An undesired disturbance within the frequency band of
interest; the summation of unwanted or disturbing energy
introduced into a communications system from man-
made and natural sources.
A disturbance that affects a signal and that may distort
the information carried by the signal.
A random signal of known statistical properties of
amplitude, distribution, and spectral density.
Loosely, any disturbance tending to interfere with the
normal operation of a device or system.
Outline of Lecture 1
Concept of digital frequency
Sampling and quantization
Solving numerical examples
Text book
Digital Signal Processing: Principles, Algorithms, and Applications
------ CHAPTER 1
J. G. Proakis & D. G. Manolakis
What is frequency?
The number of cycles per unit of time is called the
frequency.
The number of wave oscillations per unit time
most often measured in cycles per second (cps) or the
interchangeable Hertz (Hz) (50 cps = 50 Hz),
Continuous-time Sinusoidal Signal
xa (t ) A cos(t )
A cos(2 Ft ), t
Properties
(i) For every value of F xa (t ) is periodic.
(ii) CT sinusoidal signals with distinct freq. are themselves
distinct.
(iii) F results in an increase in the rate of oscillation
of the signal
(iv) As t continuous we can increase F without limit.
Discrete-time Sinusoidal Signal
x(n) A cos( n )
A cos(2 fn ), n <
where
2 f
n: an integer variable, called the sample number.
A: amplitude
: frequency in radians/sample
: phase in radians q
f : frequency in cycles/sample
What is the relationship between f and F?
Discrete-time Sinusoidal Signal
Properties
(i) A DTsinusoidal signal x(n) is periodic with period
N (N>0) if and only if x(n N ) x(n) .
cos[2 f (n N ) ] cos(2 fn )
This relation is true if there exists an integer k such that
k f
2 fN 2k , f is a ratio of two integers
N
Examples: Determine periodicity, if
periodic
3 Periodic, N=14 3 3 3
(a) cos( n) 2 f f
7 7 7 14
10 10 10 5
(b) cos( n) Aperiodic, f - irrational 2 f f
7 7 7 7
1
(c) cos( n) Aperiodic, f - irrational 2 f f
2
STEPS: A small change in the frequency f1
31
N1 60
can result in a large change in the 60
1. Express f as k/N period
f2
30 1
N2 2
60 2
2. Cancel common factors so that k and N are relatively prime
3. Then the fundamental period is equal to N
Properties: DT sinusoids (Contd.)
(ii) Discrete-time sinusoids whose frequencies are separated by an integer multiple of
2 are identical
Proof:
x(n) A cos(0 n )
x1 (n) A cos[(0 2 )n ] A cos(0n 2 n )
A cos(0 n )
x ( n)
As a result, all sinusoidal sequences xk (n) A cos(k n ), k 0,1, 2,........
are indistinguishable (i.e., identical).
where, k 0 2k , 0
1 1
The sequences of any two sinusoids with frequencies in the range or f
2 2
are distinct.
Digital Frequency Range
Independent freq. range
2 2 3
0 0 2
Alias freq. bands
2
4
Any sequence resulting from a sinusoid with a frequency| | or | f | 1/ 2 , is identica
a sequence obtained from a sinusoidal signal with frequency | | .
Because of this similarity, we call the sinusoids with frequency | | an alias of a
corresponding sinusoid with frequency | | .
CT sinusoids are all
Unique frequency range: or 1/ 2 f 1/ 2 distinct in the range
Aliases: | | or |f>1/2|
or F
Properties: DT Sinusoid (Contd.)
(iii) The highest rate of oscillation in a discrete-time sinusoid is obtained when
(or ) Or equivalently,
1 1
f (or f )
2 2
What happen for 0 2 ?
Moving from 2 is equivalent to moving from 0
Therefore frequency of oscillation will decease in that range!!
Harmonically Related Complex Exponentials
CT Exponentials:
The basic signals for CT, harmonically related exponentials are
sk (t ) e jk 0t e j 2 kF0t k 0, 1, 2,.......
sk (t ) is periodic with fundamental period 1/(kF0)=Tp/k or fundamental
frequency kF0
A signal that is periodic with period Tp/k is also periodic with period
k(Tp/k) = Tp, for any +Ve integer k
If k1 ≠ k2 , then s1 (t ) s2 (t )
Fourier series expansion for xa (t ) can be expressed as
k k
xa (t )
k
ck sk (t )
k
ck e jk 0t Linear combination of infinite no.
of harmonics
Harmonically Related Complex Exponentials
DT Exponentials:
The basic signals for DT, harmonically related exponentials are
sk (n) e jk0n e j 2 kf0n k 0, 1, 2,.......
sk ( n) is N-sample periodic, thus f0=1/N, the fundamental period
In contrast to the CT case, we note that
sk N (n) e j ( k N )2 f0n e j 2 n ( k N ) / N = e j 2 n sk (n) sk (n)
s0 (n) sN (n), s1 (n) sN 1 (n), and so on
There are only N distinct periodic complex exponentials.
Fourier series expansion for x ( n) can be expressed as
k N 1 k N 1
x ( n)
k 0
ck sk ( n)
k 0
ck e j 2 kn / N Linear combination of N no.
of harmonics
k
fk
N Frequency of the k-th harmonics
Sampling & Quantization
A/D Conversion
What does an A/D Converter do?
Sampling samples the CT signal
Quantization quantizes the DT samples
Coding represents the quantized samples in binary number
xa (t ) x ( n) xq (n) 01001….
SAMPLER xa (t ) QUANTIZER CODER
Analog signal DT signal Quantized Digital signal
signal
Sampling:
How many samples are necessary?
Sampling does not result in a loss of information nor does it introduce
distortion in the signal if the signal BW is finite.
Types of sampling: periodic/uniform & non-uniform
Quantization:
How many bits per sample are required? More bits, more accuracy!!
Sampling
Sampling is a process of measuring the amplitude of a continuous-time signal
at discrete instants CT signal into a DT signal
Three sampling methods:
Ideal sampling
Natural sampling
Flat top sampling
How many samples are required?
Depends on the type of signal
More samples for CD quality music
44,100 samples per second
4 bytes per sample
176,400 bytes per second
Speech/Voice uses fewer samples:
4,000 samples per second for speech (minimum acceptable)
8,000 samples per second for better quality
ECG uses 1000 samples per second, however, 250Hz is acceptable
for HRV, 100 Hz is good, 50Hz is not acceptable
Periodic/Uniform Sampling
T: time interval between successive samples
sampling period or sampling interval
n: sample number Discrete-time
Analog signal signal
Relationship between ‘t’ and ‘n’
Relationship between t and n
n
t nT
Fs
Analog 1
DT
Signal Fs Signal
T
Sampler
Relationship between F and f mapping
CT signal
xa (t ) A cos(2 Ft ) DT signal
F 1/ 2 f 1/ 2
After sampling we obtain,
xa (nT ) A cos(2 FnT )
F
xa (nT ) A cos 2 ( ) n x(n) A cos(2 fn )
Fs
Comparing, F
f i.e., f and F are linearly related.
Fs
What happens to frequencies above Fs/2
F
2 2 3
0 0 2
k 0 2 k
2
4
Dividing by 2 , fk f0 k
Fk F0
fk k
Fs Fs
Fk F0 kFs
Suppose: Fs = 40 Hz
F= 50Hz
Example:
Replacing ‘t’ by
Sampling Theorem
Sampling Theorem: Contd.
Sampling Theorem: Contd.
Sampling Theorem:
Articulated by Nyquist in 1928 and
mathematically proven by Shannon in 1949
The sampling theorem states that for a band-limited signal with maximum
frequency Fmax, the uniform sampling frequency Fs must be greater than
twice of Fmax, i.e.,
Fs > 2 Fmax
The frequency 2Fmax is called the Nyquist sampling rate. Half this frequency,
Fmax, is sometimes called the Nyquist frequency.
What if the sampling rate is too low:
Aliasing: fold over effect of the higher frequencies into the lower
frequencies.
Sampling a sinusoidal Signal
Sampling Theorem: Contd.
Ideal Reconstruction
Ideal Reconstruction: Contd.
Ideal Reconstruction: Contd.
Ideal Reconstruction: Contd.
Example: In a digital audio application the signal is sampled at 44 kHz and each
sample is quantized using an A/D converter having a full-range scale of 10
volts. Determine the number of bits B if the r.m.s. quantization error must be
kept below 50 micro volts. Then determine the actual r.m.s. error and the bit
rate in bits/sec. What is the dynamic range of the quantizer?
Understanding Quantization
Effect of Quantization
Quantizing a grey-level image.
Quantization
N-bit A/D converter
Input voltage (signal) range bounded by ±V volts
The A/D converter samples xa(t) once every T secs and
output N-bit binary number, i.e., quantized value
N-bit can represent Q=2N quantized voltage levels
The spacing between levels, in volts, is denoted by ∆
2V 2V +V
4
N=2
N 3
Q=22=4 levels
Q 1 2 1 -V
2
00
1
01
10
11
Quantization by Rounding
The discrete sample x(nT) is quantized to the nearest level
Quantized level ≠ true value (x(nT)), usually
Quantization error, e(n) = quantized value - true value
x(nT)
Quantization levels
Center line between
the two levels
nT
The quantization error is bounded by
2
∆ ∆
i.e., − ≤ 𝑒(𝑛) ≤
2 2
Quantization by Truncating
The discrete sample x(nT) is quantized to the lower level
Quantized level ≠ true value (x(nT)), usually
Quantization error, e(n) = quantized value -true value
Coding- Digital Signal
The quantized samples need to be digitized.
Choose the number of bits to represent each sampled value. The
more the bits the more the levels, and hence the better the
representation
If 12 bits is used to represent a sample, then the range of input
values is divided into 212 = 4096 levels
Quantizer Input-Output Characteristics
Quantization Error Modeling
The quantization error is given by
𝑒(𝑛)=𝑥𝑄 (𝑛)− 𝑥(𝑛)
∆ ∆
where the error is bounded by − ≤ 𝑒(𝑛) ≤
2 2
The quantized sample can thus be expressed as
𝑥𝑄 (𝑛)=𝑥 (𝑛)+𝑒(𝑛)
Assumptions: additive noise
e(n) is a zero-mean white noise (i.e., uncorrelated random noise)
e(n) is uniformly distributed
E
=Q
E
The probability distribution of the error signal: = 0, otherwise
The mean-square value of the error is given by
△/ 2 2
1 △
𝜎 𝑒= ∫ 𝑒 (𝑛)𝑑𝑒(𝑛)=
2 2
△ −△ / 2 12
The performance of the A/D converter is characterized by its SQNR, defined as
x2
SQNR 2
e
SQNR dB 10 log10 SQNR=10 log10 x2 10 log10 e2
2 2 2
𝜎 𝑥 𝜎 𝑥 12 𝜎 𝑥 2
SQNR= 2
= 2
= 2
=12 𝜎 ¿¿ 𝑥
𝜎 𝑒 △ /12 △
Performance of A/D Converter
For N=8, 10, or 12, we can approximate 2N 1 2N
x2
SQNR dB 10 log10 3 10 log10 2 10 log10 2 2 N
V
x2
4.77 10 log10 2 6 N
V
Thus for each bit added to the A/D converter, the SQNR is improved by app. 6 dB.
For sine wave input with amplitude V, 1
SQN R dB = 4.77 +10 log 10 +6 𝑁 =1.76 + 6 𝑁
2
(𝜎 =𝑉 )
2
2 2 𝑉
𝑥 𝑟𝑚𝑠 =
2
Problems:
Prob-1: The continuous-time signal
xa (t ) 3cos(400 t ) 5cos(1200 t ) 6cos(4400 t ) 2 cos(5200 t )
is sampled at a 4-kHz rate generating the sequence x(n). Determine the exact
expression of x(n).
Prob-2: State with reason (s) if the following signals are periodic:
(a) cos(0.6 n 0.2) 3
𝑓 1=
10
𝑁 1 =10
(b) cos(0.6 n 0.3) 8cos(0.8 n )
2
𝑵 =𝟏𝟎
3 𝑓 2=
5
𝑁 2 =5
Prob-3: A signal 10 cos 2000 t 2 sin 3000 t 2 cos(5000 t 4 ) is sampled at a rate of 4000 HZ,
Find the resulting sampled signal. Dose this sampling rate cause any aliasing?
Explain.
Problems
Consider the simple signal processing system shown in Fig p1.11. The sampling
Periods of the A/D and D/A converters are T=5 ms and T’=1 ms, respectively.
Determine the output ya(t) of the system, if the input is
xa (t ) 3cos(100 t ) 2sin(250 t ) (t in sec)
The postfilter removes any frequency component above Fs/2.
xa(t) x(n) ya(t)
A/D D/A
Postfilter
T T’
Fig. P1.11
𝑥 ( 𝑛 ) =3 cos ( 100 𝜋
200 )
𝑛 + 2sin (
250 𝜋
200
𝑛 =3 cos )
𝜋
2 ( )
𝑛 − 2 sin
3𝜋
4
𝑛 ( )
𝑥 𝑑𝑎 ( 𝑡 ) =3 cos ( 500 𝜋 𝑡 ) −2 sin ( 750 𝜋 𝑡 )
𝑦 𝑎 ( 𝑡 ) =3 cos (500 𝜋 𝑡 ) −2 sin ( 750 𝜋 𝑡 ) since