|
AM243x Motor Control SDK
09.00.00
|
|
Go to the documentation of this file.
50 #include "../dcl_common.h"
57 typedef struct dcl_df22_sps
66 #define DF22_SPS_DEFAULTS { 1.0f, 0.0f, 0.0f, 0.0f, 0.0f }
90 #define DF22_DEFAULTS { 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, \
91 &(DCL_DF22_SPS)DF22_SPS_DEFAULTS, &(DCL_CSS)DCL_CSS_DEFAULTS }
101 #define DF22_INT_DEFAULTS .x1=0.0f, .x2=0.0f, .sps=&(DCL_DF22_SPS)DF22_SPS_DEFAULTS, \
102 .css=&(DCL_CSS)DCL_CSS_DEFAULTS
109 #define DCL_initDF22() &(DCL_DF22)DF22_DEFAULTS
117 #define DCL_initDF22asParam(_b0,_b1,_b2,_a1,_a2) &(DCL_DF22){ .b0=_b0, .b1=_b1, \
118 .b2=_b2, .a1=_a1, .a2=_a2, .a3=_a3, DF22_INT_DEFAULTS }
130 #define DCL_initDF22asSPS(df_ptr,sps_ptr) \
132 DCL_DF22* new_df = (df_ptr) ? df_ptr : DCL_initDF22(); \
133 DCL_DF22_SPS* new_sps = (sps_ptr) ? sps_ptr : &(DCL_DF22_SPS)DF22_SPS_DEFAULTS; \
136 *new_df = (DCL_DF22){ (new_sps)->b0, (new_sps)->b1, (new_sps)->b2, (new_sps)->a1,\
137 (new_sps)->a2, 0.0f, 0.0f, (DCL_DF22_SPS*)new_sps, &(DCL_CSS)DCL_CSS_DEFAULTS }; \
150 df->x1 = df->x2 = 0.0f;
161 df->b0 = df->sps->b0;
162 df->b1 = df->sps->b1;
163 df->b2 = df->sps->b2;
164 df->a1 = df->sps->a1;
165 df->a2 = df->sps->a2;
180 df->b0 = df->sps->b0;
181 df->b1 = df->sps->b1;
182 df->b2 = df->sps->b2;
183 df->a1 = df->sps->a1;
184 df->a2 = df->sps->a2;
219 df->sps->b0 = df->b0;
220 df->sps->b1 = df->b1;
221 df->sps->b2 = df->b2;
222 df->sps->a1 = df->a1;
223 df->sps->a2 = df->a2;
250 #ifdef DCL_ERROR_HANDLING_ENABLED
268 float32_t a0p = 4.0f + (alpha1 * 2.0f * t_sec) + (alpha0 * t_sec * t_sec);
270 df->sps->b0 = zpk->
K * (4.0f + (beta1 * 2.0f * t_sec) + (beta0 * t_sec * t_sec)) / a0p;
271 df->sps->b1 = zpk->
K * (-8.0f + (2.0f * beta0 * t_sec * t_sec)) / a0p;
272 df->sps->b2 = zpk->
K * (4.0f - (beta1 * 2.0f * t_sec) + (beta0 * t_sec * t_sec)) / a0p;
273 df->sps->a1 = (-8.0f + (2.0f * alpha0 * t_sec * t_sec)) / a0p;
274 df->sps->a2 = (4.0f - (alpha1 * 2.0f * t_sec) + (alpha0 * t_sec * t_sec)) / a0p;
290 #ifdef DCL_ERROR_HANDLING_ENABLED
304 float32_t a2p = 1.0f / (4.0f + (4.0f * z * wn * t_sec) + v1);
305 df->sps->b0 = v1 * a2p;
306 df->sps->b1 = 2.0f * df->sps->b0;
307 df->sps->b2 = df->sps->b0;
308 df->sps->a1 = ((2.0f * v1) - 8.0f) * a2p;
309 df->sps->a2 = (4.0f - (4.0f * z * wn * t_sec) + v1) * a2p;
326 #ifdef DCL_ERROR_HANDLING_ENABLED
342 float32_t c1 = 2.0f / (t_sec + (2.0f * tau));
343 float32_t c2 = c1 * (t_sec - (2.0f * tau)) / 2.0f;
345 df->sps->b0 = Kp * (1 + Ki + Kdp);
346 df->sps->b1 = Kp * (c2 - 1 + Ki*c2 - 2*Kdp);
347 df->sps->b2 = Kp * (-c2 + Kdp);
348 df->sps->a1 = c2 - 1;
366 #ifdef DCL_ERROR_HANDLING_ENABLED
383 float32_t c1 = 2.0f / (t_sec + (2.0f * tau));
384 float32_t c2 = c1 * (t_sec - (2.0f * tau)) / 2.0f;
386 df->sps->b0 = Kp + Ki + Kdp;
387 df->sps->b1 = (Kp * (c2 - 1)) + (Ki * c2) - (2.0f * Kdp);
388 df->sps->b2 = (-c2 * Kp) + Kdp;
389 df->sps->a1 = c2 - 1;
403 df->x1 = (ek * df->b1) + df->x2 - (v7 * df->a1);
404 df->x2 = (ek * df->b2) - (v7 * df->a2);
419 return((ek * df->b0) + df->x1);
431 df->x1 = (ek * df->b1) + df->x2 - (uk * df->a1);
432 df->x2 = (ek * df->b2) - (uk * df->a2);
458 #endif // _DCL_DF22_H_
float32_t b2
pos. coefficient to e(k-2)
Definition: dcl_df22.h:61
_DCL_CODE_ACCESS void DCL_fupdateDF22(DCL_DF22 *df)
Loads DF22 tuning parameter from its SPS parameter.
Definition: dcl_df22.h:159
#define CONST_PI
Local definitions of the mathematical constant pi.
Definition: dcl_aux.h:55
float32_t K
Real gain.
Definition: dcl_zpk3.h:69
_DCL_CODE_ACCESS _DCL_CODE_SECTION bool DCL_updateDF22(DCL_DF22 *df)
Updates DF22 parameter from its SPS parameter with interrupt protection.
Definition: dcl_df22.h:174
_DCL_CODE_ACCESS bool DCL_isStableDF22(DCL_DF22 *df)
Determines stability of the shadow compensator.
Definition: dcl_df22.h:233
float32_t b2
pos. coefficient to e(k-2)
Definition: dcl_df22.h:75
_DCL_CODE_ACCESS bool DCL_isStablePn2(float32_t a0, float32_t a1, float32_t a2)
Determines stability of a second order polynomial with real coefficients P(z) = a0 z^2 + a1 z + a2.
Definition: dcl_stability.h:72
float complex z2
Complex zeros 2.
Definition: dcl_zpk3.h:64
@ dcl_param_warn_err
Parameter warning.
Definition: dcl_error.h:60
#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_runDF22PartialUpdate(DCL_DF22 *df, float32_t ek, float32_t uk)
Update DF22 controller based on pre-computed control effort.
Definition: dcl_df22.h:429
_DCL_CODE_ACCESS _DCL_CODE_SECTION float32_t DCL_runDF22(DCL_DF22 *df, float32_t ek)
Executes a 2nd order Direct Form 2 controller.
Definition: dcl_df22.h:400
#define DCL_clearPendingStatus(p)
Definition: dcl_css.h:129
float complex p2
Complex poles 2.
Definition: dcl_zpk3.h:67
#define DCL_setUpdateStatus(p)
Macros to set and clear the update-in-progress flag.
Definition: dcl_css.h:116
float32_t b1
pos. coefficient to e(k-1)
Definition: dcl_df22.h:74
_DCL_VOLATILE struct dcl_df22 * DF22_Handle
_DCL_CODE_ACCESS void DCL_loadDF22asParallelPID(DCL_DF22 *df, float32_t Kp, float32_t Ki, float32_t Kd, float32_t fc)
Loads the shadow DF22 compensator coefficients to emulate a parallel form PID. Note: Sampling period ...
Definition: dcl_df22.h:363
#define DCL_runErrorHandler(ptr)
Prototype for basic error handler.
Definition: dcl_error.h:107
@ dcl_param_range_err
Parameter range exceeded.
Definition: dcl_error.h:58
#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_VOLATILE struct dcl_df22 DCL_DF22
_DCL_CODE_ACCESS void DCL_updateDF22SPS(DCL_DF22 *df)
Update SPS parameter with active param, userful when needing to update only few active param from SPS...
Definition: dcl_df22.h:217
#define _DCL_CODE_ACCESS
Defines the scope of dcl functions (static inline/extern inline/none)
Definition: dcl_common.h:55
_DCL_CODE_ACCESS void DCL_loadDF22asZPK(DCL_DF22 *df, DCL_ZPK3 *zpk)
Loads the DF22 shadow coefficients from a ZPK3 description Note: Sampling period df->css->t_sec are u...
Definition: dcl_df22.h:247
_DCL_CODE_ACCESS void DCL_loadDF22asSeriesPID(DCL_DF22 *df, float32_t Kp, float32_t Ki, float32_t Kd, float32_t fc)
Loads the shadow DF22 compensator coefficients to emulate a series form PID. Note: Sampling period df...
Definition: dcl_df22.h:323
float complex p1
Complex poles 1.
Definition: dcl_zpk3.h:66
@ dcl_none
No error.
Definition: dcl_error.h:57
_DCL_CODE_ACCESS void DCL_resetDF22(DCL_DF22 *df)
Resets DF22 internal storage data with interrupt protection.
Definition: dcl_df22.h:147
uint32_t dcl_interrupt_t
Definition: dcl_common.h:96
DCL_DF22 object for storing df22 specific parameters.
Definition: dcl_df22.h:71
float32_t a2
neg. coefficient to u(k-2)
Definition: dcl_df22.h:63
#define DCL_isZero(x)
Determines floating point numerical proximity to zero.
Definition: dcl_aux.h:77
_DCL_CODE_ACCESS _DCL_CODE_SECTION bool DCL_pendingUpdateDF22(DCL_DF22 *df)
A conditional update based on the pending-for-update flag. If the pending status is set,...
Definition: dcl_df22.h:201
float32_t a1
neg. coefficient to u(k-1)
Definition: dcl_df22.h:76
DCL_CSS * css
configuration & debugging
Definition: dcl_df22.h:85
float32_t b0
pos. coefficient to e(k)
Definition: dcl_df22.h:73
@ dcl_param_invalid_err
Parameter not valid.
Definition: dcl_error.h:59
float32_t a2
neg. coefficient to u(k-2)
Definition: dcl_df22.h:77
Defines DCL_DF22 shadow parameter set used for updating compensator parameter.
Definition: dcl_df22.h:58
DCL_DF22_SPS * sps
updates compensator parameter
Definition: dcl_df22.h:84
_DCL_CODE_ACCESS void DCL_loadDF22asZwn(DCL_DF22 *df, float32_t z, float32_t wn)
Loads the DF22 shadow coefficients from damping ratio and un-damped natural frequency using sample ra...
Definition: dcl_df22.h:287
float32_t b1
pos. coefficient to e(k-1)
Definition: dcl_df22.h:60
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
_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
float32_t x2
x2 = b2*e(k-2) - a2*u(k-2)
Definition: dcl_df22.h:81
float32_t a1
neg. coefficient to u(k-1)
Definition: dcl_df22.h:62
#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 x1
x1 = b1*e(k-1) - a1*u(k-1) + x2
Definition: dcl_df22.h:80
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
float32_t b0
pos. coefficient to e(k)
Definition: dcl_df22.h:59
_DCL_CODE_ACCESS _DCL_CODE_SECTION float32_t DCL_runDF22Clamp(DCL_DF22 *df, float32_t ek, float32_t Umax, float32_t Umin)
Executes a 2nd order Direct Form 2 controller with clamp.
Definition: dcl_df22.h:444
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
_DCL_CODE_ACCESS float32_t DCL_runDF22PartialCompute(DCL_DF22 *df, float32_t ek)
Immediate computation to obtain DF22 servo error without updating the controller.
Definition: dcl_df22.h:417