<meter id="pryje"><nav id="pryje"><delect id="pryje"></delect></nav></meter>
          <label id="pryje"></label>

          新聞中心

          外置式PID程序模板

          作者: 時(shí)間:2016-12-01 來源:網(wǎng)絡(luò) 收藏
          外置式PID模板

          #define MuBiaoCS 0 //目標(biāo)常數(shù)
          #define CHang_aCS 0 //比例常數(shù)
          #define CHang_bCS 0 //積分常數(shù)
          #define CHang_cCS 0 //微分常數(shù)
          /*******************************************************************************************/
          struct P_I_D {
          int MuBiao; //設(shè)定目標(biāo) Desired Value
          double CHang_a; //比例常數(shù) Proportional Const
          double CHang_b; //積分常數(shù) Integral Const
          doubleCHang_c; //微分常數(shù) 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;
          }

          本文引用地址:http://www.ex-cimer.com/article/201612/324211.htm

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

          增量式PID模板

          #define MuBiaoCS 0 //目標(biāo)常數(shù)
          #define CHang_aCS 0 //比例常數(shù)
          #define CHang_bCS 0 //積分常數(shù)
          #define CHang_cCS 0 //微分常數(shù)
          /*******************************************************************************************/
          struct P_I_D {
          int MuBiao; //設(shè)定目標(biāo) Desired Value
          double CHang_a; //比例常數(shù) Proportional Const
          double CHang_b; //積分常數(shù) Integral Const
          doubleCHang_c; //微分常數(shù) 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項(xiàng)
          - PID->CHang_b*PID->Error1 //Error1項(xiàng)
          + PID->CHang_c*PID->Error2; //Error2項(xiàng)
          PID->Error2=PID->Error1; //將上次偏差存PID->Error2
          PID->Error1=Error0; //將這次偏差存PID->Error1
          return SCuu;
          }

          void main(void)
          {
          Pidinit();
          }



          關(guān)鍵詞: 外置式PID程序模

          評(píng)論


          技術(shù)專區(qū)

          關(guān)閉
          看屁屁www成人影院,亚洲人妻成人图片,亚洲精品成人午夜在线,日韩在线 欧美成人 (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })();