DSPRelated.com
Forums

IIR Coefficient Calculation

Started by ger_lough April 17, 2014
I am having difficulty finding any info on how to calculate digital IIR
filter coefficients. I know this can be done in MATLAB, for example, but I
am interested in changing IIR specs on the fly. I have done this before
using the formulae provided by  Robert Bristow-Johnson on musicdsp.org, but
these equations only cover a 2nd order biquad. So, for example, how can I
calculate the coefficients for a Butterworth (low-pass, band-pass,
high-pass, etc) of order 32 using the same input as provided by RBJ on
musicdsp.org (Fs, f0 and Q). I need formulae so that the coefficients can
be updated on the fly. Also, it would be much appreciated if somebody can
point me to some literature specifically on this subject (i.e. how to
calculate iir coefficients for various IIR types).
	 

_____________________________		
Posted through www.DSPRelated.com
On 4/17/14 4:32 PM, ger_lough wrote:
> I am having difficulty finding any info on how to calculate digital IIR > filter coefficients. I know this can be done in MATLAB, for example, but I > am interested in changing IIR specs on the fly. I have done this before > using the formulae provided by Robert Bristow-Johnson on musicdsp.org, but > these equations only cover a 2nd order biquad. So, for example, how can I > calculate the coefficients for a Butterworth (low-pass, band-pass, > high-pass, etc) of order 32 using the same input as provided by RBJ on > musicdsp.org (Fs, f0 and Q). I need formulae so that the coefficients can > be updated on the fly. Also, it would be much appreciated if somebody can > point me to some literature specifically on this subject (i.e. how to > calculate iir coefficients for various IIR types). >
okay, so "Q" doesn't have quite a definite meaning is it does for a biquad. but you can design a Butterworth (or Tchebyshev Type 1) with nice closed-form poles (these are "all-pole filters" in the s-domain). i'll bet the Wikipedia article has the equations. there's gotta be a public-domain source. for an even order, all of these poles and zeros are complex conjugate, so they have a resonant frequency f0 and a Q. so, say it's an LPF, different biquad sections will have their own resonant frequency and a Q. (Butterworths have the same resonant frequency, but different Q's for each biquad section. Tchebyshevs will have slightly different resonant frequencies and widely varying Q.) different pole locations and zero locations,. so you can have your filter prototype (in analog) spec out the f0 and Q for each section, given the family and type of filter and corner frequency and its even order. then use those same f0 and Q for the cookbook. you can do cascaded biquads of Tchebyshev Type 2 or Elliptic filter families, to. but the cookbook filters are not general enough (without mixing two biquads with the same poles and denominator) to cover those. you would have to map the resonant frequency and "Q" of the zeros as well as the poles for each section. -- r b-j rbj@audioimagination.com "Imagination is more important than knowledge."
Here's how to do the Butterworth low pass filters or any order.

The other types are found via transformations.

http://www.claysturner.com/dsp/Butterworth%20Filter%20Formulae.pdf

Clay
On Thu, 17 Apr 2014 17:41:24 -0400, robert bristow-johnson
<rbj@audioimagination.com> wrote:

>okay, so "Q" doesn't have quite a definite meaning is it does for a biquad.
Here are the quadratic factors for several Butterworth filters. 1 s + 1.00000 2 s2 + 1.41421s + 1.00000 (Q = 0.70711) 3 s2 + 1.00000s + 1.00000 (Q = 1.00000) s + 1.00000 4 s2 + 0.76536s + 1.00000 (Q = 1.30657) s2 + 1.84776s + 1.00000 (Q = 0.54120) 6 s2 + 0.51764s + 1.00000 (Q = 1.93184) s2 + 1.41421s + 1.00000 (Q = 0.70711) s2 + 1.93186s + 1.00000 (Q = 0.51764) 8 s2 + 0.39018s + 1.00000 (Q = 2.56292) s2 + 1.11114s + 1.00000 (Q = 0.89998) s2 + 1.66294s + 1.00000 (Q = 0.60134) s2 + 1.96158s + 1.00000 (Q = 0.50979) In the even-order cases, the product of the Qs is sqrt(2)/2. In the odd-order cases, the product is 1. Or, if you like, you can *define* the Q of (s + 1) to be sqrt(2)/2, in which case the product of the Qs of all Butterworth quadratic factors is sqrt(2)/2. Greg
On 4/17/14 9:18 PM, clay@claysturner.com wrote:
> > Here's how to do the Butterworth low pass filters or any order. > > The other types are found via transformations. > > http://www.claysturner.com/dsp/Butterworth%20Filter%20Formulae.pdf
i suppose i could cook up counterparts for Tchebychev Type 1 and 2. i wonder if there are good mathematical formulae (even if not closed form, i.e. with a series in it to evaluate the Jacobi elliptic function) for Elliptical filters. i s'pose there should be formulae for Bessel and Gaussian filters, somewhere. what others? like the Cookbook, it would be nice to have the mathematical formulae (not code) for all these boiled down to a single on-line document. -- r b-j rbj@audioimagination.com "Imagination is more important than knowledge."
Thanks guys for your insights and getting back to me so quick. I am
slightly wiser about it now, but need to spend a bit of time reading still.
One quick question for now; the Wikipedia Buttterworth entry does indeed
contain the polynomials in S (up to order of 8). How can I form the
transfer function of an analog prototype using these?  As in the cookbook
where there are analog prototypes provided for 2nd order LP, HP, BP, BP,
AP, notch, peakingEQ, lowShelf, highShelf biquads. 
Also, it's not just an even ordered filter I'm interested in, more the
coefficient calculation process for various IIRs of arbitrary orders.	 

_____________________________		
Posted through www.DSPRelated.com
Thanks guys for your insights and getting back to me so quick. I am
slightly wiser about it now, but need to spend a bit of time reading still.
One quick question for now; the Wikipedia Buttterworth entry does indeed
contain the polynomials in S (up to order of 8). How can I form the
transfer function of an analog prototype using these?  As in the cookbook
where there are analog prototypes provided for 2nd order LP, HP, BP, BP,
AP, notch, peakingEQ, lowShelf, highShelf biquads. 
Also, it's not just an even ordered filter I'm interested in, more the
coefficient calculation process for various IIRs of arbitrary orders.	 

_____________________________		
Posted through www.DSPRelated.com
>like the Cookbook, it would be nice to have the mathematical formulae >(not code) for all these boiled down to a single on-line document.
It certainly would Robert! And credit to you for providing the formulae in the cookbook, seems to be the only complete set of formulae provided (that I have found at least, after much searching) to implement a 2nd order IIR of any desired frequency response. _____________________________ Posted through www.DSPRelated.com
On Friday, April 18, 2014 1:18:46 PM UTC+12, cl...@claysturner.com wrote:
> Here's how to do the Butterworth low pass filters or any order. > > > > The other types are found via transformations. > > > > http://www.claysturner.com/dsp/Butterworth%20Filter%20Formulae.pdf > > > > Clay
That's only the 3dB passband attenuation case but I suppose it will do for most problems.
On Sunday, April 20, 2014 9:18:11 AM UTC+12, robert bristow-johnson wrote:
> On 4/17/14 9:18 PM, clay@claysturner.com wrote: > > > > > > Here's how to do the Butterworth low pass filters or any order. > > > > > > The other types are found via transformations. > > > > > > http://www.claysturner.com/dsp/Butterworth%20Filter%20Formulae.pdf > > > > i suppose i could cook up counterparts for Tchebychev Type 1 and 2. > > > > i wonder if there are good mathematical formulae (even if not closed > > form, i.e. with a series in it to evaluate the Jacobi elliptic function) > > for Elliptical filters. > > > > i s'pose there should be formulae for Bessel and Gaussian filters, > > somewhere. what others? > > > > like the Cookbook, it would be nice to have the mathematical formulae > > (not code) for all these boiled down to a single on-line document. > > > > -- > > > > r b-j rbj@audioimagination.com > > > > "Imagination is more important than knowledge."
your example is fine since you sample 8 times the corner frequency. But you need to remind them that if you have a sampling frequency of say 3 times then you must use frequency pre-warping.