ΣSigmaStudio Ask AI Русский Log in

Nth Order Filter Coefficient Calculations

SigmaDSP & SigmaStudio PolEx Nov 29, 2018 00:00 2 replies Original on forum ↗
Subscribe
PolEx Question
Nov 29, 2018 00:00

Anyone have Code/Algorithms to calculate the coefficients for the Nth Order filters? For a 10th order fiter there are 5 sets of coefficients, but they are all slightly different, not just cascades of the same filter. Would like to be able to calculate then in a microprocessor and download them to ADAU1452...

Audio Signal Processors

adau1452

SigmaDSP Audio Processors

KJBob Reply
Dec 2, 2018 00:00

Hello PolEx,

I'm afraid I don't have ready-to-roll C code, but I can help you through the necessary steps. As you have likely figured out, calculating coefficients for a high-order filter is actually two problems -- the first is coming up with the frequencies and Qs for the individual stages, and then calculating the coefficient sets for each stage. Here's an example for a 10th order Butterworth LP filter:

For Butterworth, each section has the same rolloff frequency -- that of the overall filter. The Qs are given by the Butterworth Polynomial -- for a 10th order they are: 3.196, 1.101, 0.7071, 0.561, 0.5062. One of the easiest ways to get the Fs and Qs for a given filter type and order is to plug a normalized frequency such as 1 KHz into any analog filter design program -- such as the one AD provides here:

https://www.analog.com/designtools/en/filterwizard/

Pick the filter type you want, play with the stopband parameters until you get the filter order desired, then go to the "Stages" output to see the F and Q of each stage. For my example, I extracted this data for a 10th order Butterworth Lowpass and made from this the attached spreadsheet. The spreadsheet calculates the five sets of coefficients given the sample rate, filter frequency and gain (if any). You can examine its formulas to translate into C code.

Finally, to test the coefficients I built a project with three filters -- the ADI Nth order filter, five second order filters and five IIR coefficient filters. Simply typing the coefficients from the spreadsheet into these tests the coefficients. We see that the responses of all three filters line up nicely.

Best regards,

Bob 10th-Order-Butterworth_LP.zip

10th-Order-LP-Filter_test-sch.png
10th-Order-LP-Filter_test-sch.png
PolEx Reply
Dec 4, 2018 00:00

Bob-

Thank you very much!! This is exactly what I was looking for. I can take your Butterworth polynomial values and the spreadsheet and easily write some C code to calculate the coefficients.

Thanks again,

-PolEx