Digital filtering help?

Thread Starter


Joined Apr 3, 2009
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?


Rich (BB code):
//Digital low pass filter to process X,Y and Z accel readings
Int16U filterReading(float* pFilter, Int16U adcr)
     Int8U i;    //Loop counter variable
     //Shift values along to make room for new readings
     for(i = 0; i < (MAX_FILTER_STORE - 1); i++)
         pFilter[i + 1] = pFilter;
     //Place the new reading in the first element
     pFilter[0] = (adcr * 0.1);
     //Loop to process reading with an average weighting
     for(i = 1; i < MAX_FILTER_STORE; i++)
         pFilter[0] += (pFilter * 0.1);
     //Return modified reading
     return (Int16U)pFilter[0];