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

          新聞中心

          EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > PID算法調(diào)節(jié)C51程序(4)

          PID算法調(diào)節(jié)C51程序(4)

          作者: 時(shí)間:2016-11-23 來源:網(wǎng)絡(luò) 收藏
          typedef struct PID
          {
          double SetPoint; // Desired Value

          double Proportion; // Proportional Const
          double Integral; // Integral Const
          double Derivative; // Derivative Const

          double LastError; // Error[-1]
          double PrevError; // Error[-2]
          double SumError; // Sums of Errors
          } PID;



          double PIDCalc ( PID *pp, double NextPoint )

          { double dError, Error;

          pp->SumError += (Error = pp->SetPoint - NextPoint);
          dError = pp->LastError - pp->PrevError;
          pp->PrevError = pp->LastError;
          pp->LastError = Error;
          return ( pp->Proportion * Error
          + pp->Integral * pp->SumError
          + pp->Derivative * dError
          );
          }



          void PIDInit ( PID *pp )

          { memset ( pp,0,sizeof(PID) );
          }



          double sensor ( void ) // Dummy Sensor Function
          { return 100.0;
          }

          void actuator ( double rDelta ) // Dummy Actuator Function
          {}

          void main ( void )
          { PID sPID; // PID Control Structure
          double rOut; // PID Response (Output)
          double rIn; // PID Feedback (Input)

          PIDInit ( &sPID ); // Initialize Structure
          sPID.Proportion = 0.5; // Set PID Coefficients
          sPID.Integral = 0.5;
          sPID.Derivative = 0.0;
          sPID.SetPoint = 100.0; // Set PID Setpoint

          for (;;) // Mock Up of PID Processing
          { rIn = sensor (); // Read Input
          rOut = PIDCalc ( &sPID,rIn ); // Perform PID Interation
          actuator ( rOut ); // Effect Needed Changes
          }
          }


          評論


          技術(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); })();