23
FILTERING OBJECTIVES The objectives of this lecture are to: Introduce signal filtering concepts Introduce filter performance criteria Introduce Finite Impulse Response (FIR) filters Introduce Infinite Impulse Response (IIR) filters Consider advantages of digital filters Consider advantages of using DSP in digital filter implementation Consider sources of noise in digital filters

FILTERING · 2010-04-14 · Depending on the application, some frequencies may be undesirable. Filters can be used to remove these undesirable frequency components. Low-pass Filters

  • Upload
    others

  • View
    2

  • Download
    0

Embed Size (px)

Citation preview

Page 1: FILTERING · 2010-04-14 · Depending on the application, some frequencies may be undesirable. Filters can be used to remove these undesirable frequency components. Low-pass Filters

FILTERING

OBJECTIVES

The objectives of this lecture are to:• Introduce signal filtering concepts• Introduce filter performance criteria• Introduce Finite Impulse Response (FIR) filters• Introduce Infinite Impulse Response (IIR) filters• Consider advantages of digital filters• Consider advantages of using DSP in digital filter implementation• Consider sources of noise in digital filters

Page 2: FILTERING · 2010-04-14 · Depending on the application, some frequencies may be undesirable. Filters can be used to remove these undesirable frequency components. Low-pass Filters

Signals and Filtering

Time Domain

Frequency Domain

AMPLITUDE

TIME

FREQUENCY

AMPLITUDE

f1 f3f2 f4 f5FREQUENCY

AMPLITUDE

f1 f3f2 f4 f5

Vin Vout

The Filter

CR

SURVIVED: f3 f4 f5

FILTERED OUT: f1 f2

Page 3: FILTERING · 2010-04-14 · Depending on the application, some frequencies may be undesirable. Filters can be used to remove these undesirable frequency components. Low-pass Filters

Depending on the application, some frequencies may beundesirable.Filters can be used to remove these undesirable frequencycomponents.

Low-pass Filters (LPF) - These filters pass low

frequencies and stop high frequencies.

High-pass Filters (HPF) - These filters pass high

frequencies and stop low frequencies.

Band pass Filters (BPF) - These filters pass a range

of frequencies and stop frequencies below and above the set range.

Band-Stop Filters (BSF) - These filters pass all

frequencies except the ones within a defined range.

All-Pass Filters (APF) - These filters pass all

frequencies, but they modify the phase of the frequency components.

Page 4: FILTERING · 2010-04-14 · Depending on the application, some frequencies may be undesirable. Filters can be used to remove these undesirable frequency components. Low-pass Filters

PhaseAMPLITUDE

TIME

|A|

t

t

|A|

900 PHASE SHIFT

1800 PHASE SHIFT

� We can see phase response

� Can we hear phase response?

� Non-linear phase response is undesirable in:� Music� Video� Data Communications

Humans locate medium frequency sound by working out the phase difference between signals arriving at each ear. This is a property that is used in stereo hi-fi reproduction.

Page 5: FILTERING · 2010-04-14 · Depending on the application, some frequencies may be undesirable. Filters can be used to remove these undesirable frequency components. Low-pass Filters

Analog Filters

VinVout

CR

XC =1

jωωωωCω ω ω ω = 2ππππf

-1j =

I

Vin= I ( R + XC )

Vout = I*R

H(ωωωω) =Vout

Vin

H(ωωωω) =R

R +1

jωωωωC

Gain = |A|= Re [H(ωωωω)]2 + Im[H(ωωωω)] 2

Re = Real PartIm = Imaginary Part

High Pass

Im[H(ωωωω)]

Re [H(ωωωω)]

|A|

φφφφ

= tan-1Phase =Im [H(ωωωω)]

Re [H(ωωωω)] φ φ φ φ

Page 6: FILTERING · 2010-04-14 · Depending on the application, some frequencies may be undesirable. Filters can be used to remove these undesirable frequency components. Low-pass Filters

High-Pass Response

High Pass

|A| = R

R 2 +1

(ωωωωC)2

|A|

f

φφφφ = = = = tan-1( )ωωωωRC

1

fc

fc

30

60

90

Phase (Degrees)

f0

fc =1

2ππππRCfc is when |A| = (1/ ) |A|2

fc = cut-off frequency (3dB point)

Page 7: FILTERING · 2010-04-14 · Depending on the application, some frequencies may be undesirable. Filters can be used to remove these undesirable frequency components. Low-pass Filters

Low-Pass Response

|A| = 1

1 + ω + ω + ω + ω2R2C2

H(ωωωω) =

R +1

jωωωωC

φ φ φ φ = = = = tan -1( ) ω ω ω ωRC

fc

- 30

- 60

- 90

Phase (Degrees)

f

0

VinVoutC

R

|A|

ffc

fc =1

2ππππRC

1

jωωωωC

Page 8: FILTERING · 2010-04-14 · Depending on the application, some frequencies may be undesirable. Filters can be used to remove these undesirable frequency components. Low-pass Filters

Performance Criteria

|A|

f

PASS BAND STOP BAND

PASS BAND RIPPLE

STOP BAND RIPPLE

3dB POINT

� Ripple in pass band causes uneven gain

� Possible to design with no ripple

� Ripple in stop band is less important than in pass band

� Fall off dB/Decade (Gain in dB/Decade of f)

� Stop band attenuation

Amplitude Response

fc

Gain at 3dB point (at fc ) = |A|

2

fc = Cut-off frequency

20 log10 |A| = Gain in dB

Page 9: FILTERING · 2010-04-14 · Depending on the application, some frequencies may be undesirable. Filters can be used to remove these undesirable frequency components. Low-pass Filters

Phase Response

f

φφφφPhase Response ofa Linear Phase Filter

� Phase response represents time delay of different frequencies

� Linear phase response delays all frequencies by the same amount

� Time delays at f1 and f2 are equal

� Non-linear phase response� Delays all frequencies by different

amounts

� Causes distortion to original signal

� Is audible in a music application

� Is visible in a video application

� Linear phase is only important in pass band

� Some non-linearity can be tolerated

f

Uniform Time Delay ofa Linear Phase Filter

Time Delay

f1 f2

f1 f2

Page 10: FILTERING · 2010-04-14 · Depending on the application, some frequencies may be undesirable. Filters can be used to remove these undesirable frequency components. Low-pass Filters

Butterworth Filter|A|

1.0

0.1

0.01

1 10f / fc

0.1

0

f / fc1.0 2.0

Delay

n=32 n=8

n=1

n=2

n=4

|A|=

f

fc( )

2n

1+

1

� Maximally flat magnitude response

� Poor phase response, non-linear around cut-off frequency

� Excessively high-order filter needed to achieve adequate roll-off

Page 11: FILTERING · 2010-04-14 · Depending on the application, some frequencies may be undesirable. Filters can be used to remove these undesirable frequency components. Low-pass Filters

Filter Types

Chebyshev

Bessel

� Steeper roll-off than Butterworth

� More ripple in pass band

� Poor phase response

Filter design software packages allow us to:

� Experiment with many designs

� Evaluate suitability of gain and phase responses

� Maximally flat phase response

� Less steep roll-off

Page 12: FILTERING · 2010-04-14 · Depending on the application, some frequencies may be undesirable. Filters can be used to remove these undesirable frequency components. Low-pass Filters

Digital Filters

ΣΣΣΣ ΣΣΣΣ

Z-1Z-1

b0 b1b2

x(n)

x(n-1) x(n-2)

x(n) sampled analog waveform, x(0) at t = 0, x(1) at t = ts, x(2) at t = 2 ts ...

Z-1 unit time delay = one sampling period

y(n) = b0 x(n) + b1 x(n - 1) + b2 x(n - 2)

ts = sampling period fs =1/ts

Tap

Weight

Summing junction

Input

y(n) Output

bn = weights (coefficients, scaling factor)

Page 13: FILTERING · 2010-04-14 · Depending on the application, some frequencies may be undesirable. Filters can be used to remove these undesirable frequency components. Low-pass Filters

Moving Average Filter

10

20

30

40

$

timemon tue wed thu fri sat sun

Input

12

40

� Assume no previous inputsX(0) = 20; X(-1) = 0; X(-2) = 0

y(0) = 0.25*x(0) + 0.5*x(-1) + 0.25*x(-2) = 5

y(1) = 0.25*20 + 0.5*20 + 0.25*0 = 15

y(2) = 0.25*20 + 0.5*20 + 0.25*20 = 20

y(3) = 0.25*12 + 0.5*20 + 0.25*20 = 18

y(5) = 0.25*20 + 0.5*40 + 0.25*12 = 28

y(4) = 0.25*40 + 0.5*12 + 0.25*20 = 21

y(6) = 0.25*20 + 0.5*20 + 0.25*40 = 25

� Moving average calculation10

20

30

40

$

timemon tue wed thu fri sat sun

Output

x(n-1) x(n-2)

ΣΣΣΣ

Z-1Z-1x(n)

y(n)ΣΣΣΣ

0.25 0.5 0.25

b0 = 0.25 b1 = 0.5 b2 = 0.25

� And let

Page 14: FILTERING · 2010-04-14 · Depending on the application, some frequencies may be undesirable. Filters can be used to remove these undesirable frequency components. Low-pass Filters

Weighted Impulse Function

1 = d(t) (t)-

∫∞

δWidth = 0

Amplitude = ∞

|A|

t

Area under pulse|A|

t3 5

3

Area under pulse

Weighted Impulse Function

Area = A Amplitude = ∞∞∞∞

|A|

tts

....

2ts 4ts3ts-ts

s(t) = δ (δ (δ (δ (t- ∞) + .......+ δ (∞) + .......+ δ (∞) + .......+ δ (∞) + .......+ δ (t - ts) + δ () + δ () + δ () + δ (t) + δ () + δ () + δ () + δ (t + ts) + ....+ δ () + ....+ δ () + ....+ δ () + ....+ δ (t + ∞) ∞) ∞) ∞)

s(t) =

Sampling Waveform as Weighted Impulse Train

pulse(t) d(t) = 3 d(t) = 6

t=3

t=5

t=3

t=5

∫∫

A= d(t) (t)A-

∫∞

δ

)( s

n

n

ntt∑−∞=

∞=

−δ

Page 15: FILTERING · 2010-04-14 · Depending on the application, some frequencies may be undesirable. Filters can be used to remove these undesirable frequency components. Low-pass Filters

Filter Functions

0.25

0.5

y(t)

t0 1 2 3

MONDAY’S INPUT VALUE

IMPULSE RESPONSE OF FILTER

� Output waveform is obtained for a single-unit weighted impulse applied at t=0

� Impulse response consists of finite number of pulses; hence finite impulse response (FIR) filter

� Impulse response may be used to obtain response to any input

10

20

30

40

$

time

FILTER INPUT AS WEIGHTED IMPULSES

0 1 2 3 4 5 6

20 = d(t) (t) 20-

∫∞

δ

Page 16: FILTERING · 2010-04-14 · Depending on the application, some frequencies may be undesirable. Filters can be used to remove these undesirable frequency components. Low-pass Filters

FIR Filters� An FIR Filter with a steeper roll-off:

� A more realistic filter designed using a software filter design package

� Specifications:� Cut-Off Frequency = 975 Hz� Stop Band Attenuation > 80dB� Sharp Roll-Off

� Filter with 64 taps

� 64 different gain values

� This filter is used in our demonstration

ΣΣΣΣ

Z-1Z-1x(t)

y(t)

b0 b63

ΣΣΣΣ

b1

64 taps

Page 17: FILTERING · 2010-04-14 · Depending on the application, some frequencies may be undesirable. Filters can be used to remove these undesirable frequency components. Low-pass Filters

FIR Response

fc = cut off frequency

fC

fC

Page 18: FILTERING · 2010-04-14 · Depending on the application, some frequencies may be undesirable. Filters can be used to remove these undesirable frequency components. Low-pass Filters

Infinite Impulse Response Filters

� Feedback loop� Non-linear phase response� Fewer taps than FIR for given roll-off� May be unstable

y(t) = b0x(t) + b1x(t - 1) + b2x(t - 2) + }Moving Average Portion

a1y(t - 1) + a2y(t - 2) }Auto Regressive Portion

Input Output

x(t) y(t)ΣΣΣΣ

Z-1

Z-1

Z-1

Z-1

b0

b1

b2

a1

a2

Page 19: FILTERING · 2010-04-14 · Depending on the application, some frequencies may be undesirable. Filters can be used to remove these undesirable frequency components. Low-pass Filters

Comb Filter

� Less Multiplication� No Filter Coefficients� Simple to Extend, Easy to Design� Can Be Used at Higher Sampling Rates Than FIR

Input Output

Z-1x(t) y(t)

a

ΣΣΣΣ Z-1 ΣΣΣΣw(t)

-1

k unit delays

y(t) = x(t) + aw(t–k) – w(t–k)

Gain

ffs/k 2fs/k 3fs/k

Page 20: FILTERING · 2010-04-14 · Depending on the application, some frequencies may be undesirable. Filters can be used to remove these undesirable frequency components. Low-pass Filters

DSP and Digital Filters

Advantages of Digital Filters

� Programmable � It is possible to implement adaptive filters that change

coefficients under certain conditions

Why use DSP for digital filter implementation?

y(n) = a0 x(n) + a1 x(n–1) + a2 x(n–2)

REMEMBER: A = B*C + D

Page 21: FILTERING · 2010-04-14 · Depending on the application, some frequencies may be undesirable. Filters can be used to remove these undesirable frequency components. Low-pass Filters

Performance IssuesNoise in Digital Filters

Dynamic-Range Constraints

0010 + 1111 = 10001

OVERFLOW

SATURATE 1111

16 bit 20 log10 ( 216 ) = 96dB

32 bit 20 log10 ( 232 ) = 192dB

Signal Quantization� Noise introduced is proportional to the number of bits that the

conversion uses

Coefficient Quantization� Coefficients determine the behavior of filters� More significant in IIR

Truncation� 0.64 x 0.73 = 0.4672 which truncates to 0.46� Double-width product registers and accumulators help reduce truncation

errors

Internal Overflow

Page 22: FILTERING · 2010-04-14 · Depending on the application, some frequencies may be undesirable. Filters can be used to remove these undesirable frequency components. Low-pass Filters

Digital Filter Design� Automates design task by software

� Design software requires information such as:� Pass Band, Stop Band, Transition Region� Ripple in Pass Band� Required Roll-Off

� Design Software Generates:� Number of Taps� Coefficients Required� DSP Specific Assembly Code� Response Plots

� Gain� Phase� Impulse

� Enables evaluation of design before implementation

� A low cost evaluation board such as DSK can be used for actual testing

Page 23: FILTERING · 2010-04-14 · Depending on the application, some frequencies may be undesirable. Filters can be used to remove these undesirable frequency components. Low-pass Filters

Summary

� Filters are used for frequency selection

� Low and high pass analog filters

� Performance� Pass Band Ripple, Roll-Off and Phase Response

� Digital finite impulse response (FIR) filters

� Digital infinite impulse response (IIR) filters

� Advantages of Digital Filters� Programmable

� Adaptive Filters

� DSP makes digital filter implementation easier