DewDSPMasterNET
Bilinear Routines
Summary
Compute bilinear transformation.

Unit
LinearSystems

Declaration
Procedure Bilinear(z, p: TVec; var k: TSample; FS: TSample = 2; AddZeros: boolean = True);

Description
Apply bilinear transform to transfer function represented in zero-pole form. FS defines the sampling frequency. If z.Length < p.Length the routine will not add zeroes at -1 to match the number of poles unless AddZeros is True.

Bilinear transformation is defined with the mapping:

2 (1 - z^(-1)) s -> - * ------------ T (1 - z^(-1))

Bilinear transform requires that the amplitude response of a continuous system is piecewise constant and can not be used to transform an analog differentiator to a digital filter (for example). Bilinear transform also does not preserve the impulse or the phase response [1].


Declaration
Procedure Bilinear(a: TMtx; b, c: TVec; var d: TSample; FS: TSample = 2);

Description
Apply bilinear transform to a linear system represented in state-space form. FS defines the sampling frequency.
Categories
IIR filter design routines
 See Also 
[1] "Theory and application of digital signal processing, Lawrence R. Rabiner and Bernard Gold. Prentice-Hall, 1975". 
MatchedZTransform 
LowpassToLowpass 
LowpassToLowpassZ 
BilinearUnwarp 
BilinearPrewarp 

Example 1

An analog lowpass filter is converted to z-domain by using the bilinear transform. The analog filter has a normalized cutoff frequency at 1 rad/sec. This frequency is mapped by the bilinear transformation to the value as returned by the function: BilinearUnwarp(1). To obtain the required cutoff frequency of an analog lowpass filter, which will map to a selected frequency in z-domain use the BilinearPrewarp routine.
uses MtxExpr, Math387, MtxVec, MtxVecTee, MtxVecEdit, LinearSystems, IirFilters, SignalUtils; procedure TForm1.Button1Click(Sender: TObject); var z,p,num,den, Response,b,c: Vector; Order: integer; k,Wc,d: TSample; A: Matrix; begin Order := 5; //design a fifth order filter. EllipticAnalog(Order,0.2,40,z,p,k); //design analog protype //passband ripple 0.2dB, stopband attenuation 40dB Bilinear(z,p,k,2); //Sampling frequency = 2 Wc := 0.6; //request a cutoff at 0.6 Hz LowpassToLowpassZ(z,p,k,WC,BilinearUnwarp(1)); //frequency transformation in z-domain ZeroPoleToTransferFun(num,den,z,p,k); //Alternative 1: // EllipticAnalog(Order,0.2,40,z,p,k); //design analog protype // Bilinear(z,p,k,2); //Sampling frequency = 2 // ZeroPoleToTransferFun(num,den,z,p,k); // Wc := 0.6; //request a cutoff at 0.6 Hz // LowpassToLowpassZ(num,den,WC,BilinearUnwarp(1)); //frequency transformation in z-domain //Alternative 2: // EllipticAnalog(Order,0.2,40,z,p,k); //design analog protype // Wc := BilinearPrewarp(0.6); //request a cutoff at 0.6 Hz // LowpassToLowpass(z,p,k,WC); //frequency transformation in s-domain // Bilinear(z,p,k,2); //Sampling frequency = 2 // ZeroPoleToTransferFun(num,den,z,p,k); //Alternative 3: // EllipticAnalog(Order,0.2,40,z,p,k); //design analog protype // ZeroPoleToStateSpace(A,B,C,D,z,p,k); // Wc := BilinearPrewarp(0.6); //request a cutoff at 0.6 Hz // LowpassToLowpass(A,B,C,D,WC); //frequency transformation in s-domain // Bilinear(A,B,C,D,2); // StateSpaceToZeroPole(z,p,k,A,B,C,D); // ZeroPoleToTransferFun(num,den,z,p,k); FrequencyResponse(num,den,Response,64); //zero padding set to 64 DrawIt(Response); 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, Response, b, c; int Order; double k,Wc,d; Matrix A; Order = 5; //design a fifth order filter. // EllipticAnalog(Order,0.2,40,z,p,k); //design analog protype // //passband ripple 0.2dB, stopband attenuation 40dB // Bilinear(z,p,k,2); //Sampling frequency = 2 // Wc = 0.6; //request a cutoff at 0.6 Hz // LowpassToLowpassZ(z,p,k,Wc,BilinearUnwarp(1)); //frequency transformation in z-domain // ZeroPoleToTransferFun(num,den,z,p,k); //Alternative 1: // EllipticAnalog(Order,0.2,40,z,p,k); //design analog protype // Bilinear(z,p,k,2); //Sampling frequency = 2 // ZeroPoleToTransferFun(num,den,z,p,k); // Wc = 0.6; //request a cutoff at 0.6 Hz // LowpassToLowpassZ(num,den,Wc,BilinearUnwarp(1)); //frequency transformation in z-domain //Alternative 2: // EllipticAnalog(Order,0.2,40,z,p,k); //design analog protype // Wc = BilinearPrewarp(0.6); //request a cutoff at 0.6 Hz // LowpassToLowpass(z,p,k,Wc); //frequency transformation in s-domain // Bilinear(z,p,k,2); //Sampling frequency = 2 // ZeroPoleToTransferFun(num,den,z,p,k); //Alternative 3: EllipticAnalog(Order,0.2,40,z,p,k); //design analog protype ZeroPoleToStateSpace(A,b,c,d,z,p,k); Wc = BilinearPrewarp(0.6); //request a cutoff at 0.6 Hz LowpassToLowpass(A,b,c,d,Wc); //frequency transformation in s-domain Bilinear(A,b,c,d,2); StateSpaceToZeroPole(z,p,k,A,b,c,d); ZeroPoleToTransferFun(num,den,z,p,k); FrequencyResponse(num,den,Response,64); //zero padding set to 64 DrawIt(Response); }
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 b = new Vector(0); Vector c = new Vector(0); double k,Wc,d; Matrix A = new Matrix(0,0); double FS = 2; int Order = 5; //design a fifth order filter. IIRFilters.EllipticAnalog(Order,0.2,40,z,p,out k); //design analog protype //passband ripple 0.2dB, stopband attenuation 40dB LinearSystems.Bilinear(z,p,ref k,FS,true); //Sampling frequency = 2 Wc = 0.6; //request a cutoff at 0.6 Hz LinearSystems.LowpassToLowpassZ(z,p,ref k,Wc, LinearSystems.BilinearUnwarp(1,FS)); //frequency transformation in z-domain LinearSystems.ZeroPoleToTransferFun(num,den,z,p,k); SignalUtils.FrequencyResponse(num, den, Response, 64, false, TSignalWindowType.wtRectangular, 0); //zero padding set to 64 TeeChart.DrawIt(Response, "Design method 0", false); //Alternative 1: IIRFilters.EllipticAnalog(Order,0.2,40,z,p,out k); //design analog protype LinearSystems.Bilinear(z,p,ref k,FS,true); //Sampling frequency = 2 LinearSystems.ZeroPoleToTransferFun(num,den,z,p,k); Wc = 0.6; //request a cutoff at 0.6 Hz LinearSystems.LowpassToLowpassZ(num,den,Wc,LinearSystems.BilinearUnwarp(1,FS)); //frequency transformation in z-domain SignalUtils.FrequencyResponse(num, den, Response, 64, false, TSignalWindowType.wtRectangular, 0); //zero padding set to 64 TeeChart.DrawIt(Response, "Design method 1", false); //Alternative 2: IIRFilters.EllipticAnalog(Order,0.2,40,z,p,out k); //design analog protype Wc = LinearSystems.BilinearPrewarp(0.6,FS); //request a cutoff at 0.6 Hz LinearSystems.LowpassToLowpass(z,p,ref k,Wc); //frequency transformation in s-domain LinearSystems.Bilinear(z,p,ref k, FS,true); //Sampling frequency = 2 LinearSystems.ZeroPoleToTransferFun(num,den,z,p,k); SignalUtils.FrequencyResponse(num, den, Response, 64, false, TSignalWindowType.wtRectangular, 0); //zero padding set to 64 TeeChart.DrawIt(Response, "Design method 2", false); //Alternative 3: IIRFilters.EllipticAnalog(Order,0.2,40,z,p,out k); //design analog protype LinearSystems.ZeroPoleToStateSpace(A,b,c,out d,z,p,k); Wc = LinearSystems.BilinearPrewarp(0.6,FS); //request a cutoff at 0.6 Hz LinearSystems.LowpassToLowpass(A,b,c,ref d,Wc); //frequency transformation in s-domain LinearSystems.Bilinear(A,b,c,ref d,2); LinearSystems.StateSpaceToZeroPole(z,p,out k,A,b,c,d); LinearSystems.ZeroPoleToTransferFun(num,den,z,p,k); SignalUtils.FrequencyResponse(num,den,Response,64,false,TSignalWindowType.wtRectangular,0); //zero padding set to 64 TeeChart.DrawIt(Response,"Design method 3",false); }

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