3.13 System Design with Bilinear Transformation
This section discusses the design of system functions using the bilinear transformation. While and were assumed to be known in the previous section, here the focus is on design, even in case is not provided.
The bilinear applications can be grouped in three main categories, as depicted in Figure 3.41:
- Mimic : A continuous-time system function already exists and the goal is to find (and ) that behaves, eventually in both time and frequency domains, as close as possible to . In this case, the value of must be chosen according to the characteristics of the involved signals and impact the hardware (ADC, DAC and other components) used in the actual digital control system deployment. This is the case in some digital control applications. For instance, may be a proportional-integral-derivative (PID) controller that needs to be converted to a discrete-time and implemented in digital hardware (see, e. g., [ url3pid]). This category will be called here mimic . We will denote the original system function as to help distinguishing it from a continuous-time function that is designed by the bilinear transformation user.
- Match single frequency: In some applications, the goal is to use the bilinear transformation to find that matches the behavior of a pre-existing continuous-time system function at a single frequency. In this case, may be a lowpass filter, for instance, and the matching frequency can be the cutoff frequency of . The bilinear sampling rate can be used to find with the property of having a cutoff frequency that maps exactly at .
- IIR filter design: This category concerns the design of IIR filters with standard frequency responses: lowpass, highpass, bandpass and bandstop. In this case, even if the filter specification was given in continuous-time, it can be converted to a discrete-time specification. From this discrete-time specification, the designer can arbitrarily choose the value of to perform pre-warping, and then design using well-known filter approximation methods such as Butterworth and Chebyshev. With and , the discrete-time filter is finally obtained through the bilinear transformation.
As highlighted in Figure 3.41, the designer can choose an arbitrary value for the sampling frequency when the bilinear is used to design a digital filter from a pre-warped continuous-time system function . In contrast, in applications that fall within the mimic category, should be carefully chosen. When the goal is use the bilinear to match a single frequency, a specific value of the sampling frequency can be used to define the matching frequency.
The next three subsections will discuss each of the categories in Figure 3.41.
3.13.1 Bilinear for IIR filter design
The design of IIR filters using the bilinear transformation relies on first designing an analog filter using a classic approximation method. The most used methods are listed in Table 3.7. In applications in which the phase linearity is important, good options are the Bessel and Butterworth. However, their magnitude response does not represent a magnitude roll-off as steep as the other options. If the phase does not need to be approximately linear, Cauer (or elliptic) filters achieve a sharper roll-off and, consequently, a lower filter order for a given project specification. However, Cauer and Chebyshev Type I present ripple along the passband frequencies, which may be a problem in some applications. When compared to Chebyshev Type I, the Chebyshev Type II approximation has the advantage of having ripple only in the stopband.
Approximation | Pros | Cons |
Bessel | Phase linearity | smooth (poor) mag. roll-off |
Butterworth | Flat passband mag. | gradual (poor) mag. roll-off |
Chebyshev Type I | Steeper mag. roll-off | ripple in passband |
Chebyshev Type II | Steeper mag. roll-off | ripple only in stopband |
Cauer (or elliptic) | Sharp (good) mag. roll-off | Non-linear phase and ripples |
This subsection assumes the goal is to design an IIR filter by applying the bilinear transformation to the designed . The next paragraphs will emphasize the importance of pre-warping frequencies and finding the order of the analog filter that complies with the project requirements.
In IIR filter design, there is no concern about the value of the sampling frequency. In this case, before obtaining the that will be adopted for the bilinear transformation, it is important to pre-warp all frequencies of interest using Eq. (3.75). This way, the non-linear behavior imposed by the bilinear transformation (see, e. g. Figure 3.36 and Figure 3.35) is pre-compensated by the filter designer.
A key message is:
- When designing a filter using the bilinear transformation, all frequencies of interest must be pre-warped and the design of based on these modified frequencies. When is obtained, the bilinear transform will “undo” the pre-warping and locate the frequencies in the desired positions.
Figure 3.42 summarizes the steps when using the bilinear transformation for IIR design. Note that the value of the sampling rate is chosen in Step 2 and reused in Step 4, which then cancels out the influence of . This will be discussed later, after some examples of IIR design with bilinear.
The following two examples illustrate pre-warping and finding the minimum order of a filter that complies with the project requirements. These projects use the bilinear function for pedagogical reasons. But instead of using this function, one could directly design IIR filters using higher-lever functions such as butter, cheby2 and others, which automatically invoke a bilinear routine.
Example 3.28. Design a digital lowpass filter using the bilinear transformation. The task is to design a Butterworth lowpass digital filter with passband and stopband frequencies, respectively, both in rad. Note that the specifications are in discrete-time. The maximum and minimum attenuations in pass and stopbands are dB and dB, respectively.
In order to use classic methods for designing analog filter , the discrete-time frequencies and are converted to continuous-time assuming an arbitrary sampling frequency. Here we will assume Hz for convenience. Hence, using Eq. (3.75) the frequencies of interest are pre-warped to and rad/s.
To find the minimum order of a Butterworth that obeys the requirements, one can use:
1Ap=4; % maximum attenuation in passband (in dB) 2As=10; % minimum attenuation in stopband (in dB) 3wp=0.325; % passband frequency in rad/s 4ws=0.509; % stopband frequency in rad/s 5[n,w_cutoff] = buttord(wp,ws,Ap,As,'s') 6[Bs,As]=butter(n,w_cutoff,'s')
The second-order Butterworth with 3-dB cutoff frequency of 0.294 rad/s obeys the corresponding mask and has the system function . In Python,29 the commands are:
1import scipy.signal 2Ap=4; # maximum attenuation in passband (in dB) 3As=10; # minimum attenuation in stopband (in dB) 4wp=0.325; # passband frequency in rad/s 5ws=0.509; # stopband frequency in rad/s 6[n,w_cutoff] = scipy.signal.buttord(wp ,ws ,Ap ,As ,analog=True) 7[Bs, As]= scipy.signal.butter(n, w_cutoff, analog=True)
Note that, while Matlab/Octave identifies a continuous-time system with ’s’, Python uses analog=True.
Having obtained , using Eq. (3.64) with Hz leads to
The frequency response of the designed has magnitudes and dB, which obey the requirements. Note that there is some slack at while the filter matches exactly30 the requirement at .
Example 3.29. Design a digital bandpass filter using the bilinear transformation. The goal is to design a filter with a bandpass from to rad, and stopbands from 0 to and from to rad. The filter must have less than 3 dB of ripple in the passband and at least 30 dB of attenuation in the stopbands. In this example, we will adopt Hz (an arbitrary value) and the Chebyshev Type II approximation, which does not have the ripples at the passband that Chebyshev Type I has.
Listing 3.25 indicates how to perform this filter design using Matlab/Octave.
1%% Passband specifications given in discrete-time: 2Wp = pi*[0.2 0.4]; % Passband Frequencies (rad) 3Wr = pi*[0.1 0.5]; % Stopband (rejection) Frequencies (rad) 4Apass = 3; % Maximum passband attenuation (ripple) (dB) 5Astop = 30; % Minimum stopband attenuation (dB) 6%% Choose convenient sampling frequency 7Fs=0.5; % in Hertz 8%% Map from discrete to continuous-time using pre-warping 9wp=2*Fs*tan(Wp/2); % in rad/s 10wr=2*Fs*tan(Wr/2); % in rad/s 11%% Design analog filter (use 's' to impose continuous-time) 12[N,w_design] = cheb2ord(wp,wr,Apass,Astop,'s')%find the filter order 13[Bs,As]=cheby2(N,Astop,w_design,'bandpass','s') %obtain H(s) = Bs/As 14figure(1), freqs(Bs,As) %plot the frequency response of H(s) 15%% Convert to discrete-time using bilinear 16[Bz,Az]=bilinear(Bs,As,Fs) %obtain H(z) from H(s) with given Fs 17%% Check some results: 18figure(2), freqz(Bz,Az) %plot DTFT of H(z). Check values at Wp and Wr 19s=1j*wp; Hs_at_wp=20*log10(abs(polyval(Bs,s)/polyval(As,s)))%cutoff 20z=exp(1j*Wp); H_at_Wp=20*log10(abs(polyval(Bz,z)/polyval(Az,z))) 21z=exp(1j*Wr); H_at_Wr=20*log10(abs(polyval(Bz,z)/polyval(Az,z)))
In case the sampling frequency is changed (line Fs=0.5) in Listing 3.25, one can observe that this does not alter the final filter given by [Bz, Az].
Bilinear sampling rate is arbitrary in IIR filter design
Example 3.26 shows the strong impact that may have when the bilinear transformation is applied to a given continuous-time system . However, when using the bilinear in the specific task of designing a digital filter, the chosen value for will cancel out and have no influence on the design. This was mentioned in Figure 3.41 and can be experimentally observed by changing in Example 3.28 or in Listing 3.25. This fact is demonstrated here through the design of a simple first-order digital filter with cutoff frequency .
The following code uses symbolic math to obtain after pre-warping and, then using bilinear to obtain .
1%define s, z, natural frequency, damping ratio and sampling interval 2syms Wc wc b0 a0 s z Fs %all as symbolic variables 3%1) Filter requirements: 1st-order Butterworth, cutoff freq. Wc rad 4%2) pre-warping 5wc = 2*Fs*tan(Wc/2); 6%3) Design H(s) with pre-warped frequencies. A first-order 7% Butterworth with cutoff frequency of 1 rad/s is H(s)=1/(s+1). 8Hs_prototype = 1/(s+1); 9% Use frequency scaling s=s/wc to move the cutoff from 1 to wc rad/s 10Hs=subs(Hs_prototype,s,s/wc); % Continuous-time H(s). 11pretty(Hs) % Use pretty(Hs) to see it 12%4) Bilinear transformation 13Hz=subs(Hs,s,(2*Fs)*((z-1)/(z+1))); %bilinear: s <- 2/Ts*(z-1)/(z+1) 14Hz=simplify(Hz); %simplify the expression 15disp('H(z) obtained with the bilinear transform:') 16pretty(Hz) %show it using an alternative view
We want to show that the value of the sampling rate can be chosen arbitrarily in this IIR design. There is only one frequency of interest in this case to be pre-warped, which leads to . Starting with the first-order Butterworth prototype with cutoff frequency equals to 1 rad/s, one uses frequency scaling to move the cutoff frequency to the pre-warped frequency . Hence, after Step 3 of the code (which implements Step 3 of Figure 3.42), one has:
After the bilinear transformation in Step 4, the code outputs:
One can observe that does not depend on because the value of was canceled. This also happens for filters of order larger than 1.
Example 3.30. Another example of the arbitrary getting canceled out. Assume a second-order digital lowpass filter (a normalized Butterworth) meets the requirements in continuous-time. We want to use the bilinear transformation to obtain with a 3-dB cutoff frequency of rad.
We can choose any convenient value for and to illustrate that, instead of using a specific numeric value, the development will be made for a generic .
Eq. (3.75) is adopted to perform pre-warping, which leads to
Then, Eq. (3.55) is used to perform frequency scaling and move the cutoff frequency rad/s of the prototype filter to . Substituting by leads to
Now, the bilinear can be applied to , which leads to
Note that was canceled out because it only appeared in dividing , which is later substituted by .
In conclusion, the value adopted for the bilinear can be different from the one actually used when implementing the digital filter (for instance, in an embedded system with ADC and DAC chips). We will use to denote the value used in the bilinear transformation and reserve to the adopted sampling frequency when implementing , as depicted in Figure 3.43.
Hence, in this very specific application of bilinear, the sampling frequency can be chosen arbitrarily. This may sound confusing31 because, as discussed here, there are other applications of the bilinear transformation in which the value of must be carefully chosen. In IIR design, one just needs to avoid choosing a too small value for , which could eventually lead to numerical issues in the design of due to an extreme pre-warping of frequencies of interest. Hence, for convenience, is chosen to be 0.5, 1 or 2 Hz in IIR design.
Figure 3.43 takes in account that two sampling frequencies can be used in a bilinear transformation: and . The former is used in the transform itself while the latter is adopted for the actual implementation of in a filtering hardware such as the one depicted in Figure 3.30.
Example 3.31. Design an IIR filter with the bilinear transformation using frequency scaling of an analog prototype filter. The task is to design on Matlab (Octave has a slightly different syntax) a third-order lowpass Butterworth digital filter using the bilinear transformation of (that can be obtained with [Bs,As]=butter(3,1,’s’)), which has a cutoff frequency rad/s. Other project requirements are a sampling frequency of Hz and with a cutoff frequency Hz (i. e., rad/s).
Pre-warping must be used because rad/s is the cutoff frequency of the prototype that has to be mapped to Hz when is implemented.
We will arbitrarily adopt Hz. The goal is to find the frequency to which is mapped to. Eq. (3.77) leads to
which corresponds to Hz.
Now, frequency scaling must be applied to in order to move its cutoff frequency from to rad/s. Substituting in leads to
Applying the bilinear to with Hz leads to . Evaluating at , with , one obtains . This indicates that, due to the pre-warping, the bilinear positioned the cutoff of at the desired value of 100 Hz.
The next paragraphs illustrate how a computer can be used to carry out the whole procedure. A first approach is to design an analog filter by first pre-warping the cutoff frequency and then use the bilinear:
1fs=500; %sampling frequency (Hz) 2[Bs,As]=butter(3,2*pi*115.63,'s'); %analog filter 3[Bz,Az]=bilinear(Bs,As,fs); %convert analog to digital 4z=exp(1j*2*pi*100/500); abs(polyval(Bz,z)/polyval(Az,z))%check cutoff
The second and simpler approach (at least from the user’s perspective) is to directly use a routine that incorporates pre-warping and bilinear transformation, such as butter:
(recall that Matlab/Octave deals with digital filters using frequencies in Hertz normalized by the Nyquist frequency as informed in Table 1.5). A comparison would show that [Bz,Az] and [B2,A2] have approximately the same elements.
A third way of dealing with a software routine that directly designs a digital filter is to convert the specification to discrete-time. In this case, rad is the desired cutoff frequency and can be obtained with:
Note that in this and in the previous (second) approach, the function butter.m was not informed about . Consequently, when the pre-warping was done inside butter.m, it used an arbitrary value of to pre-warp, then obtained , and converted using bilinear with , such that the value of gets canceled out, as previously explained.
Bilinear IIR design can start from continuous-time specifications
In previous IIR designs, the filter specification was provided in the discrete-time domain. However, the design of a digital filter may also start from specifications in the analog domain. Figure 3.44 summarizes a project flow that includes both options when designing a filter using the bilinear transformation.
Figure 3.44 considers the possibilities of having a set of filter requirements specified either in continuous () or discrete-time (). For example, a discrete-time lowpass filter can be specified by , where the subscripts and distinguish the frequencies and attenuations of the passband and stopband, respectively. Similarly, is a possible lowpass filter requirement in continuous-time, as depicted in Figure 3.3(a). Note that includes the sampling frequency used in the hardware implementation of the digital filter while does not.
In case the IIR design starts with filter requirements provided in discrete-time, is not part of the design process and is chosen arbitrarily. The designer executes the steps “” depicted in Figure 3.44, as done in Example 3.28.
The next example illustrates a design using bilinear in which the specification of the filter to be designed is given in continuous-time, which includes the sampling frequency that will actually be used when implementing the filter.
Example 3.32. Bilinear design of IIR filter from continuous-time specifications. The task is to design an elliptic lowpass digital filter that when implemented on a hardware operating at Hz obeys the requirements , where with frequencies given in Hz.
According to Block 2 of Figure 3.44, using (Eq. (1.36)) and the definition of angular frequency , the continuous-time specifications can be converted to the discrete-time specification , where with frequencies given in radians. After this, one can continue to use Hz or a new value for the sampling frequency can be chosen. For pedagogical purposes, a new value Hz is chosen here. Note that an important point is to use Hz when implementing on “hardware”, not , which will be exclusively used for the design of .
From Eq. (3.75) with , the frequencies of interest are pre-warped to and rad/s. Given the pre-warped specifications in continuous-time , one can obtain the second-order elliptic filter that obeys the corresponding mask. This design of the analog filter can be done with classical approximations and respective software, such as using ellipord and ellip in Matlab/Octave (see Listing 3.26).
Eq. (3.64) (with Hz) allows to convert into , which has and dB. Note that there is significant slack (almost 10 dB) at while the approximation matches exactly the requirement at . Listing 3.26 indicates how to perform this filter design using Matlab.
1%% Specifications given in continuous-time: 2Fp = 100; % Passband Frequency (Hz) 3Fr = 150; % Stopband Frequency (Hz) 4Apass = 4; % Maximum passband attenuation (ripple) (dB) 5Astop = 20; % Minimum stopband attenuation (dB) 6Fs=500; % in Hertz 7%% Convert to discrete-time using the fundamental relation w = W Fs 8Wp=2*pi*Fp/Fs; %in rad 9Wr=2*pi*Fr/Fs; %in rad 10%% Convert to continuous-time using pre-warping. Can pick another Fs 11Fs2=0.5; %could continue with Fs=500, but will illustrate a new value 12wp=2*Fs2*tan(Wp/2); % in rad/s 13wr=2*Fs2*tan(Wr/2); % in rad/s 14%% Design analog filter (use 's' to impose continuous-time) 15[N,w_passband]=ellipord(wp,wr,Apass,Astop,'s') %find the filter order 16[Bs,As]=ellip(N,Apass,Astop,w_passband,'s') %obtain H(s) = Bs/As 17%% Convert to discrete-time using bilinear 18[Bz,Az]=bilinear(Bs,As,Fs2) %obtain H(z) from H(s) with given Fs 19%% Check some results: 20%freqz(Bz,Az) %plot the DTFT of H(z). Now check values at Wp and Wr: 21s=1j*wp; Hs_at_wp=20*log10(abs(polyval(Bs,s)/polyval(As,s))) 22s=1j*wr; Hs_at_wr=20*log10(abs(polyval(Bs,s)/polyval(As,s))) 23z=exp(1j*Wp); Hz_at_Wp=20*log10(abs(polyval(Bz,z)/polyval(Az,z))) 24z=exp(1j*Wr); Hz_at_Wr=20*log10(abs(polyval(Bz,z)/polyval(Az,z))) 25%% Let the sofware do all the hard work (hiding the "bilinear"): 26[N,W_passband]=ellipord(Wp/pi,Wr/pi,Apass,Astop); %digital filter 27[Bz2,Az2]=ellip(N,Apass,Astop,W_passband) %obtains same H(z)
Executing Listing 3.26 allows to confirm that, due to pre-warping, the values of Hs_at_wp and Hs_at_wr coincide with Hz_at_Wp and Hz_at_Wr, respectively.
As discussed in the previous example, even when the filter specification is given in continuous-time, before the bilinear, the analog filter can be designed with several pre-warped frequencies of interest. For instance, two frequencies were pre-warped in Example 3.32. A different situation occurs when the bilinear must be applied to a given . In this case, there is only one “degree of freedom”: the choice of . Hence, it is not possible to use pre-warping to match the behavior of and at several frequencies. But it is possible to match their behavior in a single frequency. This is the topic of the next subsection.
3.13.2 Bilinear for matching a single frequency
When and are given and there is a single frequency of interest to be “matched” in the continuous and discrete-time domains, it is possible to use to take pre-warping in account and reach a matching between and . This “matching” frequency strategy can also be used to design IIR filters when there is a single frequency of interest.
The single “match” frequency is rad/s. From Eq. (3.77):
| (3.80) |
which can be writte as
The trick is to consider that at the left side is a new value , which can be chosen to impose the matching:
| (3.81) |
while in the tangent is the provided (original) value. Instead of using the angular frequency , one can use the linear frequency Hz. In summary, the matching can be imposed by32
| (3.82) |
To avoid the discontinuity of , one has to choose , which corresponds to , which is consistent with the sampling theorem. As expected, having a pre-defined restricts to be less than the Nyquist frequency.
Hence, instead of using Eq. (3.64), it is possible to incorporate pre-warping such that is the match frequency using:
| (3.83) |
Example 3.33. Simple example of matched and at specific frequency Hz. Assume Hz and was obtained from using Eq. (3.83) with sampling frequency Hz. Using Eq. (3.82), the value of at the angle rad matches the value of at Hz.
In case Hz and Hz, then it is at the angle rad that the value of matches .
In general, for any value of , is a matching frequency when the bilinear uses Eq. (3.82).
Figure 3.45 is the equivalent of Figure 3.44 for scenarios of bilinear use in which the goal is to match a single frequency and a continuous-time system function is provided.
Similar to what was done starting from Eq. (3.80), Eq. (3.75) can also be used to find that maps a specific pair and as follows:
| (3.84) |
Adapting Eq. (3.56) to the current notation, the goal of pre-warping a single frequency is to obtain:
| (3.85) |
over the first Nyquist zone (see Section 3.5.7.0).
Some extra examples of the bilinear transform are discussed in the sequel.
Example 3.34. Pre-warping for matching a single frequency applied to the system of Example 3.27. Matching a single frequency using the bilinear function is easily done in Matlab/Octave. For example, the change in frequency of the pole at rad/s in Figure 3.40 can be avoided using [Hz_num, Hz_den] = bilinear(Hs_num, Hs_den, Fs, 20/(2*pi)) instead of [Hz_num, Hz_den] = bilinear(Hs_num, Hs_den, Fs). Figure 3.46 illustrates the result of pre-warping. Note that, because in this case is already given, only for a single frequency the bilinear can achieve , while all others are non-linearly shifted.
In this example, there was a single frequency of interest to be matched. If there are several frequencies of interest, they all need to be pre-warped, before the design of .
Example 3.35. Design an IIR filter by matching a single frequency. The task here is the same as in Example 3.30: design a second-order digital lowpass filter with a 3-dB cutoff frequency of rad by using the bilinear transformation on the prototype filter . There is a single frequency to be matched, which is the cuttof frequency of . The behavior of at should match the behavior at of . Using Eq. (3.84) to match these frequencies leads to Hz. Using Eq. (3.64) leads to
Using Matlab, the following commands implements this shortcut:
which does not explicitly use pre-warping in the bilinear function, but incorporates it on the choice of .
Example 3.36. Pre-warped bilinear applied to a first-order system. Table 3.6 summarized several methods to convert a first-order into . Here we extend this table by creating Table 3.8, which incorporates the pre-warped bilinear transformation.
Method |
Mapping |
when |
Bilinear | ||
Pre-warped bilinear | and | |
The bilinear with pre-warping in Table 3.8 is based on first modifying using Eq. (3.77). In other words, the pole with cutoff frequency in is pre-warped to obtain in the end, after the conversion using bilinear. This is done with and frequency scaling, substituting by . This leads to
Applying the bilinear mapping to this leads to the result in Table 3.6.
An alternative shortcut is to use Eq. (3.83) with rad/s as the “matching frequency”. This also leads to the result in Table 3.6
3.13.3 Bilinear for mimicking G(s)
In the following discussion, is already provided and the bilinear should be used to transform it, or a scaled version of , into . An example of application is the task of obtaining a discrete-time version of a given continuous-time controller that is applied to a plant. In this case, the sampling frequency can be chosen according, e. g., to the sampling theorem (Eq. (1.30)).
Consider a control system (see [ url3pid]) that uses a PID controller given by
The dominant pole of the plant to be controlled33 is , which suggests a settling time of approximately 2 seconds. Therefore, the sampling frequency is chosen as Hz, which is fast enough when compared to the time constants involved in the dynamics of . Using bilinear transformation, the digital version of this PID controller is
which should be adjusted for the task of automatic control until the system presents good behavior in closed loop.
In the case of mimicking , there is not a small set of frequencies of interest as in IIR filter design. The most effective strategy to improve the bilinear transformation and better mimic is to increase to reach a good approximation in Eq. (3.70).