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

A PID (proportional + integral + differential) controller with variable sample-times. More...

#include <controlpp/TimeVariantControl.hpp>

Public Member Functions

 PIDControl (const T &kp, const T &ki, const T &kd, const T &omega)
 constructs a PID controller form gain parameters
 
constexpr T input (const T &u, const T &Ts)
 Input a new sample to the controller.
 
constexpr T operator() (const T &u, const T &Ts)
 resets (clears) the internal states resets the internal states ( \(u_{k-1}\), \(u_{k-2}\), \(y_{k-1}\) and \(y_{k-2}\)) to zero
 
constexpr void reset ()
 resets (clears) the internal states resets the internal states ( \(u_{k-1}\), \(u_{k-2}\), \(y_{k-1}\) and \(y_{k-2}\)) to zero
 

Static Public Member Functions

static PIDControl from_alpha_tune (const T &alpha, const T &omega_c, const T &mag_G)
 Constructa a PID controller using the alpha tuning method.
 

Friends

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

Detailed Description

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

A PID (proportional + integral + differential) controller with variable sample-times.

with the transfer function:

\[ PID(s) = \left( k_p + \frac{k_i}{s} + k_d s \right)\frac{1}{1 + \frac{s}{\omega}} \]

The therm:

\[ \frac{1}{1 + \frac{s}{\omega}} \]

has been added to:

  1. make the D controller realisable
  2. thame the D controller for high frequencies

Constructor & Destructor Documentation

◆ PIDControl()

template<class T >
controlpp::timevar::PIDControl< T >::PIDControl ( const T &  kp,
const T &  ki,
const T &  kd,
const T &  omega 
)
inline

constructs a PID controller form gain parameters

Parameters
kpThe proportional gain
kiThe integral gain
kdThe differential gain
omegaThe thaming frequency

Member Function Documentation

◆ from_alpha_tune()

template<class T >
static PIDControl controlpp::timevar::PIDControl< T >::from_alpha_tune ( const T &  alpha,
const T &  omega_c,
const T &  mag_G 
)
inlinestatic

Constructa a PID controller using the alpha tuning method.

TODO: insert image with explanation of how the alpha tuning works

Parameters
alphaDesign parameter
  • Large alpha:
    • increases phase margin but decreases gain at low frequencies
    • more robust but less performance
  • Small alpha:
    • decreses phase margin but increses gain at low frequencies
    • less robust but more performant
mag_GThe magnitude of the plant that should be controlled at the desired cutoff frequency
omega_cThe desired cutoff frequency

◆ input()

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

Input a new sample to the controller.

Parameters
uThe control input
TsThe sample-time
See also
operator()(const T& u, const T& Ts)

◆ operator()()

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

resets (clears) the internal states resets the internal states ( \(u_{k-1}\), \(u_{k-2}\), \(y_{k-1}\) and \(y_{k-2}\)) to zero

◆ reset()

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

resets (clears) the internal states resets the internal states ( \(u_{k-1}\), \(u_{k-2}\), \(y_{k-1}\) and \(y_{k-2}\)) to zero

Friends And Related Symbol Documentation

◆ operator>>

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

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