Tuesday, 22 July 2014

Doing the Bilinear Transform for a 2nd order filter again

Well it was fun yesterday learning about MathJax and playing around describing the bilinear transform for a 2nd order filter. As I was looking at a couple of sites last night I noticed that a good bunch of descriptions also shown the same transformation done slightly differently so as I got pencil and paper out last night out of curiosity to see how they came to the same result I thought I'd put another post so that both can be seen:

Starting again with our 2nd-order low-pass transfer function in the s-domain:

$$H(s) = \frac {1}{s^2 + \frac {s}{Q} + 1}$$

Yesterday we used the following bilinear transform with frequency warping:

$$ s \leftarrow \frac {1}{tan \frac {\omega}{2}} \frac {1-z^{-1}}{1+z^{-1}} $$

What I'd like to do today is to use a slightly different writing of this and see how the math juggling comes out:

$$ s \leftarrow \frac {1}{K} \frac {z-1}{z+1}$$

Where \(K= tan \frac {\omega}{2}\)

This is the same transform, which can be seen by multiplying by \( \frac {z^{-1}}{z^{-1}} \). The maths just plays out a little differently.

Substituting this in to the transfer function:

$$ H(s) = \frac {1}{s^2 + \frac {s}{Q} + 1} \leftarrow \frac {1}{\frac {1}{K^2} \frac {(z-1)^2}{(z+1)^2}+\frac {1}{KQ} \frac {(z-1)}{(z+1)}+1} $$

Multiplying top and bottom by \( K^2(z+1)^2 \) gives something slightly easier:

$$ H(z) = \frac {K^2(z+1)^2}{(z-1)^2 + \frac {K}{Q}(z-1)(z+1) + K^2(z+1)^2} $$

Expanding:

$$ H(z) = \frac {K^2(z^2 + 2z + 1)}{(z^2+2z+1)+ \frac {K}{Q}z^2 - \frac {K}{Q}+K^2(z^2+2z+1)} $$

Collecting together the terms:

$$ H(z) = \frac {K^2z^2 + 2K^2z + K^2}{z^2(1+\frac{K}{Q}+K^2) + z(-2+2K^2)+(1-\frac{K}{Q}+K^2)} $$

All very easy, which gives us our coefficients:

  • \( b_2 = K^2 \)
  • \( b_1 = 2K^2 \)
  • \( b_0 = K^2 \)
  • \( a_2 = K^2+\frac{K}{Q}+1 \)
  • \( a_1 = -2(1-K^2) \)
  • \( a_0 = K^2-\frac{K}{Q}+1 \)
What I wanted to see is how these then can be manipulated to get the same equations as in my previous post.

First step then is to get the top-half functions all looking similar, so we can take \(K^2\) and using the trig identity \(K^2 = tan^2 \frac {\omega}{2} = \frac {(1-cos \omega)}{(1+cos \omega)} \). We can use the numerator in the top and the denominator in the bottom. This makes the b coefficients:
  • \( b_2 = 1-cos \omega \)
  • \( b_1 = 2 (1-cos \omega) \)
  • \( b_0 = 1-cos \omega \)
Now taking \( a_0 \) first, with the bottom half \( (1+cos \omega)\) and substituting K:

$$ a_0 = (1+cos \omega) \left(  tan^2 \frac {\omega}{2} - \frac {1}{Q} tan \frac {\omega}{2} + 1 \right) $$

Using our favourite trig identities \(K =  tan \frac {\omega}{2} = \frac {sin \omega}{(1+cos \omega)} \) and \(K^2 = tan^2 \frac {\omega}{2} = \frac {(1-cos \omega)}{(1+cos \omega)} \) and substituting \( 1 = \frac {(1+cos \omega)}{(1+cos \omega)} \) gives:

$$ a_0 = (1+cos \omega) \left( tan^2 \frac {omega}{2} - \frac {1}{Q} tan \frac {\omega}{2} + 1 \right) = (1+cos \omega) \left(  \frac {(1-cos \omega)}{(1+cos \omega)} - \frac {1}{Q} \frac {sin \omega}{(1+cos \omega)} + \frac {(1+cos \omega)}{(1+cos \omega)} \right) $$

And crossing out terms gives:

$$ a_0 = (1-cos \omega) - \frac {sin \omega}{Q} + (1+cos \omega) = 2 - \frac {sin \omega}{Q} $$

and similarly for \(a_2\). Now taking \(a_1\):

$$ a_1 = -2 (1+cos \omega)\left(1-tan^2 \frac {\omega}{2} \right)= -2 (1+cos \omega) \left( \frac {(1+cos \omega)}{(1+cos \omega)} - \frac {(1-cos \omega)}{(1+cos \omega)} \right) = -2\left((1+cos \omega) - (1-cos \omega)\right) = -2(2cos \omega) $$

and dividing all the terms by 2 gives:
  • \( b_2 = \frac {(1-cos \omega)}{2} \)
  • \( b_1 = (1-cos \omega) \)
  • \( b_0 = \frac {(1-cos \omega)}{2}2 \)
  • \( a_2 = (1+\frac {sin \omega}{2}) \)
  • \( a_1 = -2cos \omega \)
  • \( a_0 = (1-\frac {sin \omega}{2}) \) 
Which looks just like the coefficients calculated by the previous method. QED



No comments:

Post a Comment