Sample C code for IIR filter(bessel) with cutoff frequency 15Hz and Order 6

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Sample C code for IIR filter(bessel) with cutoff frequency 15Hz and Order 6

3,088 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by eldho70 on Mon Mar 21 21:24:25 MST 2016
Hai,

My name is Eldho george,and am working as design engineer at sepack india pvt.ltd. i am using LPC1114FBD as my controller
Now am working on AD7190 adc as a part of our new weighing controller project.
Actually am new the ADC and i have to implement IIR filter on the control side(bessel filter with cutoff frequency 15Hz and order 6).

Can you please provide any sample code .

Thanks and Regards
Eldho George
Labels (1)
0 Kudos
6 Replies

2,537 Views
lpcware
NXP Employee
NXP Employee
bump
0 Kudos

2,537 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by IanB on Mon Apr 25 11:46:40 MST 2016
You changed it to "order 6" - so there's three sections with different Fc and Q, not two. Maybe you want to implement one of the second order sections in analogue as your anti-aliasing filter.
0 Kudos

2,537 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by IanB on Mon Apr 25 11:13:48 MST 2016
Thought so - and we're all standing back and not replying because we don't want to show our ignorance that we haven't heard of "rolling 4".

Anyway,  http://t-filter.engineerjs.com is a FIR filter design tool, and you wanted IIR. But before you dismiss Brownm's suggestion as not being very helpful, I assume that you chose a Bessel filter for its constant group delay, and constant group delay is one of the features of FIR filters (but they do require a lot more calculations than IIR)

First, to design an IIR filter you need to split it into second order sections, just as you would if you were designing a Sallen and Key or an MFB analogue filter. Look at the tables at the back of Texas Instruments Active Filter Design Techniques: Chapter 16 www.ti.com/lit/ml/sloa088/sloa088.pdf
You'll see that a fourth order Bessel needs two second order sections one with a 3dB frequency of 0.987 Fc (14.81Hz in your case) and a Q of 0.52 and the other with a 3dB frequency of 1.797 Fc (26.96Hz) and a Q of 0.81

The next thing I suggest you read is Chapter 6 of "DSP Filters" by Lane, Datta, Karley and Norwood ISBN 0-7906-1206-6 (which is a very good book but costs silly money). That will tell you how to turn the figures above into the α, β and γ coefficients of IIR filters. You need to know your sampling frequency, and need to make sure it is high enough so that there is nothing on your analogue input above half that frequency that would cause aliasing (I presume you know that, and I'm stating the obvious here)

And the code for each bit is no more complicated than:
y=2*((alpha*(x+ 2*x1+x2)+gamma*y1-beta*y2)


y, y1 and y2 of the first filter become x, x1 and x2 of the second, so only 9 variables are required in total.
0 Kudos

2,537 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by brownm on Mon Apr 25 02:21:42 MST 2016
Try this


http://t-filter.engineerjs.com/

0 Kudos

2,537 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by eldho70 on Sun Apr 24 22:12:48 MST 2016
Hi

I have mentioned rolling, that was actually filter order.sorry for the mistake in my question
0 Kudos

2,537 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by IanB on Sun Apr 24 08:58:09 MST 2016
What do you mean by "rolling 4"?
0 Kudos