首页 > 解决方案 > 如何在 matlab 中绘制 PD 补偿器的输出?

问题描述

我在控制回路中有一个简单的 PD 补偿器。我想查看补偿器输出阶跃响应。我的代码如下所示:

plant = tf(820,[0.08 1 0])

% PD Compensator
Kp = 2.25;
Ki = 0;
Kd = 0.025;
comp_pd = pid(Kp, Ki, Kd)

% plant with pd compensator
plant_pd = feedback(comp_pd*plant,1);
% pd compensator output
pd_output=feedback(comp_pd,plant);

figure();
step(plant_pd)
step(pd_output)
grid on;
ylim([-12 12]);
xlim([0 0.1]);

当我运行代码时,我收到此错误:

Error using DynamicSystem/step (line 95)
Cannot simulate the time response of models with more zeros than poles.

如何绘制补偿器输出?

标签: matlab

解决方案


这是因为,正如错误消息所暗示的,理想 PD 补偿器的传递函数不是“正确的”,无法表示或模拟。

为了解决这个问题,通常练习使用“近似导数”术语,而不是:

comp_pd = Kp + Kd*s

你有类似的东西

comp_pd = Kp + Kd*s/(1+Tf*s)

这是有关该主题的文档的相关部分:

在此处输入图像描述

因此,在您的代码中,只需替换:

comp_pd = pid(Kp, Ki, Kd)

经过

comp_pd = pid(Kp, Ki, Kd, Tf)

其中Tf很小,1e-3尽管您可能必须进行试验,直到根据系统的时间常数找到正确的值。


推荐阅读