Frequency Response & Digital Filters -...

18
Frequency Response & Digital Filters S Wongsa 1 Dept. of Control Systems and Instrumentation Engineering, KMUTT Today’s goals Today’s goals LTI Digital Filters Digital filter representations and structures Frequency response analysis of digital filters Ideal filters IIR & FIR filters 2 IIR & FIR filters

Transcript of Frequency Response & Digital Filters -...

Page 1: Frequency Response & Digital Filters - KMUTTwebstaff.kmutt.ac.th/~sarawan.won/INC212/OH_DigitalFilters.pdf · Frequency Response of Discrete-Time Systems 33 • In going from the

Frequency Response & Digital Filters

S Wongsa

11

S Wongsa

Dept. of Control Systems and Instrumentation Engineering,

KMUTT

Today’s goalsToday’s goals

LTI Digital Filters

Digital filter representations and structures

Frequency response analysis of digital filters

Ideal filters

IIR & FIR filters

22

IIR & FIR filters

Page 2: Frequency Response & Digital Filters - KMUTTwebstaff.kmutt.ac.th/~sarawan.won/INC212/OH_DigitalFilters.pdf · Frequency Response of Discrete-Time Systems 33 • In going from the

Relationship between ZT & DTFT

Frequency Response of Discrete-Time Systems

33

• In going from the DTFT to the ZT we replace

by . Ωje z

• This evaluation is equivalent to evaluating the z-transform on the unit circle in

the complex plane.

• Replacing with , ZT will become DTFT. z Ωje

Frequency Response of Discrete-Time Systems

• Frequency Response Analysis

Consider a DT transfer function H(z), the discrete frequency response function

(FRF) is

44

Ω=

Ω ==Ω jez

j zHeHH |)()()(

• is the magnitude or gain of the FRF. |)(| ΩH

• is the phase of the FRF. )(Ω∠H

where Ω is the discrete frequency in rad/sample.

Page 3: Frequency Response & Digital Filters - KMUTTwebstaff.kmutt.ac.th/~sarawan.won/INC212/OH_DigitalFilters.pdf · Frequency Response of Discrete-Time Systems 33 • In going from the

Frequency Response of Discrete-Time Systems

System Response to Sampled Sinusoids

55

If a DT system is stable with transfer function H(z), then in steady-state

Anx =][ )0(][ AHny =

nAnx 0sin][ Ω= ))(sin(|)(|][ 000 Ω∠+ΩΩ= HnHAny

nAnx 0cos][ Ω= ))(cos(|)(|][ 000 Ω∠+ΩΩ= HnHAny

Frequency Response of Discrete-Time Systems

nAnx 0sin][ Ω= ))(sin(|)(|][ 000 Ω∠+ΩΩ= HnHAny

nAnx 0cos][ Ω= ))(cos(|)(|][ 000 Ω∠+ΩΩ= HnHAny

66

When , the system response is nznx =][

∑∑∞

−∞=

−∞=

−∞

−∞=

==

=−=

k

nkn

k

kn

k

zHzzkhz

zkhknxkhny

)(][

][][][][

)(cos()()cos( Ω∠+ΩΩ⇒Ω HnHn

Proof:

Page 4: Frequency Response & Digital Filters - KMUTTwebstaff.kmutt.ac.th/~sarawan.won/INC212/OH_DigitalFilters.pdf · Frequency Response of Discrete-Time Systems 33 • In going from the

Frequency Response of Discrete-Time Systems

)(zHzz nn ⇒

Setting in this relationship yields Ω±= jez

)2( )(

)1( )(Ω−Ω−Ω−

ΩΩΩ

⇒jnjnj

jnjnj

eHee

eHee

77

Adding (1) and (2) yields

)(Re2)()()cos(2 ΩΩΩ−Ω−ΩΩ =+⇒Ω jnjjnjjnj eHeeHeeHen

With , we get )()()(

Ω∠ΩΩ =jeHjjj eeHeH

)(cos()()cos( ΩΩ ∠+Ω⇒Ω jj eHneHn

EXAMPLE

5.0)(

−=z

zzH

5.0)(

−=Ω Ω

Ω

j

j

e

eH

Frequency Response of Discrete-Time Systems

88

5.0−Ωje

Ω+−ΩΩ+Ω

=Ωsin)5.0(cos

sincos)(

j

jH

Page 5: Frequency Response & Digital Filters - KMUTTwebstaff.kmutt.ac.th/~sarawan.won/INC212/OH_DigitalFilters.pdf · Frequency Response of Discrete-Time Systems 33 • In going from the

EXAMPLE

Ω+−ΩΩ+Ω

=Ωsin)5.0(cos

sincos)(

j

jH

If a sinusoidal input is appliednnx3

sin][π

=

1.1547,|)3/(| =πH o30)3/( −=∠ πH

Frequency Response of Discrete-Time Systems

99

)303

1.1547sin(][ o−= nnyπ

H = tf([1 0],[1 -0.5],-1);

[mag,phase]=bode(H,pi/3)

mag =

1.1547

phase =

-30.0000

5.0)(

−=z

zzHNB:

Bode Plot

A Bode plot in the discrete time is a graph of |H(Ω)| and ∠H(Ω) plotted

as a function of Ω, where Ω is usually ranging from 0 to π.

Ω+−ΩΩ+Ω

=Ωsin)5.0(cos

sincos)(

j

jH

5.0)(

−=z

zzH

Frequency Response of Discrete-Time Systems

MATLAB: freqz

1010

num = 1; % numerator

den = [1 -0.5]; % denominator

freqz(num,den); % DT frequency response

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-30

-20

-10

0

Normalized Frequency (×π rad/sample)

Phase (degrees)

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-5

0

5

10

Normalized Frequency (×π rad/sample)

Magnitude (dB)

MATLAB: freqz

NB: The Bode plot can also be

obtained from the ‘bode’ command of

MATLAB.

Page 6: Frequency Response & Digital Filters - KMUTTwebstaff.kmutt.ac.th/~sarawan.won/INC212/OH_DigitalFilters.pdf · Frequency Response of Discrete-Time Systems 33 • In going from the

Frequency Response from Pole-Zero Location

Transfer function:

∏∏

=

=

=

=

−=

+=

N

k k

M

k k

kN

k

k

kM

k

k

zd

zcb

za

zb

zH

1

1

1

1

0

1

0

)1(

)1(

1

)(

Frequency response:

∏∏

∏∏

=

ΩΩ−

=

ΩΩ−

=

Ω−

=

Ω−

−=

−=Ω

N

k k

jjN

M

k k

jjM

N

k

j

k

M

k

j

k

dee

ceeb

ed

ecbH

1

10

1

10

)(

)(

)1(

)1()(

1111

The magnitude:

∏∏

∏∏

=

Ω

=

Ω

=

Ω

=

Ω

=−

−=Ω

N

k

j

k

M

k

j

k

N

k k

j

M

k k

j

ed

ecb

de

cebH

1

10

1

1

0

to from distance

to from distance)(

and phase:

( ) ( )∑∑ =

Ω

=

Ω −∠−−∠+−Ω=Ω∠N

k k

jM

k k

j deceMNH11

)()(

Linear phase term Sum of the angles from the zeros/poles to unit circle

Frequency Response of LTI – A Graphical View

Transfer function:

∏∏

=

=

−=

N

k k

M

k k

zd

zcbzH

1

1

1

1

0

)1(

)1()(

Ω= jezWe are going around the circle with

1212

∏ =−

k k zd1)1(

Frequency response:

Ω==Ω jez

zHH )()(

Adopted from Elena Punskaya, Basics of Digital Filters.

Page 7: Frequency Response & Digital Filters - KMUTTwebstaff.kmutt.ac.th/~sarawan.won/INC212/OH_DigitalFilters.pdf · Frequency Response of Discrete-Time Systems 33 • In going from the

Frequency Response of LTI – A Graphical View

The magnitude of the frequency response is given by b0

times the product of the distances from the zeros to

divided by the product of the distances from the poles

Ω= jez

∏∏

∏∏

=

Ω

=

Ω

=

Ω

=

Ω

=−

−=Ω

N

k

j

k

M

k

j

k

N

k k

j

M

k k

j

ed

ecb

de

cebH

1

10

1

1

0

to from distance

to from distance)(

1313Adopted from Elena Punskaya, Basics of Digital Filters.

( ) ( )∑∑ =

Ω

=

Ω −∠−−∠+−Ω=Ω∠N

k k

jM

k k

j deceMNH11

)()(

to Ω= jez

The phase response is given by the sum of the angles from

the zeros to minus the sum of the angles from the

poles to plus a linear phase term

Ω= jez

Ω= jez )( MN −Ω

Frequency Response of LTI – A Graphical View

when is close to a pole, the

magnitude of the response rises

(resonance).

Ω= jez

when is close to a zero, the Ω= jez

1414Adopted from Elena Punskaya, Basics of Digital Filters.

magnitude of the response falls (a null).

Page 8: Frequency Response & Digital Filters - KMUTTwebstaff.kmutt.ac.th/~sarawan.won/INC212/OH_DigitalFilters.pdf · Frequency Response of Discrete-Time Systems 33 • In going from the

Frequency Response of LTI – Example

1515Source: Ashok Ambadar, Digital Signal Processing: A Modern Introduction.

Example – Filters and Pole-Zero Plots

1616

Page 9: Frequency Response & Digital Filters - KMUTTwebstaff.kmutt.ac.th/~sarawan.won/INC212/OH_DigitalFilters.pdf · Frequency Response of Discrete-Time Systems 33 • In going from the

Today’s goalsToday’s goals

LTI Digital Filters

Digital filter representations and structures

Frequency response analysis of digital filters

Ideal filters

IIR & FIR filters

1717

IIR & FIR filters

What is Digital Filter?

Digital filter is a system that performs mathematical operations on a discrete-time

signal and transforms it into another sequence that has some more desirable

properties, e.g.

Digital filter x[n] y[n]

1818

In this course, we limit ourselves to LTI digital filters only.

Page 10: Frequency Response & Digital Filters - KMUTTwebstaff.kmutt.ac.th/~sarawan.won/INC212/OH_DigitalFilters.pdf · Frequency Response of Discrete-Time Systems 33 • In going from the

Example Applications of Digital Filters

Noise RemovalElectrocardiogram

(ECG)

1919

https://youtu.be/v3b-YhZmQu8?t=45

Example Applications of Digital Filters

Noise RemovalElectrocardiogram

(ECG)

2020

Low-pass filtered ECG

https://youtu.be/v3b-YhZmQu8?t=45

Page 11: Frequency Response & Digital Filters - KMUTTwebstaff.kmutt.ac.th/~sarawan.won/INC212/OH_DigitalFilters.pdf · Frequency Response of Discrete-Time Systems 33 • In going from the

Example Applications of Digital Filters

Audio Processing

2121

Digital Filter Representations

][][

][...]1[][

...][...]2[]1[][

01

10

21

knxbknya

Mnxbn-xbnxb

Nnyanyanyany

M

k

k

N

k

k

M

N

−+−−=

−+++

+−−−−−−−=

∑∑==

The linear time-invariant digital filter can be described by the linear difference

equation

The order of the filter is the larger of M or N

2222

The order of the filter is the larger of M or N

kN

k

k

kM

k

k

za

zb

zX

zYzH

=

=

+==

1

0

1)(

)()(

Transfer function of the filter is

Page 12: Frequency Response & Digital Filters - KMUTTwebstaff.kmutt.ac.th/~sarawan.won/INC212/OH_DigitalFilters.pdf · Frequency Response of Discrete-Time Systems 33 • In going from the

Adders:

Multipliers:

Digital Filter Structures: Common Elements

2323

Delays:

Digital Filter Structures

EXAMPLE: Echo Generation

y[n] = x[n] + αx[n − D], |α| < 1

Echoes are delayed signals and can be generated by the following difference equation:

where D is the delay in samples.

Direct sound Reflected sound

2424

where D is the delay in samples.

Page 13: Frequency Response & Digital Filters - KMUTTwebstaff.kmutt.ac.th/~sarawan.won/INC212/OH_DigitalFilters.pdf · Frequency Response of Discrete-Time Systems 33 • In going from the

Ideal Filters – Magnitude Response

Ideal filters let frequency components over the passband pass through undistorted

(gain = 1), while components at the stopband are completely cut off (gain = 0).

2525

Ideal Filters – Phase Response

Ideal filter: admits a linear phase response

)(|)(|)( ΩΩ=Ω θjeHH

where

Ω−=Ω0

)( Nθ

Linear phase Nonlinear phase

2626

)(|)(|)( 0 ΩΩ=Ω Ω−XeHY

jNFourier transform of

][ 0Nnx −

Linear phase Nonlinear phase

Output is merely a delayed version of input.

Page 14: Frequency Response & Digital Filters - KMUTTwebstaff.kmutt.ac.th/~sarawan.won/INC212/OH_DigitalFilters.pdf · Frequency Response of Discrete-Time Systems 33 • In going from the

Linear Phase Response

Linear-phase filters delay all frequencies by the same amount, thereby maximally

preserving waveshape.

2727Adapted from Elena Punskaya, Basics of Digital Filters.

Ω+Ω−=Ω 3150

)( 2

2 πθNonlinear phase:

Ω−=Ω 5)(1θ

Ideal Filters – Linear Phase Response

Group Delay: A measure of linearity of the phase is obtained from the group delay

function, which is defined as

ΩΩ

−=Ωd

d )()(

θτ

The group delay is constant when the phase is linear.

2828

0

Page 15: Frequency Response & Digital Filters - KMUTTwebstaff.kmutt.ac.th/~sarawan.won/INC212/OH_DigitalFilters.pdf · Frequency Response of Discrete-Time Systems 33 • In going from the

Example – A simple ideal lowpass filter

≤Ω<Ω

Ω≤Ω=Ω

if ,0

if ,1)(

πc

c

dH

The impulse response is given by

n

nnh

c

ccd Ω

ΩΩ=

sin][

π

2929

Non-causal and infinite in duration.

Clearly cannot be implemented in

real-time!.

FIR & IIR Filters

Finite Impulse Response (FIR) Filters: N = 0, no feedback. The FIR filter has no poles,

only zeros, i.e.

kN

k

k

kM

k

k

za

zb

zX

zYzH

=

=

+==

1

0

1)(

)()(

3030

Infinite Impulse Response (IIR) Filters: 0≠ka

( )]2[]1[][3

1][ −+−+= nxnxnxny

][]1[6.0][ nxnyny +−=

Page 16: Frequency Response & Digital Filters - KMUTTwebstaff.kmutt.ac.th/~sarawan.won/INC212/OH_DigitalFilters.pdf · Frequency Response of Discrete-Time Systems 33 • In going from the

FIR & IIR Filters

FIR Filers : the impulse response of a FIR filter lasts only a finite time

( )]2[]1[][3

1][ −+−+= nxnxnxny

0

0.1

0.2

0.3

0.4

=

=elsewhere 0

2,1,0,3/1][

nnh

3131

IIR Filters: the impulse response function of a IIR filter is non-zero over an infinite

length of time

][]1[6.0][ nxnyny +−=

0 1 2 3 4 50

n

FIR & IIR Filters

Stability: FIR filters are always stable . IIR filters can be unstable (because the filter

have poles in their transfer functions. ) if not designed properly.

Order: IIR filters are computationally more efficient than FIR filters as they require

fewer coefficients due to the fact that they use feedback or poles.

3232

fewer coefficients due to the fact that they use feedback or poles.

Phase: FIR filters can be guaranteed to have linear phase. IIR filters in general do

not have linear phase.

Page 17: Frequency Response & Digital Filters - KMUTTwebstaff.kmutt.ac.th/~sarawan.won/INC212/OH_DigitalFilters.pdf · Frequency Response of Discrete-Time Systems 33 • In going from the

Symmetry conditions for linear phase response

MM

n

n zMhzhhznhzH −−

=

− +++==∑ ][...]1[]0[][)( 1

0

Consider an FIR filter of order M. By definition H(z) is the z-transform of h[n]

Sufficient conditions for the phase linearity of an FIR filter:

If h[n] is either symmetric or antisymmetric about its center point, the filter phase

response is a linear function of Ω

3333

response is a linear function of Ω

][][ nMhnh −=

Symmetrical impulse response:

e.g. M=4

][][ nMhnh −−=

Antisymmetrical impulse response:

e.g. M=4

Symmetry conditions for linear phase response

][][ nMhnh −=

Symmetrical impulse response:

EXAMPLE: for M=4,

)]4[]3[]2[]1[]0[(

]4[]3[]2[]1[]0[)(

2122

4321

−−−

−−−−

++++=

++++=

zhzhhzhzhz

zhzhzhzhhzH

The frequency response is

3434

The frequency response is

)]4[]3[]2[]1[]0[()( 222 Ω−Ω−ΩΩΩ− ++++=Ω jjjjj ehehheheheH

))2cos(]0[2)cos(]1[2]2[(

])][1[]2[]][0[()(

2

222

Ω+Ω+=

++++=ΩΩ−

Ω−ΩΩ−ΩΩ−

hhhe

eehheeheH

j

jjjjj

If h[n] is symmetric about its center point, then h[0] = h[4] and h[1] = h[3]:

Hence, the phase response is given by

Ω−=Ω∠ 2)(H

Page 18: Frequency Response & Digital Filters - KMUTTwebstaff.kmutt.ac.th/~sarawan.won/INC212/OH_DigitalFilters.pdf · Frequency Response of Discrete-Time Systems 33 • In going from the

Symmetry conditions for linear phase response

][][ nMhnh −−=

Antisymmetrical impulse response:

EXAMPLE: for M=4,

)]4[]3[]2[]1[]0[(

]4[]3[]2[]1[]0[)(

2122

4321

−−−

−−−−

++++=

++++=

zhzhhzhzhz

zhzhzhzhhzH

The frequency response is

3535

The frequency response is

)]4[]3[]2[]1[]0[()( 222 Ω−Ω−ΩΩΩ− ++++=Ω jjjjj ehehheheheH

))2sin(]0[)sin(]1[(2

])][1[]][0[()(

2

222

Ω+Ω=

−+−=ΩΩ−

Ω−ΩΩ−ΩΩ−

hhje

eeheeheH

j

jjjjj

If h[n] is antisymmetric about its center point, then h[2]=0, h[0] = -h[4] and h[1] = -h[3]:

Hence, the phase response is given by

Ω−=Ω∠ 22

)(π

H