AnyMath 文档
Notebook

调节剂的合成

网络研讨会"控制系统建模的工程师能力"的一个例子

In [ ]:
using ControlSystems

连接系统的方法

In [ ]:
W1 = tf(10, [9, 0.04, 0.01]);
W2 = tf(15, [2, 0.01, 0.7]);
串行连接
Послед.png
In [ ]:
W = W1 * W2
Out[0]:
TransferFunction{Continuous, ControlSystemsBase.SisoRational{Float64}}
                                  150.0
-------------------------------------------------------------------------
18.0s^4 + 0.17s^3 + 6.320399999999999s^2 + 0.0281s + 0.006999999999999999

Continuous-time transfer function model
In [ ]:
W = series(W1, W2)
Out[0]:
TransferFunction{Continuous, ControlSystemsBase.SisoRational{Float64}}
                                                150.0
------------------------------------------------------------------------------------------------------
18.0s^4 + 0.16999999999999998s^3 + 6.320399999999999s^2 + 0.028099999999999997s + 0.006999999999999999

Continuous-time transfer function model
并联连接
平行png
In [ ]:
W = W1 + W2
Out[0]:
TransferFunction{Continuous, ControlSystemsBase.SisoRational{Float64}}
                         155.0s^2 + 0.7s + 7.15
-------------------------------------------------------------------------
18.0s^4 + 0.17s^3 + 6.320399999999999s^2 + 0.0281s + 0.006999999999999999

Continuous-time transfer function model
In [ ]:
W = parallel(W1, W2)
Out[0]:
TransferFunction{Continuous, ControlSystemsBase.SisoRational{Float64}}
                         155.0s^2 + 0.7s + 7.15
-------------------------------------------------------------------------
18.0s^4 + 0.17s^3 + 6.320399999999999s^2 + 0.0281s + 0.006999999999999999

Continuous-time transfer function model

串行控制器

在第一个例子中,我们将使用频率特性来选择串行控制器。

image.png
管理对象
In [ ]:
s = tf("s")
sys = (1s+2)/(0.2*s^2 +1.2*s+1)
Out[0]:
TransferFunction{Continuous, ControlSystemsBase.SisoRational{Float64}}
    1.0s + 2.0
-------------------
0.2s^2 + 1.2s + 1.0

Continuous-time transfer function model
管理对象的特征
In [ ]:
p1 = ControlSystems.marginplot(sys)
p2 = plot(stepinfo(step(feedback(sys),0:0.01:5); settling_th=0.05), legend=:bottomright)
plot(p1, p2, layout = (1, 2))
Out[0]:
要求:

*无静态错误
*超调<15%
*转换时间<2s
*相位裕度>60°

调节器是一个集成环节

一个星阶为零的系统,因此,为了满足无静态误差的要求,我们将首先增加一个积分环节作为调节器。:

In [ ]:
controller = 1/s
p1 = ControlSystems.marginplot(sys*controller)
p2 = plot(stepinfo(step(feedback(sys*controller),0:0.01:10); settling_th=0.05), legend=:bottomright)
plot(p1, p2, layout = (1, 2))
Out[0]:
调节器是一个积分链接+增益因子

统变得准确。 但它很慢,所以我们将添加一个增益因子。

In [ ]:
k = 5.6 # @param {type:"slider",min:0,max:10,step:0.1}
controller = k*1/s
p1 = ControlSystems.marginplot(sys*controller)
p2 = plot(stepinfo(step(feedback(sys*controller),0:0.01:5); settling_th=0.05), legend=:bottomright)
plot(p1, p2, layout = (1, 2))
Out[0]:
调节器为积分链路+增益因子+顺序提前相位校正装置

它仍然是增加相位裕度。 有必要改变中频范围内频率响应的斜率,以增加系统的稳定性。 为此,我们将添加一个顺序提前相位校正装置。

In [ ]:
wz = 6.6 # @param {type:"slider",min:1,max:10,step:0.1}
wp = 20.6 # @param {type:"slider",min:1,max:100,step:0.1}
k = 6.8 # @param {type:"slider",min:0,max:10,step:0.1}
controller = k*1/s*(s+wz)/(s+wp)
p1 = ControlSystems.marginplot(sys*controller)
ControlSystems.bodeplot!(sys*k*1/s)
p2 = plot(stepinfo(step(feedback(sys*controller),0:0.01:5); settling_th=0.05), legend=:bottomright)
annotate!(p2, 2, 0.8, text("调节器=$k*s*(s+ "* string(round(1/wz, digits=3))*")/(s + "*string(round(1/wp, digits=3))*")", :left, 8, :black))
plot(p1, p2, layout = (1, 2))
Out[0]:

得到的控制器参数也可以用在模型中,例如,在传递函数的块零点和极点中。 您可以通过检查模型来验证这一点。 synthesis.engee.

PID控制器

In [ ]:
using EngeeControlSystems
并联形式的PID控制器
In [ ]:
kp = 1.0
ki = 1.0
kd = 1.0
Tf = 0.01
pid_prl = Pid(kp, ki, kd, Tf) # 带一阶滤波器的连续PID控制器
Out[0]:
Pid(1.0, 1.0, 1.0, 0.01, nothing, nothing, nothing)
标准形式的PID控制器
In [ ]:
kp = 1.0
ti = 1.0
td = 1.0
n = 100
ts = 0.01
pid_std = PidStd(kp, ti, td, n, ts) # 具有一阶滤波器的离散PID控制器
Out[0]:
PidStd(1.0, 1.0, 1.0, 100.0, 0.01, :forward_euler, :forward_euler)
In [ ]:
discr = c2d(pid_prl, ts)
Out[0]:
Pid(1.0, 1.0, 1.5819767068693265, 0.015819767068693265, 0.01, :forward_euler, :forward_euler)
In [ ]:
d2c(discr)
Out[0]:
Pid(1.0, 1.0, 1.0, 0.01, nothing, nothing, nothing)
In [ ]:
Ts_new = 0.02
d2d(pid_std, Ts_new)
Out[0]:
PidStd(1.0, 1.0, 2.0, 100.0, 0.02, :forward_euler, :forward_euler)
自动调整PID控制器
In [ ]:
pi_c, info = pidtune(sys, :pi, :parallel)
Out[0]:
(Pid(0.3258464350718974, 3.352296639805523, 0.0, 0.0, nothing, nothing, nothing), (true, 3.2914794672549705, 59.999999999999986))
In [ ]:
Wzam = feedback(pi_c*sys)
t = 0:0.005:12.0
plot(stepinfo(step(Wzam, t)))
Out[0]:
In [ ]:
Wraz = pi_c*sys
ControlSystems.marginplot(Wraz)
Out[0]:

函数的结果 pidtune 它可以在模型中使用,例如,在PID控制器块的参数中:比例系数: pi_c.kp 和积分系数: pi_c.ki. 模型中显示了一个例子 synthesis.engee.