adapnex::core::PID
A Proportional‐Integral‐Derivative (PID) controller in the Standard (Ideal/ISA) form.
Synopsis
Declared in <adapnex/core/pid.h>
template<
typename ProcessType = double,
typename ControlType = ProcessType,
typename KpType = decltype(ControlType{} / ProcessType{})>
class PID;
Description
A PID controller continuously calculates an error value as the difference between a desired setpoint and a measured process variable. It applies a correction based on proportional, integral, and derivative terms:
-
P (Proportional) accounts for present values of the error.
-
I (Integral) accounts for past values of the error.
-
D (Derivative) accounts for possible future trends of the error based on its rate of change.
|
If limits are provided (MIN_OUT < MAX_OUT), the controller uses Integral Back‐Calculation (Anti‐Windup). The integral part will be automatically adapted as if the history of the input values had naturally produced the limited output value. To disable limitation and anti‐windup, set MIN_OUT >= MAX_OUT. |
|
The integral part can be disabled by setting TN to 0. The derivative part can be disabled by setting TV to 0. |
|
Non‐finite inputs are handled gracefully. If the controller cannot be meaningfully calculated on a cycle (KP is zero or not finite, or ACTUAL or SETPOINT is NaN), it holds the previous OUT and leaves its internal state untouched, resuming cleanly once the inputs are valid again. An infinite ACTUAL or SETPOINT is a supported value that saturates OUT to the corresponding limit. A non‐finite limit (Inf or NaN) leaves that bound unbounded. |
Member Functions
Name |
Description |
|
Constructors |
Function call operators |
Data Members
Name |
Description |
The current measured process variable (feedback). A NaN value (e.g. a momentary sensor dropout) holds the previous OUT for that cycle and resumes once it clears. An infinite value drives OUT to saturation. |
|
Proportional gain. Acts as the conversion multiplier from ProcessType to ControlType. Must be finite and non‐zero. A zero or non‐finite KP holds the previous OUT for that cycle and the internal state is not updated. |
|
Maximum allowed output limit. If MIN_OUT >= MAX_OUT, limitation and anti‐windup are disabled. A non‐finite value (+infinity or NaN) leaves the upper bound unbounded while keeping any valid lower limit active. |
|
Minimum allowed output limit. If MIN_OUT >= MAX_OUT, limitation and anti‐windup are disabled. A non‐finite value (‐infinity or NaN) leaves the lower bound unbounded while keeping any valid upper limit active. |
|
The computed control variable output. |
|
When true, re‐initializes the controller on this cycle: the internal error history (integral and previous error) is cleared and timing is re‐armed. Level‐sensitive, like the other inputs. |
|
The target setpoint value. An infinite value is supported and drives OUT to saturation. A NaN value holds the previous OUT for that cycle. |
|
Integral time / Reset time (Tn). Determines how fast the integral action duplicates the proportional action. Setting TN to 0 disables the integral part. |
|
Derivative time / Rate time (Tv). Determines how far the derivative action looks ahead. Setting TV to 0 disables the derivative part. |
Created with MrDocs