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

A PT2 (proportional time second order) filter (=low-pass element of order 1), with varying smaple-time. More...

#include <controlpp/TimeVariantControl.hpp>

Public Member Functions

 PT2Control (const PT2Control &)=default
 
 PT2Control (const T &K, const T &D, const T &omega)
 constructs a PT2 element
 
constexpr T input (const T &u, const T &Ts)
 
constexpr T operator() (const T &u, const T &Ts)
 
constexpr void reset ()
 

Friends

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

Detailed Description

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

A PT2 (proportional time second order) filter (=low-pass element of order 1), with varying smaple-time.

With the transfer function:

\[ \text{PT}_{2} = \frac{K}{\frac{s^2}{\omega^2} + \frac{2 D s}{\omega} + 1} \]

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 = \frac{K \left( u_k + 2 u_{k-1} + u_{k-2} \right) - b y_{k-1} - c y_{k-2}}{a} \\ a = \frac{4}{\omega^2 + T_s^2} + 4 D + 1 \\ b = 2 - \frac{8}{\omega^2 T_s^2} \\ c = \frac{4}{\omega^2 + T_s^2} - 4 D + 1 \]

with:

  • \(K\) the gain of the filter
  • \(T_s\) the sample-time in seconds
  • \(\omega\) the characteristic frequency of the filter (bandwidth)
  • \(D\) the dampening factor
    • Aperiodic borderline case: D = 1
    • Overdamped(creep-in) : D > 1
    • Underdamped(exponential decreasing oscillations): 0 < D < 1
    • Oscillating: D = 0
  • \(u_{k}\), \(u_{k-1}\) and \(u_{k-2}\) are current and previous control inputs
  • \(y_{k}\), \(y_{k-1}\) and \(y_{k-2}\) are current and previous control outputs
Template Parameters
TValue type of the filter like float or double

TODO: calculate the tustin discretised states space manuall and build the state space matrices directly to improve performance-

Constructor & Destructor Documentation

◆ PT2Control() [1/2]

template<class T >
controlpp::timevar::PT2Control< T >::PT2Control ( const PT2Control< T > &  )
default

◆ PT2Control() [2/2]

template<class T >
controlpp::timevar::PT2Control< T >::PT2Control ( const T &  K,
const T &  D,
const T &  omega 
)
inline

constructs a PT2 element

Parameters
KThe gain of the filter
DThen dampening factor of the filter
omegaThe characteristic frequency of the filter (bandwidth)

Member Function Documentation

◆ input()

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

◆ operator()()

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

◆ reset()

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

Friends And Related Symbol Documentation

◆ operator>>

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

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