标题:
求助模糊PID控制如何在stm32中实现
[打印本页]
作者:
zmy0514
时间:
2017-12-17 21:51
标题:
求助模糊PID控制如何在stm32中实现
有哪位大神知道模糊PID控制如何在stm32中实现吗???求告知。。。
作者:
angmall
时间:
2017-12-18 17:35
//======================================================================
//Adjust these three factor ,to achieve the best control effect
//P:1~10之间 I:0-5之间 D:0.1~1
float P_Coefficient=4.75;
float I_Coefficient=0.55;
float D_Coefficient=0.2;
#define Diff_Order 4 /* Differential order*/
int Temp,DestTemp,HeatPower;
int Set_Distant;
long int Integral=5; // Points accumulated
float Prev_Error[10]; // Record ten times before the error
float P,I,D;
float Ek,E;
unsigned char FirstFlag=1;
/*******************************************************************************
* Funtion name:PID Control
* Time:2013/3/5
* Author:zhuhao
*******************************************************************************/
float PID_Control(float Error)
{
int i;
float Output;
float Ture;
if(FirstFlag)//The first execution
{
FirstFlag=0;
for(i=0;i<10;i++)
Prev_Error=Error;
}
for(i=0;i<10;i++)
Prev_Error[i+1]=Prev_Error;// Buffer queue
Prev_Error[0]=Error;//
Ek=Error-Prev_Error[Diff_Order];//
E=0.8+Ek*0.2;//IIR
P=P_Coefficient*Error;// Calculate the proportional component
I=I_Coefficient*Integral;// Calculate the integral component
D=D_Coefficient*E;//Calculate the derivative component
Output=(P+I+D);
if(Output>0)
{
Ture=Output;
}
if(Output>=100||Output<=0||Error<-40||Error>40)//Saturated or large deviation integral
{
if(Integral>0&&Error<0)
Integral+=Error;
if(Integral<0&&Error>0)
Integral+=Error;
}
else
Integral+=Error;
if(Integral<-10) Integral=-10;
if(Integral>10) Integral=10;
if (Output>=100)
Output=99;
else if(Output<=0)
Output=Ture;
return Output;
}
复制代码
初次调试速度PID全过程(分享PID函数)
http://www.51hei.com/bbs/dpj-42514-1.html
欢迎光临 (http://www.51hei.com/bbs/)
Powered by Discuz! X3.1