• 欢迎访问开心洋葱网站,在线教程,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站,欢迎加入开心洋葱 QQ群
  • 为方便开心洋葱网用户,开心洋葱官网已经开启复制功能!
  • 欢迎访问开心洋葱网站,手机也能访问哦~欢迎加入开心洋葱多维思维学习平台 QQ群
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏开心洋葱吧~~~~~~~~~~~~~!
  • 由于近期流量激增,小站的ECS没能经的起亲们的访问,本站依然没有盈利,如果各位看如果觉着文字不错,还请看官给小站打个赏~~~~~~~~~~~~~!

Matlab 仿真——直流电机速度控制(3)PID控制器设计

人工智能 chuchu 2595次浏览 0个评论

文章目录

    • 0. 被控对象与设计要求
    • 1. 比例控制
    • 2.PID 控制
    • 3. 调参

0. 被控对象与设计要求

  上一节我们知道了我们的开环响应并不能满足设计需求,这一节我们通过一个PID控制器使我们的系统满足设计需求。   这里把设计需求和系统转换方程粘贴在这里:   设计需求(阶跃响应):  

  • 稳定时间<2s
  • 超调<5%
  • 稳态误差<1%

  转换方程:
Matlab 仿真——直流电机速度控制(3)PID控制器设计  

1. 比例控制

  首先来看一个加了控制器的单位负反馈系统的框图  
在这里插入图片描述   我们的目标是通过设计控制器 C ( s ) C(s)C(s) 来使系统满足要求。我们先从单纯的比例控制开始,在电机Plant前面加一个比例控制器,然后得到新的系统(这里我们随意定了比例系数为100)  

<code class="prism language-csharp has-numbering"><span class="token operator">%</span>motor parameter
J <span class="token operator">=</span> <span class="token number">0.01</span><span class="token punctuation">;</span>
b <span class="token operator">=</span> <span class="token number">0.1</span><span class="token punctuation">;</span>
K <span class="token operator">=</span> <span class="token number">0.01</span><span class="token punctuation">;</span>
R <span class="token operator">=</span> <span class="token number">1</span><span class="token punctuation">;</span>
L <span class="token operator">=</span> <span class="token number">0.5</span><span class="token punctuation">;</span>
<span class="token operator">%</span>motor tf function
s <span class="token operator">=</span> <span class="token function">tf</span><span class="token punctuation">(</span><span class="token string">'s'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
P_motor <span class="token operator">=</span> K<span class="token operator">/</span><span class="token punctuation">(</span><span class="token punctuation">(</span>J<span class="token operator">*</span>s<span class="token operator">+</span>b<span class="token punctuation">)</span><span class="token operator">*</span><span class="token punctuation">(</span>L<span class="token operator">*</span>s<span class="token operator">+</span>R<span class="token punctuation">)</span><span class="token operator">+</span>K<span class="token operator">^</span><span class="token number">2</span><span class="token punctuation">)</span>
<span class="token operator">%</span>定义我们的纯比例控制器
Kp <span class="token operator">=</span> <span class="token number">100</span><span class="token punctuation">;</span>
C <span class="token operator">=</span> <span class="token function">pid</span><span class="token punctuation">(</span>Kp<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token operator">%</span>新的单位负反馈系统
sys_cl <span class="token operator">=</span> <span class="token function">feedback</span><span class="token punctuation">(</span>C<span class="token operator">*</span>P_motor<span class="token punctuation">,</span><span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token function">linearSystemAnalyzer</span><span class="token punctuation">(</span><span class="token string">'step'</span><span class="token punctuation">,</span>sys_cl<span class="token punctuation">,</span><span class="token number">0</span><span class="token punctuation">:</span><span class="token number">0.01</span><span class="token punctuation">:</span><span class="token number">5</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
</code>

  得到新系统的单位阶跃响应  
在这里插入图片描述   新的系统稳定时间控制在了0.567s,满足了稳定时间<2s的要求。但是新系统的超调很大,变得不满足要求。   回顾控制理论知识,增大Kp在减小稳态误差的同时也会增大超调,我们来检查一下是不是这样。 运行以下代码打开matlab的控制系统设计工具(输入是开环转换方程)  

<code class="prism language-csharp has-numbering"><span class="token function">controlSystemDesigner</span><span class="token punctuation">(</span>P_motor<span class="token punctuation">)
</span>
</code>

  在弹出的窗口选择添加新的阶跃输入图像  
在这里插入图片描述   选择IOTransfer_r2y(画出输入输出图像),然后点击plot  
在这里插入图片描述   接下来双击左边的C,该变它的值之后按Enter,看系统响应如何变化  
在这里插入图片描述   可以发现,增加比例系数确实能够减少稳态误差,但是增加超调。因此我们还需要微分和积分控制。  

2.PID 控制

  这次我们给控制器加上微分和积分系数(随便定的值)  

<code class="prism language-csharp has-numbering"><span class="token operator">%</span>PID 控制器(未调参)
Kp <span class="token operator">=</span> <span class="token number">75</span><span class="token punctuation">;</span>
Ki <span class="token operator">=</span> <span class="token number">1</span><span class="token punctuation">;</span>
Kd <span class="token operator">=</span> <span class="token number">1</span><span class="token punctuation">;</span>
C <span class="token operator">=</span> <span class="token function">pid</span><span class="token punctuation">(</span>Kp<span class="token punctuation">,</span>Ki<span class="token punctuation">,</span>Kd<span class="token punctuation">)</span><span class="token punctuation">;</span>
sys_cl <span class="token operator">=</span> <span class="token function">feedback</span><span class="token punctuation">(</span>C<span class="token operator">*</span>P_motor<span class="token punctuation">,</span><span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token function">linearSystemAnalyzer</span><span class="token punctuation">(</span><span class="token string">'step'</span><span class="token punctuation">,</span>sys_cl<span class="token punctuation">,</span><span class="token number">0</span><span class="token punctuation">:</span><span class="token number">1</span><span class="token punctuation">:</span><span class="token number">200</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
</code>

 
在这里插入图片描述   系统的稳定时间变长,依旧不满足设计要求,因此我们需要调节我们的PID参数知道系统满足设计要求。  

3. 调参

  稳定时间很长的原因是Ki太小,系统不能很快的收敛,我们增大Ki至200,重新绘制响应图  

<code class="prism language-csharp has-numbering"><span class="token operator">%</span>PID 控制器(调节Ki)
Kp <span class="token operator">=</span> <span class="token number">75</span><span class="token punctuation">;</span>
Ki <span class="token operator">=</span> <span class="token number">200</span><span class="token punctuation">;</span>
Kd <span class="token operator">=</span> <span class="token number">1</span><span class="token punctuation">;</span>
C <span class="token operator">=</span> <span class="token function">pid</span><span class="token punctuation">(</span>Kp<span class="token punctuation">,</span>Ki<span class="token punctuation">,</span>Kd<span class="token punctuation">)</span><span class="token punctuation">;</span>
sys_cl <span class="token operator">=</span> <span class="token function">feedback</span><span class="token punctuation">(</span>C<span class="token operator">*</span>P_motor<span class="token punctuation">,</span><span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token function">linearSystemAnalyzer</span><span class="token punctuation">(</span><span class="token string">'step'</span><span class="token punctuation">,</span>sys_cl<span class="token punctuation">,</span><span class="token number">0</span><span class="token punctuation">:</span><span class="token number">0.01</span><span class="token punctuation">:</span><span class="token number">4</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
</code>

 
在这里插入图片描述   系统稳定时间快了很多,但是超调很大。现在我们增大Kd,来试着减少超调  

<code class="prism language-csharp has-numbering"><span class="token operator">%</span>PID 控制器(调节Kd)
Kp <span class="token operator">=</span> <span class="token number">75</span><span class="token punctuation">;</span>
Ki <span class="token operator">=</span> <span class="token number">200</span><span class="token punctuation">;</span>
Kd <span class="token operator">=</span> <span class="token number">10</span><span class="token punctuation">;</span>
C <span class="token operator">=</span> <span class="token function">pid</span><span class="token punctuation">(</span>Kp<span class="token punctuation">,</span>Ki<span class="token punctuation">,</span>Kd<span class="token punctuation">)</span><span class="token punctuation">;</span>
sys_cl <span class="token operator">=</span> <span class="token function">feedback</span><span class="token punctuation">(</span>C<span class="token operator">*</span>P_motor<span class="token punctuation">,</span><span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token function">linearSystemAnalyzer</span><span class="token punctuation">(</span><span class="token string">'step'</span><span class="token punctuation">,</span>sys_cl<span class="token punctuation">,</span><span class="token number">0</span><span class="token punctuation">:</span><span class="token number">0.01</span><span class="token punctuation">:</span><span class="token number">4</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
</code>

 
在这里插入图片描述   发现系统已经完全满足设计要求,因此Kp=75, Ki=200,Kd=10 定义的PID控制器可以用在这里作为电机控制器。   这里也可以用Matlab自带的PID tunner工具箱来调参,不再赘述


开心洋葱 , 版权所有丨如未注明 , 均为原创丨未经授权请勿修改 , 转载请注明Matlab 仿真——直流电机速度控制(3)PID控制器设计
喜欢 (0)

您必须 登录 才能发表评论!

加载中……