API for the qLTISys library for recursive evaluation of LTI systems defined by transfer functions.
More...
|
#define | QLTISYS_DISCRETE |
| Macro to specify that the system is time-discrete.
|
|
|
typedef qNumA_state_t | qLTISys_ContinuosX_t |
| Type to specify continuos states.
|
|
typedef float | qLTISys_DiscreteX_t |
| Type to specify continuos states.
|
|
|
float | qLTISys_Excite (qLTISys_t *const sys, float u) |
| Drives the LTI system recursively using the input signal provided.
|
|
int | qLTISys_SetDelay (qLTISys_t *const sys, float *const w, const size_t n, const float initVal) |
| Set the input delay for LTI system.
|
|
int | qLTISys_SetSaturation (qLTISys_t *const sys, const float min, const float max) |
| Setup the output saturation for the LTI system.
|
|
int | qLTISys_IsInitialized (const qLTISys_t *const sys) |
| Check if the LTI system is initialized.
|
|
int | qLTISys_SetInitStates (qLTISys_t *const sys, const float *const xi) |
| Set the initial states for the given system.
|
|
int | qLTISys_Setup (qLTISys_t *const sys, float *num, float *den, void *x, const size_t nb, const size_t na, const float dt) |
| Setup and initialize an instance of a LTI system.
|
|
float | qLTISys_DiscreteFIRUpdate (float *w, const float *const c, const size_t wsize, const float x) |
| Evaluate the discrete FIR filter by updating the delay lines of x inside the window w of size wsize with the coefficients given in c. If c it's not supplied, this function just perform the window update.
|
|
int | qLTISys_SetIntegrationMethod (qLTISys_t *const sys, qNumA_IntegrationMethod_t im) |
| Set integration method for continuos systems.
|
|
API for the qLTISys library for recursive evaluation of LTI systems defined by transfer functions.
For a brief description of this module, please read Recursive LTI Systems Evaluation by transfer functions.
◆ qLTISys_DiscreteFIRUpdate()
float qLTISys_DiscreteFIRUpdate |
( |
float * | w, |
|
|
const float *const | c, |
|
|
const size_t | wsize, |
|
|
const float | x ) |
Evaluate the discrete FIR filter by updating the delay lines of x inside the window w of size wsize with the coefficients given in c. If c it's not supplied, this function just perform the window update.
- Parameters
-
[in,out] | w | An array of wsize elements that holds the window with the delay lines of x. |
[in] | c | An array of wsize elements with the coefficients of the FIR filter. Coefficients should be given in descending powers of the nth-degree polynomial. To ignore pass NULL . |
[in] | wsize | The number of elements of w. |
[in] | x | A sample of the input signal. |
- Returns
- If c is provided, returns the evaluation of the FIR filter. otherwise return the sum of the updated window w.
◆ qLTISys_Excite()
float qLTISys_Excite |
( |
qLTISys_t *const | sys, |
|
|
float | u ) |
Drives the LTI system recursively using the input signal provided.
- Precondition
- Instance must be previously initialized by qLTISys_Setup()
- Note
- The user must ensure that this function is executed in the time specified in dt either by using a HW or SW timer, a real time task, or a timing service.
- Parameters
-
[in] | sys | A pointer to the LTI system instance |
[in] | u | A sample of the input signal that excites the system |
- Returns
- The system response.
◆ qLTISys_IsInitialized()
int qLTISys_IsInitialized |
( |
const qLTISys_t *const | sys | ) |
|
Check if the LTI system is initialized.
- Returns
- 1 if the system has been initialized, otherwise return 0.
◆ qLTISys_SetDelay()
int qLTISys_SetDelay |
( |
qLTISys_t *const | sys, |
|
|
float *const | w, |
|
|
const size_t | n, |
|
|
const float | initVal ) |
Set the input delay for LTI system.
- Parameters
-
[in] | sys | A pointer to the LTI system instance |
[in] | w | A array of n elements with the delay window for the input channel. |
[in] | n | The number of elements of w. |
[in] | initVal | The initial value of the input channel. |
- Returns
- 1 if the system has been initialized, otherwise return 0.
◆ qLTISys_SetInitStates()
int qLTISys_SetInitStates |
( |
qLTISys_t *const | sys, |
|
|
const float *const | xi ) |
Set the initial states for the given system.
- Precondition
- System should be previously initialized by using qLTISys_Setup()
- Parameters
-
[in] | sys | A pointer to the LTI system instance |
[in] | xi | An array of n-elements with the initial state values. User can pass NULL as argument to set initial conditions equal to zero. |
- Returns
- 1 on success, otherwise return 0.
◆ qLTISys_SetIntegrationMethod()
int qLTISys_SetIntegrationMethod |
( |
qLTISys_t *const | sys, |
|
|
qNumA_IntegrationMethod_t | im ) |
Set integration method for continuos systems.
- Parameters
-
[in] | sys | A pointer to the continuous LTI system instance |
[in] | im | The desired integration method. Use one of the following: |
qNumA_IntegralRe
: Integrate using the Rectangular rule.
qNumA_IntegralTr
: (default) Integrate using the Trapezoidal rule.
qNumA_IntegralSi
: Integrate using the Simpson's 1/3 rule.
- Returns
- 1 on success, otherwise return 0.
◆ qLTISys_SetSaturation()
int qLTISys_SetSaturation |
( |
qLTISys_t *const | sys, |
|
|
const float | min, |
|
|
const float | max ) |
Setup the output saturation for the LTI system.
- Parameters
-
[in] | sys | A pointer to the LTI system instance |
[in] | min | The minimal value allowed for the output. |
[in] | max | The maximal value allowed for the output. |
- Returns
- 1 on success, otherwise return 0.
◆ qLTISys_Setup()
int qLTISys_Setup |
( |
qLTISys_t *const | sys, |
|
|
float * | num, |
|
|
float * | den, |
|
|
void * | x, |
|
|
const size_t | nb, |
|
|
const size_t | na, |
|
|
const float | dt ) |
Setup and initialize an instance of a LTI system.
- Parameters
-
[in] | sys | A pointer to the continuous LTI system instance |
[in,out] | num | : An array of n+1(if continuous) or nb+1(if discrete) 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] | den | An array of n+1(if continuous) or na+1(if discrete) 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] | x | Initial conditions of the system. For a continuos system, an array of type qLTISys_ContinuosX_t with n elements. For a discrete system, an array of type qLTISys_DiscreteX_t with max(na,nb) elements For both cases, the supplied array will be updated on every invocation of qLTISys_Excite(). |
[in] | nb | The order of polynomial num + 1 (Only for discrete systems). example: \( b_{0}+b_{1}z^{-1}+b_{2}z^{-2}+b_{3}z^{-3}, nb = 4 \) |
- Note
- If the system is continuous, pass 0 as argument.
- Parameters
-
[in] | na | The order of polynomial den. (if system is discrete). For continuous system the number of elements of num and den. |
example 1: \( a_{0}+a_{1}z^{-1}+a_{2}z^{-2}+a_{3}z^{-3}, na = 3 \)
example 2: \( \frac{ b_{0}s^{2}+b_{1}s+b_{2} }{ a_{0}s^{2} + a_{1}s + a_{2} }, na = 3 \)
- Note
- For continuous systems, size of num and den should be equal.
- Parameters
-
[in] | dt | The time-step of the continuos system. For discrete systems pass QLTISYS_DISCRETE as argument |
- Returns
- 1 on success, otherwise return 0.
- Note
- By default, initial conditions are set to zero. To change the initial conditions to the desired values, use the qLTISys_SetInitStates() function.