finite impulse response filter presentation

Upload: timothy-teo

Post on 10-Mar-2016

12 views

Category:

Documents


0 download

DESCRIPTION

presentation slides on FIR filtering

TRANSCRIPT

  • DSP for Dummies aka

    2530

    2540

    2550

    2560

    2570

    2580

    2590

    1 14 27 40 53 66 79 92 105 118 131 144 157 170 183 196 209 222 235 248 261 274 287 300 313 326 339 352 365 378 391 404 417 430 443 456

    How to turn this (actual raw sonar trace)

    Into this .. (filtered sonar data)

    2552

    2554

    2556

    2558

    2560

    2562

    2564

    2566

    2568

    2570

    2572

    2574

    1 14 27 40 53 66 79 92 105 118 131 144 157 170 183 196 209 222 235 248 261 274 287 300 313 326 339 352 365 378 391 404 417 430 443 456

  • Fundamental property of all analog signals

    complex signals

    i.e. audio

    i.e. digital bitstream

    Decompose

    into summation

    of sinusoids

    amplitude

    phase

    frequency

    properties

  • Fourier Transform

    How do we analyze the frequency components of a complex signal

    Time space x(t)

    Frequency space X()

    single frequency signal 0

    t

    0

    t

    X() is complex -- complex conjugate encodes phase

    Fourier transform is invertable

    Some properties

  • Digital Signals

    Sample amplitude at discrete time intervals

    .55

    .46

    1,0

    -1.0

    -,6

    Nyquist limit (http://www.medcyclopaedia.com)

    (Harry Nyquist, 18891976, Swedish - American physicist), the maximum frequency of a signal that can be measured with a method that employs sampling of the signal with a specific frequency, the sampling frequency. According to Shannons sampling theorem, a signal must be sampled with a frequency at least twice the frequency of the signal itself. The maximum measurable frequency the Nyquist limit or frequency is thus half the sampling frequency. If the signal frequency is higher than the Nyquist limit, aliasing occurs.

  • Discrete Fourier Transform

    Given a signal represented as a time sequence of samples, the DFT gives us a seqence of frequency/phase amplitudes

    .55

    .46

    1,0

    -1.0

    -,6

    0

  • Signals and noise

    What is noise?

    Any signal other than the one you are interested in!

    Sources of Noise (the usual suspects)

    statistical signals from active electronic components

    crosstalk from other channels or other signals in the same channel

    signals sensed from external sources (power supply, EM radiation)

    Trival Example

    -1.5

    -1

    -0.5

    0

    0.5

    1

    1.5

    1 4 7 10 13 16 19 22 25 28 31 34 37 40 43 46 49 52 55 58 61 64 67 70 73 76 79 82

    -1.5

    -1

    -0.5

    0

    0.5

    1

    1.5

    1 5 9 13 17 21 25 29 33 37 41 45 49 53 57 61 65 69 73 77 81

    -1.5

    -1

    -0.5

    0

    0.5

    1

    1.5

    1 4 7 10 13 16 19 22 25 28 31 34 37 40 43 46 49 52 55 58 61 64 67 70 73 76 79 82

    Signal of interest +

    Noise signal =

    Noisey Signal

    Signal to Noise ratio

    The relative amplitude of the signal of interest o the

    noise signal

  • Filtering out the Noise

    Finite Impulse response (FIR) filter

    Ideal Pulse (time domain)

    t

    Ideal Pulse (frequency domain)

    to inifinity

    to inifinity

    Ideal Pulse (time domain)

    Zero rise/fall time

    actual rise/fall time

    finite band of component frequencies

    The number and values of the component freqencies is related to the rise/fall time of the pulse

    http://www.chem.uoa.gr/Applets/AppletFourAnal/Appl_FourAnal2.html

  • xt = Cii=0

    i=(taps1)

    *Sti

    FIR filterA special type of weighted average designed to enhance signal

    components at some frequencies while attenuating others

    C1

    St

    St-1

    St-2

    St-3

    St-4

    St-5

    *

    C2

    *

    C3

    *

    C4

    *

    C5

    *

    C5

    *

    + Xt

    Selecting the coefficients tunes

    the filter to pass or attenuated specific

    frequency bands

  • Selecting the coefficients a.k.a designing the filter

    Matlab demo

  • How a filter works (theoretically)

    -1.5

    -1

    -0.5

    0

    0.5

    1

    1.5

    1 4 7 10 13 16 19 22 25 28 31 34 37 40 43 46 49 52 55 58 61 64 67 70 73 76 79 82

    -1.5

    -1

    -0.5

    0

    0.5

    1

    1.5

    1 5 9 13 17 21 25 29 33 37 41 45 49 53 57 61 65 69 73 77 81

    -1.5

    -1

    -0.5

    0

    0.5

    1

    1.5

    1 4 7 10 13 16 19 22 25 28 31 34 37 40 43 46 49 52 55 58 61 64 67 70 73 76 79 82

    signal

    noise

    FFT

    noise

    minus

    FFT-1

    signal

  • Sample Code

    /*

    fir.h

    simple fir filter code

    * dmc - 03-04-08

    * for cs 1567 note this code does not set up coefficents

    */

    #define TAPS 4 // how many filter taps

    typedef struct

    {

    float coefficients[TAPS];

    unsigned next_sample;

    float samples[TAPS];

    } filter;

    /* firFilterCreate()

    * creates, allocates, and iniitializes a new firFilter

    */

    filter *firFilterCreate()

    {

    int i;

    filter *f = malloc(sizeof(filter));

    for (i=0; isamples[i] = 0;

    f->coefficients[i] = 1. /(float) TAPS; // user must set coef's

    }

    f->next_sample = 0;

    }

    /* firFilter

    * inputs take a filter (f) and the next sample (val)

    * returns the next filtered sample

    * incorporates new sample into filter data array

    */

    float firFilter(filter *f, float val)

    {

    float sum =0;

    int i,j;

    /* assign new value to "next" slot */

    f->samples[f->next_sample] = val;

    /* calculate a weighted sum

    i tracks the next coeficeint

    j tracks the samples w/wrap-around */

    for( i=0,j=f->next_sample; icoefficients[i]*f->samples[j++];

    if(j==TAPS) j=0;

    }

    if(++(f->next_sample) == TAPS) f->next_sample = 0;

    return(sum);

    }

  • Filtered Wheel Encoder Data

    Left Wheel

    Right Wheel

  • Filtered NorthStar data

    X Position

    Y Position

    Theta