|
AM263x Digital Power SDK
09.01.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 }; \
151 df->x1 = df->x2 = 0.0f;
162 df->b0 = df->sps->b0;
163 df->b1 = df->sps->b1;
164 df->b2 = df->sps->b2;
165 df->a1 = df->sps->a1;
166 df->a2 = df->sps->a2;
178 df->b0 = df->sps->b0;
179 df->b1 = df->sps->b1;
180 df->b2 = df->sps->b2;
181 df->a1 = df->sps->a1;
182 df->a2 = df->sps->a2;
229 #ifdef DCL_ERROR_HANDLING_ENABLED
247 float32_t a0p = 4.0f + (alpha1 * 2.0f * T) + (alpha0 * T * T);
249 df->sps->b0 = zpk->
K * (4.0f + (beta1 * 2.0f * T) + (beta0 * T * T)) / a0p;
250 df->sps->b1 = zpk->
K * (-8.0f + (2.0f * beta0 * T * T)) / a0p;
251 df->sps->b2 = zpk->
K * (4.0f - (beta1 * 2.0f * T) + (beta0 * T * T)) / a0p;
252 df->sps->a1 = (-8.0f + (2.0f * alpha0 * T * T)) / a0p;
253 df->sps->a2 = (4.0f - (alpha1 * 2.0f * T) + (alpha0 * T * T)) / a0p;
269 #ifdef DCL_ERROR_HANDLING_ENABLED
283 float32_t a2p = 1.0f / (4.0f + (4.0f * z * wn * T) + v1);
284 df->sps->b0 = v1 * a2p;
285 df->sps->b1 = 2.0f * df->sps->b0;
286 df->sps->b2 = df->sps->b0;
287 df->sps->a1 = ((2.0f * v1) - 8.0f) * a2p;
288 df->sps->a2 = (4.0f - (4.0f * z * wn * T) + v1) * a2p;
305 #ifdef DCL_ERROR_HANDLING_ENABLED
321 float32_t c1 = 2.0f / (T + (2.0f * tau));
322 float32_t c2 = c1 * (T - (2.0f * tau)) / 2.0f;
324 df->sps->b0 = Kp * (1 + Ki + Kdp);
325 df->sps->b1 = Kp * (c2 - 1 + Ki*c2 - 2*Kdp);
326 df->sps->b2 = Kp * (-c2 + Kdp);
327 df->sps->a1 = c2 - 1;
345 #ifdef DCL_ERROR_HANDLING_ENABLED
362 float32_t c1 = 2.0f / (T + (2.0f * tau));
363 float32_t c2 = c1 * (T - (2.0f * tau)) / 2.0f;
365 df->sps->b0 = Kp + Ki + Kdp;
366 df->sps->b1 = (Kp * (c2 - 1)) + (Ki * c2) - (2.0f * Kdp);
367 df->sps->b2 = (-c2 * Kp) + Kdp;
368 df->sps->a1 = c2 - 1;
382 df->x1 = (ek * df->b1) + df->x2 - (v7 * df->a1);
383 df->x2 = (ek * df->b2) - (v7 * df->a2);
398 return((ek * df->b0) + df->x1);
410 df->x1 = (ek * df->b1) + df->x2 - (uk * df->a1);
411 df->x2 = (ek * df->b2) - (uk * df->a2);
437 #endif // _DCL_DF22_H_
float32_t b2
pos. coefficient to e(k-2)
Definition: dcl_df22.h:61
#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)
A conditional update based on the update flag. If the update status is set, the function will update ...
Definition: dcl_df22.h:195
_DCL_CODE_ACCESS bool DCL_isStableDF22(DCL_DF22 *df)
Determines stability of the shadow compensator.
Definition: dcl_df22.h:212
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:63
_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:408
_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:379
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:115
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:342
#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_clearUpdateStatus(p)
Definition: dcl_css.h:116
_DCL_VOLATILE struct dcl_df22 DCL_DF22
_DCL_CODE_ACCESS void DCL_forceUpdateDF22(DCL_DF22 *df)
Loads DF22 tuning parameter from its SPS parameter without interrupt protection.
Definition: dcl_df22.h:160
#define _DCL_CODE_ACCESS
Defines the scope of dcl functions (static inline/extern inline/none)
Definition: dcl_common.h:58
_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 are used ...
Definition: dcl_df22.h:226
_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:302
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:99
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
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:266
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_restoreInts(v)
Definition: dcl_common.h:98
_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
_DCL_CODE_ACCESS _DCL_CODE_SECTION void DCL_updateDF22NoCheck(DCL_DF22 *df)
Loads DF22 tuning parameter from its SPS parameter with interrupt protection.
Definition: dcl_df22.h:174
#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:71
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:54
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:423
float complex z1
Complex zeros 1.
Definition: dcl_zpk3.h:63
#define DCL_disableInts()
Define enable and disable interrupt operations.
Definition: dcl_common.h:97
_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:396