|
AM243x Motor Control SDK
09.00.00
|
|
Go to the documentation of this file.
48 #include "../dcl_common.h"
55 typedef struct dcl_pi_sps
65 #define PI_SPS_DEFAULTS { 1.0f, 0.0f, 1.0f, -1.0f }
89 #define PI_DEFAULTS { 1.0f, 0.0f, 1.0f, -1.0f, 1.0f, 0.0f, 0.0f, \
90 &(DCL_PI_SPS)PI_SPS_DEFAULTS, &(DCL_CSS)DCL_CSS_DEFAULTS }
100 #define PI_INT_DEFAULTS .i6=1.0f, .i10=0.0f, .i11=0.0f, \
101 .sps=&(DCL_PI_SPS)PI_SPS_DEFAULTS, .css=&(DCL_CSS)DCL_CSS_DEFAULTS
108 #define DCL_initPI() &(DCL_PI)PI_DEFAULTS
116 #define DCL_initPIasParam(kp,ki,umax,umin) &(DCL_PI){ .Kp=kp, .Ki=ki, \
117 .Umax=umax, .Umin=umin, PI_INT_DEFAULTS }
129 #define DCL_initPIasSPS(pi_ptr,sps_ptr) \
131 DCL_PI* new_pi = (pi_ptr) ? pi_ptr : DCL_initPI(); \
132 DCL_PI_SPS* new_sps = (sps_ptr) ? sps_ptr : &(DCL_PI_SPS)PI_SPS_DEFAULTS; \
135 *new_pi = (DCL_PI){ (new_sps)->Kp, (new_sps)->Ki, (new_sps)->Umax, (new_sps)->Umin,\
136 1.0f, 0.0f, 0.0f, (DCL_PI_SPS*)new_sps, &(DCL_CSS)DCL_CSS_DEFAULTS }; \
150 pi->i10 = pi->i11 = 0.0f;
162 #ifdef DCL_ERROR_HANDLING_ENABLED
176 pi->Kp = pi->sps->Kp;
177 pi->Ki = pi->sps->Ki;
178 pi->Umax = pi->sps->Umax;
179 pi->Umin = pi->sps->Umin;
191 #ifdef DCL_ERROR_HANDLING_ENABLED
209 pi->Kp = pi->sps->Kp;
210 pi->Ki = pi->sps->Ki;
211 pi->Umax = pi->sps->Umax;
212 pi->Umin = pi->sps->Umin;
247 pi->sps->Kp = pi->Kp;
248 pi->sps->Ki = pi->Ki;
249 pi->sps->Umax = pi->Umax;
250 pi->sps->Umin = pi->Umin;
265 #ifdef DCL_ERROR_HANDLING_ENABLED
279 pi->sps->Kp = zpk->
K * (1.0f + (t_sec * z1) / 2.0f);
280 pi->sps->Ki = (-2.0f * t_sec * z1) / (2.0f + (t_sec * z1));
295 #ifdef DCL_ERROR_HANDLING_ENABLED
309 pi->sps->Kp = zpk->
K * (1.0f + (t_sec * z1) / 2.0f);
310 pi->sps->Ki = -zpk->
K * t_sec * z1;
325 v2 = pi->Kp * (rk - yk);
326 v4 = pi->i10 + (pi->Ki * pi->i6 * v2);
329 pi->i6 = (v5 == v9) ? 1.0f : 0.0f;
332 #ifdef DCL_TESTPOINTS_ENABLED
354 v4 = (v1 * pi->Ki * pi->i6) + pi->i10;
358 pi->i6 = (v5 == v9) ? 1.0f : 0.0f;
360 #ifdef DCL_TESTPOINTS_ENABLED
382 bool l11, l14, l17, l18, l19;
385 v5 = (v1 * pi->Ki * pi->i6) + pi->i10;
387 v7 = (v1 * pi->Kp) + v5;
389 l17 = (v7 == v8) ?
true :
false;
390 l11 = (
DCL_runSat(v5,Imax,Imin) == v5) ?
true :
false;
391 l19 = (v5 > 0) ?
true :
false;
392 l14 = (v1 > 0) ?
true :
false;
393 l18 = l17 && (!l11 || (l19 ^ l14));
394 pi->i6 = (l18) ? 1.0f : 0.0f;
396 #ifdef DCL_TESTPOINTS_ENABLED
415 v2 = (rk - yk) * pi->Kp;
416 v8 = v2 * pi->Ki * pi->i6;
417 v4 = v8 + pi->i11 + pi->i10;
422 pi->i6 = (v5 == v9) ? 1.0f : 0.0f;
424 #ifdef DCL_TESTPOINTS_ENABLED
float32_t i11
Tustin integrator storage.
Definition: dcl_pi.h:80
float32_t K
Real gain.
Definition: dcl_zpk3.h:69
float32_t Kp
Proportional gain.
Definition: dcl_pi.h:57
float32_t Umax
Upper saturation limit.
Definition: dcl_pi.h:59
float32_t Umin
Lower saturation limit.
Definition: dcl_pi.h:60
_DCL_CODE_ACCESS _DCL_CODE_SECTION float32_t DCL_runPIParallelEnhanced(DCL_PI *pi, float32_t rk, float32_t yk, float32_t Imax, float32_t Imin)
Executes a parallel form PI controller with enhanced anti-windup logic incorporating an addintional i...
Definition: dcl_pi.h:379
@ 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
#define DCL_clearPendingStatus(p)
Definition: dcl_css.h:129
#define DCL_setUpdateStatus(p)
Macros to set and clear the update-in-progress flag.
Definition: dcl_css.h:116
#define DCL_runErrorHandler(ptr)
Prototype for basic error handler.
Definition: dcl_error.h:107
float32_t Umin
Lower control saturation limit.
Definition: dcl_pi.h:75
@ dcl_param_range_err
Parameter range exceeded.
Definition: dcl_error.h:58
float32_t Ki
Integral gain.
Definition: dcl_pi.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
#define _DCL_CODE_ACCESS
Defines the scope of dcl functions (static inline/extern inline/none)
Definition: dcl_common.h:55
_DCL_VOLATILE struct dcl_pi * PI_Handle
@ dcl_none
No error.
Definition: dcl_error.h:57
_DCL_CODE_ACCESS void DCL_resetPI(DCL_PI *pi)
Resets PI internal storage data with interrupt protection.
Definition: dcl_pi.h:146
_DCL_CODE_ACCESS void DCL_loadParallelPIasZPK(DCL_PI *pi, DCL_ZPK3 *zpk)
Configures a parallel PI controller in "zero-pole-gain" form Note: Sampling period pi->css->t_sec are...
Definition: dcl_pi.h:293
uint32_t dcl_interrupt_t
Definition: dcl_common.h:96
_DCL_CODE_ACCESS _DCL_CODE_SECTION bool DCL_pendingUpdatePI(DCL_PI *pi)
A conditional update based on the pending-for-update flag. If the pending status is set,...
Definition: dcl_pi.h:229
_DCL_CODE_ACCESS _DCL_CODE_SECTION float32_t DCL_runPISeriesTustin(DCL_PI *pi, float32_t rk, float32_t yk)
Executes a series form PI controller with Tustin integrator.
Definition: dcl_pi.h:411
DCL_PI object for storing PI specific parameters.
Definition: dcl_pi.h:70
DCL_PI_SPS * sps
updates controller parameter
Definition: dcl_pi.h:83
@ dcl_param_invalid_err
Parameter not valid.
Definition: dcl_error.h:59
float32_t i10
I path feedback value.
Definition: dcl_pi.h:79
_DCL_CODE_ACCESS _DCL_CODE_SECTION bool DCL_updatePI(DCL_PI *pi)
Updates PI parameter from its SPS parameter with interrupt protection.
Definition: dcl_pi.h:188
_DCL_VOLATILE struct dcl_pi DCL_PI
#define DCL_runSat(data, Umax, Umin)
Macro to saturate a control variable but does not change the data itself unlike runClamp()
Definition: dcl_clamp.h:89
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
float32_t Ki
Integral gain.
Definition: dcl_pi.h:73
#define DCL_restoreInts(v)
Definition: dcl_common.h:95
_DCL_CODE_ACCESS void DCL_fupdatePI(DCL_PI *pi)
Loads PI tuning parameter from its SPS parameter
Definition: dcl_pi.h:159
float32_t Umax
Upper control saturation limit.
Definition: dcl_pi.h:74
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 void DCL_loadSeriesPIasZPK(DCL_PI *pi, DCL_ZPK3 *zpk)
Configures a series PI controller in "zero-pole-gain" form Note: Sampling period pi->css->t_sec are u...
Definition: dcl_pi.h:263
#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 Kp
Proportional gain.
Definition: dcl_pi.h:72
Defines DCL_PI shadow parameter set used for updating controller parameter.
Definition: dcl_pi.h:56
_DCL_CODE_ACCESS _DCL_CODE_SECTION float32_t DCL_runPISeries(DCL_PI *pi, float32_t rk, float32_t yk)
Executes an inline series form PI controller.
Definition: dcl_pi.h:321
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_CODE_ACCESS _DCL_CODE_SECTION float32_t DCL_runPIParallel(DCL_PI *pi, float32_t rk, float32_t yk)
Executes a parallel form PI controller Implemented as inline C function.
Definition: dcl_pi.h:348
_DCL_CODE_ACCESS void DCL_updatePISPS(DCL_PI *pi)
Update SPS parameter with active param, userful when needing to update only few active param from SPS...
Definition: dcl_pi.h:245
DCL_CSS * css
configuration & debugging
Definition: dcl_pi.h:84
float complex z1
Complex zeros 1.
Definition: dcl_zpk3.h:63
float32_t i6
Saturation storage.
Definition: dcl_pi.h:78
#define DCL_disableInts()
Define enable and disable interrupt operations.
Definition: dcl_common.h:94