亚洲春色中文字幕久久久-三上亚,一吻二脱三床四吻胸,国产真实伦对白视频全集,在线毛片观看,精品成品入口黄网,国产毛aⅴ片久久久,亚洲AV色香蕉一区二区三区老师,萧皇后A级艳片,色情日本视频更新,99久久亚洲精品日本无码

專注電子技術學習與研究
當前位置:單片機教程網 >> MCU設計實例 >> 瀏覽文章

外置式與增量式PID模板程序(51單片機c語言)

作者:huqin   來源:本站原創   點擊數:  更新時間:2014年11月11日   【字體:

外置式PID模板

#define MuBiaoCS 0 //目標常數
#define CHang_aCS 0 //比例常數
#define CHang_bCS 0 //積分常數
#define CHang_cCS 0 //微分常數
/*******************************************************************************************/
struct P_I_D {
int MuBiao; //設定目標 Desired Value
double CHang_a; //比例常數 Proportional Const
double CHang_b; //積分常數 Integral Const
double CHang_c; //微分常數 Derivative Const
int Error1; //Error[-1]
int Error2; //Error[-2]
}Pidn;
struct P_I_D *PID=&Pidn;
/********************************************************************************************/
void Pidinit(void) //pid初始化
{
PID->MuBiao=MuBiaoCS;
PID->CHang_a=CHang_aCS;
PID->CHang_b=CHang_bCS;
PID->CHang_c=CHang_cCS;
PID->Error1=0;
PID->Error2=0;
}

int PID_WZ(int SRuu) //位置式PID
{
int Error0,SCuu;
Error0 = PID->MuBiao - SRuu;
PID->Error1+=Error0;
SCuu = PID->CHang_a*Error0 //比例項
+ PID->CHang_b*PID->Error1 //積分項
+ PID->CHang_c*(Error0-PID->Error2);//微分項
PID->Error2=Error0;
return SCuu;
}
void main(void)
{
Pidinit();
}

增量式PID模板

#define MuBiaoCS 0 //目標常數
#define CHang_aCS 0 //比例常數
#define CHang_bCS 0 //積分常數
#define CHang_cCS 0 //微分常數
/*******************************************************************************************/
struct P_I_D {
int MuBiao; //設定目標 Desired Value
double CHang_a; //比例常數 Proportional Const
double CHang_b; //積分常數 Integral Const
double CHang_c; //微分常數 Derivative Const
int Error1; //Error[-1]
int Error2; //Error[-2]
}Pidn;
struct P_I_D *PID=&Pidn;
/********************************************************************************************/
void Pidinit(void) //pid初始化
{
PID->MuBiao=MuBiaoCS;
PID->CHang_a=CHang_aCS;
PID->CHang_b=CHang_bCS;
PID->CHang_c=CHang_cCS;
PID->Error1=0;
PID->Error2=0;
}

int PID_WC(int SRuu) //增量式PID
{
int Error0,SCuu;
Error0 = PID->MuBiao - SRuu; //偏差
SCuu = PID->CHang_a*Error0 //Error項
- PID->CHang_b*PID->Error1 //Error1項
+ PID->CHang_c*PID->Error2; //Error2項
PID->Error2=PID->Error1; //將上次偏差存PID->Error2
PID->Error1=Error0; //將這次偏差存PID->Error1
return SCuu;
}

void main(void)
{
Pidinit();
}
 

 

關閉窗口

相關文章