balancing IIR filter (after adding extra registers)

On Jan 19, 3:43 pm, Gabor <ga...@szakacs.invalid> wrote:
Tim Wescott wrote:
On Wed, 18 Jan 2012 10:53:09 -0800, davew wrote:

On Jan 18, 6:49 pm, davew <david.wo...@gmail.com> wrote:
(Hi Tim,)
sorry I must admit I waded straight in myself without reading all of
the thread however:

Let c_{n-3} = a_{n-3}, which we can do by definition because a is
good at the beginning of the 3rd clock.
I'm not sure I follow this.  Please continue.

As we have one sample per clock cycle on a single channel stream, x{0},
x{1}, x{2} etc. what we want is:

y{0} = A * x{-1} + B * y{-1}

But the best we can do at the desired clock rate (assuming we have a
pipeline delay of 3) is:

y{0} = A * x{-3} + B * y{-3}

Is this doable?
Or to put it in words, if it takes 3 clocks to produce an output y from
x, but you need y on the next clock cycle to combine with the next value
of x then you simply can't have it, or can you?

Pretty much.

So I was trying to elucidate what you _can_ do if you have some imposed
delay, which is to make a stable IIR filter that happens to work for
minimum delays that are greater than 1.

There are limits, the two chief ones being bandwidth and delay.  Your
answer is going to have some pretty healthy delays both because of the
computation of the feedback portion of the filter (which is limited to
delays of N or more) and the feed-forward part of your filter (which
needs to have at least N terms if you're going to get a sensible
frequency response).  A your bandwidth (as a proportion to your sample
rate) that you can sensibly "ask for" gets ever narrower as your delays
get greater (really, it's probably better to say that your bandwidth in
real terms reaches a plateau above which it's hard to get).

In amongst all the math don't miss the point that I also made, that you
can pre-filter with something easy like a CIC, then decimate, then either
be done or follow that with an IIR filter.

From:

y{0} = A * x{-3} + B * y{-3}

A point that should not be missed is that you really have three
interleaved IIR filters each running at 1/3 the sample rate.  If
the signal bandwidth is high enough, there will be a significant
output component at 1/3 the sample rate due to this.  As a worst
case, an input with a lot of energy at 1/3 the sample rate would
be almost unfiltered.

-- Gabor
You're mixing up samples and clock cycles.
 
On Thu, 19 Jan 2012 10:43:22 -0500, Gabor wrote:

Tim Wescott wrote:
On Wed, 18 Jan 2012 10:53:09 -0800, davew wrote:

On Jan 18, 6:49 pm, davew <david.wo...@gmail.com> wrote:
(Hi Tim,)
sorry I must admit I waded straight in myself without reading all of
the thread however:

Let c_{n-3} = a_{n-3}, which we can do by definition because a is
good at the beginning of the 3rd clock.
I'm not sure I follow this. Please continue.

As we have one sample per clock cycle on a single channel stream,
x{0}, x{1}, x{2} etc. what we want is:

y{0} = A * x{-1} + B * y{-1}

But the best we can do at the desired clock rate (assuming we have a
pipeline delay of 3) is:

y{0} = A * x{-3} + B * y{-3}

Is this doable?
Or to put it in words, if it takes 3 clocks to produce an output y
from x, but you need y on the next clock cycle to combine with the
next value of x then you simply can't have it, or can you?

Pretty much.

So I was trying to elucidate what you _can_ do if you have some imposed
delay, which is to make a stable IIR filter that happens to work for
minimum delays that are greater than 1.

There are limits, the two chief ones being bandwidth and delay. Your
answer is going to have some pretty healthy delays both because of the
computation of the feedback portion of the filter (which is limited to
delays of N or more) and the feed-forward part of your filter (which
needs to have at least N terms if you're going to get a sensible
frequency response). A your bandwidth (as a proportion to your sample
rate) that you can sensibly "ask for" gets ever narrower as your delays
get greater (really, it's probably better to say that your bandwidth in
real terms reaches a plateau above which it's hard to get).

In amongst all the math don't miss the point that I also made, that you
can pre-filter with something easy like a CIC, then decimate, then
either be done or follow that with an IIR filter.


From:

y{0} = A * x{-3} + B * y{-3}

A point that should not be missed is that you really have three
interleaved IIR filters each running at 1/3 the sample rate. If the
signal bandwidth is high enough, there will be a significant output
component at 1/3 the sample rate due to this. As a worst case, an input
with a lot of energy at 1/3 the sample rate would be almost unfiltered.
Which is why, in my original recommendation, I suggested that the filter
be something like

y{0} = A * (x{-3} + x{-4} + x{-5}) + B * y{-3}

(Actually I left out the extra delay in the forward path in the equation,
but mentioned it in the text -- and you may need still more).

The feedforward path then has deep nulls right at the points where the
feedback path tends to blow up, and the overall frequency response looks
pretty good.

I'm still not sure that -- if you're going to have a CIC filter in there
anyway -- it isn't better to just do CIC -> decimate -> filter ->
reconstruct if necessary. But, the OP hasn't chimed in with much real
information pertinent to my suggestions, so we're deep into hypothetical
territory anyway.

--
What if there were no hypothetical questions?

Tim Wescott, Communications, Control, Circuits & Software
http://www.wescottdesign.com
 
Tim Wescott wrote:
On Thu, 19 Jan 2012 10:43:22 -0500, Gabor wrote:

Tim Wescott wrote:
On Wed, 18 Jan 2012 10:53:09 -0800, davew wrote:

On Jan 18, 6:49 pm, davew <david.wo...@gmail.com> wrote:
(Hi Tim,)
sorry I must admit I waded straight in myself without reading all of
the thread however:

Let c_{n-3} = a_{n-3}, which we can do by definition because a is
good at the beginning of the 3rd clock.
I'm not sure I follow this. Please continue.

As we have one sample per clock cycle on a single channel stream,
x{0}, x{1}, x{2} etc. what we want is:

y{0} = A * x{-1} + B * y{-1}

But the best we can do at the desired clock rate (assuming we have a
pipeline delay of 3) is:

y{0} = A * x{-3} + B * y{-3}

Is this doable?
Or to put it in words, if it takes 3 clocks to produce an output y
from x, but you need y on the next clock cycle to combine with the
next value of x then you simply can't have it, or can you?
Pretty much.

So I was trying to elucidate what you _can_ do if you have some imposed
delay, which is to make a stable IIR filter that happens to work for
minimum delays that are greater than 1.

There are limits, the two chief ones being bandwidth and delay. Your
answer is going to have some pretty healthy delays both because of the
computation of the feedback portion of the filter (which is limited to
delays of N or more) and the feed-forward part of your filter (which
needs to have at least N terms if you're going to get a sensible
frequency response). A your bandwidth (as a proportion to your sample
rate) that you can sensibly "ask for" gets ever narrower as your delays
get greater (really, it's probably better to say that your bandwidth in
real terms reaches a plateau above which it's hard to get).

In amongst all the math don't miss the point that I also made, that you
can pre-filter with something easy like a CIC, then decimate, then
either be done or follow that with an IIR filter.


From:

y{0} = A * x{-3} + B * y{-3}

A point that should not be missed is that you really have three
interleaved IIR filters each running at 1/3 the sample rate. If the
signal bandwidth is high enough, there will be a significant output
component at 1/3 the sample rate due to this. As a worst case, an input
with a lot of energy at 1/3 the sample rate would be almost unfiltered.

Which is why, in my original recommendation, I suggested that the filter
be something like

y{0} = A * (x{-3} + x{-4} + x{-5}) + B * y{-3}

(Actually I left out the extra delay in the forward path in the equation,
but mentioned it in the text -- and you may need still more).

The feedforward path then has deep nulls right at the points where the
feedback path tends to blow up, and the overall frequency response looks
pretty good.

I'm still not sure that -- if you're going to have a CIC filter in there
anyway -- it isn't better to just do CIC -> decimate -> filter -
reconstruct if necessary. But, the OP hasn't chimed in with much real
information pertinent to my suggestions, so we're deep into hypothetical
territory anyway.
I haven't proved it to myself yet, but it seems that the idea of making
the "multiple IIR filters at a lower rate," i.e. your original equation
could be followed by a short FIR filter and end up with the same effect
as an IIR filter with just more latency. For example the equation:

y{0} = A * x{-3} + B * y{-3}

Could be followed by a 3-term FIR filter to reconstruct the original
IIR (A and B are not the original A and B, though).

The usual reason to use IIR rather than FIR filters is that you use
a lot fewer storage elements (both for intermediate results and for
coefficients. A FIR filter with enough terms to satisfy the required
resolution could emulate an IIR filter. How many terms depends on the
resolution of the data and the values of A and B. Smaller A would
result in shorter FIR filters. Once you dump the IIR approach any
amount of pipelining can be added, as long as you have the latency
budget for it.

The last time I used an IIR filter was in a microprocessor-based LORAN
receiver, and that was just a matter of not having enough storage for
a FIR filter of reasonable length.

-- Gabor
 
On Mon, 23 Jan 2012 15:38:23 -0500, Gabor wrote:

Tim Wescott wrote:
On Thu, 19 Jan 2012 10:43:22 -0500, Gabor wrote:

Tim Wescott wrote:
On Wed, 18 Jan 2012 10:53:09 -0800, davew wrote:

On Jan 18, 6:49 pm, davew <david.wo...@gmail.com> wrote:
(Hi Tim,)
sorry I must admit I waded straight in myself without reading all
of the thread however:

Let c_{n-3} = a_{n-3}, which we can do by definition because a is
good at the beginning of the 3rd clock.
I'm not sure I follow this. Please continue.

As we have one sample per clock cycle on a single channel stream,
x{0}, x{1}, x{2} etc. what we want is:

y{0} = A * x{-1} + B * y{-1}

But the best we can do at the desired clock rate (assuming we have
a pipeline delay of 3) is:

y{0} = A * x{-3} + B * y{-3}

Is this doable?
Or to put it in words, if it takes 3 clocks to produce an output y
from x, but you need y on the next clock cycle to combine with the
next value of x then you simply can't have it, or can you?
Pretty much.

So I was trying to elucidate what you _can_ do if you have some
imposed delay, which is to make a stable IIR filter that happens to
work for minimum delays that are greater than 1.

There are limits, the two chief ones being bandwidth and delay. Your
answer is going to have some pretty healthy delays both because of
the computation of the feedback portion of the filter (which is
limited to delays of N or more) and the feed-forward part of your
filter (which needs to have at least N terms if you're going to get a
sensible frequency response). A your bandwidth (as a proportion to
your sample rate) that you can sensibly "ask for" gets ever narrower
as your delays get greater (really, it's probably better to say that
your bandwidth in real terms reaches a plateau above which it's hard
to get).

In amongst all the math don't miss the point that I also made, that
you can pre-filter with something easy like a CIC, then decimate,
then either be done or follow that with an IIR filter.


From:

y{0} = A * x{-3} + B * y{-3}

A point that should not be missed is that you really have three
interleaved IIR filters each running at 1/3 the sample rate. If the
signal bandwidth is high enough, there will be a significant output
component at 1/3 the sample rate due to this. As a worst case, an
input with a lot of energy at 1/3 the sample rate would be almost
unfiltered.

Which is why, in my original recommendation, I suggested that the
filter be something like

y{0} = A * (x{-3} + x{-4} + x{-5}) + B * y{-3}

(Actually I left out the extra delay in the forward path in the
equation, but mentioned it in the text -- and you may need still more).

The feedforward path then has deep nulls right at the points where the
feedback path tends to blow up, and the overall frequency response
looks pretty good.

I'm still not sure that -- if you're going to have a CIC filter in
there anyway -- it isn't better to just do CIC -> decimate -> filter -
reconstruct if necessary. But, the OP hasn't chimed in with much real
information pertinent to my suggestions, so we're deep into
hypothetical territory anyway.


I haven't proved it to myself yet, but it seems that the idea of making
the "multiple IIR filters at a lower rate," i.e. your original equation
could be followed by a short FIR filter and end up with the same effect
as an IIR filter with just more latency. For example the equation:

y{0} = A * x{-3} + B * y{-3}

Could be followed by a 3-term FIR filter to reconstruct the original IIR
(A and B are not the original A and B, though).

The usual reason to use IIR rather than FIR filters is that you use a
lot fewer storage elements (both for intermediate results and for
coefficients. A FIR filter with enough terms to satisfy the required
resolution could emulate an IIR filter. How many terms depends on the
resolution of the data and the values of A and B. Smaller A would
result in shorter FIR filters. Once you dump the IIR approach any
amount of pipelining can be added, as long as you have the latency
budget for it.

The last time I used an IIR filter was in a microprocessor-based LORAN
receiver, and that was just a matter of not having enough storage for a
FIR filter of reasonable length.
Well, mostly, with the exception of nit-picky little details like
quantization noise.

The IIR portion of the filter will have three poles, at the roots of
z^3 - B = 0; one of these is the desired one, the two will generate an
unwanted peak at Fs/3. Pairing that up with a FIR filter with zeros to
match the unwanted poles will give you the effect -- assuming you have
enough numerical precision -- of the original IIR filter you wanted.

But: the OP was just asking for a cruddy old 1st-order lowpass in the
first place. That's hardly ever what you really want in a signal
processing problem, so the IIR portion followed by a four-stage CIC
filter would be loads easier to compute (no multiplies, just an addition,
some delays, and a subtraction), that you probably wouldn't want to go
beyond that.

--
Tim Wescott
Control system and signal processing consulting
www.wescottdesign.com
 

Welcome to EDABoard.com

Sponsor

Back
Top