调节剂的合成
网络研讨会"控制系统建模的工程师能力"的一个例子
In [ ]:
using ControlSystems
连接系统的方法
In [ ]:
W1 = tf(10, [9, 0.04, 0.01]);
W2 = tf(15, [2, 0.01, 0.7]);
串行连接
In [ ]:
W = W1 * W2
Out[0]:
In [ ]:
W = series(W1, W2)
Out[0]:
并联连接
In [ ]:
W = W1 + W2
Out[0]:
In [ ]:
W = parallel(W1, W2)
Out[0]:
串行控制器
在第一个例子中,我们将使用频率特性来选择串行控制器。
管理对象
In [ ]:
s = tf("s")
sys = (1s+2)/(0.2*s^2 +1.2*s+1)
Out[0]:
管理对象的特征
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控制器
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]:
In [ ]:
discr = c2d(pid_prl, ts)
Out[0]:
In [ ]:
d2c(discr)
Out[0]:
In [ ]:
Ts_new = 0.02
d2d(pid_std, Ts_new)
Out[0]:
自动调整PID控制器
In [ ]:
pi_c, info = pidtune(sys, :pi, :parallel)
Out[0]:
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.