COMPGROUPS.NET | Search | Post Question | Groups | Stream | About | Register

### Low Pass Digital Filter Stability Question

• Follow

```I have used the cheby2 routine in Matlab to design a simple low-pass filter
of order 2.  However, the cutoff frequency is very low at 0.001.  This
filter works on my input signal as a second-order filter, but when I try to
increase the order of the filter for better stop-band attenuation, it goes
unstable.  Besides down-sampling the input signal in order to raise the
cutoff frequency of the LP filter, does anyone know of a trick to make my
filter stable with a very low cutoff frequency?
```
 0
Reply ptd26 (11) 1/31/2011 11:50:50 PM

```On 1/31/2011 3:50 PM, j26 wrote:
> I have used the cheby2 routine in Matlab to design a simple low-pass filter
> of order 2.  However, the cutoff frequency is very low at 0.001.  This
> filter works on my input signal as a second-order filter, but when I try to
> increase the order of the filter for better stop-band attenuation, it goes
> unstable.  Besides down-sampling the input signal in order to raise the
> cutoff frequency of the LP filter, does anyone know of a trick to make my
> filter stable with a very low cutoff frequency?

Yeah, don't go any farther than second order or it'll go unstable.

Less sarcastically, what you want to do is break your filter up into
second-order sections, each one representing either a pair of real poles
or (more likely) a complex pole-pair.  Under Octave there are some
functions beginning with "sos" that work on those sorts of things;
there's probably something similar in Matlab.

By the way, by the time you've got your coefficients out in transfer
function [b, a] format, floating point errors have already killed you.
Stick to zeros and poles until you've got the order down.

--
Email address is currently out of order
```
 0

```On 01/31/2011 03:54 PM, Rob Gaddi wrote:
> On 1/31/2011 3:50 PM, j26 wrote:
>> I have used the cheby2 routine in Matlab to design a simple low-pass
>> filter
>> of order 2. However, the cutoff frequency is very low at 0.001. This
>> filter works on my input signal as a second-order filter, but when I
>> try to
>> increase the order of the filter for better stop-band attenuation, it
>> goes
>> unstable. Besides down-sampling the input signal in order to raise the
>> cutoff frequency of the LP filter, does anyone know of a trick to make my
>> filter stable with a very low cutoff frequency?
>
> Yeah, don't go any farther than second order or it'll go unstable.
>
> Less sarcastically, what you want to do is break your filter up into
> second-order sections, each one representing either a pair of real poles
> or (more likely) a complex pole-pair. Under Octave there are some
> functions beginning with "sos" that work on those sorts of things;
> there's probably something similar in Matlab.

Really, you should keep the real poles as 1st order.  But you'll
generally only ever have one, and then only if your filter has odd order.

> By the way, by the time you've got your coefficients out in transfer
> function [b, a] format, floating point errors have already killed you.
> Stick to zeros and poles until you've got the order down.
>
Yup.  The underlying problem is the representation of the transfer
function as a ratio of polynomials -- polynomial roots can be _very_
sensitive to coefficient variation as the order goes up, which is _not_
what you need in a case like this.

--

Tim Wescott
Wescott Design Services
http://www.wescottdesign.com

Do you need to implement control loops in software?
"Applied Control Theory for Embedded Systems" was written for you.
See details at http://www.wescottdesign.com/actfes/actfes.html
```
 0

```>On 1/31/2011 3:50 PM, j26 wrote:
>> I have used the cheby2 routine in Matlab to design a simple low-pass
filter
>> of order 2.  However, the cutoff frequency is very low at 0.001.  This
>> filter works on my input signal as a second-order filter, but when I try
to
>> increase the order of the filter for better stop-band attenuation, it
goes
>> unstable.  Besides down-sampling the input signal in order to raise the
>> cutoff frequency of the LP filter, does anyone know of a trick to make
my
>> filter stable with a very low cutoff frequency?
>
>Yeah, don't go any farther than second order or it'll go unstable.
>
>Less sarcastically, what you want to do is break your filter up into
>second-order sections, each one representing either a pair of real poles
>or (more likely) a complex pole-pair.  Under Octave there are some
>functions beginning with "sos" that work on those sorts of things;
>there's probably something similar in Matlab.
>
>By the way, by the time you've got your coefficients out in transfer
>function [b, a] format, floating point errors have already killed you.
>Stick to zeros and poles until you've got the order down.
>
>--
>Email address is currently out of order
>

So basically, I want to feed the signal through a series of 1st and 2nd
order filters or would I get the same result by leaving everything in
pole-zero form?  How do I process a signal using poles and zeros without
using the filter coefficients?  As I recall, the coefficients come from the
poles and zeros.  I apologize if this is a dumb question, I'm just a bit
rusty.  I did suspect that rounding errors were my problem.  Also, is a 4th
order cheby filter the same as 2 second order cheby filters in series?
```
 0

```On 01/31/2011 04:59 PM, j26 wrote:
>> On 1/31/2011 3:50 PM, j26 wrote:
>>> I have used the cheby2 routine in Matlab to design a simple low-pass
> filter
>>> of order 2.  However, the cutoff frequency is very low at 0.001.  This
>>> filter works on my input signal as a second-order filter, but when I try
> to
>>> increase the order of the filter for better stop-band attenuation, it
> goes
>>> unstable.  Besides down-sampling the input signal in order to raise the
>>> cutoff frequency of the LP filter, does anyone know of a trick to make
> my
>>> filter stable with a very low cutoff frequency?
>>
>> Yeah, don't go any farther than second order or it'll go unstable.
>>
>> Less sarcastically, what you want to do is break your filter up into
>> second-order sections, each one representing either a pair of real poles
>> or (more likely) a complex pole-pair.  Under Octave there are some
>> functions beginning with "sos" that work on those sorts of things;
>> there's probably something similar in Matlab.
>>
>> By the way, by the time you've got your coefficients out in transfer
>> function [b, a] format, floating point errors have already killed you.
>> Stick to zeros and poles until you've got the order down.
>>
>> --
>> Email address is currently out of order
>>
>
> So basically, I want to feed the signal through a series of 1st and 2nd
> order filters or would I get the same result by leaving everything in
> pole-zero form?  How do I process a signal using poles and zeros without
> using the filter coefficients?  As I recall, the coefficients come from the
> poles and zeros.

You make a bunch of 2nd-order filters and you cascade them, by feeding
the output of filter1 into the input of filter2, etc.

In Scilab you can make one filter in state-space form, that takes care
of this for you (at least when you run the filter).  I don't know if
Matlab has the equivalent, and if so if you can get it without buying
some \$\$\$\$ toolbox.

> I apologize if this is a dumb question, I'm just a bit
> rusty.  I did suspect that rounding errors were my problem.

No problem -- that's why we're here.

> Also, is a 4th
> order cheby filter the same as 2 second order cheby filters in series?

No -- in general the "named" filters have poles that do not lie atop one
another.

--

Tim Wescott
Wescott Design Services
http://www.wescottdesign.com

Do you need to implement control loops in software?
"Applied Control Theory for Embedded Systems" was written for you.
See details at http://www.wescottdesign.com/actfes/actfes.html
```
 0

```Ok, so it sounds like the approach for filtering is to use state-space form
in order to avoid having to filter in the time domain via filter
coefficients (and associated rounding errors)?  I still want to design the
filter experimentally (via genetic algorithm - differential evolution)
using the approach outlined in this paper:

(sorry for the long link).  So the algorithm described there will give me a
set of poles and zeros to use.  What's the best ways to take those
poles/zeros and use them to filter, preferably in Java.

>On 01/31/2011 04:59 PM, j26 wrote:
>>> On 1/31/2011 3:50 PM, j26 wrote:
>>>> I have used the cheby2 routine in Matlab to design a simple low-pass
>> filter
>>>> of order 2.  However, the cutoff frequency is very low at 0.001.
This
>>>> filter works on my input signal as a second-order filter, but when I
try
>> to
>>>> increase the order of the filter for better stop-band attenuation, it
>> goes
>>>> unstable.  Besides down-sampling the input signal in order to raise
the
>>>> cutoff frequency of the LP filter, does anyone know of a trick to
make
>> my
>>>> filter stable with a very low cutoff frequency?
>>>
>>> Yeah, don't go any farther than second order or it'll go unstable.
>>>
>>> Less sarcastically, what you want to do is break your filter up into
>>> second-order sections, each one representing either a pair of real
poles
>>> or (more likely) a complex pole-pair.  Under Octave there are some
>>> functions beginning with "sos" that work on those sorts of things;
>>> there's probably something similar in Matlab.
>>>
>>> By the way, by the time you've got your coefficients out in transfer
>>> function [b, a] format, floating point errors have already killed you.
>>> Stick to zeros and poles until you've got the order down.
>>>
>>> --
>>> Email address is currently out of order
>>>
>>
>> So basically, I want to feed the signal through a series of 1st and 2nd
>> order filters or would I get the same result by leaving everything in
>> pole-zero form?  How do I process a signal using poles and zeros
without
>> using the filter coefficients?  As I recall, the coefficients come from
the
>> poles and zeros.
>
>You make a bunch of 2nd-order filters and you cascade them, by feeding
>the output of filter1 into the input of filter2, etc.
>
>In Scilab you can make one filter in state-space form, that takes care
>of this for you (at least when you run the filter).  I don't know if
>Matlab has the equivalent, and if so if you can get it without buying
>some \$\$\$\$ toolbox.
>
>> I apologize if this is a dumb question, I'm just a bit
>> rusty.  I did suspect that rounding errors were my problem.
>
>No problem -- that's why we're here.
>
>> Also, is a 4th
>> order cheby filter the same as 2 second order cheby filters in series?
>
>No -- in general the "named" filters have poles that do not lie atop one
>another.
>
>--
>
>Tim Wescott
>Wescott Design Services
>http://www.wescottdesign.com
>
>Do you need to implement control loops in software?
>"Applied Control Theory for Embedded Systems" was written for you.
>See details at http://www.wescottdesign.com/actfes/actfes.html
>
```
 0

```On 1/31/2011 5:58 PM, j26 wrote:
> Ok, so it sounds like the approach for filtering is to use state-space form
> in order to avoid having to filter in the time domain via filter
> coefficients (and associated rounding errors)?  I still want to design the
> filter experimentally (via genetic algorithm - differential evolution)
> using the approach outlined in this paper:
>
>
> (sorry for the long link).  So the algorithm described there will give me a
> set of poles and zeros to use.  What's the best ways to take those
> poles/zeros and use them to filter, preferably in Java.
>
>> On 01/31/2011 04:59 PM, j26 wrote:
>>>> On 1/31/2011 3:50 PM, j26 wrote:
>>>>> I have used the cheby2 routine in Matlab to design a simple low-pass
>>> filter
>>>>> of order 2.  However, the cutoff frequency is very low at 0.001.
> This
>>>>> filter works on my input signal as a second-order filter, but when I
> try
>>> to
>>>>> increase the order of the filter for better stop-band attenuation, it
>>> goes
>>>>> unstable.  Besides down-sampling the input signal in order to raise
> the
>>>>> cutoff frequency of the LP filter, does anyone know of a trick to
> make
>>> my
>>>>> filter stable with a very low cutoff frequency?
>>>>
>>>> Yeah, don't go any farther than second order or it'll go unstable.
>>>>
>>>> Less sarcastically, what you want to do is break your filter up into
>>>> second-order sections, each one representing either a pair of real
> poles
>>>> or (more likely) a complex pole-pair.  Under Octave there are some
>>>> functions beginning with "sos" that work on those sorts of things;
>>>> there's probably something similar in Matlab.
>>>>
>>>> By the way, by the time you've got your coefficients out in transfer
>>>> function [b, a] format, floating point errors have already killed you.
>>>> Stick to zeros and poles until you've got the order down.
>>>>
>>>> --
>>>> Email address is currently out of order
>>>>
>>>
>>> So basically, I want to feed the signal through a series of 1st and 2nd
>>> order filters or would I get the same result by leaving everything in
>>> pole-zero form?  How do I process a signal using poles and zeros
> without
>>> using the filter coefficients?  As I recall, the coefficients come from
> the
>>> poles and zeros.
>>
>> You make a bunch of 2nd-order filters and you cascade them, by feeding
>> the output of filter1 into the input of filter2, etc.
>>
>> In Scilab you can make one filter in state-space form, that takes care
>> of this for you (at least when you run the filter).  I don't know if
>> Matlab has the equivalent, and if so if you can get it without buying
>> some \$\$\$\$ toolbox.
>>
>>> I apologize if this is a dumb question, I'm just a bit
>>> rusty.  I did suspect that rounding errors were my problem.
>>
>> No problem -- that's why we're here.
>>
>>> Also, is a 4th
>>> order cheby filter the same as 2 second order cheby filters in series?
>>
>> No -- in general the "named" filters have poles that do not lie atop one
>> another.
>>
>> --
>>
>> Tim Wescott
>> Wescott Design Services
>> http://www.wescottdesign.com
>>
>> Do you need to implement control loops in software?
>> "Applied Control Theory for Embedded Systems" was written for you.
>> See details at http://www.wescottdesign.com/actfes/actfes.html
>>

You're still not quite getting it.  At the end of the day, yes, you're
going to filter in the time domain, which will mean turning your poles
and zeros back into time domain coefficients.  What you don't want to
do, however, is turn them all into one giant polynomial.  You want to
turn them into a cascade of polynomials, none of them more than second
order.

Start by going through your poles and pairing them off into complex
conjugate pairs.  Each of those pole pairs represents one second order
section, which can be turned into a difference equation.  Then you chain
the output of each of those second order sections into the input of the
next.

If you sit down and do the math by hand of actually trying to turn all
of those poles into one giant difference equation instead, what you'll
find is that you're doing a whole lot of "small difference of large
numbers".  The inability of the computer to express that with infinite
resolution is why you get an unstable result; the result you get is
wrong and not a perfect match for the poles you put in.

--
Email address is currently out of order
```
 0

```On Feb 1, 12:50=A0am, "j26" <ptd26@n_o_s_p_a_m.live.com> wrote:
> I have used the cheby2 routine in Matlab to design a simple low-pass filt=
er
> of order 2. =A0However, the cutoff frequency is very low at 0.001. =A0Thi=
s
> filter works on my input signal as a second-order filter, but when I try =
to
> increase the order of the filter for better stop-band attenuation, it goe=
s
> unstable. =A0Besides down-sampling the input signal in order to raise the
> cutoff frequency of the LP filter, does anyone know of a trick to make my
> filter stable with a very low cutoff frequency?

You need to do a full design of your filter. If you have
either the signal processig toolbox or the filter design
elaborate design tools (I *think* one is caled FDATOOL),
that allows the novice user to do thse kinds of things
without having to worry too much about the technicalities.

Rune
```
 0

```On 01/31/2011 05:58 PM, j26 wrote:
(Top posting fixed)
>> On 01/31/2011 04:59 PM, j26 wrote:
>>>> On 1/31/2011 3:50 PM, j26 wrote:
>>>>> I have used the cheby2 routine in Matlab to design a simple low-pass
>>> filter
>>>>> of order 2.  However, the cutoff frequency is very low at 0.001.
> This
>>>>> filter works on my input signal as a second-order filter, but when I
> try
>>> to
>>>>> increase the order of the filter for better stop-band attenuation, it
>>> goes
>>>>> unstable.  Besides down-sampling the input signal in order to raise
> the
>>>>> cutoff frequency of the LP filter, does anyone know of a trick to
> make
>>> my
>>>>> filter stable with a very low cutoff frequency?
>>>>
>>>> Yeah, don't go any farther than second order or it'll go unstable.
>>>>
>>>> Less sarcastically, what you want to do is break your filter up into
>>>> second-order sections, each one representing either a pair of real
> poles
>>>> or (more likely) a complex pole-pair.  Under Octave there are some
>>>> functions beginning with "sos" that work on those sorts of things;
>>>> there's probably something similar in Matlab.
>>>>
>>>> By the way, by the time you've got your coefficients out in transfer
>>>> function [b, a] format, floating point errors have already killed you.
>>>> Stick to zeros and poles until you've got the order down.
>>>>
>>>> --
>>>> Email address is currently out of order
>>>>
>>>
>>> So basically, I want to feed the signal through a series of 1st and 2nd
>>> order filters or would I get the same result by leaving everything in
>>> pole-zero form?  How do I process a signal using poles and zeros
> without
>>> using the filter coefficients?  As I recall, the coefficients come from
> the
>>> poles and zeros.
>>
>> You make a bunch of 2nd-order filters and you cascade them, by feeding
>> the output of filter1 into the input of filter2, etc.
>>
>> In Scilab you can make one filter in state-space form, that takes care
>> of this for you (at least when you run the filter).  I don't know if
>> Matlab has the equivalent, and if so if you can get it without buying
>> some \$\$\$\$ toolbox.
>>
>>> I apologize if this is a dumb question, I'm just a bit
>>> rusty.  I did suspect that rounding errors were my problem.
>>
>> No problem -- that's why we're here.
>>
>>> Also, is a 4th
>>> order cheby filter the same as 2 second order cheby filters in series?
>>
>> No -- in general the "named" filters have poles that do not lie atop one
>> another.
>
> Ok, so it sounds like the approach for filtering is to use
> state-space form
> in order to avoid having to filter in the time domain via filter
> coefficients (and associated rounding errors)?

Slow down there -- you have to filter in the time domain, that's the
domain that we live in.  The state-space representation is just a
convenient one if your tools conveniently support it.  Scilab does.
It's an easier way to get high-order filters that don't run into
numerical problems that execute all in one thump -- but that's not
necessarily best.

> I still want to
> design the
> filter experimentally (via genetic algorithm - differential evolution)
> using the approach outlined in this paper:
>
>
>
> (sorry for the long link).  So the algorithm described there will
give me a
> set of poles and zeros to use.  What's the best ways to take those
> poles/zeros and use them to filter, preferably in Java.
>
Java?  You were talking about Matlab!  Java's different -- while it does
have built-in functions that are faster than what you get from coding
your own, none of them support filtering.  So you may as well go for

Probably a cascade of 2nd-order filters, in whichever one of the direct
forms is supposed to be best for floating point math.

--

Tim Wescott
Wescott Design Services
http://www.wescottdesign.com

Do you need to implement control loops in software?
"Applied Control Theory for Embedded Systems" was written for you.
See details at http://www.wescottdesign.com/actfes/actfes.html
```
 0

```First of all, I really appreciate all the help here!  Definitely!
Thanks!!!

Here's what I now understand.  Please let me know if I got it:

I want to design a low-pass filter that meets certain requirements which
can be characterized / specified as frequency response and group lag
constraints.  Assume that I can follow the approach of the paper linked
above to find the poles and zeros of the complex filter which meets these
requirements.  This, I envision, would be done in Java (I'd use Octave /
Matlab to double-check my setup).  So I end up with a collection of poles
and zeros that describe my filter.  Now I need to implement this filter in
Java to be used in a real-time application (yes, otherwise, I could have
just done everything in Octave / Matlab).  The suggestion from the posts
above lead me towards pairing up the poles / zeros into groups of no
greater than second order such that I have a cascade of second-order
filters.  I then find the coefficients of these second-order filters and
process the signal in the time-domain by running it through one filter at a
time.  If all that is true, then I think I now know how to design my
filter.  Although, I might ask well ask, does anyone know of an open-source
/ free software implementation of the algorithm described in the paper
above -- some software that can output filter coefficients based upon
frequency response as well as group delay constraints?
```
 0

```>First of all, I really appreciate all the help here!  Definitely!
>Thanks!!!
>
>Here's what I now understand.  Please let me know if I got it:
>
>I want to design a low-pass filter that meets certain requirements which
>can be characterized / specified as frequency response and group lag
>constraints.  Assume that I can follow the approach of the paper linked
>above to find the poles and zeros of the complex filter which meets these
>requirements.  This, I envision, would be done in Java (I'd use Octave /
>Matlab to double-check my setup).  So I end up with a collection of poles
>and zeros that describe my filter.  Now I need to implement this filter
in
>Java to be used in a real-time application (yes, otherwise, I could have
>just done everything in Octave / Matlab).  The suggestion from the posts
>above lead me towards pairing up the poles / zeros into groups of no
>greater than second order such that I have a cascade of second-order
>filters.  I then find the coefficients of these second-order filters and
>process the signal in the time-domain by running it through one filter at
a
>time.  If all that is true, then I think I now know how to design my
>filter.  Although, I might ask well ask, does anyone know of an
open-source
>/ free software implementation of the algorithm described in the paper
>above -- some software that can output filter coefficients based upon
>frequency response as well as group delay constraints?
>

It may also be worth mentioning...  As well as grouping complex conjugate
poles together to make the biquads implementation simpler, you'll also want
to:
- Put the poles closest to the unit circle in the 1st stages.
- Pair the poles and zeros that are closest to each other in the same
stage.
I'd also recommend using the Direct Form I realization over the Direct Form

```
 0

```>>First of all, I really appreciate all the help here!  Definitely!
>>Thanks!!!
>>
>>Here's what I now understand.  Please let me know if I got it:
>>
>>I want to design a low-pass filter that meets certain requirements which
>>can be characterized / specified as frequency response and group lag
>>constraints.  Assume that I can follow the approach of the paper linked
>>above to find the poles and zeros of the complex filter which meets
these
>>requirements.  This, I envision, would be done in Java (I'd use Octave /
>>Matlab to double-check my setup).  So I end up with a collection of
poles
>>and zeros that describe my filter.  Now I need to implement this filter
>in
>>Java to be used in a real-time application (yes, otherwise, I could have
>>just done everything in Octave / Matlab).  The suggestion from the posts
>>above lead me towards pairing up the poles / zeros into groups of no
>>greater than second order such that I have a cascade of second-order
>>filters.  I then find the coefficients of these second-order filters and
>>process the signal in the time-domain by running it through one filter
at
>a
>>time.  If all that is true, then I think I now know how to design my
>>filter.  Although, I might ask well ask, does anyone know of an
>open-source
>>/ free software implementation of the algorithm described in the paper
>>above -- some software that can output filter coefficients based upon
>>frequency response as well as group delay constraints?
>>
>
>It may also be worth mentioning...  As well as grouping complex conjugate
>poles together to make the biquads implementation simpler, you'll also
want
>to:
>- Put the poles closest to the unit circle in the 1st stages.
>- Pair the poles and zeros that are closest to each other in the same
>stage.
>I'd also recommend using the Direct Form I realization over the Direct
Form
>
>

Ok, I will keep that in mind.  Thanks for the tips!
```
 0

```There is another interesting possiblity, proposed by Fred Harris. Instead
of designing low-pass IIR you can design it as a band-pass, upconvert
signal before filtering and after that - downconvert it back. Band-pass IIR
maintaints higher stability, and frequency shift by fs/8 can be performed
by multiplying signal with sequence [-1, 0, 1, 0, -1, ...], so there is no
need to use full multiplier. This technique is described in SDR conference
papers -> http://data.memberclicks.com/site/sdf/SDR07-2.3-1.pdf.

Regards
Dominik
```
 0

12 Replies
195 Views

Similiar Articles:

7/11/2012 6:02:31 PM