Controlpp
Loading...
Searching...
No Matches
controlpp::timevar::IAntiWindup< T > Class Template Reference

An I (integrating) controller with anti windup protection (rate and value limits), with varying smaple-time. More...

#include <controlpp/TimeVariantControl.hpp>

Public Types

using value_type = T
 

Public Member Functions

constexpr IAntiWindup (const T &ki, const T &min, const T &max, const T &vn=std::numeric_limits< T >::lowest(), const T &vp=std::numeric_limits< T >::max())
 Constructs an I (Integrator) controller with anti-windup controller.
 
constexpr IAntiWindup (const IAntiWindup &)=default
 Default copy constructor.
 
constexpr void set_param (const T &ki)
 Sets the integrator gain.
 
constexpr void prate_limit (const T &pv)
 Sets the positive rate limit of the I controller.
 
constexpr const T & prate_limit () const
 returns the positive rate limit
 
constexpr void nrate_limit (const T &nv)
 Sets the negative rate limit of the I controller.
 
constexpr const T & nrate_limit () const
 returns the negative rate limit
 
constexpr void max_limit (const T &max)
 Sets the maximal value limit.
 
constexpr const T & max_limit () const
 returns the maximal value limit
 
constexpr void min_limit (const T &min)
 Sets the minimal value limit.
 
constexpr const T & min_limit () const
 returns the minimal value limit
 
constexpr void reset ()
 resets (clears) the internal states
 
constexpr T input (const T &u, const T &Ts)
 Adds a new value input and sample time to calculate the next output.
 
constexpr T operator() (const T &u, const T &Ts)
 Adds a new value input and sample time to calculate the next output.
 

Friends

constexpr ValueSampletimePair< T > operator>> (const ValueSampletimePair< T > &p, IAntiWindup &c)
 

Detailed Description

template<class T>
class controlpp::timevar::IAntiWindup< T >

An I (integrating) controller with anti windup protection (rate and value limits), with varying smaple-time.

Anti-windup prevents the controller’s integrator from accumulating excessive error when the actuator cannot keep up with the commanded output. Without anti-windup protection, the integrator continues to grow—even though the actuator is saturated and unable to reflect these changes—resulting in increasingly unrealistic control signals. Once the system reaches its target, the controller must then "unwind" or de-integrate the surplus error, which leads to a delayed response and potential overshoot. Anti-windup mitigates this by limiting or adjusting the integrator during saturation, improving stability and responsiveness.

Its an I controller with a transfer function like:

\[ I(s) = \frac{k_i}{s} \]

discretised with the tustin transformation:

\[ s = \frac{2}{T_s} \frac{1 - z^{-1}}{1 + z^{-1}} \]

but with a conditional time-series:

\[ y_k = \begin{cases} \if y_k > max \text{ then } max \\ \if y_k < min \text{ then } max \\ \if \frac{y_k - y_{k-1}}{Ts} > v_p \text{ then } v_p * Ts \\ \if \frac{y_k - y_{k-1}}{Ts} < v_n \text{ then } v_n * Ts \\ \text{else } \frac{k_i T_s}{2} \left( u_k + u_{k-1} \right) + y_{k-1} \end{cases} \]

where:

  • \(k_i\) is the integrator gain
  • \(T_s\) is the sample-time in seconds
  • \(u_k\) and \(u_{k-1}\) are the current and previous control inputs
  • \(y_k\) and \(y_{k-1}\) are the current and previous control outputs
  • \(max\) is the maximal output clamp at which positive integration stops
  • \(min\) is the minimal outpout clamp at which negative integration stops
  • \(v_p\) is the positive rate output speed clamp. (Limits integration speed)
  • \(v_n\) is the negative rate output speed clamp. (Limits integration speed)
Template Parameters
Tthe data type the controller uses, like float or double
See also
controlpp::I

Member Typedef Documentation

◆ value_type

template<class T >
using controlpp::timevar::IAntiWindup< T >::value_type = T

Constructor & Destructor Documentation

◆ IAntiWindup() [1/2]

template<class T >
constexpr controlpp::timevar::IAntiWindup< T >::IAntiWindup ( const T &  ki,
const T &  min,
const T &  max,
const T &  vn = std::numeric_limits<T>::lowest(),
const T &  vp = std::numeric_limits<T>::max() 
)
inlineconstexpr

Constructs an I (Integrator) controller with anti-windup controller.

Parameters
kiThe integrator constant. Assumes: \(k_i > 0\)
vnThe maximal negaive velocity of the output. Assumes: \(v_n < 0 < v_p\)
vpThe maximal positive velocity of the output. Assumes: \(v_n < 0 < v_p\)
maxThe maximal output value. Assumes: \(min < max\)
minThe minimal output value. Assumes: \(min < max\)

◆ IAntiWindup() [2/2]

template<class T >
constexpr controlpp::timevar::IAntiWindup< T >::IAntiWindup ( const IAntiWindup< T > &  )
constexprdefault

Default copy constructor.

Member Function Documentation

◆ input()

template<class T >
constexpr T controlpp::timevar::IAntiWindup< T >::input ( const T &  u,
const T &  Ts 
)
inlineconstexpr

Adds a new value input and sample time to calculate the next output.

Also advances the internal states

Returns
The control output

◆ max_limit() [1/2]

template<class T >
constexpr const T & controlpp::timevar::IAntiWindup< T >::max_limit ( ) const
inlineconstexpr

returns the maximal value limit

◆ max_limit() [2/2]

template<class T >
constexpr void controlpp::timevar::IAntiWindup< T >::max_limit ( const T &  max)
inlineconstexpr

Sets the maximal value limit.

Parameters
maxThe new maximal value limit

◆ min_limit() [1/2]

template<class T >
constexpr const T & controlpp::timevar::IAntiWindup< T >::min_limit ( ) const
inlineconstexpr

returns the minimal value limit

◆ min_limit() [2/2]

template<class T >
constexpr void controlpp::timevar::IAntiWindup< T >::min_limit ( const T &  min)
inlineconstexpr

Sets the minimal value limit.

Parameters
minThe new minimal value limit

◆ nrate_limit() [1/2]

template<class T >
constexpr const T & controlpp::timevar::IAntiWindup< T >::nrate_limit ( ) const
inlineconstexpr

returns the negative rate limit

◆ nrate_limit() [2/2]

template<class T >
constexpr void controlpp::timevar::IAntiWindup< T >::nrate_limit ( const T &  nv)
inlineconstexpr

Sets the negative rate limit of the I controller.

Parameters
nvThe new negative rate limit

◆ operator()()

template<class T >
constexpr T controlpp::timevar::IAntiWindup< T >::operator() ( const T &  u,
const T &  Ts 
)
inlineconstexpr

Adds a new value input and sample time to calculate the next output.

Also advances the internal states

Returns
The control output
See also
controlpp::I::input(const T& u, const T& Ts)

◆ prate_limit() [1/2]

template<class T >
constexpr const T & controlpp::timevar::IAntiWindup< T >::prate_limit ( ) const
inlineconstexpr

returns the positive rate limit

◆ prate_limit() [2/2]

template<class T >
constexpr void controlpp::timevar::IAntiWindup< T >::prate_limit ( const T &  pv)
inlineconstexpr

Sets the positive rate limit of the I controller.

Parameters
pvThe new positive rate limit

◆ reset()

template<class T >
constexpr void controlpp::timevar::IAntiWindup< T >::reset ( )
inlineconstexpr

resets (clears) the internal states

resets the internal states to zero

Parameters
u_k1The previous input u
y_k1The previous output y

◆ set_param()

template<class T >
constexpr void controlpp::timevar::IAntiWindup< T >::set_param ( const T &  ki)
inlineconstexpr

Sets the integrator gain.

Parameters
kiThe integrator gain for the next sample;

Friends And Related Symbol Documentation

◆ operator>>

template<class T >
constexpr ValueSampletimePair< T > operator>> ( const ValueSampletimePair< T > &  p,
IAntiWindup< T > &  c 
)
friend

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