pid-controller-server icon indicating copy to clipboard operation
pid-controller-server copied to clipboard

Incorrect implementation of differential error calculation

Open svenwanzenried opened this issue 2 years ago • 1 comments

Hi @ussserrr Thanks for sharing this neat library! I use it to control the temperature in an chamber I use for smoking meat. Now while implementing, I looked at your code and I think the calculation of the D error is not done correctly.

You are currently calculating the difference between the input and the last_input. But I think it should be the difference between the Perr and the last Perr. Because we want the D portion to react fast to jumps in the error value.

Do you agree?

svenwanzenried avatar Oct 02 '22 11:10 svenwanzenried

Hello! There are many variations of PID algos and implementations, each of them is tweaking some parameter to better suite some specific cases and show better performance on different machines. I believe you're talking about one of these formulas there. Anyway, it was some kind of student project for me long time ago already and I don't really recall such small quirks anymore :)

ussserrr avatar Oct 03 '22 12:10 ussserrr