bubulescu
Member level 3
Hello
I am trying to get to a general solution for transforming H(s) to H(z), in terms of V(out)=f( V(in) ), I am using wxMaxima as a help and LTspice for implementation. Here's what I did:
\[ H(s) = \frac{a_{2} s^{2} + a_{1} s + a_{0}}{b_{2} s^{2} + b_{1} s + b_{0}} \]
\[ Z = \frac{1-z^{-1}}{1+z^{-1}} \]
\[ \omega_{D} = tan \left( \pi \frac{f_{p}}{f_{0}} \right) \]
Here's what wxMaxima gave me as a result for H(Z/wD), after simplification (b2=1):
\[ H(z) = \frac{ \left( a_{0} \omega_{D}^{2} - a_{1} \omega_{D} + a_{2} \right) z^{-2}
+ 2 \left( a_{0} \omega_{D}^{2} - a_{2} \right) z^{-1} + \left( a_{0} \omega_{D}^{2} + a_{1} \omega_{D} + a_{2} \right) }
{ \left( b_{0} \omega_{D}^{2} - b_{1} \omega_{D} + 1 \right) z^{-2}
+ 2 \left( b_{0} \omega_{D}^{2} - 1 \right) z^{-1} + \left( b_{0} \omega_{D}^{2} + b_{1} \omega_{D} + 1 \right) } \]
Which is the known general Z bilinear transform:
\[ H(z) = \frac{ A_{2} z^{-2} + A_{1} z^{-1} + A_{0} } { - B_{2} z^{-2} - B_{1} z^{-1} + 1 } \]
From this, V(out) can be expressed as:
\[ V(out) = \frac{1}{B_{0}}\left( A_{2} z_{in}^{-2} + A_{1} z_{in}^{-1} + A_{0} v(in) + B_{2} z_{out}^{-2} + B_{1} z_{out}^{-1} \right) \]
where z_in and z_out are the delays of the V(in) and V(out). This can be easily implemented in LTspice using a behavioural source with the function delay(x,y) (= delay x by y) where x can be either V(in) or V(out), and that's how I implemented it, but I am getting strange results, not at all what I would expect. For example, here's a comparison of an 8th order analog Butterworth filter -- V(out) -- and its IIR counterpart -- V(outD) -- as they appear after simulation for fp=1Hz and f0=7Hz (random value):
The functions are implemented exactly as you see them above. Since I don't expect LTspice to give wrong results, my question is: is there something wrong in my calculations? If yes, can someone please correct me? This is no homework, exam, etc, it's meant to be an IIR filter I am doing in LTspice.
Anticipated thanks,
Vlad
I am trying to get to a general solution for transforming H(s) to H(z), in terms of V(out)=f( V(in) ), I am using wxMaxima as a help and LTspice for implementation. Here's what I did:
\[ H(s) = \frac{a_{2} s^{2} + a_{1} s + a_{0}}{b_{2} s^{2} + b_{1} s + b_{0}} \]
\[ Z = \frac{1-z^{-1}}{1+z^{-1}} \]
\[ \omega_{D} = tan \left( \pi \frac{f_{p}}{f_{0}} \right) \]
Here's what wxMaxima gave me as a result for H(Z/wD), after simplification (b2=1):
\[ H(z) = \frac{ \left( a_{0} \omega_{D}^{2} - a_{1} \omega_{D} + a_{2} \right) z^{-2}
+ 2 \left( a_{0} \omega_{D}^{2} - a_{2} \right) z^{-1} + \left( a_{0} \omega_{D}^{2} + a_{1} \omega_{D} + a_{2} \right) }
{ \left( b_{0} \omega_{D}^{2} - b_{1} \omega_{D} + 1 \right) z^{-2}
+ 2 \left( b_{0} \omega_{D}^{2} - 1 \right) z^{-1} + \left( b_{0} \omega_{D}^{2} + b_{1} \omega_{D} + 1 \right) } \]
Which is the known general Z bilinear transform:
\[ H(z) = \frac{ A_{2} z^{-2} + A_{1} z^{-1} + A_{0} } { - B_{2} z^{-2} - B_{1} z^{-1} + 1 } \]
From this, V(out) can be expressed as:
\[ V(out) = \frac{1}{B_{0}}\left( A_{2} z_{in}^{-2} + A_{1} z_{in}^{-1} + A_{0} v(in) + B_{2} z_{out}^{-2} + B_{1} z_{out}^{-1} \right) \]
where z_in and z_out are the delays of the V(in) and V(out). This can be easily implemented in LTspice using a behavioural source with the function delay(x,y) (= delay x by y) where x can be either V(in) or V(out), and that's how I implemented it, but I am getting strange results, not at all what I would expect. For example, here's a comparison of an 8th order analog Butterworth filter -- V(out) -- and its IIR counterpart -- V(outD) -- as they appear after simulation for fp=1Hz and f0=7Hz (random value):
The functions are implemented exactly as you see them above. Since I don't expect LTspice to give wrong results, my question is: is there something wrong in my calculations? If yes, can someone please correct me? This is no homework, exam, etc, it's meant to be an IIR filter I am doing in LTspice.
Anticipated thanks,
Vlad