piclist 2002\09\21\205239a >
Thread: Challenge: FIR Filter on an 18f series device
face BY : Scott Dattalo email (remove spam text)

On Sat, 21 Sep 2002, Bob Ammerman wrote:

{Quote hidden}

Kinda cute, but kinda slow... But that's just the way it is. Perhaps the
dsPic handles this better?

I prefer to work exclusively with unsigned numbers on a PIC. If you're
careful then it's possible to express your data as though if it were
unsigned. If the data is coming from an A2D converter, then it's *always*
possible to treat the input stream as an unsigned number. But in general
you should be able to do this:

 signed number = unsigned number  -  offset

Suppose we were computing the FIR of a vector of signed numbers:

  Filt = sum ( w[i] * sdata[i])

 w[i] is the i'th filter coefficient
 sdata[i] is the i'th signed data element
 sum() is the sum-of-products operator
 Filt is the result

Note that: sdata[i] = udata[i] + offset
 udata[i] is the i'th data element represented as an unsigned entity

Substitute this into the FIR:

 Filt = sum( w[i] * (udata[i] + offset) )
      = sum( w[i] * udata[i] )  +  sum(w[i] * offset)
      = sum( w[i] * udata[i] )  +  offset * sum(w[i])

The sum on the left is the one that can be optimized with the routines
Tony K. and I posted. The sum on the right doesn't depend on the data. If
the FIR weights are constant then so will this sum. If they're not, then
this sum can be precomputed - or at least re-computed only when the
weights change.

In addition, if the w[i]'s are signed a similar transformation can be
performed for them. But you shouldn't need to do this. A better approach
is to treat them (or transform them) as unsigned numbers and then convert
the final value, Filt, to a signed number.

> Of course, in the normal course of events the values of the filter
> coefficients will be known in advance. Then, for maximum performance you can
> unroll the loop, and build in the signedness stuff at least for the filter
> coefficients.



http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


In reply to: <001201c2619e$4145b690$6500a8c0@DELL8100>
See also: www.piclist.com/techref/microchip/math/filter.htm?key=filter
Reply You must be a member of the piclist mailing list (not only a www.piclist.com member) to post to the piclist. This form requires JavaScript and a browser/email client that can handle form mailto: posts.
Subject (change) Challenge: FIR Filter on an 18f series device

month overview.

new search...