30
DSP [Digital Signal Processing] A.H.M. Asadul Huq, Ph.D. [email protected] http://asadul.drivehq.com/students.htm Monday, June 20, 2022 A.H. 1 [Design of FIR: Window method] Vol-6

Dsp lecture vol 6 design of fir

  • Upload
    -

  • View
    341

  • Download
    2

Embed Size (px)

Citation preview

Page 1: Dsp lecture vol 6 design of fir

DSP [Digital Signal Processing]

A.H.M. Asadul Huq, Ph.D.

[email protected]://asadul.drivehq.com/students.htm

April 13, 2023 A.H. 1

[Design of FIR: Window method]Vol-6

Page 2: Dsp lecture vol 6 design of fir

Introduction to FIR Filter• What does "FIR" mean?

- "FIR" means "Finite Impulse Response". • Why is the impulse response "finite" ? – because there is no feedback in the FIR.

- A lack of feedback guarantees that the impulse response will be finite.

April 13, 2023 A.H. 2

Page 3: Dsp lecture vol 6 design of fir

Advantages of FIR (compared to IIR) Filters

• Easily be designed to be "linear phase"– Put simply, linear-phase filters delay the input signal but

don’t distort its phase.• Simple to implement.– On most DSP microprocessors, the FIR calculation can be

done by looping a single instruction.• They are suited to multi-rate applications.• Have desirable numeric properties.

- FIR filters without feedback can usually be implemented using fewer bits.

• Unconditionally stable unlike IIR

April 13, 2023 A.H. 3

Page 4: Dsp lecture vol 6 design of fir

FIR equations

April 13, 2023 A.H. 4

h(k), k = 0, 1, … , N - 1 are the Impulse Response (coefficients).H(z) is the Transfer Function, N is the Filter Length (No. of Filter Coefficients) of the filter.

Difference Equation

System function (Transfer function) equation

Page 5: Dsp lecture vol 6 design of fir

Linear Phase Response

April 13, 2023 A.H. 5

•"Linear Phase" refers to the condition where the phase response of the filter is a linear (straight-line) function of frequency (excluding phase wraps at +/- 180 degrees). •This results in the delay through the filter being the same at all frequencies. •Therefore, the filter does not cause "phase distortion" or "delay distortion". •The lack of phase/delay distortion is an advantage of FIR filters over IIR and analogue filters in certain systems, for example, in digital data modems.

Page 6: Dsp lecture vol 6 design of fir

Phase Delay and Group delay

•The Phase Delay (Tp) or Group Delay (Tg) of the filter is a measure of how a filter modifies the phase characteristics of the signal. •Consider a signal consisting of several frequency components, like: Speech waveform, or a Modulated signal• Phase Delay (Tp) =

is the amount of time delay each frequency component of the signal suffers in going through the filter.

• Group Delay (Tg) = is the average time delay the composite signal suffers at each frequency.

April 13, 2023 A.H. 6

Page 7: Dsp lecture vol 6 design of fir

Problems of Non-linear Phase Filter• A non-linear phase filter will cause phase distortion in the signal that

passes through it.• This is due to the fact that the frequency components in the signal will

each be delayed by an amount NOT proportional to frequency, hence altering their harmonic relationship.

• This distortion is extremely undesirable in applications involving: • Music, Data transmission, Video, and Bio-medical applications • This distortion can be avoided by using filters with linear phase

characteristics.• Non-linear phase filters will distort the audio of AM broadcast signals, blur

the edges of television video images, blunt the sharp edges of received radar pulses, and increase data errors in digital communication signals.

• None-linear phase filters are also called “minimum phase”

April 13, 2023 A.H. 7

Page 8: Dsp lecture vol 6 design of fir

Types of linear phase FIR filters

April 13, 2023 A.H. 8

4 types of linear phase FIR filters

Page 9: Dsp lecture vol 6 design of fir

Linear-Phase FIR types

• Type 1 –most versatile• Type 2 – frequency response is always 0 at

ω=π. (not suitable as a high-pass filter)• Type 3 and 4 – Introduce a π/2 phase shift,

frequency response is always 0 at ω=π. (not suitable as a high-pass filter)

April 13, 2023 A.H. 9

Page 10: Dsp lecture vol 6 design of fir

Type 1 and 2 FIR coefficients• Type-1: Positive symmetry, Odd length of Coefficients• Example impulse response -

April 13, 2023 A.H. 10

• Type-2: Positive symmetry, Even length of Coefficients• Example impulse response -

Page 11: Dsp lecture vol 6 design of fir

Type 3 and 4 Fir CoefficientsType 3 [Negative Symmetry, Odd Length (Coefficients)]: 90° phase shift Always zero at f = 0, hence unsuitable as a Low-pass filter. In addition, always zero at f = 0.5, hence unsuitable as a High-pass filter. The sample impulse response is given by:

April 13, 2023 A.H. 11

Type 4 [Negative Symmetry, Even Length (Coefficients)]: 90° phase shift Always zero at f = 0, hence unsuitable as a Low-pass filter. The example impulse response is given by:

Page 12: Dsp lecture vol 6 design of fir

Steps for designing FIR Filter

5 Steps:1. Determine the filter specifications2. Choose a suitable filter structure3. Calculate the filter coefficient values4. Analysis the finite wordlength effect5. Construct the filter using software and/or

hardware.

April 13, 2023 A.H. 12

11:24 PM

Page 13: Dsp lecture vol 6 design of fir

FIR filter design flowchart

April 13, 2023 A.H. 13

Page 14: Dsp lecture vol 6 design of fir

Ideal Specifications

• Unity magnitude over passband• Zero magnitude over stopband• Linear response over passband

April 13, 2023 A.H. 14

1

0 c –c

HLP(e j)

0 c –c

1

HHP (e j)

11–

–c1 c1 –c2 c2

HBP (e j)

1

–c1 c1 –c2 c2

HBS(e j)

Page 15: Dsp lecture vol 6 design of fir

Tolerance scheme: magnitude-frequency response of a LP Filter

The following parameters are of interest:

• δp: Passband Deviation

• δs: Stopband Deviation

• fp or ωp : Passband Edge Frequency

• fs or ωs Stopband Edge Frequency

• Fs: Sampling Frequency

April 13, 2023 A.H. 15

Page 16: Dsp lecture vol 6 design of fir

Tolerance scheme with normalized filter parameters

• passband= 0.18 – 0.33• transition band= 0.14 – 0.18

and 0.33 – 0.37• stopband= 0 – 0.14 and 0.37

– 0.5• stopband deviation, δs= 0.001

• passband deviation, δs= 1.05, 1, 0.95

• 1 + δp= 1.05

• 1 – δp = 0.95

April 13, 2023 A.H. 16

Page 17: Dsp lecture vol 6 design of fir

Un-normalized filter parameters Normalized filter parameters• passband= 0.18 – 0.33• transition band= 0.14 – 0.18 and

0.33 – 0.37• stopband= 0 – 0.14 and 0.37 –

0.5• stopband deviation, δs= 0.001

• passband deviation, δs= 1.05, 1, 0.95

• 1 + δp= 1.05

• 1 – δp = 0.95

Un-normalized filter parametersWith sampling frequency of 10 kHz: • Passband=1.8 - 3.3 kHz• Stopband(s)=0 - 1.4 kHz and 3.7 -

5 kHz• Stopband Attenuation (As)=-20

log10 δs

• =-20 log10 (0.001)• =60 dB• Passband Ripple (Ap)=20 log10 δp

• =20 log10 (1 + 0.05)• =0.42 dB

April 13, 2023 A.H. 17

Normalized filter frequencies are also expressed as:ω=2.fn π rad/sec (specially for matlab)

Page 18: Dsp lecture vol 6 design of fir

Coefficient calculation MethodsWindow Method: • Offers a very simple and flexible way of computing FIR filter coefficients.• However, does not allow the over the filter parameters. designer adequate

control

The Optimal Method • With efficient and easy-to-use programs it is now widely used in industry.• For most applications, this method will yield the desired FIR filter.• Should be the first choice, unless a particular application dictates otherwise, or a

CAD facility is unavailable. The Frequency Sampling Method • The main attraction is that it allows for a recursive realization of FIR filters, which

can be computationally very efficient. • However, it also lacks flexibility in specifying or controlling filter parameters. •

April 13, 2023 A.H. 18

Page 19: Dsp lecture vol 6 design of fir

Steps of Window method

April 13, 2023 A.H. 19

Step 1: Specify the “ideal” or desired frequency response of the filter, HD(ω). Step 2: Obtain the IDEAL impulse response, hD(n), of the desired filter by evaluating the IDFT. Step 3: Select a window function w(n) that satisfies the passband and stopband attenuation specifications. Determine the filter length N. Step 4: Multiply the ideal coefficients by the selected window function to get the filter coefficients h(n) = hD(n) . w(n)

Page 20: Dsp lecture vol 6 design of fir

Ideal Impulse response for LP Filter

April 13, 2023 A.H. 20

Note that hD(n) is symmetrical about n = 0 (i.e. hD(n) = hD(-n)), so the filter will have linear phase response. Although hD(n) decreases as we move away from n = 0, the impulse

response is infinite in length (as n = ±∞).Hence, this is not a FIR filter!

Ideal frequency response for LP

Ideal (infinite)Impulse response for LP

Page 21: Dsp lecture vol 6 design of fir

Ideal Impulse responses for different filter types

April 13, 2023 A.H. 21

Page 22: Dsp lecture vol 6 design of fir

Truncation of Impulse response

• A possible solution is to truncate the ideal impulse response by setting hD(n) = 0 for n greater than M (equivalent to a rectangular window).

• Rectangular window function - w(n)=1, where, n = 0, 1, …, ± (N - 1)/2 = 0, elsewhere• A practical approach is to multiply the ideal impulse response, hD(n) by a

suitable window function, w (n), whose duration is finite. • This way the resulting impulse response decays smoothly towards zero. Finally, • The ideal impulse response, hD(n) is multiplied by finite duration window

w(n), to obtain the filter coefficients, h(n).

April 13, 2023 A.H. 22

Page 23: Dsp lecture vol 6 design of fir

Truncation Effect on frequency response

April 13, 2023 A.H. 23

13 coefficients 25 coefficients

Infinite coefficients (no truncation)

Page 24: Dsp lecture vol 6 design of fir

Ideal impulse response hD(n)is multiplied by finite duration window w(n) to get filter coefficients h(n)

April 13, 2023 A.H. 24

)()()( nwnhnh D

Page 25: Dsp lecture vol 6 design of fir

Types of Window functions

• Rectangular• Hamming• Hanning• Blackman• Kaiser

April 13, 2023 A.H. 25

Page 26: Dsp lecture vol 6 design of fir

Features of popular window functions

April 13, 2023 A.H. 26

Page 27: Dsp lecture vol 6 design of fir

Window functions in time domain

April 13, 2023 A.H. 27

Different window functions for N=61

0 20 40 600

0.2

0.4

0.6

0.8

1

1.2Blackman Window

0 20 40 600

0.2

0.4

0.6

0.8

1

1.2Rectangular Window

0 20 40 600

0.2

0.4

0.6

0.8

1

1.2Hamming Window

Page 28: Dsp lecture vol 6 design of fir

0 0.2 0.4 0.6 0.8-150

-100

-50

0

Normalized Frequency

|W(f

)| (d

B)

|W(f)| in dB for Blackman Window w(n)

0 0.2 0.4 0.6 0.8-100

-80

-60

-40

-20

0

Normalized Frequency

|W(f

)| dB

|W(f)| for Hamming window w(n)

0 0.2 0.4 0.6 0.8 1-100

-80

-60

-40

-20

0

Normalized Frequency ( rad/sample)

|W(f

)||W(f)| (dB) vs f for rectanular window w(n)

Window functions in Frequency domain

April 13, 2023 A.H. 28

(a) Rectangular , (b) Hamming, (c) Blackman windows for N = 61.

Rectangular Hamming

Blackman

Page 29: Dsp lecture vol 6 design of fir

Example

April 13, 2023 A.H. 29

Calculate the coefficients of an FIR lowpass filter to meet the specifications given below using the WINDOW method.[E.C. Ifeachor 2/e P. 359]

Passband cutoff frequency = 1.5 kHzTransition width = 0.5 kHz

Stopband attenuation > 50dBSampling frequency = 8 kHz

Solution: See appendix

Page 30: Dsp lecture vol 6 design of fir

DSP Lecture

FIR Filter and Window Method

THE ENDTHANK YOU

This ppt may be downloaded from my web site:http://asadul.drivehq.com/students.htm

Password (email address): [email protected] password does not live long !

April 13, 2023 A.H. 30

11:24 PM