# Re: FIR filter in 8051 micro

• From: Jerry Avins <jya@xxxxxxxx>
• Date: Tue, 20 Oct 2009 10:28:29 -0400

webmasterpdx wrote:
First, filtering using an embedded 8-bit micro is possible. Ignore people
who are talking double precision, etc, etc....they aren't embedded people
with experience in this area. I have invented an algorithm that works well
on a PIC (8-bit also). I call it the "tri-band filter". I had a situation
where I had to generate a measure of the power spectrum in 3 bands in an
audio spectrum of a piano (about 4.5KHz). So, I took 32 samples at a time
(I was limted by memory) and ran a FIR filter on the data. I basically
chose a FIR filter of the form ax0+bx1+cx2 and centered it at the midpoint
of my frequency range. My sample rate was twice the highest frequency (by
Nyquist).
Now, I used some online filter coefficient generator. What I noticed is
the LPF coefficients were the same as the HPF coefficients just swapping
signs here and there, so as long as I calculated ax0, bx1 and cx2, I could
use the same calculations for both filters. The second trick I used was to
round any floating point values to the nearest powers of two. For example,
one term was 0.3664, and I rounded it to 0.375 (3/8*x), which can be
calculated as ((x << 2) + x) >> 3, which involves no multiplies (my PIC
didn't have a multiply) and only involves integer calculations. Note that
the frequency response of the filter (if you choose your coefficients
carefully) was almost identical to the non-altered one and my results were
very accurate (much better than my older state variable filter that I used
to use). If you combine the touching of coords to be combinations of power
of two so you can do your calculations using shifts and adds and reuse
coefficients to give you both High and Low pass results simultaneously. The
band pass was obtained by subtracting the LPF and HPF values from the
original data. You will need to use a 16 bit accumulator (assuming you are
using 8-bit sampled data) and remember to shift left and add BEFORE
shifting right as you'll get more accurate results that way.
This algorithm works very well for 8-bit processors.
Enjoy...

You do realize that this is a year-old thread? Whatever, you seem like the kind of pragmatic programmer I admire.

Jerry
--
Engineering is the art of making what you want from things you can get.
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
.

## Relevant Pages

• Re: why are LMS coefficients wandering away?
... noise cancellation system on a ADSP-21369 EZ-KIT Lite. ... chosen the Normalized Leaky LMS algorithm to update coefficients ... where N is the filter order. ...
(comp.dsp)
• Re: FIR filter optimization
... algorithm (or any other algorithm that uses power of 2 coefficients for ... i have a 25 tap symmetric Half band filter. ... original coefficients to canonic signed digits, ... the CSD methos will need more bits in the adder to keep full precision. ...
(comp.dsp)
• Re: Linear Phase via Phase Cloning New Method
... reasons why i wont just post the algorithm. ... They are in the form I would use to represent the tap weights of a transversal filter. ... If you apply ot to a transversal filter you will reproduce the list of coefficients. ... It's not a matter of admitting it, the filter has approximately linear phase. ...
(comp.dsp)
• Re: FIR filter in 8051 micro
... and ran a FIR filter on the data. ... the LPF coefficients were the same as the HPF coefficients just swapping ... didn't have a multiply) and only involves integer calculations. ... If you combine the touching of coords to be combinations of power ...
(comp.dsp)
• Re: Obtaining band-pass/stop coeffiecients from low/high-pass
... The type of filter that I'm ... then I use those coefficients to filter it as is standard. ... tweak my coefficient algorithm, or transform the low-pass/high-pass ... there is a method of Geffe for converting lowpass biquad function Hto bandpass/bandstop function with the 2x increase of order; that is one biquad gets converted into two biquads. ...
(comp.dsp)