欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136

 找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 3193|回復: 1
收起左側

求助模糊PID控制如何在stm32中實現

[復制鏈接]
ID:262876 發表于 2017-12-17 21:51 | 顯示全部樓層 |閱讀模式
有哪位大神知道模糊PID控制如何在stm32中實現嗎???求告知。。。
回復

使用道具 舉報

ID:155507 發表于 2017-12-18 17:35 | 顯示全部樓層
  1. //======================================================================
  2. //Adjust these three factor ,to achieve the best control effect
  3. //P:1~10之間 I:0-5之間 D:0.1~1
  4. float P_Coefficient=4.75;
  5. float I_Coefficient=0.55;
  6. float D_Coefficient=0.2;
  7. #define Diff_Order 4 /* Differential order*/
  8. int Temp,DestTemp,HeatPower;
  9. int Set_Distant;
  10. long int Integral=5; // Points accumulated
  11. float Prev_Error[10]; // Record ten times before the error
  12. float P,I,D;
  13. float Ek,E;
  14. unsigned char FirstFlag=1;
  15. /*******************************************************************************
  16. * Funtion name:PID Control
  17. * Time:2013/3/5
  18. * Author:zhuhao
  19. *******************************************************************************/
  20. float PID_Control(float Error)
  21. {
  22.         int i;
  23.         float Output;
  24.         float Ture;
  25.         if(FirstFlag)//The first execution
  26.         {
  27.                 FirstFlag=0;
  28.                 for(i=0;i<10;i++)
  29.                 Prev_Error=Error;
  30.         }
  31.         for(i=0;i<10;i++)
  32.         Prev_Error[i+1]=Prev_Error;// Buffer queue
  33.         Prev_Error[0]=Error;//
  34.         Ek=Error-Prev_Error[Diff_Order];//
  35.         E=0.8+Ek*0.2;//IIR
  36.         P=P_Coefficient*Error;// Calculate the proportional component
  37.         I=I_Coefficient*Integral;// Calculate the integral component
  38.         D=D_Coefficient*E;//Calculate the derivative component
  39.         Output=(P+I+D);
  40.         if(Output>0)
  41.         {
  42.                 Ture=Output;
  43.         }
  44.         if(Output>=100||Output<=0||Error<-40||Error>40)//Saturated or large deviation integral
  45.         {
  46.                 if(Integral>0&&Error<0)
  47.                 Integral+=Error;
  48.                 if(Integral<0&&Error>0)
  49.                 Integral+=Error;
  50.         }
  51.         else
  52.         Integral+=Error;
  53.         if(Integral<-10) Integral=-10;
  54.         if(Integral>10) Integral=10;
  55.         if (Output>=100)
  56.         Output=99;
  57.         else if(Output<=0)
  58.         Output=Ture;
  59.         return Output;
  60. }

復制代碼



初次調試速度PID全過程(分享PID函數)
http://m.raoushi.com/bbs/dpj-42514-1.html
回復

使用道具 舉報

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規則

小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術交流QQ群281945664

Powered by 單片機教程網

快速回復 返回頂部 返回列表