一般若需要將控制系統透過 電腦 實現控制力 或者 對連續時間系統進行取樣,則我們稱此類系統為 電腦控制系統 或稱 數位控制系統。這次我們要介紹如何從連續時間模型 將其 透過適當的數學操作,從而獲得其對應的離散化的模型。
現在考慮有限維 線性非時變 連續時間狀態空間模型如下:
\[\left\{ \begin{array}{l}
\dot x\left( t \right) = A_cx\left( t \right) + B_cu\left( t \right);\begin{array}{*{20}{c}}
{}&{}
\end{array}x\left( 0 \right) = {x_0}\\
y\left( t \right) = C_c x\left( t \right) + D_cu\left( t \right)
\end{array} \right. \ \ \ \ \ \ \ \ \ (\star)
\]注意到上述狀態空間模型含有微分項 $\dot x$,若我們想要透過電腦實現微分方程,則我們需將其進行 離散化(Discretization),
\[\dot x\left( t \right): = \mathop {\lim }\limits_{\Delta \to 0} \frac{{x\left( {t + \Delta } \right) - x\left( t \right)}}{\Delta }\]則前述連續時間的狀態方程 $(\star)$ 可表為
\[\begin{array}{l}
\dot x\left( t \right) = {A_c}x\left( t \right) + {B_c}u\left( t \right)\\
\Rightarrow x\left( {t + \Delta } \right) - x\left( t \right) = {A_c}x\left( t \right)\Delta + {B_c}u\left( t \right)\Delta \\
\Rightarrow x\left( {t + \Delta } \right) = x\left( t \right) + {A_c}x\left( t \right)\Delta + {B_c}u\left( t \right)\Delta
\end{array}\]前述的 $\Delta$ 一般在實現上稱為取樣時間 (sampling time),且對 $k \in \mathbb{Z}$, $t := k \Delta$,我們可改寫
\[\begin{array}{l}
\left\{ {\begin{array}{*{20}{l}}
{x\left( {k\Delta + \Delta } \right) = \left( {I + {A_c}\Delta } \right)x\left( {k\Delta } \right) + {B_c}u\left( {k\Delta } \right)\Delta }\\
{y\left( {k\Delta } \right) = {C_c}x\left( {k\Delta } \right) + {D_c}u\left( {k\Delta } \right)}
\end{array}} \right.\\
\Rightarrow \left\{ {\begin{array}{*{20}{l}}
{x\left( {\left( {k + 1} \right)\Delta } \right) = \left( {I + {A_c}\Delta } \right)x\left( {k\Delta } \right) + {B_c}u\left( {k\Delta } \right)\Delta }\\
{y\left( {k\Delta } \right) = {C_c}x\left( {k\Delta } \right) + {D_c}u\left( {k\Delta } \right)}
\end{array}} \right.
\end{array}\]上式現在可以很容易地透過 MATLAB 實現。
更進一步,若考慮 $u(t)$ 也透過電腦計算而得,再透過數位類比轉換 (Digital-Analog converter ) 或 零階保持(Zero-Order Hold),則 $u(t)$ 將會是 piecewise constant 。也就是說對任意 $t$ 滿足 $k\Delta \le t < (k+1) \Delta$,我們的控制力可定義為
$$u(t) := u(k \Delta) := u(k) \;\;\; \forall k=0,1,2,...$$ 此時控制力 $u(k)$ 將只會在 取樣點 $k\Delta$ 上有變動,且在取樣點上,我們連續時間系統的解仍然成立,故對於 $t = k \Delta$ ,我們可定義狀態方程的解
\[\begin{array}{*{20}{l}}
{x\left( k \right): = x\left( {k\Delta } \right) = {{\left. {x\left( t \right)} \right|}_{t = k\Delta }}}\\
{\begin{array}{*{20}{c}}
{}&{}&{}
\end{array} = {{\left. {\left( {{e^{{A_c}t}}{x_0} + \int_0^t {{e^{{A_c}\left( {t - \tau } \right)}}} Bu\left( \tau \right)d\tau } \right)} \right|}_{t = k\Delta }}}\\
{\begin{array}{*{20}{c}}
{}&{}&{}
\end{array} = {e^{{A_c}k\Delta }}{x_0} + \int_0^{k\Delta } {{e^{{A_c}\left( {k\Delta - \tau } \right)}}} Bu\left( \tau \right)d\tau }
\end{array}
\]且 對於 $t = (k+1) \Delta$ 而言,我們亦可定義
\[\small \begin{array}{*{20}{l}}
{x\left( {k + 1} \right): = x\left( {\left( {k + 1} \right)\Delta } \right) = {{\left. {x\left( t \right)} \right|}_{t = \left( {k + 1} \right)\Delta }}}\\
{\begin{array}{*{20}{c}}
{}&{}&{}
\end{array} = {{\left. {\left( {{e^{{A_c}t}}{x_0} + \int_0^t {{e^{{A_c}\left( {t - \tau } \right)}}} Bu\left( \tau \right)d\tau } \right)} \right|}_{t = \left( {k + 1} \right)\Delta }}}\\
{\begin{array}{*{20}{c}}
{}&{}&{}
\end{array} = {e^{{A_c}\left( {k + 1} \right)\Delta }}{x_0} + \int_0^{\left( {k + 1} \right)\Delta } {{e^{{A_c}\left( {\left( {k + 1} \right)\Delta - \tau } \right)}}} Bu\left( \tau \right)d\tau }\\
{\begin{array}{*{20}{c}}
{}&{}&{}
\end{array} = {e^{{A_c}\left( {k + 1} \right)\Delta }}{x_0} + \int_0^{k\Delta } {{e^{{A_c}\left( {\left( {k + 1} \right)\Delta - \tau } \right)}}} Bu\left( \tau \right)d\tau + \int_{k\Delta }^{\left( {k + 1} \right)\Delta } {{e^{{A_c}\left( {\left( {k + 1} \right)\Delta - \tau } \right)}}} Bu\left( \tau \right)d\tau }\\
{\begin{array}{*{20}{c}}
{}&{}&{}
\end{array} = {e^{{A_c}\Delta }}\underbrace {\left[ {{e^{{A_c}k\Delta }}{x_0} + \int_0^{k\Delta } {{e^{{A_c}\left( {k\Delta - \tau } \right)}}} Bu\left( \tau \right)d\tau } \right]}_{ = x\left( k \right)} + \int_{k\Delta }^{\left( {k + 1} \right)\Delta } {{e^{{A_c}\left( {\left( {k + 1} \right)\Delta - \tau } \right)}}} Bu\left( \tau \right)d\tau }\\
{\begin{array}{*{20}{c}}
{}&{}&{}
\end{array} = {e^{{A_c}\Delta }}x\left( k \right) + \int_{k\Delta }^{\left( {k + 1} \right)\Delta } {{e^{{A_c}\left( {\left( {k + 1} \right)\Delta - \tau } \right)}}} Bu\left( \tau \right)d\tau \;\;\;\;\;(**)}
\end{array}\]現在若令新的變數 $\alpha : = \left( {k + 1} \right)\Delta - \tau $ 則 $(**)$ 可被改寫為
\[ \begin{array}{l}
x\left( {k + 1} \right) = {e^{A\Delta }}x\left( k \right) + \int_{\left( k \right)\Delta }^{\left( {k + 1} \right)\Delta } {{e^{A\left( {\left( {k + 1} \right)\Delta - \tau } \right)}}} Bu\left( \tau \right)d\tau \\
\Rightarrow x\left( {k + 1} \right) = {e^{A\Delta }}x\left( k \right) + \left( {\int_0^\Delta {{e^{A\alpha }}} d\alpha } \right)Bu\left( k \right)
\end{array}\]注意到上式中第二行 $u(k)$ 被提到積分外面是因為 $u(t)$ 在 $k\Delta \le t < (k+1)\Delta$ 之間為 constant。
故總結上式,我們有
\[\left\{ \begin{array}{l}
x\left( {k + 1} \right) = \underbrace {{e^{{A_c}\Delta }}}_Ax\left( k \right) + \underbrace {\left( {\int_0^\Delta {{e^{{A_c}\alpha }}} d\alpha } \right)B}_Bu\left( k \right)\\
y\left( k \right) = Cx\left( k \right) + Du\left( k \right)
\end{array} \right.\] 上式即稱為對應的 零階自保持的 有限維 線性非時變 離散時間狀態空間模型 。
若 $A_c$ 反矩陣存在,則上述的 $B$ 矩陣 可更進一步計算如下,
\[\begin{array}{l}
B = \left( {\int_0^\Delta {{e^{{A_c}\alpha }}d\alpha } } \right)B\\
\begin{array}{*{20}{c}}
{}&{}
\end{array} = \left( {\int_0^\Delta {\left( {I + {A_c}\alpha + \frac{{{{\left( {{A_c}\alpha } \right)}^2}}}{{2!}} + ...} \right)d\alpha } } \right)B\\
\begin{array}{*{20}{c}}
{}&{}
\end{array} = \left( {\int_0^\Delta {\left( I \right)d\alpha } + \int_0^\Delta {\left( {{A_c}\alpha } \right)d\alpha } + \int_0^\Delta {\left( {\frac{{{{\left( {{A_c}\alpha } \right)}^2}}}{{2!}}} \right)d\alpha } + ...} \right)B\\
\begin{array}{*{20}{c}}
{}&{}
\end{array} = \left( {I\Delta + {A_c}\frac{{{\Delta ^2}}}{2} + {A_c}^2\frac{{{\Delta ^3}}}{{3!}} + ...} \right)B\\
\begin{array}{*{20}{c}}
{}&{}
\end{array} = \left( {\sum\limits_{k = 1}^\infty {{A_c}^{k - 1}\frac{{{\Delta ^k}}}{{k!}}} } \right)B\\
\begin{array}{*{20}{c}}
{}&{}
\end{array} = \left( {{A_c}^{ - 1}\sum\limits_{k = 1}^\infty {\frac{{{{\left( {{A_c}\Delta } \right)}^k}}}{{k!}}} } \right)B = \left( {{A_c}^{ - 1}\left( {{e^{{A_c}\Delta }} - I} \right)} \right)B
\end{array}\]
現在我們可以開始求解離散化的狀態空間方程
\[\left\{ {\begin{array}{*{20}{l}}
{x\left( {k + 1} \right) = Ax\left( k \right) + Bu\left( k \right)}\\
{y\left( k \right) = Cx\left( k \right) + Du\left( k \right)}
\end{array}} \right.\]首先觀察
\[\left\{ \begin{array}{l}
x\left( 1 \right) = Ax\left( 0 \right) + Bu\left( 0 \right)\\
x\left( 2 \right) = Ax\left( 1 \right) + Bu\left( 1 \right)\\
\begin{array}{*{20}{c}}
{}&{}&{}
\end{array} = {A^2}x\left( 0 \right) + ABu\left( 0 \right) + Bu\left( 1 \right)\\
\begin{array}{*{20}{c}}
{}&{}&{}
\end{array} = {A^2}x\left( 0 \right) + \sum\limits_{j = 0}^1 {{A^{1 - j}}Bu\left( j \right)} \\
x\left( 3 \right) = Ax\left( 2 \right) + Bu\left( 2 \right)\\
\begin{array}{*{20}{c}}
{}&{}&{}
\end{array} = {A^3}x\left( 0 \right) + {A^2}Bu\left( 0 \right) + ABu\left( 1 \right) + Bu\left( 2 \right)\\
\begin{array}{*{20}{c}}
{}&{}&{}
\end{array} = {A^3}x\left( 0 \right) + \sum\limits_{j = 0}^2 {{A^{2 - j}}Bu\left( j \right)} \\
\vdots
\end{array} \right.\]故
\[x\left( k \right) = {A^k}x\left( 0 \right) + \sum\limits_{j = 0}^{k - 1} {{A^{k - 1 - j}}Bu\left( j \right)} \]
現在考慮有限維 線性非時變 連續時間狀態空間模型如下:
\[\left\{ \begin{array}{l}
\dot x\left( t \right) = A_cx\left( t \right) + B_cu\left( t \right);\begin{array}{*{20}{c}}
{}&{}
\end{array}x\left( 0 \right) = {x_0}\\
y\left( t \right) = C_c x\left( t \right) + D_cu\left( t \right)
\end{array} \right. \ \ \ \ \ \ \ \ \ (\star)
\]注意到上述狀態空間模型含有微分項 $\dot x$,若我們想要透過電腦實現微分方程,則我們需將其進行 離散化(Discretization),
\[\dot x\left( t \right): = \mathop {\lim }\limits_{\Delta \to 0} \frac{{x\left( {t + \Delta } \right) - x\left( t \right)}}{\Delta }\]則前述連續時間的狀態方程 $(\star)$ 可表為
\[\begin{array}{l}
\dot x\left( t \right) = {A_c}x\left( t \right) + {B_c}u\left( t \right)\\
\Rightarrow x\left( {t + \Delta } \right) - x\left( t \right) = {A_c}x\left( t \right)\Delta + {B_c}u\left( t \right)\Delta \\
\Rightarrow x\left( {t + \Delta } \right) = x\left( t \right) + {A_c}x\left( t \right)\Delta + {B_c}u\left( t \right)\Delta
\end{array}\]前述的 $\Delta$ 一般在實現上稱為取樣時間 (sampling time),且對 $k \in \mathbb{Z}$, $t := k \Delta$,我們可改寫
\[\begin{array}{l}
\left\{ {\begin{array}{*{20}{l}}
{x\left( {k\Delta + \Delta } \right) = \left( {I + {A_c}\Delta } \right)x\left( {k\Delta } \right) + {B_c}u\left( {k\Delta } \right)\Delta }\\
{y\left( {k\Delta } \right) = {C_c}x\left( {k\Delta } \right) + {D_c}u\left( {k\Delta } \right)}
\end{array}} \right.\\
\Rightarrow \left\{ {\begin{array}{*{20}{l}}
{x\left( {\left( {k + 1} \right)\Delta } \right) = \left( {I + {A_c}\Delta } \right)x\left( {k\Delta } \right) + {B_c}u\left( {k\Delta } \right)\Delta }\\
{y\left( {k\Delta } \right) = {C_c}x\left( {k\Delta } \right) + {D_c}u\left( {k\Delta } \right)}
\end{array}} \right.
\end{array}\]上式現在可以很容易地透過 MATLAB 實現。
更進一步,若考慮 $u(t)$ 也透過電腦計算而得,再透過數位類比轉換 (Digital-Analog converter ) 或 零階保持(Zero-Order Hold),則 $u(t)$ 將會是 piecewise constant 。也就是說對任意 $t$ 滿足 $k\Delta \le t < (k+1) \Delta$,我們的控制力可定義為
$$u(t) := u(k \Delta) := u(k) \;\;\; \forall k=0,1,2,...$$ 此時控制力 $u(k)$ 將只會在 取樣點 $k\Delta$ 上有變動,且在取樣點上,我們連續時間系統的解仍然成立,故對於 $t = k \Delta$ ,我們可定義狀態方程的解
\[\begin{array}{*{20}{l}}
{x\left( k \right): = x\left( {k\Delta } \right) = {{\left. {x\left( t \right)} \right|}_{t = k\Delta }}}\\
{\begin{array}{*{20}{c}}
{}&{}&{}
\end{array} = {{\left. {\left( {{e^{{A_c}t}}{x_0} + \int_0^t {{e^{{A_c}\left( {t - \tau } \right)}}} Bu\left( \tau \right)d\tau } \right)} \right|}_{t = k\Delta }}}\\
{\begin{array}{*{20}{c}}
{}&{}&{}
\end{array} = {e^{{A_c}k\Delta }}{x_0} + \int_0^{k\Delta } {{e^{{A_c}\left( {k\Delta - \tau } \right)}}} Bu\left( \tau \right)d\tau }
\end{array}
\]且 對於 $t = (k+1) \Delta$ 而言,我們亦可定義
\[\small \begin{array}{*{20}{l}}
{x\left( {k + 1} \right): = x\left( {\left( {k + 1} \right)\Delta } \right) = {{\left. {x\left( t \right)} \right|}_{t = \left( {k + 1} \right)\Delta }}}\\
{\begin{array}{*{20}{c}}
{}&{}&{}
\end{array} = {{\left. {\left( {{e^{{A_c}t}}{x_0} + \int_0^t {{e^{{A_c}\left( {t - \tau } \right)}}} Bu\left( \tau \right)d\tau } \right)} \right|}_{t = \left( {k + 1} \right)\Delta }}}\\
{\begin{array}{*{20}{c}}
{}&{}&{}
\end{array} = {e^{{A_c}\left( {k + 1} \right)\Delta }}{x_0} + \int_0^{\left( {k + 1} \right)\Delta } {{e^{{A_c}\left( {\left( {k + 1} \right)\Delta - \tau } \right)}}} Bu\left( \tau \right)d\tau }\\
{\begin{array}{*{20}{c}}
{}&{}&{}
\end{array} = {e^{{A_c}\left( {k + 1} \right)\Delta }}{x_0} + \int_0^{k\Delta } {{e^{{A_c}\left( {\left( {k + 1} \right)\Delta - \tau } \right)}}} Bu\left( \tau \right)d\tau + \int_{k\Delta }^{\left( {k + 1} \right)\Delta } {{e^{{A_c}\left( {\left( {k + 1} \right)\Delta - \tau } \right)}}} Bu\left( \tau \right)d\tau }\\
{\begin{array}{*{20}{c}}
{}&{}&{}
\end{array} = {e^{{A_c}\Delta }}\underbrace {\left[ {{e^{{A_c}k\Delta }}{x_0} + \int_0^{k\Delta } {{e^{{A_c}\left( {k\Delta - \tau } \right)}}} Bu\left( \tau \right)d\tau } \right]}_{ = x\left( k \right)} + \int_{k\Delta }^{\left( {k + 1} \right)\Delta } {{e^{{A_c}\left( {\left( {k + 1} \right)\Delta - \tau } \right)}}} Bu\left( \tau \right)d\tau }\\
{\begin{array}{*{20}{c}}
{}&{}&{}
\end{array} = {e^{{A_c}\Delta }}x\left( k \right) + \int_{k\Delta }^{\left( {k + 1} \right)\Delta } {{e^{{A_c}\left( {\left( {k + 1} \right)\Delta - \tau } \right)}}} Bu\left( \tau \right)d\tau \;\;\;\;\;(**)}
\end{array}\]現在若令新的變數 $\alpha : = \left( {k + 1} \right)\Delta - \tau $ 則 $(**)$ 可被改寫為
\[ \begin{array}{l}
x\left( {k + 1} \right) = {e^{A\Delta }}x\left( k \right) + \int_{\left( k \right)\Delta }^{\left( {k + 1} \right)\Delta } {{e^{A\left( {\left( {k + 1} \right)\Delta - \tau } \right)}}} Bu\left( \tau \right)d\tau \\
\Rightarrow x\left( {k + 1} \right) = {e^{A\Delta }}x\left( k \right) + \left( {\int_0^\Delta {{e^{A\alpha }}} d\alpha } \right)Bu\left( k \right)
\end{array}\]注意到上式中第二行 $u(k)$ 被提到積分外面是因為 $u(t)$ 在 $k\Delta \le t < (k+1)\Delta$ 之間為 constant。
故總結上式,我們有
\[\left\{ \begin{array}{l}
x\left( {k + 1} \right) = \underbrace {{e^{{A_c}\Delta }}}_Ax\left( k \right) + \underbrace {\left( {\int_0^\Delta {{e^{{A_c}\alpha }}} d\alpha } \right)B}_Bu\left( k \right)\\
y\left( k \right) = Cx\left( k \right) + Du\left( k \right)
\end{array} \right.\] 上式即稱為對應的 零階自保持的 有限維 線性非時變 離散時間狀態空間模型 。
若 $A_c$ 反矩陣存在,則上述的 $B$ 矩陣 可更進一步計算如下,
\[\begin{array}{l}
B = \left( {\int_0^\Delta {{e^{{A_c}\alpha }}d\alpha } } \right)B\\
\begin{array}{*{20}{c}}
{}&{}
\end{array} = \left( {\int_0^\Delta {\left( {I + {A_c}\alpha + \frac{{{{\left( {{A_c}\alpha } \right)}^2}}}{{2!}} + ...} \right)d\alpha } } \right)B\\
\begin{array}{*{20}{c}}
{}&{}
\end{array} = \left( {\int_0^\Delta {\left( I \right)d\alpha } + \int_0^\Delta {\left( {{A_c}\alpha } \right)d\alpha } + \int_0^\Delta {\left( {\frac{{{{\left( {{A_c}\alpha } \right)}^2}}}{{2!}}} \right)d\alpha } + ...} \right)B\\
\begin{array}{*{20}{c}}
{}&{}
\end{array} = \left( {I\Delta + {A_c}\frac{{{\Delta ^2}}}{2} + {A_c}^2\frac{{{\Delta ^3}}}{{3!}} + ...} \right)B\\
\begin{array}{*{20}{c}}
{}&{}
\end{array} = \left( {\sum\limits_{k = 1}^\infty {{A_c}^{k - 1}\frac{{{\Delta ^k}}}{{k!}}} } \right)B\\
\begin{array}{*{20}{c}}
{}&{}
\end{array} = \left( {{A_c}^{ - 1}\sum\limits_{k = 1}^\infty {\frac{{{{\left( {{A_c}\Delta } \right)}^k}}}{{k!}}} } \right)B = \left( {{A_c}^{ - 1}\left( {{e^{{A_c}\Delta }} - I} \right)} \right)B
\end{array}\]
現在我們可以開始求解離散化的狀態空間方程
\[\left\{ {\begin{array}{*{20}{l}}
{x\left( {k + 1} \right) = Ax\left( k \right) + Bu\left( k \right)}\\
{y\left( k \right) = Cx\left( k \right) + Du\left( k \right)}
\end{array}} \right.\]首先觀察
\[\left\{ \begin{array}{l}
x\left( 1 \right) = Ax\left( 0 \right) + Bu\left( 0 \right)\\
x\left( 2 \right) = Ax\left( 1 \right) + Bu\left( 1 \right)\\
\begin{array}{*{20}{c}}
{}&{}&{}
\end{array} = {A^2}x\left( 0 \right) + ABu\left( 0 \right) + Bu\left( 1 \right)\\
\begin{array}{*{20}{c}}
{}&{}&{}
\end{array} = {A^2}x\left( 0 \right) + \sum\limits_{j = 0}^1 {{A^{1 - j}}Bu\left( j \right)} \\
x\left( 3 \right) = Ax\left( 2 \right) + Bu\left( 2 \right)\\
\begin{array}{*{20}{c}}
{}&{}&{}
\end{array} = {A^3}x\left( 0 \right) + {A^2}Bu\left( 0 \right) + ABu\left( 1 \right) + Bu\left( 2 \right)\\
\begin{array}{*{20}{c}}
{}&{}&{}
\end{array} = {A^3}x\left( 0 \right) + \sum\limits_{j = 0}^2 {{A^{2 - j}}Bu\left( j \right)} \\
\vdots
\end{array} \right.\]故
\[x\left( k \right) = {A^k}x\left( 0 \right) + \sum\limits_{j = 0}^{k - 1} {{A^{k - 1 - j}}Bu\left( j \right)} \]
留言
張貼留言