48 "Sends the output of the PIDController. This is known as manipulated"
49 " variable (MV) in control theory. This should be fed into the process"
50 " which we are trying to control.");
57 "Handle process calls.",
60 "Reinitialize the object.",
62 static Finfo* processShared[] = {
67 "This is the proportional gain (Kp). This tuning parameter scales the"
68 " proportional term. Larger gain usually results in faster response, but"
69 " too much will lead to instability and oscillation.",
73 "Bound on the permissible range of output. Defaults to maximum double"
78 "The command (desired) value of the sensed parameter. In control theory"
79 " this is commonly known as setpoint(SP).",
83 "Sensed (measured) value. This is commonly known as process variable"
84 "(PV) in control theory.",
87 "The integration time constant, typically = dt. This is actually"
88 " proportional gain divided by integral gain (Kp/Ki)). Larger Ki"
89 " (smaller tauI) usually leads to fast elimination of steady state"
90 " errors at the cost of larger overshoot.",
94 "The differentiation time constant, typically = dt / 4. This is"
95 " derivative gain (Kd) times proportional gain (Kp). Larger Kd (tauD)"
96 " decreases overshoot at the cost of slowing down transient response"
97 " and may lead to instability.",
101 "Output of the PIDController. This is given by:"
102 " gain * ( error + INTEGRAL[ error dt ] / tau_i + tau_d * d(error)/dt )\n"
103 "Where gain = proportional gain (Kp), tau_i = integral gain (Kp/Ki) and"
104 " tau_d = derivative gain (Kd/Kp). In control theory this is also known"
105 " as the manipulated variable (MV)",
108 "The error term, which is the difference between command and sensed"
112 "The integral term. It is calculated as INTEGRAL(error dt) ="
113 " previous_integral + dt * (error + e_previous)/2.",
116 "The derivative term. This is (error - e_previous)/dt.",
119 "The error term for previous step.",
122 "Command (desired value) input. This is known as setpoint (SP) in"
126 "Sensed parameter - this is the one to be tuned. This is known as"
127 " process variable (PV) in control theory. This comes from the process"
128 " we are trying to control.",
131 "Destination message to control the PIDController gain dynamically.",
134 "This is a shared message to receive Process messages "
135 "from the scheduler objects."
136 "The first entry in the shared msg is a MsgDest "
137 "for the Process operation. It has a single argument, "
138 "ProcInfo, which holds lots of information about current "
139 "time, thread, dt and so on. The second entry is a MsgDest "
140 "for the Reinit operation. It also uses ProcInfo. ",
141 processShared,
sizeof( processShared ) /
sizeof(
Finfo* )
145 static Finfo* pidFinfos[] = {
163 static string doc[] = {
164 "Name",
"PIDController",
165 "Author",
"Subhasis Ray",
166 "Description",
"PID feedback controller."
167 "PID stands for Proportional-Integral-Derivative. It is used to"
168 " feedback control dynamical systems. It tries to create a feedback"
169 " output such that the sensed (measured) parameter is held at command"
170 " value. Refer to wikipedia (http://wikipedia.org) for details on PID"
177 sizeof( pidFinfos ) /
sizeof(
Finfo* ),
180 sizeof(doc)/
sizeof(
string));
188 saturation_(DBL_MAX),
259 if (saturation <= 0) {
260 cout <<
"Error: PIDController::setSaturation - saturation must be positive." << endl;
293 double dt = proc->
dt;
void reinit(const Eref &e, ProcPtr process)
double getEDerivative() const
double getCommand() const
double getEPrevious() const
void setSensed(double sensed)
double getEIntegral() const
void setGain(double gain)
void process(const Eref &e, ProcPtr process)
double getSaturation() const
void setTauD(double tau_d)
static const Cinfo * initCinfo()
void setCommand(double command)
static const Cinfo * pidCinfo
static const Cinfo * initCinfo()
static SrcFinfo1< double > * outputOut()
void setSaturation(double saturation)
void setTauI(double tau_i)