|
FhSim
3.1.0
Marine systems simulation
|
PID controller for use inside a SimObject, whose integral is a state that FhSim integrates. More...
#include <PidWithExternalState.h>
Public Member Functions | |
| void | Initialize (const PidSettings &settings) |
| double | Output (double error, double integratedError, double time) const |
| double | IntegralRate (double error, double integratedError) const |
| The rate of the integral state: the error, or zero while the integral part is past a bound (anti-windup). | |
| void | Accept (double error, double time) |
| Stores the error of an accepted step and updates the held derivative from the previous one. | |
Out = bound(-P e + (InitOutput - I integral(e)) + bound(-D de/dt, MaxDerivativePart), MinOut, MaxOut). The owner adds one state for the integral, sets its derivative to IntegralRate(), and calls Accept() from AcceptedStep(). The derivative de/dt is the rate between the last two accepted errors, held until the next accepted step (zero until two steps are accepted), so the output depends on the state and the accepted history only, never on where in a step it is evaluated.
Anti-windup: the integral freezes while the integral part is past the tighter of MaxIntegratorPart and the output bounds, and the error would drive it further out. The direction takes the sign of I.
| double PidWithExternalState::Output | ( | double | error, |
| double | integratedError, | ||
| double | time | ||
| ) | const |
The bounded controller output for error and the integrated error. time is unused: the derivative part is held from the accepted steps.