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.

Member Functions

Name

Description

PID [constructor]

Constructors

operator()

Function call operators

Data Members

Name

Description

ACTUAL

The current measured process variable (feedback).

KP

Proportional gain. Acts as the conversion multiplier from ProcessType to ControlType.

MAX_OUT

Maximum allowed output limit. If MIN_OUT >= MAX_OUT, limitation and anti‐windup are disabled.

MIN_OUT

Minimum allowed output limit. If MIN_OUT >= MAX_OUT, limitation and anti‐windup are disabled.

OUT

The computed control variable output.

RESET

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.

SETPOINT

The target setpoint value.

TN

Integral time / Reset time (Tn). Determines how fast the integral action duplicates the proportional action.

TV

Derivative time / Rate time (Tv). Determines how far the derivative action looks ahead.

Created with MrDocs