LoginSignup
3
7

More than 3 years have passed since last update.

【制御工学】PID制御とステップ応答の可視化・分析

Last updated at Posted at 2020-02-29

1 はじめに

前回記事( https://qiita.com/sato235/items/5e006ebbf2949cf59463 )のなかで、制御器を入れた回路にて、ステップ入力とステップ応答の可視化を推奨されたので、今回の記事を作成した。
ゆくゆくは、ロボットの制御系設計に役立てたい。

2 参考文献

2.1 書籍

[1] 南裕樹 著、オーム社、「Pythonによる制御工学入門」

2.2 Webページ

[a] 制御ブロック図: https://tajimarobotics.com/pid-block-diagram-transfer-function/
[b] 【制御工学】Pythonによる伝達関数のグラフ化: https://qiita.com/sato235/items/5e006ebbf2949cf59463
[c] 【制御工学】Pythonによる伝達関数や状態空間モデルの計算: https://qiita.com/sato235/items/f991411074c578d1640c

3 実施内容

3.1 PID制御のブロック図

ブロック線図.png
出典: [a]

上記の「C」が制御器に相当する。
上記のフィードバック制御回路を、伝達関数にし、ステップ入力・応答を可視化する。

3.2 伝達関数

初期値
K=1
Kd=1
Wn=1
Ki=1
ita=1
Kp=1

伝達関数を作成

C=matlab.tf([Kd, Kp, Ki],[1,0])
G=matlab.tf([K*Wn**2],[1,2*ita*Wn, Wn**2])
H=1
print("H")
print(H)
print("------------")
print("C")
print(C)
print("------------")

print("G")
print(G)
print("------------")


CG=matlab.series(C,G)
print("C*G")
print(CG)
print("------------")

CGH= matlab.feedback(CG,H,-1)
print("C*G/(1+C*G*H)")
print(CGH)
print("------------")

出力は以下の通り。

H
1
------------
C

s^2 + s + 1
-----------
     s

------------
G

      1
-------------
s^2 + 2 s + 1

------------
C*G

  s^2 + s + 1
---------------
s^3 + 2 s^2 + s

------------
C*G/(1+C*G*H)

     s^2 + s + 1
---------------------
s^3 + 3 s^2 + 2 s + 1

------------

3.3 ステップ入力・応答

上で作成した伝達関数を用いて、ステップ入力と応答を可視化する。

t = np.linspace(0, 3, 1000)
yout, T = matlab.step(P, t)

fig = plt.figure()
ax = fig.add_subplot(1,1,1)
ax.plot(T,yout, label="step response")
ax.plot(T,[1]*1000, linestyle="--", label="step input")
ax.set_xlabel("time[s]")
plt.legend(bbox_to_anchor=(1, 0.25), loc='upper right', borderaxespad=0, fontsize=11)

図にまとめると以下の通り。

step_input_response.png

4 まとめ

・制御器を入れたフィードバック回路でのステップ応答まで可視化できた。
・次は、安定性の考察や、C,G,Hの関数の係数を変えた場合の挙動の比較などを行いたい。

3
7
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
7