elen e4810: digital signal processing topic 6: filters - introduction

36
2013-10-16 Dan Ellis 1 ELEN E4810: Digital Signal Processing Topic 6: Filters - Introduction 1. Simple Filters 2. Ideal Filters 3. Linear Phase and FIR filter types

Upload: others

Post on 12-Sep-2021

9 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: ELEN E4810: Digital Signal Processing Topic 6: Filters - Introduction

2013-10-16Dan Ellis 1

ELEN E4810: Digital Signal ProcessingTopic 6:

Filters - Introduction1. Simple Filters2. Ideal Filters3. Linear Phase and FIR filter types

Page 2: ELEN E4810: Digital Signal Processing Topic 6: Filters - Introduction

2013-10-16Dan Ellis 2

1. Simple Filters Filter = system for altering signal in

some ‘useful’ way LSI systems:

are characterized by H(z) (or h[n]) have different gains (& phase shifts)

at different frequencies can be designed systematically

for specific filtering tasks

Page 3: ELEN E4810: Digital Signal Processing Topic 6: Filters - Introduction

2013-10-16Dan Ellis 3

FIR & IIR FIR = finite impulse response⇔ no feedback in block diagram

⇔ no poles (only zeros)

IIR = infinite impulse response⇔ feedback in block diagram

⇔ poles (and often zeros)

Page 4: ELEN E4810: Digital Signal Processing Topic 6: Filters - Introduction

2013-10-16Dan Ellis 4

Simple FIR Lowpass hL[n] = {1/2 1/2} (2 pt moving avg.)

HL z( ) = 12 1+ z1( ) = z +1

2z 1ZP

zero atz = -1

HL ej( ) = e j 2 cos 2( )

n-1 1 2 3 4-2

1/2

hL[n]

|HL(ej!)|

1/2 sample delay

ej!/2+e-j!/2

Page 5: ELEN E4810: Digital Signal Processing Topic 6: Filters - Introduction

2013-10-16Dan Ellis 5

Filters are often characterized by their cutoff frequency !c:

Cutoff frequency is most often defined as the half-power point, i.e.

If

then �

H e jc( ) 2 = 12 max H e j( ) 2{ } H = 1

2 Hmax

Simple FIR Lowpass

!!c

|H(ej!)|

H e j( ) = cos 2( )

c = 2cos1 12 =

2

π

11/√2

≈ 0.707

π/2

Page 6: ELEN E4810: Digital Signal Processing Topic 6: Filters - Introduction

2013-10-16Dan Ellis 6

deciBels Filter magnitude responses are

often described in deciBels (dB) dB is simply a scaled log value:

Half-power also known as 3dB point:

dB = 20 log10 level( ) =10 log10 power( )

H cutoff = 12 H max

dB H cutoff{ } = dB H max{ }+ 20 log10 12( )

= dB H max{ } 3.01

power = level2

Page 7: ELEN E4810: Digital Signal Processing Topic 6: Filters - Introduction

2013-10-16Dan Ellis 7

We usually plot magnitudes in dB:

A gain of 0 corresponds to -∞ dB

deciBels

0 0.2 0.4 0.6 0.8 10

0.2

0.4

0.6

0.81/√2

1

t//

|H(e

jt)|

0 0.2 0.4 0.6 0.8 1-20

-15

-10

-5-3

0

t//

|H(e

jt)|

/ dB

Page 8: ELEN E4810: Digital Signal Processing Topic 6: Filters - Introduction

2013-10-16Dan Ellis 8

Simple FIR Highpass hH[n] = {1/2 -1/2}

3dB point !c = π/2 (again)�

HH z( ) = 12 1 z

1( ) = z 12z 1

ZP

zero atz = 1

HH e j( ) = je j 2 sin 2( )

|HH(ej!)|

n-1 2 3 4-2

1/2

hH[n]

-1/2

!c

π/2

Page 9: ELEN E4810: Digital Signal Processing Topic 6: Filters - Introduction

2013-10-16Dan Ellis 9

FIR Lowpass and Highpass Note:

hL[n] = {1/2 1/2} hH[n] = {1/2 -1/2} i.e.

i.e. 180° rotation of the z-plane, ⇒ π shift of frequency

response

hH n[ ] = (1)n hL n[ ] HH z( ) = HL z( ) 1

z

−1

j

-j

−1-z

1

-j

j

!|HL(ej!)|

!|HH(ej!)|

π

Page 10: ELEN E4810: Digital Signal Processing Topic 6: Filters - Introduction

2013-10-16Dan Ellis

-1 0 1 -1

0

1

z-plane

freq t / /

|H(e

jt)|

|H(e

jt)|

freq t / /0 0.5 1

0

0.5

1

10-2 10-1 10010-2

10-1

100

_ _A1_A1

10

Simple IIR LowpassIIR → feedback, zeros and poles,

conditional stability, h[n] less useful

scale to makegain = 1 at ! = 0→ K = (1 - Æ)/2

pole-zerodiagram

frequencyresponse

FR on log-log axes

0dB

-20dB

-40dB

x[n]z-1

+z-1

+

y[n]K

HLP (z) = K1 + z�1

1� �z�1

Page 11: ELEN E4810: Digital Signal Processing Topic 6: Filters - Introduction

2013-10-16Dan Ellis 11

Simple IIR Lowpass

Cutoff freq. !c from

HLP z( ) = K 1+ z1

1z1

HLP e jc( ) 2 =max2

max = 1using K=(1-Æ)/2

1( )2

41+ e jc( ) 1+ e jc( )1e jc( ) 1e jc( )

= 12

cosc = 21+2

=1 sinc

coscDesign Equation

Page 12: ELEN E4810: Digital Signal Processing Topic 6: Filters - Introduction

2013-10-16Dan Ellis

-1 0 1-1

-0.5

0

0.5

1

z-plane

Freq t / /Freq t / /

|H(e

jt)|

/ dB

|H(e

jt)|

10-2 10-1 100-40

-30

-20

-10

0

0 0.5 10

0.5

1

_ A 1_ A 1

12

Simple IIR Highpass

Pass ! = π → HHP(-1) = 1 → K = (1+Æ)/2

Design Equation:

(again)

=1 sinc

cosc

HHP (z) = K1�z�1

1� �z�1

Page 13: ELEN E4810: Digital Signal Processing Topic 6: Filters - Introduction

2013-10-16Dan Ellis 13

Highpass and Lowpass Consider lowpass filter:

Then:

However, (unless H(ej!) is pure real - not for IIR)

• Highpass

• c/w (-1)nh[n]

just another z poly

HLP (ej�) =

�1 � � 0� 0 large �

1�HLP (ej�) =

�0 � � 0� 1 large �

|1�HLP (z)| �= 1� |HLP (z)|

Page 14: ELEN E4810: Digital Signal Processing Topic 6: Filters - Introduction

2013-10-16Dan Ellis

-1 0 1 1

0.5

0

0.5

1

z-plane

t / /

t / /

|H(e

jw)|

|H(e

jw)|

/ dB

0 0.5 10

0.5

1

10-2 10-1 100-40

-30

-20

-10

0

r

B

e

_

`

14

Simple IIR Bandpass

HBP z( ) =12

1 z2

1 1+( )z1 +z2

= K1+ z1( ) 1 z1( )

1 2r cos z1 + r2z2

where

Center freq3dB bandwidth

r = cos = 1+( )2

c = cos1

Des

ign

B1/√2

B cos 1 21 2

Page 15: ELEN E4810: Digital Signal Processing Topic 6: Filters - Introduction

2013-10-16Dan Ellis 15

Simple Filter Example Design a second-order IIR bandpass

filter with !c = 0.4π, 3dB b/w of 0.1π

⇒�

c = 0.4 = cosc = 0.3090

B = 0.1 21+2

= cos 0.1( ) = 0.7265

HBP z( ) =12

1 z2

1 1+( )z1 +z2

=0.1367 1 z2( )

1 0.5335z1 + 0.7265z2M

sensitive..

Page 16: ELEN E4810: Digital Signal Processing Topic 6: Filters - Introduction

2013-10-16Dan Ellis

t / /

t / /

|H(e

jw)|

|H(e

jw)|

/ dB

-1 0 1-1

-0.5

0

0.5

1

0 0.5 10

0.5

1

10-2 10-1 100-40

-30

-20

-10

0

z-plane

16

Simple IIR Bandstop

Design eqns:

HBS z( ) =1+2

1 2z1 + z2

1 1+( )z1 +z2

zeros at !c (per 1 - 2r cosµ z-1 + r2z-2)

same poles as HBP

B = cos1 21+2

= 1cosB

1cos2 B

1�

c = cos1 = coscB

Page 17: ELEN E4810: Digital Signal Processing Topic 6: Filters - Introduction

2013-10-16Dan Ellis 17

Cascading Filters Repeating a filter (cascade connection)

makes its characteristics more abrupt:

Repeated roots in z-plane:

H(ej!)

H(ej!) H(ej!) H(ej!)

!

|H(ej!)|

!

|H(ej!)|3

1ZP

h

h3

Page 18: ELEN E4810: Digital Signal Processing Topic 6: Filters - Introduction

2013-10-16Dan Ellis 18

1/81/4

Cascading Filters Cascade systems are higher order

e.g. longer (finite) impulse response:

In general, cascade filters will not be optimal (...) for a given order

n-1 2 3 4-2

1/2

h[n]

-1/2

n-1 2 3 4-2

-1/2

n-1 2 4-2-3/8

h[n]∗h[n] h[n]∗h[n]∗h[n]

Page 19: ELEN E4810: Digital Signal Processing Topic 6: Filters - Introduction

2013-10-16Dan Ellis

10-2 10-1 100-60

-50

-40

-30

-20

-10

0

2nd order-6dB/oct

-12dB/oct

4th order

t//

|H(ejt)|

19

Cascading Filters Cascading filters improves rolloff slope:

But: 3dB cutoff frequency will change(gain at !c → 3N dB)

!c

Page 20: ELEN E4810: Digital Signal Processing Topic 6: Filters - Introduction

2013-10-16Dan Ellis

Interlude: The Big Picture

20

IR

LCCDE

DTFT

ZT

y[n] = h[n] � x[n] Y (ej�) = H(ej�)X(ej�)

Y (z) = G

�Mj=1(1� �jz�1)

�Nk=1(1� �kz�1)

X(z)y[n] =M�

j=0

pjx[n� j]�N�

k=1

dky[n� k]

h[k]

x[n – k]

0

1

2

3

0

0

H ej

H ej

DTFT

IDTFT

ZT

IZT

X(ej�) =�

n

x[n]e�j�n

x[n] =12�

� �

��X(ej�)ej�nd�

j

pjx[n� j]��

j

pjz�jX(z)

X(z) = �

nx[n]z�n

X(ej�) = X(z)|z=ej�yc[n] + yp[n] =

i

�i�ni + ��n

0 n � 0

x[n] y[n]+z

p0

p1

p2

-d1

-d2

-1

z-1

z-1

z-1

�nµ[n]� 1

1� �z�1 |z| > |�|

Page 21: ELEN E4810: Digital Signal Processing Topic 6: Filters - Introduction

2013-10-16Dan Ellis 21

2. Ideal filters Typical filter requirements:

gain = 1 for wanted parts (pass band) gain = 0 for unwanted parts (stop band)

“Ideal” characteristics would be like: no phase distortion etc.

What is this filter? can calculate IR h[n] as IDTFT of ideal

response...

!

|H(ej!)|“brickwallLP filter”

Page 22: ELEN E4810: Digital Signal Processing Topic 6: Filters - Introduction

2013-10-16Dan Ellis 22

Ideal Lowpass Filter Given ideal H(ej!):

(assume µ(!) = 0)⇒

!−π π!c−!c

h n[ ] = IDTFT H e j( ){ }= 12 H e j( )e jnd

= 12 e jnd

c

c

h n[ ] = sincnn

Ideal lowpass filter

0

Page 23: ELEN E4810: Digital Signal Processing Topic 6: Filters - Introduction

2013-10-16Dan Ellis 23

Ideal Lowpass Filter

Problems! doubly infinite (n = -∞..∞) no rational polynomial → very long FIR excellent frequency-domain characteristics↔ poor time-domain characteristics (blurring, ringing – a general problem)

h n[ ] = sincnn

-20 -15 -10 -5 0 5 10 15-0.05

0

0.05

0.1

0.15

0.2

n

h[n]

(sinc)

Page 24: ELEN E4810: Digital Signal Processing Topic 6: Filters - Introduction

2013-10-16Dan Ellis 24

lower-order realization (less computation) better time-domain properties (less ringing) easier to design...

Practical filter specifications

|H(e

j !)|

/ dB !

-40

-11

Pass band Stop band

Tran

sitio

n

• allow PB ripples

• allow SB ripples

• allow transition band

Page 25: ELEN E4810: Digital Signal Processing Topic 6: Filters - Introduction

2013-10-16Dan Ellis 25

|H(ej!)| alone can hide phase distortion differing delays for adjacent frequencies

can mangle the signal Prefer filters with a flat phase response

e.g. µ(!) = 0 “zero phase filter” A filter with constant delay øp = D at all

freqs has µ(!) = −D! “linear phase”

Linear phase can ‘shift’ to zero phase

H e j( ) = e jD ˜ H ( )

3. Linear-phase Filters

pure-real (zero-phase)portion

Page 26: ELEN E4810: Digital Signal Processing Topic 6: Filters - Introduction

2013-10-16Dan Ellis 26

Time reversal filtering

v[n] = x[n]∗h[n] → V(ej!) = H(ej!)X(ej!) u[n] = v[-n] → U(ej!) = V(e-j!) = V*(ej!) w[n] = u[n]∗h[n] → W(ej!) = H(ej!)U(ej!) y[n] = w[-n] → Y(ej!) = W*(ej!) = (H(ej!)(H(ej!)X(ej!))*)* → Y(ej!) = X(ej!)|H(ej!)|2

Achieves zero-phase result Not causal! Need whole signal first

H(z)x[n] Timereversal H(z) Time

reversal y[n]v[n] u[n]= v[-n] w[n]

if v real

Page 27: ELEN E4810: Digital Signal Processing Topic 6: Filters - Introduction

2013-10-16Dan Ellis

(Anti)Symmetric FIR filters are almost the only way to get zero/linear phase

4 types:

27

Linear Phase FIR filters

Odd length Even length

Symmetric

Anti-symmetric

Type 1 Type 2

Type 3 Type 4

n n

n n

L-1(L-1)/20

Page 28: ELEN E4810: Digital Signal Processing Topic 6: Filters - Introduction

2013-10-16Dan Ellis

0.4 0.2 0 0.2 0.4 0.6 0.8 1-1

-0.5

0

0.5

1

t//

n=1

n=2

28

Linear Phase FIR: Type 1 Length L odd → order N = L - 1 even Symmetric → h[n] = h[N - n]

(h[N/2] unique)

H e j( ) = h n[ ]e jnn=0

N= e j

N2 h N

2[ ] + 2 h N2 n[ ]cosnn=1

N /2( )linear phaseD = -µ(!)/! = N/2 pure-real H(!) from cosine basis:~

!

H(!)~

Page 29: ELEN E4810: Digital Signal Processing Topic 6: Filters - Introduction

2013-10-16Dan Ellis

0 2 4 6 81 3 5 7 n0

1

2

3

4

5

-10

0

10

20

-/ -0. 5/ 0 0.5/ /-/ -0. 5/ 0 0.5/ /-/

-0.5/

0

0.5/

/Impulse response Magnitude response Phase response

dB

29

Linear Phase FIR: Type 1

Where are the N zeros?

thus for a zero ≥

h n[ ] = h N n[ ] H z( ) = zNH 1z( )

H ( ) = 0 H 1( ) = 0

Reciprocal zeros(as well as cpx conj)

Reciprocalpair

Conjugatereciprocal

constellation

No reciprocal on u.circle

= -D!

-2º

Page 30: ELEN E4810: Digital Signal Processing Topic 6: Filters - Introduction

2013-10-16Dan Ellis

0.4 0.2 0 0.2 0.4 0.6 0.8 1 1

0.5

0

0.5

1

t//

n - 1/2 = 1/2

n - 1/2 = 11/2

n - 1/2 = 21/2

30

Linear Phase FIR: Type 2 Length L even → order N = L - 1 odd Symmetric → h[n] = h[N - n]

(no unique point)

H e j( ) = e jN2 h N+1

2 n[ ]cos n 12( )n=1

N+1( ) /2Non-integer delay

of N/2 samples H(!) from double-length cosine basis~

alwayszeroat !=º

Page 31: ELEN E4810: Digital Signal Processing Topic 6: Filters - Introduction

2013-10-16Dan Ellis

0 2 4 6 8 100

1

2

3

4

5

-/ -0.5/ 0 0.5/ /

-/ -0.5/ 0 0.5/ /

-20

0

20

-0.5/

0

0.5/

/

-/-2 -1 0 1 2

-1-0.5

00.5

1

Impulse Response Magnitude Response

Phase ResponsePole-zero diagram

31

Linear Phase FIR: Type 2

Zeros: at z = -1,

H z( ) = zNH 1z( )

H 1( ) = 1( )N H 1( ) H e j( ) = 0odd

LPF-like

dB

Page 32: ELEN E4810: Digital Signal Processing Topic 6: Filters - Introduction

2013-10-16Dan Ellis

-0. 4 -0. 2 0 0.2 0.4 0.6 0.8 1-1

-0. 5

0

0.5

1

t//

n = 2

n = 1odd

functionszero att = 0, /

32

Linear Phase FIR: Type 3 Length L odd → order N = L - 1 even Antisymmetric → h[n] = –h[N - n] ⇒ h[N/2]= –h[N/2] = 0

H e j( ) = h N2 n[ ] e j

N2n( ) e j

N2+n( )( )n=1

N /2= je j

N2 2 h N

2 n[ ]n=1

N /2 sinn( )µ(!) = º/2 - !·N/2Antisymmetric ⇒º/2 phase shift in addition to linear phase

Page 33: ELEN E4810: Digital Signal Processing Topic 6: Filters - Introduction

2013-10-16Dan Ellis

-/ -0.5/ 0 0.5/ /

-/ -0.5/ 0 0.5/ /-2 -1 0 1 2

Impulse Response Magnitude Response

Phase ResponsePole-zero diagram

0 2 4 6 8 10

-2

0

2

-20

0

20

-0.5/

0

0.5/

/

-/

33

Linear Phase FIR: Type 3

Zeros:

H z( ) = zNH 1z( )

H 1( ) = H 1( ) = 0 ; H 1( ) = H 1( ) = 0

Page 34: ELEN E4810: Digital Signal Processing Topic 6: Filters - Introduction

2013-10-16Dan Ellis 34

Linear Phase FIR: Type 4 Length L even → order N = L - 1 odd Antisymmetric → h[n] = -h[N - n]

(no center point)

H e j( ) = je jN2 2 h N+1

2 n[ ]n=1

N /2 sin n 12( )

fractional-sampledelay

º/2 offset offset sine basis

0.4 0.2 0 0.2 0.4 0.6 0.8 1 1

0.5

0

0.5

1

t//

odd functions

n - 1/2 = 1/2

n - 1/2 = 11/2

Page 35: ELEN E4810: Digital Signal Processing Topic 6: Filters - Introduction

2013-10-16Dan Ellis 35

Linear Phase FIR: Type 4

Zeros: (H(-1) OK because N is odd)

H 1( ) = H 1( ) = 0

-/ -0.5/ 0 0.5/ /

Impulse Response Magnitude Response

Phase ResponsePole-zero diagram

-20

0

20

-0.5/

0

0.5/

/

-/

0 2 4 6 8 10-4

-2

0

2

4

-2 0 2

-1

0

1

-/ -0.5/ 0 0.5/ /t

dB

t

Page 36: ELEN E4810: Digital Signal Processing Topic 6: Filters - Introduction

2013-10-16Dan Ellis 36

4 Linear Phase FIR TypesOdd length Even length

Ant

isym

met

ricS

ymm

etric 1 2

3 4

h[n]

n

!H(!)~

ZP

h[n]

n

!H(!)~

ZPD D

º

h[n]

n

!H(!)~

ZPD

º h[n]

n

!H(!)~

ZPD

º