見出し画像

Mapleで制御工学の基礎虎の巻8「状態フィードバック①」


制御で一番よく使うのはフィードバック制御だと思いますが、フィードバック制御にはシステムの出力をフィードバックする出力フィードバックと状態をフィードバックする状態フィードバックがあります。制御を習いたてのころは、その違いをあまり理解せずに使いやすい出力フィードバックばかり使っていたのを思い出します。しかし、この出力フィードバックと状態フィードバックは、その違いをしっかりと理解して目的に応じて両方を使っていかないと、実際の製品開発では一向に目的を達成できず延々と終わらないモグラ叩き(パラメータ調整)をすることになりかねません。そこで本記事では出力フィードバックと状態フィードバックを簡単に説明し、特に利用を敬遠されえがちな状態フィードバックについて解説したいと思います。

出力フィードバック制御

主な目的: システムの出力を目標値に追従させること
出力フィードバック制御は、システムの出力(観測できる量)に基づいて制御入力を調整します。特にPID制御のようなフィードバック制御では、目標値と実際の出力の誤差を使ってシステムを制御し、出力を目標にできるだけ近づけることが主な目的です。
この手法は、目標値追従(Tracking)や、位置制御、温度制御など、出力を直接的に目標に合わせたい場合に多く使われます。

状態フィードバック制御

主な目的: システム自体の動作特性を所望のものにすること
状態フィードバック制御は、システムの内部状態(位置、速度、角度などの状態変数)を利用して、システム全体の動作を制御します。これにより、システムの極(固有値)を望ましい位置に配置したり、システム全体の安定性や応答特性を調整したりします。

Mapleで状態フィードバックをしてみよう!

図1は状態フィードバックを示しています。状態フィードバック制御はシステムの状態xをフィードバックゲインKをかけて入力にフィードバックします。フィードバックはマイナスして入力に戻すため、ゲインKは「-K」としています。

図1 状態フィードバック

それでは状態をフィードバックゲインKをかけて入力に戻すと何が起こるのでしょうか?
簡単に言うと、システムの固有値を任意に変えることができるのです。システムの固有値を変えることで、そのシステムの挙動をあなたが望む特性に変えていくのです。

Mapleでシステムの固有値を変えて、システムの挙動の変化を見ていきましょう。
Mapleで固有値を計算するのに「LinearAlgebra」のライブラリをインクルードします。

with(LinearAlgebra):

次にシステムを定義します。なお、直達項であるDはゼロとします。ゼロなので定義していません。

A := Matrix([[0, 1, 0], [0, 0, 1], [-1, 1, 1]]);
B := Matrix([[0], [0], [1]]);
C := Matrix([[1, 0, 0]]);
システムの状態空間表現

このシステムの固有値はシステム行列Aの固有値が対応します。「Eigenvalues」コマンドでシステム行列Aの固有値を見てみましょう。

Eigenvalues(A);

固有値の値が正のものが存在していますね。
このことから、このシステムは不安定であることがわかります。固有値を変えることで、このシステムを安定化させていきます。

システム行列Aの固有値

なお、状態フィードバック制御は不安定なシステムを安定化させることだけが制御の役割ではありません。応答性や収束性など、あなたが望む応答特性にすることができます。

フィードバックゲインKを定義します。
システム行列が3次なのフィードバックゲインは3要素の行ベクトルになります。

K := Matrix([k1, k2, k3]);

次にフィードバックゲインKを作用させたシステムの特性方程式を求めます。

eq1 := Determinant(s*IdentityMatrix(3) - (A - (B . K));
フィードバックゲインKを作用させたシステムの特性方程式

このままでは見にくいので「collect」コマンドを使って「s」で括ります。

eq1 := collect(char_eq, s)
フィードバックゲインKを作用させたシステムの特性方程式(sの降べきの順)

次に期待するシステムの特性方程式を作っていきます。
今回は期待するシステムの固有値を-0.5、-1+i、-1-iとします。
これら3つの固有値を解とする特性方程式にすればよいので、次のように求めます。なお「expand」コマンドは式の展開をしてくれます。

eq2 := expand((s + 0.5)*(s + (1 - 5*I))*(s + (1 + 5*I)))
期待するシステムの特性方程式

フィードバックゲインKを作用させたシステムの特性方程式と期待するシステムの特性方程式の係数を比較してフィードバックゲインKを求めます。

k3 := solve(coeff(eq1, s, 2) = coeff(eq2, s, 2));

k2 := solve(coeff(eq1, s, 1) = coeff(eq2, s, 1));

k1 := solve(coeff(eq1, s, 0) = coeff(eq2, s, 0));
フィードバックゲインK

状態をフィードバックしたシステムの固有値を確認してみましょう。
当たり前ですが、設定した固有値になっていますね。

Eigenvalues(A - (B . K));
求めたフィードバックゲインKによるシステムの固有値

システムの応答

それでは固有値を変える前後でシステムの応答がどのように変わったかを見てみましょう。図2は元のシステムと状態フィードバック後のシステムのインパルス応答の結果です。
元のシステムは固有値が正の値を持っていたので不安定であり、発散してしまっていますね。一方で固有値の実数部がすべて負に変えた状態フィードバック後のシステムは収束しています。
このようにシステムの状態フィードバックをすることにより、固有値を任意の値にすることで、システムの挙動をあなたの希望するもの変えることができるのです。

図2 システムのインパルス応答

今回の記事では固有値を変えることでシステムの挙動が変化することだけを見てみましたが、固有値の違いでのシステムの挙動がどのように変わるかについては次の記事で紹介したいと思います。

【English】

Feedback control is probably the most commonly used type of control, but there are two types of feedback control: output feedback, which feeds back the output of the system, and state feedback, which feeds back the state of the system. I remember that when I first started learning control, I used only output feedback, which was easy to use, without understanding the difference between the two. However, unless you understand the difference between output feedback and state feedback and use both according to your objectives, you may end up doing endless whack-a-mole (parameter adjustment) in actual product development without ever achieving your goals. Therefore, in this article, I would like to briefly explain output feedback and state feedback, and in particular, explain state feedback, which is often avoided.

Output Feedback

Main objective: to make the system's output follow a target value
Output feedback control adjusts control inputs based on system outputs (observable quantities). In particular, in feedback control, such as PID control, the main objective is to control the system using the error between the target value and the actual output to bring the output as close to the target as possible. This technique is often used in tracking, position control, temperature control, and other situations where the output is directly aligned with a target.

State Feedback

Main objective: to achieve the desired operating characteristics of the system itself
State feedback control uses the internal state of the system (state variables such as position, velocity, angle, etc.) to control the behavior of the entire system. This allows the poles (eigenvalues) of the system to be placed in a desired position, or the stability and response characteristics of the overall system to be adjusted.

Let's do state feedback in Maple!

Figure 1 shows state feedback. The state feedback control feeds back the system state x to the input by applying a feedback gain K. The feedback is negative and returned to the input, so the gain K is “-K”.

Figure 1. State Feedback

So what happens when we apply a feedback gain K to the state and return it to the input? Simply put, you can arbitrarily change the eigenvalues of the system. By changing the eigenvalues of the system, you are changing its behavior to the characteristics you desire.

Let's change the eigenvalues of the system in Maple and see how the behavior of the system changes.
Include the “LinearAlgebra” library to calculate eigenvalues in Maple.

with(LinearAlgebra):

Next, define the system. Note that the direct term, D, is set to zero. Since it is zero, it is not defined.

A := Matrix([[0, 1, 0], [0, 0, 1], [-1, 1, 1]]);
B := Matrix([[0], [0], [1]]);
C := Matrix([[1, 0, 0]]);
State Space Representation of the System

The eigenvalues of this system correspond to the eigenvalues of system matrix A. Let's look at the eigenvalues of system matrix A with Maple's “Eigenvalues” command.

Eigenvalues(A);

You see that there are positive eigenvalues. This indicates that this system is unstable. By changing the eigenvalues, we can stabilize this system.

Eigenvalues of system matrix A

In addition, the role of state feedback control is not only to stabilize an unstable system. It can be made to have the response characteristics you desire, such as responsiveness and convergence.

Define the feedback gain K. Since the system matrix is cubic, the feedback gain is a row vector of three elements.

K := Matrix([k1, k2, k3]);

Next, we obtain the characteristic equation of the system with feedback gain K acting on it.

eq1 := Determinant(s*IdentityMatrix(3) - (A - (B . K));
Characteristic equation of the system with feedback gain K acting

It is not easy to see it as it is, so use the “collect” command and bracket it with “s”.

eq1 := collect(char_eq, s)
Characteristic equation of the system with feedback gain K acting (in descending order of s)

Next, we will create the characteristic equations of the expected system. In this case, let the eigenvalues of the expected system be -0.5, -1+i, and -1-i. The equation should be a characteristic equation with these three eigenvalues as solutions, which is obtained as follows. Note that the “expand” command will expand the equations.

eq2 := expand((s + 0.5)*(s + (1 - 5*I))*(s + (1 + 5*I)))
Characteristic equation of the expected system

The feedback gain K is obtained by comparing the coefficients of the characteristic equation of the system in which the feedback gain K is applied with the coefficients of the characteristic equation of the expected system.

k3 := solve(coeff(eq1, s, 2) = coeff(eq2, s, 2));

k2 := solve(coeff(eq1, s, 1) = coeff(eq2, s, 1));

k1 := solve(coeff(eq1, s, 0) = coeff(eq2, s, 0));
Feedback Gain K

Let's check the eigenvalues of the system with the state feedback. Of course, they are the eigenvalues you set!

Eigenvalues(A - (B . K));
Eigenvalues of the system with the obtained feedback gain K

System Response

Now we can see how the response of the system changed before and after changing the eigenvalues. Figure 2 shows the results of the impulse response of the original system and the system after state feedback. The original system is unstable and divergent because the eigenvalues had positive values. On the other hand, the system after state feedback, in which all real parts of the eigenvalues were changed to negative, has converged. Thus, by doing state feedback of the system, you can change the behavior of the system to whatever you want by setting the eigenvalues to arbitrary values.

Figure 2. Impulse response of the system

In this article we have only looked at how changing the eigenvalues changes the behavior of the system, but we will show in the next article how the behavior of the system changes for different eigenvalues.

【Sample】

Created by Maple 2024.1

いいなと思ったら応援しよう!