| ??? 05/22/03 08:58 Read: times |
#46357 - RE: MY project Details Responding to: ???'s previous message |
I see. If you want the easiest implementation of an FIR filter, floating-point math would be the way. It is also the slowest. I wouldn't want to code this in assembly:
float code c[16] = { <put 16 coefficients here> }; // FIR coefficients unsigned int u[16]; // past inputs float accumulator; // used in MAC unsigned int INPUTVALUE; // count from A/D unsigned int OUTPUTVALUE; // FIR output int i; // counter variable // First, shift the input variables and insert a new input value for (i=15; i>0; i--) { u[i] = u[i-1]; } u[0]=INPUTVALUE; // Then multiply-and-accumulate coefficients with inputs accumulator = 0; // zero accumulator for(i=0; i<16; i++) { accumulator = accumulator + c[i]*u[i]; } OUTPUTVALUE = accumulator; // done (note - this is not the most efficient way to do this. unrolling the loops is one way to speed it up) The concept is pretty simple. The harder part is coming up with the coefficients. There are a Java applets on the net that will calculate them for you. You might have to search for a while to find one that does it properly for this approach. I am interested to see how an FIR filter is a better approach than averaging for your scales. - Lee |



