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

A Thamed PI controller (PI controller with a low pass filter) with variable sample-times. More...

#include <controlpp/TimeVariantControl.hpp>

Public Member Functions

constexpr PT1IControl (const PT1IControl &)=default
 
constexpr PT1IControl (const T &kp, const T &ki, const T &omega)
 Constructs a PT1I (proportional time delayed + integral) controller.
 
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)
 Input a new sample to the controller.
 
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
 

Friends

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

Detailed Description

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

A Thamed PI controller (PI controller with a low pass filter) with variable sample-times.

The purely proportional component of a PI controller can amplify high-frequency noise.  * While this does not improve control performance, it may lead to increased power consumption due to rapid steering actions.  * To mitigate this, the proportional gain (P) can be replaced with a first-order low-pass filter (PT1), effectively transforming the PI controller into a PT1I controller.

With the transfer function:

\[ \text{PI} = \frac{s k_p + k_i}{s + \frac{s^2}{\omega}} \]

and the discretisation using the tustin transformation:

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

resulting in the controlers time series:

\[ y_k = (K * (b_0 * u_k + b_1 * u_{k-1} + b_2 * u_{k-2}) - a_1 * y_{k-1} - a_2 * y_{k-2}) / a_0 \]

where:

\[ K = \omega * T_s a0 = 4 + 2 * \omega * T_s a1 = -8 a2 = 4 - 2 * \omega * T_s b0 = 2 * k_p + k_i * T_s b1 = 2 * k_i * T_s b2 = k_i * T_s - 2 * k_p \]

with:

  • \(T_s\) the sample-time in seconds
  • \(u_{k}\) and \(u_{k-1}\) are current and previous control inputs
  • \(y_{k}\) and \(y_{k-1}\) are current and previous control outputs
  • \(k_p\) the proportional gain
  • \(k_i\) the integral gain
  • \(\omega\) the characteristic frequency of the low pass filter aimed to thame the P control at high frequencies
See also
controlpp::vartime::PT1I
Template Parameters
TValue type of the filter like float or double

Constructor & Destructor Documentation

◆ PT1IControl() [1/2]

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

◆ PT1IControl() [2/2]

template<class T >
constexpr controlpp::timevar::PT1IControl< T >::PT1IControl ( const T &  kp,
const T &  ki,
const T &  omega 
)
inlineconstexpr

Constructs a PT1I (proportional time delayed + integral) controller.

Parameters
kpThe proportional gain of the controller
kiThe integral gain of the controller
omegaThe lowpass filter bandwidth

Member Function Documentation

◆ input()

template<class T >
constexpr T controlpp::timevar::PT1IControl< 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::PT1IControl< T >::operator() ( const T &  u,
const T &  Ts 
)
inlineconstexpr

Input a new sample to the controller.

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

◆ reset()

template<class T >
constexpr void controlpp::timevar::PT1IControl< 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,
PT1IControl< T > &  c 
)
friend

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