DewDSPMasterNET
ButterOrder Routine
Summary
Estimate the order a butterworth IIR filter.

Unit
IIRFilters

Declaration
Function ButterOrder(const BEdges: array of TSample; PassRipple, StopRipple: TSample; FilterType: TFilterType; var CutoffFreq: array of TSample; Analog: boolean = False): integer;

Description
Returns the order of a butterworth type IIR filter. Bedg array must contain the band edges of the transition region(s) sorted in ascending order. PassRipple defines the ripple of the passband and StopRipple defines the ripple of the stopband. The length of the CutoffFreq array must be equal to one half of the length of the BEdg array and must match the specified FilterType. The routine returns the estimated order as a result and fill's the CutoffFreq array. This array can then be passed to the ButterFilter routine.
Categories
IIR filter order estimation
 See Also 
ButterFilter 

Example 1

Design an analog lowpass filter with transition band between 2 and 6 rad/sec and with at least 40dB attenuation at the end of the transition band and. The passband should not have more then 0.2dB ripple.
uses MtxExpr, Math387, MtxVec, SignalUtils, MtxVecTee, MtxVecEdit, IirFilters, LinearSystems; procedure TForm1.Button1Click(Sender: TObject); var z,p, num,den, FreqFr,Response: Vector; Order: integer; k,BW: TSample; WcArray: array of TSample; //modified 3dB frequency begin SetLength(WcArray,1); Order := ButterOrder([2,6],0.2,40,ftLowpass,WcArray,True); ButterAnalog(Order,z,p,k); //design analog protype LowpassToLowpass(z,p,k,WcArray[0]); //frequency transformation in s-domain ZeroPoleToTransferFun(num,den,z,p,k); FreqFr.Length := 1000; //Define the frequency grid (logarithmic) LogRamp(FreqFr,-1,1); //between 0.1 (=10^(-1)) and 10 (=10^1) rad/sec FrequencyResponseS(num,den,FreqFr,Response); //Laplace DrawIt(Response); //Y axis linear, X axis logarithmic; end;
#include "MtxVecCPP.h" //MtxVecCPP.cpp must be included in the project #include "MtxVecEdit.hpp" #include "MtxVecTee.hpp" #include "SignalUtils.hpp" #include "IirFilters.hpp" #include "LinearSystems.hpp" void __fastcall TForm1::BitBtn1Click(TObject *Sender) { Vector z,p, num,den, FreqFr, Response, WcArray; int Order; double k,Wc,BW; WcArray->Size(1); Order = ButterOrder(OPENARRAY(double,(2,6)),0.2,40,ftLowPass,WcArray->PValues1D(0),WcArray->Length-1,True); ButterAnalog(Order,z,p,k); //design analog protype LowpassToLowpass(z,p,k,WcArray[0]); //frequency transformation in s-domain ZeroPoleToTransferFun(num,den,z,p,k); FreqFr->Length = 1000; //Define the frequency grid (logarithmic) LogRamp(FreqFr,-1,1); //between 0.1 (=10^(-1)) and 10 (=10^1) rad/sec FrequencyResponseS(num,den,FreqFr,Response); //Laplace DrawIt(Response); //Y axis linear, X axis logarithmic; }
using Dew.Math; using Dew.Math.Editors; using Dew.Math.Units; using Dew.Signal; using Dew.Signal.Units; using Dew.Math.Tee; using Dew.Signal.Tee; private void button1_Click(object sender, EventArgs e) { Vector z = new Vector(0); Vector p = new Vector(0); Vector num = new Vector(0); Vector den = new Vector(0); Vector Response = new Vector(0); Vector FreqFr = new Vector(0); double k; double[] Wc = new double[1]; int Order; //design a fifth order filter. Order = IIRFilters.ButterOrder(new double[2] { 2, 6 }, 0.2,40,TFilterType.ftLowPass,ref Wc,true); //design analog protype IIRFilters.ButterAnalog(Order,z, p, out k); //design analog protype LinearSystems.LowpassToLowpass(z, p, ref k, Wc[0]); LinearSystems.ZeroPoleToTransferFun(num, den, z, p, k); FreqFr.Length = 1000; SignalUtils.LogRamp(FreqFr, -1, 1); SignalUtils.FrequencyResponseS(num, den, FreqFr, Response, 0); TeeChart.DrawIt(Response, "Frequency response", false); }

Copyright 2008 Dew Research
http://www.dewresearch.com