PID:我應該什麼時候計算積分項?

  最近看到了Brett Beauregard發表的有關PID的系列文章,感受對於理解PID算法頗有幫助,因而將系列文章翻譯過來!在自我提升的過程當中,也但願對同道中人有所幫助。做者Brett Beauregard的原文網址:http://brettbeauregard.com/blog/2011/07/pid-when-should-i-compute-the-integral-term/算法

 

  最近有一個建議張貼到初學者的PID系列。爭議的焦點是,若是您解決拉普拉斯域中的問題,它指定了執行積分項的不一樣方式。評論人士建議,與其看某一點的偏差總和,不如看最後一個點的總和。性能

  所以,當前的代碼是這樣的:測試

 1 /*Compute all the working error variables*/
 2 double input = *myInput;
 3 double error = *mySetpoint - input;
 4 ITerm+= (ki * error);
 5 if(ITerm > outMax) ITerm= outMax;
 6 else if(ITerm < outMin) ITerm= outMin;
 7 double dInput = (input - lastInput);
 8  
 9 /*Compute PID Output*/
10 double output = kp * error + ITerm- kd * dInput;

  建議是這樣的:spa

 1 /*Compute all the working error variables*/
 2 double input = *myInput;
 3 double error = *mySetpoint - input;
 4  
 5 double dInput = (input - lastInput);
 6  
 7 /*Compute PID Output*/
 8 double output = kp * error + ITerm- kd * dInput;
 9  
10 ITerm+= (ki * error);
11 if(ITerm > outMax) ITerm= outMax;
12 else if(ITerm < outMin) ITerm= outMin;

  我從未見過這樣作,但我想我應該試一試。我設計的測試是一個簡單的設定值階躍,而後是一個斜坡降低。翻譯

 

  當控制器設置爲默認的採樣時間時,差別是沒法察覺的。爲了突出這兩種方法之間的差別,我決定將PID採樣時間從默認值100mS提升到5秒。設計

 

  這裏咱們能夠看到一個明顯的贏家。現有的PID代碼的性能比建議的要好,這多是由於積分項對進程更改的響應要早5秒。可是爲了確保我沒有遺漏任何東西,我決定再作一次測試。我沒有改變設定值,而是在系統中引入了負載變化。code

 

  一樣,現有的 PID 代碼性能更好,處理負載變化更快。blog

  那麼判決呢?雖然這是一個有趣的鍛鍊,但我認爲結果很清楚。我會保持原來的代碼。進程

歡迎關注:get

相關文章
相關標籤/搜索