|
AM243x Motor Control SDK
09.00.00
|
|
Go to the documentation of this file.
50 #include "../dcl_common.h"
57 typedef struct dcl_df23_sps
68 #define DF23_SPS_DEFAULTS { 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f }
95 #define DF23_DEFAULTS { 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, \
96 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, \
97 &(DCL_DF23_SPS)DF23_SPS_DEFAULTS, &(DCL_CSS)DCL_CSS_DEFAULTS }
107 #define DF23_INT_DEFAULTS .x1=0.0f, .x2=0.0f, .x3=0.0f, \
108 .sps=&(DCL_DF23_SPS)DF23_SPS_DEFAULTS, .css=&(DCL_CSS)DCL_CSS_DEFAULTS
115 #define DCL_initDF23() &(DCL_DF23)DF23_DEFAULTS
123 #define DCL_initDF23asParam(_b0,_b1,_b2,_b3,_a1,_a2,_a3) &(DCL_DF23){ .b0=_b0, .b1=_b1, \
124 .b2=_b2, .b3=_b3, .a1=_a1, .a2=_a2, .a3=_a3, DF23_INT_DEFAULTS }
136 #define DCL_initDF23asSPS(df_ptr,sps_ptr) \
138 DCL_DF23* new_df = (df_ptr) ? df_ptr : DCL_initDF23(); \
139 DCL_DF23_SPS* new_sps = (sps_ptr) ? sps_ptr : &(DCL_DF23_SPS)DF23_SPS_DEFAULTS;\
142 *new_df = (DCL_DF23){ (new_sps)->b0, (new_sps)->b1, (new_sps)->b2, \
143 (new_sps)->b3,(new_sps)->a1, (new_sps)->a2, (new_sps)->a3, 0.0f, \
144 0.0f, 0.0f, (DCL_DF23_SPS*)new_sps, &(DCL_CSS)DCL_CSS_DEFAULTS }; \
157 df->x1 = df->x2 = df->x3 = 0.0f;
168 df->b0 = df->sps->b0;
169 df->b1 = df->sps->b1;
170 df->b2 = df->sps->b2;
171 df->b3 = df->sps->b3;
172 df->a1 = df->sps->a1;
173 df->a2 = df->sps->a2;
174 df->a3 = df->sps->a3;
189 df->b0 = df->sps->b0;
190 df->b1 = df->sps->b1;
191 df->b2 = df->sps->b2;
192 df->b3 = df->sps->b3;
193 df->a1 = df->sps->a1;
194 df->a2 = df->sps->a2;
195 df->a3 = df->sps->a3;
230 df->sps->b0 = df->b0;
231 df->sps->b1 = df->b1;
232 df->sps->b2 = df->b2;
233 df->sps->b3 = df->b3;
234 df->sps->a1 = df->a1;
235 df->sps->a2 = df->a2;
236 df->sps->a3 = df->a3;
260 #ifdef DCL_ERROR_HANDLING_ENABLED
281 float32_t a0p = 8.0f + (alpha2 * 4.0f * t_sec) + (alpha1 * 2.0f * t_sec * t_sec) + (alpha0 * t_sec * t_sec * t_sec);
283 df->sps->b0 = zpk->
K * (8.0f + (beta2 * 4.0f * t_sec) + (beta1 * 2.0f * t_sec * t_sec) + (beta0 * t_sec * t_sec * t_sec)) / a0p;
284 df->sps->b1 = zpk->
K * (-24.0f - (beta2 * 4.0f * t_sec) + (beta1 * 2.0f * t_sec * t_sec) + (3.0f * beta0 * t_sec * t_sec * t_sec)) / a0p;
285 df->sps->b2 = zpk->
K * (24.0f - (beta2 * 4.0f * t_sec) - (beta1 * 2.0f * t_sec * t_sec) + (3.0f * beta0 * t_sec * t_sec * t_sec)) / a0p;
286 df->sps->b3 = zpk->
K * (-8.0f + (beta2 * 4.0f * t_sec) - (beta1 * 2.0f * t_sec * t_sec) + (beta0 * t_sec * t_sec * t_sec)) / a0p;
288 df->sps->a1 = (-24.0f - (alpha2 * 4.0f * t_sec) + (alpha1 * 2.0f * t_sec * t_sec) + (3.0f * alpha0 * t_sec * t_sec * t_sec)) / a0p;
289 df->sps->a2 = (24.0f - (alpha2 * 4.0f * t_sec) - (alpha1 * 2.0f * t_sec * t_sec) + (3.0f * alpha0 * t_sec * t_sec * t_sec)) / a0p;
290 df->sps->a3 = (-8.0f + (alpha2 * 4.0f * t_sec) - (alpha1 * 2.0f * t_sec * t_sec) + (alpha0 * t_sec * t_sec * t_sec)) / a0p;
303 df->x1 = (ek * df->b1) + df->x2 - (v7 * df->a1);
304 df->x2 = (ek * df->b2) + df->x3 - (v7 * df->a2);
305 df->x3 = (ek * df->b3) - (v7 * df->a3);
319 return((ek * df->b0) + df->x1);
331 df->x1 = (ek * df->b1) + df->x2 - (uk * df->a1);
332 df->x2 = (ek * df->b2) + df->x3 - (uk * df->a2);
333 df->x3 = (ek * df->b3) - (uk * df->a3);
359 #endif // _DCL_DF23_H_
_DCL_CODE_ACCESS bool DCL_isStablePn3(float32_t a0, float32_t a1, float32_t a2, float32_t a3)
Determines stability of a third order polynomial with real coefficients P(z) = a0 z^3 + a1 z^2 + a2 z...
Definition: dcl_stability.h:93
float32_t x2
x2 = b2*e(k-2) - a2*u(k-2) + x3
Definition: dcl_df23.h:85
float32_t K
Real gain.
Definition: dcl_zpk3.h:69
float32_t a1
neg. coefficient to u(k-1)
Definition: dcl_df23.h:63
_DCL_CODE_ACCESS bool DCL_isStableDF23(DCL_DF23 *df)
Determines stability of the shadow compensator.
Definition: dcl_df23.h:245
float32_t a3
neg. coefficient to u(k-3)
Definition: dcl_df23.h:65
float complex z2
Complex zeros 2.
Definition: dcl_zpk3.h:64
_DCL_CODE_ACCESS _DCL_CODE_SECTION float32_t DCL_runDF23(DCL_DF23 *df, float32_t ek)
Executes a 3rd order Direct Form 2 controller.
Definition: dcl_df23.h:300
#define _DCL_CODE_SECTION
Defines dcl function section that users can specify in the linker file(.cmd) and to accelerate perfor...
Definition: dcl_common.h:60
_DCL_CODE_ACCESS void DCL_runDF23PartialUpdate(DCL_DF23 *df, float32_t ek, float32_t uk)
Update DF22 controller based on pre-computed control effort.
Definition: dcl_df23.h:329
#define DCL_clearPendingStatus(p)
Definition: dcl_css.h:129
float complex p2
Complex poles 2.
Definition: dcl_zpk3.h:67
_DCL_CODE_ACCESS _DCL_CODE_SECTION bool DCL_updateDF23(DCL_DF23 *df)
Updates DF23 parameter from its SPS parameter with interrupt protection.
Definition: dcl_df23.h:183
#define DCL_setUpdateStatus(p)
Macros to set and clear the update-in-progress flag.
Definition: dcl_css.h:116
_DCL_CODE_ACCESS _DCL_CODE_SECTION bool DCL_pendingUpdateDF23(DCL_DF23 *df)
A conditional update based on the pending-for-update flag. If the pending status is set,...
Definition: dcl_df23.h:212
DCL_CSS * css
configuration & debugging
Definition: dcl_df23.h:90
#define DCL_runErrorHandler(ptr)
Prototype for basic error handler.
Definition: dcl_error.h:107
_DCL_VOLATILE struct dcl_df23 * DF23_Handle
float32_t b0
pos. coefficient to e(k)
Definition: dcl_df23.h:75
#define DCL_getUpdateStatus(p)
Determine whether a parameter update-in-progress flag is set.
Definition: dcl_css.h:123
#define DCL_clearUpdateStatus(p)
Definition: dcl_css.h:117
_DCL_CODE_ACCESS float32_t DCL_runDF23PartialCompute(DCL_DF23 *df, float32_t ek)
Immediate computation to obtain DF23 servo error without updating the controller.
Definition: dcl_df23.h:317
float32_t b3
pos. coefficient to e(k-3)
Definition: dcl_df23.h:62
#define _DCL_CODE_ACCESS
Defines the scope of dcl functions (static inline/extern inline/none)
Definition: dcl_common.h:55
float32_t a2
neg. coefficient to u(k-2)
Definition: dcl_df23.h:80
float complex p1
Complex poles 1.
Definition: dcl_zpk3.h:66
_DCL_CODE_ACCESS void DCL_fupdateDF23(DCL_DF23 *df)
Loads DF23 tuning parameter from its SPS parameter.
Definition: dcl_df23.h:166
_DCL_CODE_ACCESS void DCL_loadDF23asZPK(DCL_DF23 *df, DCL_ZPK3 *zpk)
Loads the DF23 shadow coefficients from a ZPK3 description Note: Sampling period df->css->t_sec are u...
Definition: dcl_df23.h:258
float32_t x1
x1 = b1*e(k-1) - a1*u(k-1) + x2
Definition: dcl_df23.h:84
@ dcl_none
No error.
Definition: dcl_error.h:57
_DCL_CODE_ACCESS void DCL_updateDF23SPS(DCL_DF23 *df)
Update SPS parameter with active param, userful when needing to update only few active param from SPS...
Definition: dcl_df23.h:228
uint32_t dcl_interrupt_t
Definition: dcl_common.h:96
float complex z3
Complex zeros 3.
Definition: dcl_zpk3.h:65
float32_t a2
neg. coefficient to u(k-2)
Definition: dcl_df23.h:64
float32_t a3
neg. coefficient to u(k-3)
Definition: dcl_df23.h:81
float32_t b1
pos. coefficient to e(k-1)
Definition: dcl_df23.h:76
#define DCL_isZero(x)
Determines floating point numerical proximity to zero.
Definition: dcl_aux.h:77
float32_t b0
pos. coefficient to e(k)
Definition: dcl_df23.h:59
@ dcl_param_invalid_err
Parameter not valid.
Definition: dcl_error.h:59
float32_t x3
x3 = b3*e(k-3) - a3*u(k-3)
Definition: dcl_df23.h:86
DCL_DF23_SPS * sps
updates compensator parameter
Definition: dcl_df23.h:89
float32_t b1
pos. coefficient to e(k-1)
Definition: dcl_df23.h:60
float32_t b2
pos. coefficient to e(k-2)
Definition: dcl_df23.h:61
Defines the controller common support structure.
Definition: dcl_css.h:57
#define DCL_getPendingStatus(p)
Determine whether a parameter pending-for-update flag is set.
Definition: dcl_css.h:135
#define DCL_restoreInts(v)
Definition: dcl_common.h:95
float complex p3
Complex poles 3.
Definition: dcl_zpk3.h:68
_DCL_CODE_ACCESS bool DCL_runClamp(float32_t *data, float32_t Umax, float32_t Umin)
Saturates a control variable and returns true if either limit is exceeded.
Definition: dcl_clamp.h:59
Defines the DCL_ZPK3 controller structure.
Definition: dcl_zpk3.h:62
#define _DCL_VOLATILE
Defines volatile for DCL strctures Flags can be defined in dcl.h or user files before including DCL l...
Definition: dcl_common.h:68
_DCL_CODE_ACCESS _DCL_CODE_SECTION float32_t DCL_runDF23Clamp(DCL_DF23 *df, float32_t ek, float32_t Umax, float32_t Umin)
Executes a 3rd order Direct Form 2 controller with clamp.
Definition: dcl_df23.h:345
float32_t b2
pos. coefficient to e(k-2)
Definition: dcl_df23.h:77
#define DCL_getErrorInfo(ptr)
Macro to store error info in CSS.
Definition: dcl_error.h:97
#define DCL_setError(ptr, code)
Macro to set error code in CSS.
Definition: dcl_error.h:79
float32_t a1
neg. coefficient to u(k-1)
Definition: dcl_df23.h:79
Defines DCL_DF23 shadow parameter set used for updating compensator parameter.
Definition: dcl_df23.h:58
_DCL_VOLATILE struct dcl_df23 DCL_DF23
float float32_t
Defines single,double precision data type. Note: Assumes ABI to be TI_EABI, does not support legacy T...
Definition: dcl_common.h:51
DCL_DF23 object for storing df23 specific parameters.
Definition: dcl_df23.h:73
_DCL_CODE_ACCESS void DCL_resetDF23(DCL_DF23 *df)
Resets DF23 internal storage data with interrupt protection.
Definition: dcl_df23.h:154
float32_t b3
pos. coefficient to e(k-3)
Definition: dcl_df23.h:78
float complex z1
Complex zeros 1.
Definition: dcl_zpk3.h:63
#define DCL_disableInts()
Define enable and disable interrupt operations.
Definition: dcl_common.h:94