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

QuickPID::Initialize() is not public #67

Closed drf5n closed 1 year ago

drf5n commented 1 year ago

On https://github.com/Dlloydev/QuickPID#initialize the README.md highlights the QuickPID::Initialize() function, which is a desirable feature for manual control and tweaking the controller.

https://github.com/Dlloydev/QuickPID/blob/6adfc2c6a8245c36286bebe59dacd11971daaa88/README.md?plain=1#L56-L61

Commercial controllers have a Manual/Auto switch that is often toggled twice to reset things as they are. If the process is oscillating, you can toggle to manual and back, and it often calms the oscillation. The QuickPID::Initialize function would be helpful for this, although the existing user-space workaround of toggling to manual, and back to automatic also works:

myPID.SetMode(myPID.Control::manual);
myPID.SetMode(myPID.Control::automatic);

One interesting use of Initialize() is when using QuickPID as a P-only controller, after the process has approached the setpoint, settling down at some offset, you could Initialize() (or toggle manual-auto) at that point and the controller will use that output level as a new baseline, copying it into the outputSum integral and making it easier for the proportional term to push the residual error down towards zero.

Please move the Initialize() function from private to public so it matches the README.md documentation.