Introduction to FIR Filter Design

Embed Size (px)

Citation preview

  • 8/12/2019 Introduction to FIR Filter Design

    1/34

    Digital Signal Processing

    H. Introduction to FIR filters design

    Athanassios C. Iossifides

    February 2013

  • 8/12/2019 Introduction to FIR Filter Design

    2/34

    2

    .1 Discrete time systems and filters.2 FIR filter design with windows

    . Introduction to FIR digital filter design

  • 8/12/2019 Introduction to FIR Filter Design

    3/34

    3

    .1 Discrete time systems and filters

    . Introduction to FIR digital filter design

  • 8/12/2019 Introduction to FIR Filter Design

    4/34

    4

    H.1 Discrete time systems and filters

    LSI system as frequency filters

    The frequency response H(e j ) of an LSI system, leads to the modificationof the input (e j ) in the frequency domain, and creates the output (e j )according to the formula

    Therefore, every LSI system can be considered as a frequency filter, inthe sense that it passes, amplifies, attenuates or cuts frequencies of theinput . The terms LSI system and filter are used interchangeably.

    The characteristics of a filter in the frequency domain depend on The positions of the zeros and the poles of the transfer (system)

    function

    The positions of zeros and poles are determined by the coefficients of the difference equation that describes the

    system

    ( ) ( ) ( ) j j jY e H e X e

  • 8/12/2019 Introduction to FIR Filter Design

    5/34

    5

    H.1 Discrete time systems and filters

    Distortionless response

    The response y (n) of an LSI system to an input x (n) has no distortion (ingeneral) when it is of the form

    so that the input signal is only uniformly attenuated with a constant C anddelayed by n0 samples. Using the properties of DTFT, we have

    so thatTherefore, a system does not introduce distortion when

    The magnitude of the frequency response is constant The phase is a linear function of frequency

    The group delay is defined as

    and provides the delay that undergoes each frequency passing throughthe system. In the case of distortionless response systems, the groupdelay is constant.

    0( ) ( )y n Cx n n

    00

    ( ) ( ) j n j x n n e X eF

    0 0( ) ( ) or ( ) j jn j j jnY e Ce X e H e Ce

    ( )( ) , ( ) ( ) j g

    d H e

    d

  • 8/12/2019 Introduction to FIR Filter Design

    6/34

    6

    H.1 Discrete time systems and filters

    Ideal filters

    The frequency response of an ideal filter has unit amplitude (gain) at thepassband, zero amplitude at the stopband and linear phase.

    0| ( )| j H e

    cc

    B

    0| ( )| j H e

    cc

    0| ( )| j H e

    00

    B

    1 2

    0| ( )| j H e

    00

    0| ( )| j H e

    Lowpass filter (LPF) Highpass filter (HPF)

    Bandpass filter (BPF) Bandstop filter (BSF)

    Allpass filter

  • 8/12/2019 Introduction to FIR Filter Design

    7/34 7

    H.1 Discrete time systems and filters

    deal filters

    he ideal Lowpass Filter (LPF) may be expressed by the frequencyresponse

    The impulse response is calculated by the inverse DTFT as follows

    This filter is not causal and therefore it is not realizable.

    1, | |( )

    0, | |c j

    c

    H e

    1 1 1( ) ( ) ( )

    2 2 2

    sin( ),

    cc c

    c

    j jn jn j n j n

    c

    h n X e e d e d e e jn

    nn

    n

  • 8/12/2019 Introduction to FIR Filter Design

    8/34 8

    H.1 Discrete time systems and filters

    Transfer functions of real (non-ideal) filters

    The principle of zeros and poles positioning for the production of thedesirable frequency response is to put

    the poles near to the points of the unit circle that correspond tothe frequencies that we want to amplify (or not attenuate)

    the zeros close (or exactly on) the frequencies that we want toattenuate (make zero)

    Additionally, the following restrictions should apply: All the poles must be in the unto circle so that the filter is stable. All the complex zeros and poles must be complex conjugate pairs

    so that the coefficients of the filter in the diefference equation arereal.1

    0 10

    1

    1 1

    (1 )( )

    1 (1 )

    MMk

    k k k k

    N Nk

    k k k k

    z zb z

    H z b

    a z p z

  • 8/12/2019 Introduction to FIR Filter Design

    9/34 9

    H.1 Discrete time systems and filters

    Examples of real (non-ideal) filters

    Lowpass

    Highpass

    Bandpass

    1

    1

    1( )

    1z

    H zaz

    1

    1

    1( )

    1

    zH z

    az

    2

    2

    1( )

    1z

    H zaz

  • 8/12/2019 Introduction to FIR Filter Design

    10/34 10

    H.1 Discrete time systems and filters

    FIR filter realization

    An FIR filter is described by the difference equation

    and a transfer function (including only zeros) of the form

    This can be realized in a direct form as drawn below

    This requires + 1 multiplications, additions and memory places.

    0( )

    M

    k k k

    H z b z

    0 0( ) ( ) ( ) ( )

    M M

    k k k

    y n b x n k h k x n k

    1z

    0b 1b

    1z 1z 1z

    2b 3b 1Mb Mb

    ( ) x n

    ( )y n

  • 8/12/2019 Introduction to FIR Filter Design

    11/34 11

    H.1 Discrete time systems and filters

    FIR direct form realization

    Simplified form

    1z

    0b 1b

    1z 1z 1z

    2b 3b 1Mb Mb

    ( ) x n

    ( )y n

    1z 1z 1z1z

    0b 1b 2b 1Mb Mb

    ( )y n

    ( ) x n

  • 8/12/2019 Introduction to FIR Filter Design

    12/34 12

    H.1 Discrete time systems and filters

    FIR filters of ljnear phase

    A filter has a linear phase when

    where = 0 or /2 and constant. For an FIR filter in the interval [0 , ] , the linear phase condition leads to the following symmetry conditions ofthe impulse response:

    ( ) , j H e

    ( ) ( ), / 2, 0

    ( ) ( ), / 2, / 2

    h n h M n N

    h n h M n N

    V

  • 8/12/2019 Introduction to FIR Filter Design

    13/34 13

    H.1 Discrete time systems and filters

    IIR filter realization

    An IR filter is described by the difference equation

    and a transfer function of the form

    0

    1

    ( )

    1

    Mk

    k k

    Nk

    k k

    b z

    H z

    a z

    1 0( ) ( ) ( )

    N M

    k k k k

    y n a y n k b x n k

  • 8/12/2019 Introduction to FIR Filter Design

    14/34 14

    H.1 Discrete time systems and filters

    IIR filter realization

    Direct Form of type I Direct Form of type II

    Number of mult.: + + 1 Number of mult.: + + 1

    Number of add.: + Number of add.: +

    Memory places: + Memory places: max{ ,}

    1z

    1z

    1z

    1z

    0b

    1b

    1Mb

    Mb

    ( )y n( ) x n

    1z

    1z

    1a

    1Na

    Na

    1z

    1z

    0b

    1b

    1Mb

    Mb

    ( )y n( ) x n

    1z

    1a

    1Na

    Na

  • 8/12/2019 Introduction to FIR Filter Design

    15/34 15

    . 2 FIR filter design with windows

    . Introduction to FIR digital filter design

  • 8/12/2019 Introduction to FIR Filter Design

    16/34 16

    . 2 FIR filter design with windows

    The basic idea

    The basic idea of the window method (windowing) is based on: The selection of a non-causal ideal filter of infinite impulse

    response duration. The modification of the impulse response with a proper function

    (window) so that to produce a causal and linear phase filter.

    The modification of the impulse response h(n) is applied withmultiplication with a proper function w (n) which is called window.

    An ideal Lowpass Filter (LPF) with cuttof frequency c has a frequencyresponse of the form

    where a is a delay that does not affect the phase linearity of the filter andis mandatory in order to convert the non-causal filter to a causal one.

    1 , | |( ) 0, | |

    ja

    c j d c

    e H e

  • 8/12/2019 Introduction to FIR Filter Design

    17/34 17

    . 2 FIR filter design with windows

    Impulse response of ideal filter

    The impulse response of an ideal LPF may be found with an IDFT of theprevious formula, which leads to

    and is symmetrical with respect to delay a .

    sin[ ( )]( )

    ( )c

    d n a

    h n n a

  • 8/12/2019 Introduction to FIR Filter Design

    18/34 18

    . 2 FIR filter design with windows

    Conversion to an FIR filter

    In order to produce a FIR filter, causal and with linear phase, we restrictthe impulse response with a proper window function w (n), that issymmetrical with respect to a , so that to conserve the symmetry of thefinal impulse response.

    The greater the delay a is, the greater the impulse response duration isand the better the ideal filter is approximated (this results in smallertransition band)

    ( ) ( ) ( )d h n h n w n

  • 8/12/2019 Introduction to FIR Filter Design

    19/34 19

    . 2 FIR filter design with windows

    Filter characteristics

    The characteristics of the filters that are of interest are: The order (length) of the filter. The transition band width. The attenuation in the stopband.

    With the window method it is not possible to control independently the

    passband and the stopband and the ripples are not uniform (equal).

    10

    10

    120log

    1

    20log1

    p p

    p

    ss

    p

    R

    A

  • 8/12/2019 Introduction to FIR Filter Design

    20/34

    20

    . 2 FIR filter design with windows

    Classic windows ( h(n) = 0, n [0, N-1]):

    21

    21

    2 41 1

    Rectangular : ( ) 1, 0 1

    Hanning : ( ) 0.5 0.5cos , 0 1

    Hamming : ( ) 0.54 0.46cos , 0 1

    Blackman : ( ) 0.42 0.5cos 0.08cos , 0 1

    nN

    nN

    n nN N

    w n n N

    w n n N

    w n n N

    w n n N

    windowTransition

    bandwidth f Minimum stopband

    attenuation

    Rectangular 0.9/ 21dB

    Hanning 3.1/ 44dB

    Hamming 3.3/ 53dB

    Blackman 5.5/ 74dB

  • 8/12/2019 Introduction to FIR Filter Design

    21/34

    21

    . 2 FIR filter design with windows

    Kaiser parametric window

    The parametric window Kaiser is defined as

    Given p, s, R p, and As, the length of the filter and the parameter arecalculated as:

    0.4

    Transition bandwidth : 2

    7.95Order (length) : 114.36

    0.1102( 8.7), 50Parameter

    0.5842( 21) 0.07886( 21), 21 50

    s p

    s

    s s

    s s s

    f

    AN f

    A A

    A A A

    220 10

    1 1, 0 1( ) ( )

    0,

    nNI n Nw n I

  • 8/12/2019 Introduction to FIR Filter Design

    22/34

    22

    . 2 FIR filter design with windows

    ( ) ( ) ( )d h n h n w n

    Windows comparison

    Rectangular

    Hanning

  • 8/12/2019 Introduction to FIR Filter Design

    23/34

    23

    . 2 FIR filter design with windows

    Windows comparison

    Hamming

    Blackman

  • 8/12/2019 Introduction to FIR Filter Design

    24/34

    24

    . 2 FIR filter design with windows

    Windows comparison

    Kaiser = 2

    Kaiser = 8

  • 8/12/2019 Introduction to FIR Filter Design

    25/34

    25

    . 2 FIR filter design with windows

    Example (LPF with cutoff frequency 0.2 )Rectangular Hanning

    Hamming Blackman

  • 8/12/2019 Introduction to FIR Filter Design

    26/34

    26

    . 2 FIR filter design with windows

    Example (LPF with cutoff frequency 0.2 )Rectangular Hanning

    Hamming Blackman

  • 8/12/2019 Introduction to FIR Filter Design

    27/34

    27

    . 2 FIR filter design with windows

    Example (LPF with cutoff frequency 0.2 )Hamming, = 31 Hamming, = 63

    Hamming, = 127 Hamming, = 255

  • 8/12/2019 Introduction to FIR Filter Design

    28/34

    28

    . 2 FIR filter design with windows

    Example of FIR filter design with windows

    A. Design a filter with the following characteristics

    ------------------------------------------------

    Attenuation more than 50 dB is given by the Hamming window. Wecalculate the transition bandwidth

    The cutoff frequency is given by

    The order of the filter is

    The ripple of the passband is 0.039 dB (calculated only with a computer).

    0.2 , 0.25 dB

    0.3 , 50 dB p p

    s s

    R

    A

    0.3 0.2 0.05

    2 2s p f

    3.3 1 67

    N N f

    0.252

    s pc

  • 8/12/2019 Introduction to FIR Filter Design

    29/34

    29

    . 2 FIR filter design with windows

    Example of FIR filter design with windows

    1

    2331

    2

    sin[ ( )] sin[0.25 ( 33)]( ) ( ) ( ) ( ) 0.54 0.46cos( 33)( )

    Nc n

    d N n nh n h n w n w n

    n n

  • 8/12/2019 Introduction to FIR Filter Design

    30/34

    30

    . 2 FIR filter design with windows

    Example of FIR filter design with windows

    B. Design the following filter with the Kaiser window

    ------------------------------------------------

    We calculate the transition bandwidth

    The cutoff frequency is

    The ripple in the passband is 0.044 dB (calculated with computer).

    0.2 , 0.25 dB

    0.3 , 50 dB p p

    s s

    R

    A

    0.3 0.2 0.05

    2 2s p f

    0.252

    s pc

    7.95Order (length) : 1 1 6114.36 Parameter 0.1102( 8.7) 4.5512

    s

    s

    AN f

    A

  • 8/12/2019 Introduction to FIR Filter Design

    31/34

    31

    . 2 FIR filter design with windows

    Example of FIR filter design with windows

    2

    1 0 3021

    02

    4.5512 1 1sin[ ( )] sin[0.25 ( 30)]( ) ( ) ( ) ( )( 30) (4.5512)( )

    nNcd N

    I n nh n h n w n w n n I n

  • 8/12/2019 Introduction to FIR Filter Design

    32/34

    32

    . 2 FIR filter design with windows

    Example of FIR filter design with windows

    C. Design the following bandpass filter

    ------------------------------------------------

    Attenuation over 60 dB can be achieved by the Blackman or the Kaiserwindow. We will design the Blackman.

    The impulse response of the bandpass filter has the form

    The cutoff frequencies are

    1 1

    2 2

    0.4 , 60 dB, 0.5 , 1 dB

    0.7 , 1 dB, 0.8 , 60 dBs s p p

    p p s s

    A R

    R A

    1 1 2 21 20.45 , 0.752 2

    s p s pc c

    1 12 12 2

    1 12 2

    ( ) ( ) ( )

    sin[ ( )] sin[ ( )]

    ( ) ( ) ( )

    d

    N Nc c

    d N N

    h n h n w n

    n n

    h n n n

  • 8/12/2019 Introduction to FIR Filter Design

    33/34

    33

    . 2 FIR filter design with windows

    Example of FIR filter design with windows

    The transition bandwidth is

    The order of the filter is calculated as

    The ripple in the passband is equal to R p 0.0033 dB (calculated by acomputer).

    5.51 111N N f

    1 1 2 2 0.052 2

    p s s p f

  • 8/12/2019 Introduction to FIR Filter Design

    34/34

    . 2 FIR filter design with windows

    Example of FIR filter design with windows

    2 4110 110sin[0.75 ( 55)] sin[0.45 ( 55)]( ) 0.42 0.5cos 0.08cos( 55) ( 55)n n n nh n

    n n