Fixed Point IIR implementation
CASTalk.com Forum Index CASTalk.com
Discussion of DSP, FPGA, storage and embedded system.
 
 FAQFAQ   MemberlistMemberlist     RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Google
 
Web castalk.com
Fixed Point IIR implementation
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CASTalk.com Forum Index -> DSP
Author Message
robert bristow-johnson
Guest





Posted: Thu Dec 01, 2005 5:16 pm    Post subject: Re: Fixed Point IIR implementation Reply with quote

Just Cocky wrote:

Quote:
Isn't this a case where a lattice filter implementaion helps?

the "normalized ladder" architecture is supposed to address this
problem. it preserves the mean power in those internal states but does
not guarantee against saturation. in the DF1, you can scale down b0,
b1, b2 to such a point that the summer (and output y[n]) does not
saturate (and then scale it up later, if you can get away with it).

r b-j
Back to top
Fred Nach
Guest





Posted: Thu Dec 01, 2005 5:16 pm    Post subject: Re: Fixed Point IIR implementation Reply with quote

Hi all !

Firstly thanks a lot for your fast and usefull help ;-)

It seems that my previous post was not clear enough so here are some
extra details :

* The filter structure is indeed the From II that robert B-J has
described very clearly.

* a1 and a2 are hence the DENOMINATORS coeff (I was born in the 80's !!)
and ... b1 and b2 are NUMERATOR (no b0 cause it is supposed scaled)

* The input signal is x(n) and it is a bounded signal : PCM 16 bits so
it varies from -32768 to 32767

* The s(k) are the internal states that I save between each sample
processing...

* The filter is indeed stable hence |a1| <= 2 and |a2| <= 1

I think I understood that this implementation is not recommended because
it compute first the feedback terms and leads to big variations...
But is there a way to retrieve the boudary of s(k) mathematicaly ?

I think that as long as a1 and a2 are given for a stable filter s(k)
should be bounded...

For my program, this implementation is very interesting cause i code in
Assembly and It save a lot of MPIS to only read 2 states variable (s1
and s2) then 4 (x1 x2 y1 y2)...

Fred.


robert bristow-johnson a écrit :
Quote:
Fred Nach wrote:

I would like to implement a IIR Biquad filter using the fixed point
arithmetics...
Hence to reduced the intermediate states I plan to use the following trick:
s(k) = x(k) -a1*s(k-1) -a2*s(k-2)
y(n) = b0*s(k) + b1*s(k-1) + b2*s(k-2)

The I can compute each y, saving only 2 states (s(k-1) aénd s(k-2))...


this is the Direct 2 Form (sometimes called the "Direct II Canonical
Form"). unrecommeded for floating-point (if the Q is quite high, you
end up subtracting numbers very close to each other and losing
precision) and *highly* unrecommended for fixed-point (saturation
clipping will be your lot).

try the Direct 1 Form:

y[n] = b0*x[n] + b1*x[n-1] + b2*x[n-2] - a1*y[n-1] - a2*y[n-2]

every product on the right side of the = sign is a double precision
fixed point and all of those products should be added together in
double precision. this is trivial in the Mot 56K and the ADI SHArC and
maybe in the TI fixed-pointers.


BUT ... in order to scale my coefficients or input, I need to know what
are the boundaries of the s(k) serie... in order to find a proper Fixed
Point format for my coefficients..


your coefs are defined strictly in terms of the frequency response you
want. the gross range of a1 is -2 to +2 and a2 is -1 to +1 for any
stable biquad filter. the b0, b1, b2 coefs can be nearly anything but
you will have to choose a range and possibly do some scaling using the
arithmetic shift operation on the result before saving to y[n].


So my questions are :

* for which conditions, s(k) is bounded
* If the s(k) is bounded, what are the boundaries?


that is a purely artificial construct. are your fixed-point signal
values considered 16 bit signed integers? then it's -32768 <= x[n]
+32768 . are they normalized? then it's -1 <= x[n]< +1. their range
is whatever you want them to be.


Thanks in advance for your help (and sorry for my poor englsih)


as Jerry said, your English is fine.

r b-j
Back to top
robert bristow-johnson
Guest





Posted: Fri Dec 02, 2005 12:02 am    Post subject: Re: Fixed Point IIR implementation Reply with quote

Just Cocky wrote:

Quote:
Isn't this a case where a lattice filter implementaion helps?

the "normalized ladder" architecture is supposed to address this
problem. it preserves the mean power in those internal states but does
not guarantee against saturation. in the DF1, you can scale down b0,
b1, b2 to such a point that the summer (and output y[n]) does not
saturate (and then scale it up later, if you can get away with it).

r b-j
Back to top
Jerry Avins
Guest





Posted: Fri Dec 02, 2005 12:29 am    Post subject: Re: Fixed Point IIR implementation Reply with quote

robert bristow-johnson wrote:
Quote:
Jerry Avins wrote:

robert bristow-johnson wrote:

Jerry Avins wrote:

...

Quote:
OK. Back to the books with my thinking cap on.


no need. here's a simple way to look at it:

...

Thanks much. Part of my problem was misreading the original equations,
the ones with () instead of [].

Jerry
--
Engineering is the art of making what you want from things you can get.
ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
Back to top
Jon Harris
Guest





Posted: Sat Dec 03, 2005 9:15 am    Post subject: Re: Fixed Point IIR implementation Reply with quote

"Andrew Reilly" <andrew-newspost@areilly.bpc-users.org> wrote in message
news:pan.2005.12.01.00.10.23.587775@areilly.bpc-users.org...
Quote:
On Wed, 30 Nov 2005 11:01:31 -0800, Noway2 wrote:
I have seen Matlab scripts that run an impulse response till it
stabilizes and then sum up the impulse responses and use the maximum
value as a scale factor, though I don't know if this is a correct
solution.

It's pretty close. This is the main reason why these "direct form 2"
implmentations are not preferred. A direct form 1 implmentation will use
more memory but (a) memory is relatively cheap and (b) the values stored
will be as constrained as the input and output values.

Even though memory is cheap, sometimes I find the overhead of the extra memory
stores/fetches slows the filter down a bit (depending on the architecture).
Back to top
 
Post new topic   Reply to topic    CASTalk.com Forum Index -> DSP All times are GMT
Goto page Previous  1, 2
Page 2 of 2

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum




VoIP Electronics Powered by phpBB