理论推导
原式
G\left( s \right) =\frac{Y\left( s \right)}{X\left( s \right)}=K_p+\frac{2K_r\omega _cs}{s^2+2\omega _cs+\omega _{0}^{2}}
离散化公式
s=\frac{2}{T}\frac{z-1}{z+1}
离散化推导
\begin{aligned}
\frac{Y\left( z \right)}{X\left( z \right)}&=K_p+\frac{2K_r\omega _c\left( \frac{2}{T}\frac{z-1}{z+1} \right)}{\left( \frac{2}{T}\frac{z-1}{z+1} \right) ^2+2\omega _c\left( \frac{2}{T}\frac{z-1}{z+1} \right) +\omega _{0}^{2}}
\\
&=K_p+\frac{\frac{4K_r\omega _c\left( z-1 \right)}{T\left( z+1 \right)}}{\frac{4\left( z-1 \right) ^2}{\left[ T\left( z+1 \right) \right] ^2}+\frac{4\omega _c\left( z-1 \right)}{T\left( z+1 \right)}+\omega _{0}^{2}}
\\
&=K_p+\frac{4K_r\omega _cT\left( z-1 \right) \left( z+1 \right)}{4\left( z-1 \right) ^2+4\omega _cT\left( z-1 \right) \left( z+1 \right) +\omega _{0}^{2}\left[ T\left( z+1 \right) \right] ^2}
\\
&=K_p+\frac{4K_r\omega _cT\left( z^2-1 \right)}{4\left( z^2-2z+1 \right) +4\omega _cT\left( z^2-1 \right) +\omega _{0}^{2}T^2\left( z^2+2z+1 \right)}
\\
&=K_p+\frac{4K_r\omega _cTz^2-4K_r\omega _cT}{4z^2-8z+4+4\omega _cTz^2-4\omega _cT+\omega _{0}^{2}T^2z^2+2\omega _{0}^{2}T^2z+\omega _{0}^{2}T^2}
\\
&=K_p+\frac{4K_r\omega _cTz^2-4K_r\omega _cT}{\left( \omega _{0}^{2}T^2+4\omega _cT+4 \right) z^2+\left( 2\omega _{0}^{2}T^2-8 \right) z+\left( \omega _{0}^{2}T^2-4\omega _cT+4 \right)}
\\
&=K_p+\frac{4K_r\omega _cT-4K_r\omega _cTz^{-2}}{\left( \omega _{0}^{2}T^2+4\omega _cT+4 \right) +\left( 2\omega _{0}^{2}T^2-8 \right) z^{-1}+\left( \omega _{0}^{2}T^2-4\omega _cT+4 \right) z^{-2}}
\\
&=\frac{\left[ K_p\left( \omega _{0}^{2}T^2+4\omega _cT+4 \right) +4K_r\omega _cT \right] +K_p\left( 2\omega _{0}^{2}T^2-8 \right) z^{-1}+\left[ K_p\left( \omega _{0}^{2}T^2-4\omega _cT+4 \right) -4K_r\omega _cT \right] z^{-2}}{\left( \omega _{0}^{2}T^2+4\omega _cT+4 \right) +\left( 2\omega _{0}^{2}T^2-8 \right) z^{-1}+\left( \omega _{0}^{2}T^2-4\omega _cT+4 \right) z^{-2}}
\end{aligned}
简化并转换为程序语言
\begin{aligned}
a_0&=\omega _{0}^{2}T^2+4\omega _cT+4
\\
a_1&=2\omega _{0}^{2}T^2-8
\\
a_2&=\omega _{0}^{2}T^2-4\omega _cT+4
\\
b_0&=K_p\left( \omega _{0}^{2}T^2+4\omega _cT+4 \right) +4K_r\omega _cT
\\
b_1&=K_p\left( 2\omega _{0}^{2}T^2-8 \right)
\\
b_2&=K_p\left( \omega _{0}^{2}T^2-4\omega _cT+4 \right) -4K_r\omega _cT
\end{aligned}
a_0y\left[ 0 \right] +a_1y\left[ 1 \right] +a_2y\left[ 2 \right] =b_0x\left[ 0 \right] +b_1x\left[ 1 \right] +b_2x\left[ 2 \right]
y\left[ 0 \right] =\frac{b_0x\left[ 0 \right] +b_1x\left[ 1 \right] +b_2x\left[ 2 \right] -a_1y\left[ 1 \right] -a_2y\left[ 2 \right]}{a_0}
评论区