Having used up 5 days already, cutting and pasting the internet source code for Butterworth filters, only to have the audio spectrum analyzer show a terrible mess, I have to drop back to first principles in order to get something to work correctly. 1. I have the general Butterworth normalized polynomials for order-n (or can generate them) See http://en.wikipedia.org/wiki/Butterworth_filter 2. I am told to substitute for s, the value c*(z-1)/(z+1) for the bilateral transform where c = cotangent(wc*T/2) where T is the sample time. See http://www.apicsllc.com/apics/Sr_3/Sr_3.htm. This will give a rational polynomial equation in z, with the coefficients for the difference equation. But I am having problems getting things to work out correctly. For wc = 1/2, T = 1 sec, and order 3, I get B_n(3) = 1 / (s^3 + 2*s^2 + 2*s + 1) c = cot(1/4) = 3.9131736.. s = 3.9131736*(z-1)/(z+1) and thence 99.5744*z^3 - 200.04249*z^2 + 144.6923*z - 36.22423 H(z) --------------------------------------------------- z^3 + 3*z^2 + 3*z + 1 Which is no where close to octave's answer for the command [b,a]=butter(3,1/2) b = 1/6 1/2 1/2 1/6 a = 1 0 1/3 0 (we notice that sum(b) = sum(a) = 4/3 What steps am I missing to take H(z) above to match octave's answer? Or am I misunderstanding octave's answer and misapplying it? I am trying to automate the answers to H(z) for any order n and cut off frequency wc.

# General implementation of Butterworth filter questions

Started by ●August 29, 2010

Reply by ●August 29, 20102010-08-29

Randall wrote:> Having used up 5 days already, cutting and pasting the internet source code > for Butterworth filters, only to have the audio spectrum analyzer show a > terrible mess, I have to drop back to first principles in order to get > something to work correctly.Nobody gives up good stuff for free. Butterworth filter design is simple: either do it yourself or pay money for someone doing it for you. Vladimir Vassilevsky DSP and Mixed Signal Design Consultant http://www.abvolt.com

Reply by ●August 30, 20102010-08-30

On Aug 30, 3:07�am, "Randall" <website.reader3@n_o_s_p_a_m.gmail.com> wrote:> Having used up 5 days already, cutting and pasting the internet source code > for Butterworth filters, only to have the audio spectrum analyzer show a > terrible mess, I have to drop back to first principles in order to get > something to work correctly. > > 1. I have the general Butterworth normalized polynomials for order-n (or > can generate them) �Seehttp://en.wikipedia.org/wiki/Butterworth_filter > > 2. I am told toThose aren't even halfway close to first principles: You have only dug up stuff you don't understand and accepted orders to do stuff beyond your abilities. 'First principles' would be to 1) Find a book on the subject 2) Read it 3) Contemplate it 4) Test the recipes and algorithms 5) Iterate items 1)-4) as many times as necessary The question you ask is like riding a bicycle: Requires some effort and pain to learn, but ridiculously easy once you know how. Rune

Reply by ●August 30, 20102010-08-30

Randall <website.reader3@n_o_s_p_a_m.gmail.com> wrote:>c = cot(1/4) = 3.9131736..I must admire you for using a slide rule in this day and age. cot(1/4) = 3.916317364645940... Steve

Reply by ●August 30, 20102010-08-30

>Having used up 5 days already, cutting and pasting the internet sourcecode>for Butterworth filters, only to have the audio spectrum analyzer show a >terrible mess, I have to drop back to first principles in order to get >something to work correctly. > >1. I have the general Butterworth normalized polynomials for order-n (or >can generate them) See http://en.wikipedia.org/wiki/Butterworth_filter > >2. I am told to substitute for s, the value c*(z-1)/(z+1) for thebilateral>transform where c = cotangent(wc*T/2) where T is the sample time. See >http://www.apicsllc.com/apics/Sr_3/Sr_3.htm. > >This will give a rational polynomial equation in z, with the coefficients >for the difference equation. > >But I am having problems getting things to work out correctly. >For wc = 1/2, T = 1 sec, and order 3, I get > >B_n(3) = 1 / (s^3 + 2*s^2 + 2*s + 1) >c = cot(1/4) = 3.9131736.. >s = 3.9131736*(z-1)/(z+1) and thence > > 99.5744*z^3 - 200.04249*z^2 + 144.6923*z - 36.22423 >H(z) --------------------------------------------------- > z^3 + 3*z^2 + 3*z + 1 > >Which is no where close to octave's answer for the command >[b,a]=butter(3,1/2) >b = 1/6 1/2 1/2 1/6 >a = 1 0 1/3 0 > >(we notice that sum(b) = sum(a) = 4/3 > >What steps am I missing to take H(z) above to match octave's answer? Oram>I misunderstanding octave's answer and misapplying it? I am trying to >automate the answers to H(z) for any order n and cut off frequency wc.The answer to your problem is easy as pi. :-) Steve

Reply by ●August 30, 20102010-08-30

On Aug 29, 9:07�pm, "Randall" <website.reader3@n_o_s_p_a_m.gmail.com> wrote:> Having used up 5 days already, cutting and pasting the internet source code > for Butterworth filters, only to have the audio spectrum analyzer show a > terrible mess, I have to drop back to first principles in order to get > something to work correctly. > > 1. I have the general Butterworth normalized polynomials for order-n (or > can generate them) �Seehttp://en.wikipedia.org/wiki/Butterworth_filter > > 2. I am told to substitute for s, the value c*(z-1)/(z+1) for the bilateral > transform where c = cotangent(wc*T/2) where T is the sample time. �Seehttp://www.apicsllc.com/apics/Sr_3/Sr_3.htm. > > This will give a rational polynomial equation in z, with the coefficients > for the difference equation. > > But I am having problems getting things to work out correctly. > For wc = 1/2, T = 1 sec, and order 3, I get > > B_n(3) = 1 / (s^3 + 2*s^2 + 2*s + 1) > c = cot(1/4) = 3.9131736.. > s = 3.9131736*(z-1)/(z+1) and thence > > � � � �99.5744*z^3 - 200.04249*z^2 + 144.6923*z - 36.22423 > H(z) � --------------------------------------------------- > � � � � � � � � � �z^3 + 3*z^2 + 3*z + 1 > > Which is no where close to octave's answer for the command > [b,a]=butter(3,1/2) > b = 1/6 1/2 1/2 1/6 > a = 1 0 1/3 0 > > (we notice that sum(b) = sum(a) = 4/3 > > What steps am I missing to take H(z) above to match octave's answer? Or am > I misunderstanding octave's answer and misapplying it? �I am trying to > automate the answers to H(z) for any order n and cut off frequency wc.See if this helps: http://www.claysturner.com/dsp/Butterworth%20Filter%20Formulae.pdf Clay

Reply by ●September 7, 20102010-09-07

On 8/29/2010 6:07 PM, Randall wrote: <SNIP> Hi; I wrote these notes for a class I took on filters this spring. If you find any errors, pls let me know: butterworth based IIR digital filter design: http://12000.org/my_notes/IIR_digital_filter_design/index.htm I have list of butter lowpass normalized poly's here for up to N=20 http://12000.org/my_notes/list_of_normalized_low_pass_butterworth/index.htm For butter analog filter design http://12000.org/my_notes/butterworth_analog_filter_design/index.htm hth --Nasser