Digital filtering help?

Discussion in 'Homework Help' started by martini1, Apr 3, 2009.

  1. martini1

    Thread Starter New Member

    Apr 3, 2009
    1
    0
    I think I've been using an IIR instead of an FIR to filter accelerometer readings in my embedded system. The reason being that...

    The filtering routine takes a new ADC reading and stores it in element[0] of the filter storage array. Then it takes the previous 9 stored elements, adds them together with element[0] and copies the resulting average back into element[0]. So, when we re-enter the filter routine, to process the next new reading we are using previously filtered outputs.

    Now, it is my belief that the difference between IIR and FIR is that IIR uses previously filtered outputs in the equation. Am I correct in thinking that I'm using an IIR? Any help?

    Code:

    Code ( (Unknown Language)):
    1. //Digital low pass filter to process X,Y and Z accel readings
    2. Int16U filterReading(float* pFilter, Int16U adcr)
    3. {
    4.      Int8U i;    //Loop counter variable
    5.  
    6.      //Shift values along to make room for new readings
    7.      for(i = 0; i < (MAX_FILTER_STORE - 1); i++)
    8.    {
    9.          pFilter[i + 1] = pFilter[i];
    10.    }
    11.      //Place the new reading in the first element
    12.      pFilter[0] = (adcr * 0.1);
    13.  
    14.      //Loop to process reading with an average weighting
    15.      for(i = 1; i < MAX_FILTER_STORE; i++)
    16.      {
    17.          pFilter[0] += (pFilter[i] * 0.1);
    18.      }
    19.      //Return modified reading
    20.      return (Int16U)pFilter[0];
    21. }         [/i][/i]
     
Loading...