Documentation
Tools for embedded systems
Loading...
Searching...
No Matches
qlibs::continuousSystem Class Reference

A LTI continuous system object. More...

#include <ltisys.hpp>

Inheritance diagram for qlibs::continuousSystem:
qlibs::ltisys qlibs::tdl

Public Member Functions

virtual ~continuousSystem ()
 
 continuousSystem (real_t *num, real_t *den, nState *x, const size_t nD, const real_t dT) noexcept
 Constructor for an instance of a LTI continuous system.
 
template<size_t order>
 continuousSystem (continuousTF< order > &ctf, const real_t dT)
 Constructor for an instance of a LTI continuous system from a transfer function definition.
 
template<size_t systemOrder>
 continuousSystem (real_t(&num)[systemOrder+1], real_t(&den)[systemOrder+1], nState(&x)[systemOrder], const real_t dT) noexcept
 Constructor for an instance of a LTI continuous system.
 
bool setup (real_t *num, real_t *den, nState *x, const size_t nD, const real_t dT) noexcept
 Setup and initialize an instance of a LTI continuous system.
 
template<size_t systemOrder>
bool setup (real_t(&num)[systemOrder+1], real_t(&den)[systemOrder+1], nState(&x)[systemOrder], const real_t dT) noexcept
 Setup and initialize an instance of a LTI continuous system.
 
template<size_t order>
bool setup (continuousTF< order > &ctf, const real_t dT)
 Setup and initialize an instance of a LTI continuous system from a transfer function definition.
 
bool isInitialized (void) const override
 Check if the LTI continuous system is initialized.
 
bool setInitStates (const real_t *xi=nullptr) override
 Set the initial states for the continuous system.
 
bool setIntegrationMethod (integrationMethod m)
 Set integration method of the continuous system.
 
- Public Member Functions inherited from qlibs::ltisys
virtual ~ltisys ()
 
 ltisys ()=default
 
real_t excite (real_t u)
 Drives the LTI system recursively using the input signal provided.
 
ltisysType getType (void) const
 Get the LTI system type.
 
bool setDelay (real_t *const w, const size_t nD, const real_t initVal=0.0_re) noexcept
 Set the input delay for LTI system.
 
bool setSaturation (const real_t minV, const real_t maxV) noexcept
 Setup the output saturation for the LTI system.
 
- Public Member Functions inherited from qlibs::tdl
virtual ~tdl ()
 
 tdl ()=default
 
 tdl (real_t *const area, const size_t n, const real_t initVal=0.0_re)
 Constructor for the Tapped Delay Line (TDL) instance.
 
template<size_t numberOfDelays>
 tdl (real_t(&area)[numberOfDelays], const real_t initVal=0.0_re) noexcept
 Constructor for the Tapped Delay Line (TDL) instance.
 
void setup (real_t *const area, const size_t n, const real_t initVal=0.0_re) noexcept
 Setup and initialize a Tapped Delay Line (TDL) instance by setting the default optimal parameters.
 
template<size_t numberOfDelays>
void setup (real_t(&area)[numberOfDelays], const real_t initVal=0.0_re) noexcept
 Setup and initialize a Tapped Delay Line (TDL) instance by setting the default optimal parameters.
 
void flush (const real_t initVal=0.0_re) noexcept
 Clears all delays from the TDL and sets them to the specified value.
 
real_t getOldest (void) const noexcept
 Get the oldest sample from the TDL x(k-n)
 
real_t getRecent (void) const noexcept
 Get the most recent sample from the TDL x(k)
 
real_t getAtIndex (const size_t i) const noexcept
 Get the specified delayed sample from the TDL x(k-i)
 
void insertSample (const real_t sample) noexcept
 Insert a new sample to the TDL removing the oldest sample.
 
const real_toperator[] (int index) noexcept
 Get the specified delayed sample from the TDL x(k-i)
 
void operator() (const real_t sample) noexcept
 Insert a new sample to the TDL removing the oldest sample.
 
bool isInitialized (void) const
 Check if the TDL has been initialized.
 

Detailed Description

A LTI continuous system object.

The instance should be initialized using the continuousSystem::setup() method.

Constructor & Destructor Documentation

◆ ~continuousSystem()

virtual qlibs::continuousSystem::~continuousSystem ( )
inlinevirtual

◆ continuousSystem() [1/3]

qlibs::continuousSystem::continuousSystem ( real_t * num,
real_t * den,
nState * x,
const size_t nD,
const real_t dT )
inlinenoexcept

Constructor for an instance of a LTI continuous system.

Parameters
[in,out]num: An array of n+1 elements with the numerator coefficients of the transfer function. Coefficients should be given in descending powers of the n or nb-degree polynomial. Coefficients will be normalized internally.
[in,out]denAn array of n+1 elements with the denominator coefficients of the transfer function. Coefficients should be given in descending powers of the n or nb-degree polynomial. Coefficients will be normalized internally.
[in,out]xInitial conditions of the system. For a continuos system, an array of type continuousStates with n elements. The supplied array will be updated on every invocation of continuousSystem::excite().
[in]nDThe system order ( n ).

example 2: \( \frac{ b_{0}s^{2}+b_{1}s+b_{2} }{ a_{0}s^{2} + a_{1}s + a_{2} }, na = 3 \)

Note
Size of num and den should be equal.
Parameters
[in]dTThe time-step of the continuos system.
Note
By default, initial conditions are set to zero. To change the initial conditions to the desired values, use the continuousSystem::setInitStates() method.

◆ continuousSystem() [2/3]

template<size_t order>
qlibs::continuousSystem::continuousSystem ( continuousTF< order > & ctf,
const real_t dT )
inline

Constructor for an instance of a LTI continuous system from a transfer function definition.

Parameters
[in]ctf: The continuous transfer-function
[in]dTThe time-step of the continuos system.

◆ continuousSystem() [3/3]

template<size_t systemOrder>
qlibs::continuousSystem::continuousSystem ( real_t(&) num[systemOrder+1],
real_t(&) den[systemOrder+1],
nState(&) x[systemOrder],
const real_t dT )
inlinenoexcept

Constructor for an instance of a LTI continuous system.

Parameters
[in,out]num: An array of n+1 elements with the numerator coefficients of the transfer function. Coefficients should be given in descending powers of the n or nb-degree polynomial. Coefficients will be normalized internally.
[in,out]denAn array of n+1 elements with the denominator coefficients of the transfer function. Coefficients should be given in descending powers of the n or nb-degree polynomial. Coefficients will be normalized internally.
[in,out]xInitial conditions of the system. For a continuos system, an array of type continuousStates with n elements. The supplied array will be updated on every invocation of continuousSystem::excite().
Note
Size of num and den should be equal.
Parameters
[in]dTThe time-step of the continuos system.
Note
By default, initial conditions are set to zero. To change the initial conditions to the desired values, use the continuousSystem::setInitStates() method.

Member Function Documentation

◆ isInitialized()

bool qlibs::continuousSystem::isInitialized ( void ) const
inlineoverridevirtual

Check if the LTI continuous system is initialized.

Returns
true if the system has been initialized, otherwise return false.

Implements qlibs::ltisys.

◆ setInitStates()

bool continuousSystem::setInitStates ( const real_t * xi = nullptr)
overridevirtual

Set the initial states for the continuous system.

Precondition
System should be previously initialized by using the discreteSystem::setup() method
Parameters
[in]xiAn array of n-elements with the initial state values. User can pass nullptr as argument to set initial conditions equal to zero.
Returns
true on success, otherwise return false.

Implements qlibs::ltisys.

◆ setIntegrationMethod()

bool continuousSystem::setIntegrationMethod ( integrationMethod m)

Set integration method of the continuous system.

Parameters
[in]mThe desired integration method. Use one of the following:

INTEGRATION_RECTANGULAR : Integrate using the Rectangular rule.

INTEGRATION_TRAPEZOIDAL : (default) Integrate using the Trapezoidal rule.

INTEGRATION_SIMPSON : Integrate using the Simpson's 1/3 rule.

Returns
true on success, otherwise return false.

◆ setup() [1/3]

template<size_t order>
bool qlibs::continuousSystem::setup ( continuousTF< order > & ctf,
const real_t dT )
inline

Setup and initialize an instance of a LTI continuous system from a transfer function definition.

Parameters
[in]ctf: The continuous transfer-function
[in]dTThe time-step of the continuos system.
Returns
true on success, otherwise return false.

◆ setup() [2/3]

bool continuousSystem::setup ( real_t * num,
real_t * den,
nState * x,
const size_t nD,
const real_t dT )
noexcept

Setup and initialize an instance of a LTI continuous system.

Parameters
[in,out]num: An array of n+1 elements with the numerator coefficients of the transfer function. Coefficients should be given in descending powers of the n or nb-degree polynomial. Coefficients will be normalized internally.
[in,out]denAn array of n+1 elements with the denominator coefficients of the transfer function. Coefficients should be given in descending powers of the n or nb-degree polynomial. Coefficients will be normalized internally.
[in,out]xInitial conditions of the system. For a continuos system, an array of type continuousStates with n elements. The supplied array will be updated on every invocation of continuousSystem::excite().
[in]nDThe system order ( n ).

example 2: \( \frac{ b_{0}s^{2}+b_{1}s+b_{2} }{ a_{0}s^{2} + a_{1}s + a_{2} }, na = 3 \)

Note
Size of num and den should be equal.
Parameters
[in]dTThe time-step of the continuos system.
Returns
true on success, otherwise return false.
Note
By default, initial conditions are set to zero. To change the initial conditions to the desired values, use the continuousSystem::setInitStates() method.

◆ setup() [3/3]

template<size_t systemOrder>
bool qlibs::continuousSystem::setup ( real_t(&) num[systemOrder+1],
real_t(&) den[systemOrder+1],
nState(&) x[systemOrder],
const real_t dT )
inlinenoexcept

Setup and initialize an instance of a LTI continuous system.

Parameters
[in,out]num: An array of n+1 elements with the numerator coefficients of the transfer function. Coefficients should be given in descending powers of the n or nb-degree polynomial. Coefficients will be normalized internally.
[in,out]denAn array of n+1 elements with the denominator coefficients of the transfer function. Coefficients should be given in descending powers of the n or nb-degree polynomial. Coefficients will be normalized internally.
[in,out]xInitial conditions of the system. For a continuos system, an array of type continuousStates with n elements. The supplied array will be updated on every invocation of continuousSystem::excite().
Note
Size of num and den should be equal.
Parameters
[in]dTThe time-step of the continuos system.
Returns
true on success, otherwise return false.
Note
By default, initial conditions are set to zero. To change the initial conditions to the desired values, use the continuousSystem::setInitStates() method.