Dlloydev / QuickPID

A fast PID controller with multiple options. Various Integral anti-windup, Proportional, Derivative and timer control modes.
MIT License
195 stars 50 forks source link

Expose outputSum for monitoring and userspace anti-windup #65

Closed drf5n closed 1 year ago

drf5n commented 1 year ago

This PR moves the outputSum variable from public to private.

While the same functionality might be provided by a GetIntegral() and SetIntegral(value) or a user-space myPID.SetMode(myPID.Control::manual);Output=value;myPID.SetMode(myPID.Control::automatic); trick, moving the variable up to Public is a minimal change.

Why I think it is an important change is it helps for understanding the trickiest parts of PIDs: the behavior of the integral term. Good explanations of the functionality of PIDs often include graphs of the behavior of the components. Without access to the internal outputSum, it is impossible to see what is going on in the black box.

I've been experimenting with simulating a 1-D heat transfer problem controlled by a PID:

https://wokwi.com/projects/359818835102393345

image

Note that it shows the exposed integral on the LCD and the time-series, which I think is very helpful for understanding the interactions of the tuning parameters.

Dlloydev commented 1 year ago

Very nice simulation setup! Thanks for your recent comments and suggestions. I agree with your suggestions, but I hope to get some time later today (but probably tomorrow) to have a closer look .

drf5n commented 1 year ago

Thanks. I updated the simulator at https://wokwi.com/projects/359818835102393345 to use your current version unmodified.

The current version doesn't seem to have migrated into the Arduino Library system yet, but should soon.

Dlloydev commented 1 year ago

Oh, I only pushed the updates ... I'll create a new version shortly (QuickPID 3.1.5) and tag so Arduino can migrate it.