当前位置:网站首页>PID Controller Improvement Notes No. 7: Improve the anti-overshoot setting of the PID controller
PID Controller Improvement Notes No. 7: Improve the anti-overshoot setting of the PID controller
2022-08-04 22:50:00 【foxclever】
我们已经设计了PID控制器,And according to the actual use of many improvements were made to implement.In this article we will discuss how to improvePIDThe controller overshoot problem.
1、问题提出
在前面的文章中,We have derived the incrementalPIDThe controller's formula,And on the discretization to apply to the program to realize,Specific discretization formula is as follows:
On the basis of this formula,We realize incrementalPID控制器,Only need to calculate according to the deviation increment and adjust output can achieve automatic adjustment.But we analyse will find,If the parameter set not appropriate,Or deviation value is bigger,Then computed incremental value will be very big,So the change of the output will be a lot,This case is prone to overshoot problem.
Overshoot once appear,Takes a long time to make the system stable,Serious and even cause oscillation.This nature is not the result of that we want to,所以我们希望PIDController has to prevent overshoot ability.
2、分析设计
About overshoot the problem,Let's analyze what factors can cause overshoot.We can understand the so-called overshoot for the adjustment of the excessive instead caused the instability of the system.That what situation will cause the excessive adjustment?Generally speaking too often adjust、Input signal changes drastically、The abrupt change of the output signal and the characteristics of controlled object.
For the above situation we have to analyze the response.The adjustment of the first is too often,Many times we may think to adjust fast can speed up the response of the system.But, in fact, related to the characteristics of the system itself.If the system does not exist lag or lag characteristics is small,自然是没有问题的.但很多时候,System is relatively large lag features,So frequent adjustment can be accumulated quickly output control generating overshoot.This case, we can increase to adjust cycle to stabilise the system.
Secondly we come to the input signal suddenly changes significantly affect.The input signal we here refers toPIDController Settings.In a stable system,Dramatically change the set point can make deviation increased,And large deviation tend to cause the output of the controller rapid accumulation,This rapid accumulation often can cause overshoot.这种情况下,We can control to improve the speed of change in value of.Generally make value linear slowly changing,As to step into the value can be adjusted according to the characteristics of the system.
Take a look at the output signal of the influence of abrupt change,In some cases because the parameter setting and system matching problem,The change of little change even if the deviation of output will be a big.At this time of the control variables will have great change,This change will increase the deviation,Further affect the output,So cycle accumulation can produce overshoot.In particular, some relatively fast reaction system is easier to appear this kind of circumstance.Generally we can by limiting the output changes to prevent this kind of phenomenon.
The characteristics of the controlled object mainly displays in the system lag features,Generally speaking the more lag system more not easy adjustable steady,Also the more prone to overshoot and oscillation.Cope with the situation in general, can adopt the way of slow adjustment to adjust.The specific way is in front of three.
3、软件实现
We have analyzed the overshoot of the main causes and ways to deal with,Then we have to consider how to improvePIDThe effect of the controller in order to achieve the overshoot.In view of the aforesaid mentioned several we respectively for design software is implemented on the.
To adjust the relative frequent problem,我们的PIDController design has been given the sampling period is adjustable,So we just according to the different controlled object to properly adjust it well.For the value of the big mutation and adjust output the abrupt change of two things,We have introduced two parameters,A parameter is used to switch setting smoothing function,A parameter is used to set the output increment limit switch function.We adopt two enumeration to achieve this,具体定义如下:
/*Define an enum type to set data smoothing*/
typedef enum ClassicPIDSM{
SMOOTH_DISABLE, //Is not enabled value smooth
SMOOTH_ENABLE //Enable value smooth
}ClassicPIDSMType;
/*Define output to prevent the abrupt change of enumeration*/
typedef enum ClassicPIDPAC{
PREVENT_ABRUPT_DISABLE, //Don't enable the output against the abrupt change
PREVENT_ABRUPT_ENABLE //To enable the output against the abrupt change
}ClassicPIDPACType;
The same we need toPIDObject type to add the corresponding property.我们为PIDController object type to add set data smoothing parameter and output increment limit parameters,所以我们实现PIDThe controller object types are defined as follows:
/*定义PID对象类型*/
typedef struct CLASSIC
{
float *pPV; //Measured value pointer
float *pSV; //Set data pointer
float *pMV; //The output value pointer
uint16_t *pMA; //Hand automatic operation pointer
#if PID_PARAMETER_STYLE > (0)
float *pKp; //Pointer proportion coefficient
float *pKi; //Integral coefficient of pointer
float *pKd; //Differential coefficient of pointer
#else
float *pPb; //比例带
float *pTi; //积分时间,单位为秒
float *pTd; //微分时间,单位为秒
float ts; //采样周期,单位为秒
#endif
float setpoint; //设定值
float lasterror; //前一拍偏差
float preerror; //前两拍偏差
float deadband; //死区
float result; //PID控制器计算结果
float output; //输出值0-100%
float maximum; //输出值上限
float minimum; //输出值下限
float errorabsmax; //偏差绝对值最大值
float errorabsmin; //偏差绝对值最小值
float alpha; //不完全微分系数
float deltadiff; //微分增量
float integralValue; //积分累计量
float gama; //微分先行滤波系数
float lastPv; //上一拍的过程测量值
float lastDeltaPv; //上一拍的过程测量值增量
ClassicPIDDRType direct; //正反作用
ClassicPIDSMType sm; //Set data smooth
ClassicPIDCSType cas; //Cascade set
ClassicPIDPACType pac; //Output against the abrupt change
}CLASSICPID;
修改了PIDThe definition of the controller object,我们还需要对PIDController to do the necessary improvement.We add value smooth operation,并通过设置参数smTo control whether to enable the operation.We add the output against the abrupt change of operation,And through the configuration parameterspac来决定是否启用.具体实现如下:
void PIDRegulator(CLASSICPID *vPID)
{
float thisError;
float result;
float factor;
float increment;
float pError,dError,iError;
float kp,ki,kd;
#if PID_PARAMETER_STYLE > (0)
kp=*vPID->pKp;
ki=*vPID->pKi;
kd=*vPID->pKd;
#else
if((*vPID->pTi)<vPID->ts)
{
*vPID->pTi=vPID->ts;
}
kp=100.0/(*vPID->pPb);
ki=kp*(vPID->ts/(*vPID->pTi));
kd=kp*((*vPID->pTd)/vPID->ts);
#endif
if(*vPID->pMA<1) //手动模式
{
vPID->output=*vPID->pMV;
//Set the undisturbed switching
vPID->result=(vPID->maximum-vPID->minimum)*vPID->output/(float)100.0+vPID->minimum;
*vPID->pSV=*vPID->pPV;
vPID->setpoint=*vPID->pSV;
}
else //自动模式
{
if(vPID->sm==SMOOTH_ENABLE) //Set data smooth change
{
SmoothSetpoint(vPID);
}
else
{
if(vPID->cas==CASCADE) //Cascade processing
{
vPID->setpoint=(vPID->maximum-vPID->minimum)*(*vPID->pSV)/(float)100.0+vPID->minimum;
}
else
{
vPID->setpoint=*vPID->pSV;
}
}
thisError=vPID->setpoint-(*vPID->pPV); //得到偏差值
result=vPID->result;
if (fabsf(thisError)>vPID->deadband)
{
pError=thisError-vPID->lasterror;
iError=(thisError+vPID->lasterror)/(float)2.0;
dError=thisError-2*(vPID->lasterror)+vPID->preerror;
//Variable integral coefficient to obtain
factor=VariableIntegralCoefficient(thisError,vPID->errorabsmax,vPID->errorabsmin);
//Calculate the differential item of incremental with incomplete differential
vPID->deltadiff=kd*(1-vPID->alpha)*dError+vPID->alpha*vPID->deltadiff;
increment=kp*pError+ki*factor*iError+vPID->deltadiff; //增量计算
}
else
{
if((fabsf(vPID->setpoint-vPID->minimum)<vPID->deadband)&&(fabsf((*vPID->pPV)-vPID->minimum)<vPID->deadband))
{
result=vPID->minimum;
}
increment=0.0;
}
//The output change in
if(vPID->pac==PREVENT_ABRUPT_ENABLE)
{
increment=fabsf(increment)>fabsf(thisError)?thisError:increment;
}
//Positive and negative effects set
if(vPID->direct==DIRECT)
{
result=result+increment;
}
else
{
result=result-increment;
}
/*The output threshold,Avoid overshoot and integral saturation problem*/
if(result>=vPID->maximum)
{
result=vPID->maximum;
}
if(result<=vPID->minimum)
{
result=vPID->minimum;
}
vPID->preerror=vPID->lasterror; //存放偏差用于下次运算
vPID->lasterror=thisError;
vPID->result=result;
vPID->output=(vPID->result-vPID->minimum)/(vPID->maximum-vPID->minimum)*(float)100.0;
*vPID->pMV=vPID->output;
}
}
Here we are going to set data smoothing step value according to the range of a fixed proportion,But in fact set data smoothing step value should be adjusted according to the sampling period.And also in different controlled system should make appropriate adjust.While the output against the abrupt change of the threshold we adopted deviation.
4、总结
在这一篇中,We analyzed the several reasons cause overshoot and think about their coping strategies.依据这些,我们改进了PIDController makes it have the overshoot the basic function of.We actually used in the temperature control and flow control improvedPID控制器,The overshoot of the inhibitory effect was very obvious.But it should be pointed out that if the value of smooth step value is set too small or the output increment of limiting threshold teenager will make the adjustment process is very slow.
In general as temperature、Level lags behind relatively large system such as using set data smoothing will have a good effect,While increasing output increment limiter may adjust slowly.而流量、Pressure lags behind relatively small system such as using the output increment limit will have a good effect,Increased value is smooth likely yes adjustment becomes slow.
Finally, we simply say it's just the matter of the adjustment cycle.The choice of adjustment cycle is an issue that needs careful consideration.Even if we use the same parameter setting,Use the same against overshoot processing,When the adjustment cycle is not at the same time,Effect may have bigger difference,So adjust the cycle must be sure good.一般来说,Lag of system adjustment cycle need to set up a bit longer,And small lag system regulating cycles need to set up a bit short,Also need according to the specific requirements to set up.
欢迎关注:
边栏推荐
猜你喜欢
祝福一路顺风
【模拟面试-10年工作】项目多一定是优势吗?
Pytest learning - fixtures
[Mock Interview - 10 Years of Work] Are more projects an advantage?
【3D建模制作技巧分享】ZBrush纹理贴图怎么导入
Deep Learning RNN Architecture Analysis
赶紧进来!!!教你C语言实现扫雷小游戏(文章最后有源码!!!)
备战9月,美团50道软件测试经典面试题及答案汇总
地面高度检测/平面提取与检测(Fast Plane Extraction in Organized Point Clouds Using Agglomerative Hierarchical Clu)
BUG | The interface returns abnormal data
随机推荐
Jbpm3.2 开发HelloWorld (简单请假流程)客户端
2022/8/4 树上差分+线段树
【3D建模制作技巧分享】如何使用ZBrush导出效果图
应用联合、体系化推进。集团型化工企业数字化转型路径
【项目实战】仿照Room实现简单管理系统
Latex快速插入作者ORCID
The Record of Reminding myself
【3D建模制作技巧分享】ZBrush纹理贴图怎么导入
Pytest learning - fixtures
线上虚拟展馆展示具有哪些优势
测试薪资这么高?刚毕业20K,仅需3.5个月
现在学习次世代3D游戏建模还能找到高薪好工作吗
PAN3020 Sub-1G无线收发芯片
字节跳动秋招提前批高频面试问题汇总!(内附答案!)
后排乘客不系安全带?事故瞬间被甩出
单片机原理[一] 学好单片机必会的五张图
【2020】【Paper Notes】Metasurfaces: Multifunctional and Programmable——
Since a new byte of 20K came out, I have seen what the ceiling is
湖仓一体电商项目(五):内网穿透工具-网云穿
Service Mesh落地路径