使用m函数进行基于Ziegler-Nichols方法的PID参数整定

PID参数整定

文章源自B站UP主学海行舟 https://www.bilibili.com/read/cv20072776?spm_id_from=333.999.0.0 出处:bilibili

Ziegler-Nichols整定PID 是一种工程经验方法,可以比较方便地进行PID参数整定。

该方法的基本思路是将积分呢和微分增益设置为0,然后bili增益从0开始增加,直至达到极限增益Ku,结合此时的系统振荡周期Tu,就可以进行Z-N参数整定。

方法可概括为5步。

1、考虑纯比例控制下的系统的闭环特性。

2、根据Routh判据确定极限增益Ku。

3、根据极限增益Ku和辅助多项式确定振荡周期Tu。

4、结合如下表格确定PID参数 。

5根据响应性能微调PID参数 。

给定一系统传递函数:

根据控制理论知识,PID控制器是串在系统前级根据误差产生控制效果的。根据系统控制框图可知,整个系统的闭环传递函数的分母部分为->也就是系统的特征方程:

根据劳斯判据并结合系统稳定性判据可得到Kp取值范围:

令Ku=10,使其处于临界稳定状态,构造辅助多项式:

下面是使用m文件进行系统仿真的尝试。

simulink文件.

%经典PID
Kp=6.1;
Ki=9.74;
Kd=0.924;
[t,x]=sim('sons',[0,25]);
figure(1)
subplot(1,2,1);
plot(t,y)
grid on
%部分过冲
Kp=3.11;
Ki=3.246;
Kd=0.9692;
%PI控制
%  Kp=4.5;
%  Ki=4.38;
 %Kd=0;
[t,x]=sim('sons',[0,25]);
subplot(1,2,2);
plot(t,y)
grid on


%%尝试进行纯m文件仿真
g1=pid(Kp,Ki,Kd);
g2=tf(21,[1 9 26 24]);
g3_cl=feedback(g1*g2,1);

a=step(1,g3_cl);
b=step(2,g3_cl);
figure(2)
subplot(1,2,1);
plot(a);
subplot(1,2,2);
plot(b);

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
使用Python来实现Ziegler-Nichols方法进行自动调节PID值的步骤如下: 1. 设定PID控制器的积分和微分部分为零,只保留比例部分。 2. 增大比例参数,观察系统的响应。 3. 根据响应曲线的形状确定临界增益(即系统开始震荡的增益值)。 4. 根据临界增益计算出比例、积分和微分参数的初值。 这里提供一个简单的示例代码,你可以根据你的具体系统进行修改: ```python import time import numpy as np import matplotlib.pyplot as plt # Simulate the system response def simulate_system(Kp, Ki, Kd): # Simulate your system here # Return the system response pass # Ziegler-Nichols method for tuning PID parameters def ziegler_nichols_tuning(): # Initial PID parameters Kp = 0.0 Ki = 0.0 Kd = 0.0 # Initial step size for increasing Kp step_size = 0.1 # Settling time threshold for oscillations to stabilize settling_time_threshold = 2.0 # Start with increasing Kp until oscillations occur while True: Kp += step_size # Simulate the system response response = simulate_system(Kp, Ki, Kd) # Measure the settling time of the response settling_time = calculate_settling_time(response) # If oscillations occur, stop increasing Kp if settling_time < settling_time_threshold: break # Calculate the critical gain Kc Kc = Kp # Calculate the ultimate period Tu (time period of oscillations) Tu = calculate_ultimate_period(response) # Calculate PID parameters based on Ziegler-Nichols formulas Kp = 0.6 * Kc Ki = 1.2 * Kc / Tu Kd = 0.075 * Kc * Tu return Kp, Ki, Kd # Helper functions for calculating settling time and ultimate period def calculate_settling_time(response): # Calculate the settling time of the response # You can use your own criteria to determine the settling time pass def calculate_ultimate_period(response): # Calculate the ultimate period (Tu) of the response # You can use your own method to estimate the ultimate period pass # Main function def main(): # Tune PID parameters using Ziegler-Nichols method Kp, Ki, Kd = ziegler_nichols_tuning() # Print the tuned PID parameters print("Tuned PID parameters:") print("Kp =", Kp) print("Ki =", Ki) print("Kd =", Kd) if __name__ == '__main__': main() ``` 以上代码是一个简单的示例,你需要根据你的实际系统进行适当的修改,包括编写`simulate_system`函数来模拟系统响应,并实现`calculate_settling_time`和`calculate_ultimate_period`函数来计算响应的稳定时间和最终周期。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值