FhSim  3.1.0
Marine systems simulation
Loading...
Searching...
No Matches
PidWithExternalState Class Reference

PID controller for use inside a SimObject, whose integral is a state that FhSim integrates. More...

#include <PidWithExternalState.h>

Public Member Functions

void Initialize (double P, double I, double D, double minOut, double maxOut)
 
double Output (double error, double integratedError, double time) const
 The bounded controller output for error, the integrated error and the time.
 
double IntegralRate (double error, double integratedError) const
 The rate of the integral state: the error, or zero while the integral part alone is past a bound (anti-windup).
 
void Accept (double error, double time)
 Stores the error of an accepted step for the derivative part.
 

Detailed Description

Out = bound(-(P e + I integral(e) + D de/dt), MinOut, MaxOut). The owner adds one state for the integral, sets its derivative to IntegralRate(), and calls Accept() from AcceptedStep() so that the derivative part differences against the last accepted error.

Usage

controller.Initialize(P, I, D, minOut, maxOut);
// OdeFcn and output ports (const):
out = controller.Output(error, X[integralState], T);
XDot[integralState] = controller.IntegralRate(error, X[integralState]);
// AcceptedStep:
controller.Accept(error, T);

The documentation for this class was generated from the following file: