Society of Robots - Robot Forum

Software => Software => Topic started by: TrickyNekro on August 22, 2012, 12:12:21 PM

Title: Butterworth Filter for PC, Need code references and notes
Post by: TrickyNekro on August 22, 2012, 12:12:21 PM
Hallo guys,

For once more I need your expertise in this matter. I need to implement a Butterworth filter in a PC application I am building.
I know google is full of references and I already have some materials to work on, but more in never bad.

So I am practically asking you, if you know any videos/sites/.pdf etc that you have used and you were satisfied with.

I know that there are other filters like Chebychev and Elliptic filters but I don't really need that fast of a response plus the ripple like
behaviour would be good for my project.

So thank you in advance for any replies,
My best regards,
Lefteris, Greece (still in Germany... ahem  :P )
Title: Re: Butterworth Filter for PC, Need code references and notes
Post by: waltr on August 22, 2012, 06:42:29 PM
Cut-off frequency?
Passive or Active?
Number of Poles?

Microchip has a interactive design app for designing Active filters (using Op-amps).
Maybe this help.
Title: Re: Butterworth Filter for PC, Need code references and notes
Post by: TrickyNekro on August 22, 2012, 07:11:14 PM
Thank you for your reply!

It's not that I don't know how to do the math but thank you, I don't know the cut off frequency yet, I'll have  to find it out,
and that's going to be an experimentation process. I don't even know the order of the filter I am going to use yet.

And it's neither a passive nor an active design, it's going to be a digital filter, that's why I said PC application.
All the data are passed to the PC application and then I am going to build/code a low pass Butterworth.
And probably I'll go for a high order butterworth, I need it to have a very fast response and only smooth out
the switching noise from the electronics.

But thanks for the reply anyhow :-D


Best Regards,
Lefteris, Greece
Title: Re: Butterworth Filter for PC, Need code references and notes
Post by: waltr on August 24, 2012, 05:56:21 PM
Ahh...I took "PC application" as meaning you wanted to filter a signal going to the PC (like the Audio input) with hardware.

What need to look for are algorithms for IIR and FIR filters. These should be covered in any good book (or web site) on DSP (Digital Signal Processing). These filters can be calculated for any of the response types including Butterworth.
Sorry I can't help more than that.
Title: Re: Butterworth Filter for PC, Need code references and notes
Post by: TrickyNekro on August 26, 2012, 09:31:42 AM
Don't be, I wasn't asking for a solution just some suggestions,

From my research it seems that the only thing to do is to take the Butterworth polynomials and turn them from the infinite s plane
to the cycle z plane with this transformation:

s = (1/K)*((z - 1)/(z + 1)) where K = tan(pi * Fc / Fs), where Fc is the cut-off frequency and Fs is the sampling frequency.

Also from my research I have found out that it's better when you want a higher order filter to cascade smaller order filters
than to take the direct equation for the sake of floating point maths in computers.

That's all for now, if someone knows something more or/and can correct me if I am wrong, please by all means!

Best Regards,
Lefteris, Greece
Title: Re: Butterworth Filter for PC, Need code references and notes
Post by: Billy on August 29, 2012, 02:53:23 PM
Here is a link to a book that has code samples. Although you can download the book for free, I bought a hard copy and was very happy with it.
http://www.dspguide.com/ (http://www.dspguide.com/)

Anyone that wants to do anything with sensors and microcontrollers would be well served to spend some time with this book. It is well written and the material presented in a very pragmatic way. Limited math and with complex ideas presented in simple way.
Title: Re: Butterworth Filter for PC, Need code references and notes
Post by: waltr on August 29, 2012, 06:14:22 PM
Nice one Billy.
Title: Re: Butterworth Filter for PC, Need code references and notes
Post by: TrickyNekro on August 29, 2012, 08:31:43 PM
Thanks Billy,

I got the whole thing working by now and when I am finished I'll try to document it with examples.
The good thing is that generally I document good enough what I am doing now cause it's all about my thesis.
So expect some stuff after October from me :-D

Thanks again!
Best Regards,
Lefteris, Greece