FIR Filter Basics

Embed Size (px)

Citation preview

  • 8/13/2019 FIR Filter Basics

    1/26

  • 8/13/2019 FIR Filter Basics

    2/26

    &hey are suited to multirate applications. 5y multirate, we mean either

    decimation (reducing the sampling rate), interpolation (increasing the sampling

    rate), or both. hether decimating or interpolating, the use of FIR filters allows

    some of the calculations to be omitted, thus proiding an important computational

    efficiency. In contrast, if IIR filters are used, each output must be indiidually

    calculated, een if it that output will discarded (so the feedbac$ will be incorporatedinto the filter).

    &hey hae desireable numeric properties. In practice, all DSP filters must be

    implemented using finiteprecision arithmetic, that is, a limited number of bits. &he

    use of finiteprecision arithmetic in IIR filters can cause significant problems due to

    the use of feedbac$, but FIR filters without feedbac$ can usually be implemented

    using fewer bits, and the designer has fewer practical problems to sole related to

    nonideal arithmetic.

    &hey can be implemented using fractional arithmetic. 6nli$e IIR filters, it is always

    possible to implement a FIR filter using coefficients with magnitude of less than !.".(&he oerall gain of the FIR filter can be ad7usted at its output, if desired.) &his is an

    important consideration when using fiedpoint DSP0s, because it ma$es the

    implementation much simpler.

    1..2 What are the disad!anta#es of FIR Filters $compared toIIR filters%?

    3ompared to IIR filters, FIR filters sometimes hae the disadantage that they re8uire more

    memory and9or calculation to achiee a gien filter response characteristic. %lso, certain

    responses are not practical to implement with FIR filters.

    1.& What terms are used in descri'in# FIR filters?

    Impulse Response &he impulse response of a FIR filter is actually 7ust the set of

    FIR coefficients. (If you put an impluse into a FIR filter which consists of a !

    sample followed by many " samples, the output of the filter will be the set of

    coefficients, as the ! sample moes past each coefficient in turn to form the output.)

    Tap % FIR tap is simply a coefficient9delay pair. &he number of FIR taps, (often

    designated as *) is an indication of !) the amount of memory re8uired to

    implement the filter, :) the number of calculations re8uired, and ;) the amount of

    filtering the filter can do- in effect, more taps means more stopband attenuation,

    less ripple, narrower filters, etc.

    Multiply-Accumulate (MAC) In a FIR contet, a

  • 8/13/2019 FIR Filter Basics

    3/26

  • 8/13/2019 FIR Filter Basics

    4/26

    2.1.4 What is the alternati!e to linear phase?

    *onlinear phase, of course. -) %ctually, the most popular alternatie is minimum phase.

  • 8/13/2019 FIR Filter Basics

    5/26

  • 8/13/2019 FIR Filter Basics

    6/26

    Since FIR filters do not use feedbac$, only those outputs which are actually going to be used

    hae to be calculated. &herefore, in the case of decimating FIRs (in which only ! of *

    outputs will be used), the other *! outputs don0t hae to be calculated. Similarly, for

    interpolating filters (in which #eroes are inserted between the input samples to raise the

    sampling rate) you don0t actually hae to multiply the inserted #eroes with their

    corresponding FIR coefficients and sum the result- you 7ust omit the multiplicationadditionsthat are associated with the #eroes (because they don0t change the result anyway.)

    In contrast, since IIR filters use feedbac$, eery input must be used, and eery input must

    be calculated because all inputs and outputs contribute to the feedbac$ in the filter.

    2. What special types of FIR filters are there?

    %side from regular and etra crispy there are+

    Bo!car 5ocar FIR filters are simply filters in which each coefficient is !.".

    &herefore, for an *tap bocar, the output is 7ust the sum of the past * samples.

    5ecause bocar FIRs can be implemented using only adders, they are of interestprimarily in hardware implementations, where multipliers are epensie to

    implement.

    "ilbert Transformer 'ilbert &ransformers shift the phase of a signal by " degrees.

    &hey are used primarily for creating the imaginary part of a comple signal, gien its

    real part.

    Differentiator Differentiators hae an amplitude response which is a linear function

    of fre8uency. &hey are not ery popular nowadays, but are sometimes used for Fample of a FIR interpolator?

    'ere0s an eample of a !:tap FIR filter that implements interpolation by a factor of four.&he coefficients are h"h!!, and three data samples, ": (with the newest, :, on the

    left) hae made their way into the filter0s delay line+

    h

    0 h1 h2 h3 h4 h5 h6 h7 h8 h9 h10 h11 Result

    x

    2 0 0 0

    x

    1 0 0 0

    x

    0 0 0 0

    x2h0+x1h4+

    x0h8

    0 x2

    0 0 0 x1

    0 0 0 x0

    0 0 x2h1+x1h5+x0h9

    0 0 x

    2 0 0 0

    x

    1 0 0 0 x0 0

    x2h2+x1h6+

    x0h10

    0 0 0 x

    2 0 0 0 x1 0 0 0 x0

    x2h3+x1h7+x

    0h11

    3.4.3 What can I #enerali=e from that e>ample?&he table suggests the following general obserations about FIR interpolators+

    Since the interpolation ratio is four (?CK), there are four subfilters (whose

    coefficient sets are mar$ed here with matching colors.) &hese subfilters are officially

    called polyphase filters.

  • 8/13/2019 FIR Filter Basics

    21/26

    For each input, we calculate ? outputs by doing ? basic FIR calculations, each using a

    different set of coefficients.

    &he number of taps per polyphase filter is ;, or, epressed as a formula+

    *polyC*total 9 ?.

    &he coefficients of each polyphase filter can be determined by s$ipping eery ?th

    coefficient, starting at coefficients " through ?!, to calculate corresponding outputs

    " through ?!.

    %lternatiely, if you rearranged your coefficients in adance in scrambled order li$e

    this+

    h?@ h>@ h

  • 8/13/2019 FIR Filter Basics

    22/26

    ".0 Im!lementation

    3..1 How do I implement a FIR interpolator?

    %n interpolating FIR is actually the same as a regular FIR, ecept that, for each input, you

    calculate ? outputs per input using ? polyphase filters, each haing *9? taps.

  • 8/13/2019 FIR Filter Basics

    23/26

    >.6 Basics

    4.1.1 What is "resamplin#"?

    Resampling means combining interpolation and decimation to change the sampling rate by

    a rational factor.

    4.1.2 Why resample?

    Resampling is usually done to interface two systems which hae different sampling rates. If

    the ratio of two system0s rates happens to be an integer, decimation or interpolation can be

    used to change the sampling rate (depending on whether the rate is being decreased or

    increased)- otherwise, interpolation and decimation must be used toget#erto change the

    rate

    % practical and well$nown eample results from the fact that professional audio e8uipment

    uses a sampling rate of KA $'#, but consumer audio e8uipment uses a rate of KK.! $'#.

    &herefore, to transfer music from a professional recording to a 3D, the sampling rate must

    be changed by a factor of+

    (KK!"" 9 KA""") C (KK! 9 KA") C (!KQ 9 !H")

    &here are no common factors in !KQ and !H", so we must stop factoring at that point.

    &herefore, in this eample, we would interpolate by a factor of !KQ then decimate by a

    factor of !H".

    4.1.3 What is the "resamplin# factor"?

    &he interpolation factor is simply the ratio of the output rate to the input rate. /ien that

    the interpolation factor is ? and the decimation factor is

  • 8/13/2019 FIR Filter Basics

    24/26

    4.1. How do I desi#n the resamplin# filter?

    %s hinted at aboe+

    Determine the cutoff fre8uency of the decimation filter (as eplained in Part 2'

    Decimation.)

    Determine the cutoff fre8uency of the interpolation filter (as eplained in Part "'

    Inter!olation)

    6se the lower of the two cutoff fre8uencies to design the resampling filter.

    >.2 Multistage

    4.2.1 -an I resample in multiple sta#es?

    Ges, but there are a couple of restrictions+

    If either the interpolation or decimation factors are prime numbers, you won0t be

    able to decompose those parts of the resampler into stages.

    Gou must presere the *y8uist criteria at each stage or else aliasing will result. &hat

    is, no stage can hae an output rate which is less than twice the highest fre8uency of

    interest.

    4.2.2 -ool. 9ut why 'other with all that?

    ust as with interpolation and decimation, the computational and9or memory re8uirements

    of the resampling filtering can sometimes be greatly reduced by using multiple stages.

    >." Im!lementation

    4.3.1 How do I implement resamplin#?

    &he straightforward implementation of resampling is to do interpolation by a factor of ?,

    then decimation by a factor of

  • 8/13/2019 FIR Filter Basics

    25/26

    4.3.3 o what

  • 8/13/2019 FIR Filter Basics

    26/26

    o 2rdinary Filtering+ &he interpolation and decimation factors, ? and