br3ttb / Arduino-PID-Library

1.93k stars 1.11k forks source link

P_ON_M functionality doesn't seem to do what it's supposed to - same as D #106

Closed louis-potvin closed 4 years ago

louis-potvin commented 4 years ago

Hi,

Looking at Brett's blog about Proportional on Measurement, I see that when used, the gain induced by Kp should be Kp[input(t)-input(init). However, looking at the code, it seems it's actually not doing that, but rather having the same effect as Kd:

Kp Gain: if(!pOnE) outputSum-= kp * dInput;

Kd Gain: output += outputSum - kd * dInput;

Really appreciate if someone could tell me what I'm missing, or if there is indeed a discrepancy between the code and the blog, and in that case, which is right :)

Thanks!

br3ttb commented 4 years ago

take a look at the next post: http://brettbeauregard.com/blog/2017/06/proportional-on-measurement-the-code/

On Sun, Oct 4, 2020, 3:18 PM louis-potvin notifications@github.com wrote:

Hi,

Looking at Brett's blog about Proportional on Measurement http://brettbeauregard.com/blog/2017/06/introducing-proportional-on-measurement/, I see that when used, the gain induced by Kp should be Kp[input(t)-input(init). However, looking at the code, it seems it's actually not doing that, but rather having the same effect as Kd:

Kp Gain: if(!pOnE) outputSum-= kp * dInput;

Kd Gain: output += outputSum - kd * dInput;

Really appreciate if someone could tell me what I'm missing, or if there is indeed a discrepancy between the code and the blog, and in that case, which is right :)

Thanks!

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/br3ttb/Arduino-PID-Library/issues/106, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACYX4XVGDV5ITC246M6TN3SJDC65ANCNFSM4SD4NCJA .

louis-potvin commented 4 years ago

Thanks for the quick reply Brett. I realize I fundamentally missed the part where the gain of Kp goes in outputSum and therefore is "memorized" between iterations, whereas the gain of Kd does not.

And thanks for the library!