AM263x Motor Control SDK  09.00.00
dcl_pid.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2023 Texas Instruments Incorporated
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  *
8  * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  *
11  * Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in the
13  * documentation and/or other materials provided with the
14  * distribution.
15  *
16  * Neither the name of Texas Instruments Incorporated nor the names of
17  * its contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * "AS IS" AND ANY EXPgResS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 
33 #ifndef _DCL_PID_H_
34 #define _DCL_PID_H_
35 
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39 
48 #include "../dcl_common.h"
49 
50 //--- Linear PID controller --------------------------------------------------
51 
55 typedef struct dcl_pid_sps
56 {
65 } DCL_PID_SPS;
66 
69 #define PID_SPS_DEFAULTS { 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f, -1.0f }
70 
73 typedef _DCL_VOLATILE struct dcl_pid
74 {
75  /* controller parameter */
84 
85  /* internal storage */
90 
91  /* miscellaneous */
95 
98 #define PID_DEFAULTS { 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, \
99  1.0f, -1.0f, 0.0f, 0.0f, 0.0f, 1.0f, \
100  &(DCL_PID_SPS)PID_SPS_DEFAULTS, &(DCL_CSS)DCL_CSS_DEFAULTS }
101 
110 #define PID_INT_DEFAULTS .d2=0.0f, .d3=0.0f, .i10=0.0f, .i14=1.0f, \
111  .sps=&(DCL_PID_SPS)PID_SPS_DEFAULTS, .css=&(DCL_CSS)DCL_CSS_DEFAULTS
112 
118 #define DCL_initPID() &(DCL_PID)PID_DEFAULTS
119 
126 #define DCL_initPIDasParam(kp,ki,kd,kr,_c1,_c2,umax,umin) &(DCL_PID){ .Kp=kp, .Ki=ki, .Kd=kd, .Kr=kr, \
127  .c1=_c1, .c2=_c2, .Umax=umax, .Umin=umin, PID_INT_DEFAULTS }
128 
140 #define DCL_initPIDasSPS(pid_ptr,sps_ptr) \
141 ({ \
142  DCL_PID* new_pid = (pid_ptr) ? pid_ptr : DCL_initPID(); \
143  DCL_PID_SPS* new_sps = (sps_ptr) ? sps_ptr : &(DCL_PID_SPS)PID_SPS_DEFAULTS; \
144  if(sps_ptr) \
145  { \
146  *new_pid = (DCL_PID){ (new_sps)->Kp, (new_sps)->Ki, (new_sps)->Kd,(new_sps)->Kr,\
147  (new_sps)->c1, (new_sps)->c2, (new_sps)->Umax, (new_sps)->Umin, 0.0f, 0.0f, \
148  0.0f, 1.0f, (DCL_PID_SPS*)new_sps, &(DCL_CSS)DCL_CSS_DEFAULTS }; \
149  } \
150  new_pid; \
151 })
152 
159 {
161  pid->d2 = pid->d3 = pid->i10 = 0.0f;
162  pid->i14 = 1.0f;
163  DCL_restoreInts(ints);
164 }
165 
172 {
173 
174 #ifdef DCL_ERROR_HANDLING_ENABLED
175  float32_t tau = (2.0f - pid->sps->c1 * pid->css->t_sec) / (2.0f * pid->sps->c1);
176  float32_t ec2 = pid->sps->c1 * (pid->css->t_sec - 2.0f * tau) / 2.0f;
177  uint32_t err_code = dcl_none;
178  err_code |= DCL_isValue(pid->sps->c2, ec2) ? dcl_none : dcl_param_invalid_err;
179  err_code |= (pid->sps->Umax > pid->sps->Umin) ? dcl_none : dcl_param_invalid_err;
180  err_code |= (pid->css->t_sec > 0.0f) ? dcl_none : dcl_param_range_err;
181  err_code |= ((pid->sps->Kp > 0.0f) && (pid->sps->Ki > 0.0f) && (pid->sps->Kd > 0.0f) && (pid->sps->Kr > 0.0f)) ? dcl_none : dcl_param_range_err ;
182  if (err_code)
183  {
184  DCL_setError(pid,err_code);
185  DCL_getErrorInfo(pid);
186  DCL_runErrorHandler(pid);
187  }
188 #endif
189 
190  pid->Kp = pid->sps->Kp;
191  pid->Ki = pid->sps->Ki;
192  pid->Kd = pid->sps->Kd;
193  pid->Kr = pid->sps->Kr;
194  pid->c1 = pid->sps->c1;
195  pid->c2 = pid->sps->c2;
196  pid->Umax = pid->sps->Umax;
197  pid->Umin = pid->sps->Umin;
198 }
199 
207 {
208 
209 #ifdef DCL_ERROR_HANDLING_ENABLED
210  float32_t tau = (2.0f - pid->sps->c1 * pid->css->t_sec) / (2.0f * pid->sps->c1);
211  float32_t ec2 = pid->sps->c1 * (pid->css->t_sec - 2.0f * tau) / 2.0f;
212  uint32_t err_code = dcl_none;
213  err_code |= DCL_isValue(pid->sps->c2, ec2) ? dcl_none : dcl_param_invalid_err;
214  err_code |= (pid->sps->Umax > pid->sps->Umin) ? dcl_none : dcl_param_invalid_err;
215  err_code |= (pid->css->t_sec > 0.0f) ? dcl_none : dcl_param_range_err;
216  err_code |= ((pid->sps->Kp > 0.0f) && (pid->sps->Ki > 0.0f) && (pid->sps->Kd > 0.0f) && (pid->sps->Kr > 0.0f)) ? dcl_none : dcl_param_range_err ;
217  if (err_code)
218  {
219  DCL_setError(pid,err_code);
220  DCL_getErrorInfo(pid);
221  DCL_runErrorHandler(pid);
222  }
223 #endif
224 
225  if (!DCL_getUpdateStatus(pid))
226  {
228  DCL_setUpdateStatus(pid);
229  pid->Kp = pid->sps->Kp;
230  pid->Ki = pid->sps->Ki;
231  pid->Kd = pid->sps->Kd;
232  pid->Kr = pid->sps->Kr;
233  pid->c1 = pid->sps->c1;
234  pid->c2 = pid->sps->c2;
235  pid->Umax = pid->sps->Umax;
236  pid->Umin = pid->sps->Umin;
238  DCL_restoreInts(ints);
239  return true;
240  }
241  return false;
242 }
243 
254 {
255  if (DCL_getPendingStatus(pid) && DCL_updatePID(pid))
256  {
258  return true;
259  }
260  return false;
261 }
262 
270 {
271  pid->sps->Kp = pid->Kp;
272  pid->sps->Ki = pid->Ki;
273  pid->sps->Kd = pid->Kd;
274  pid->sps->Kr = pid->Kr;
275  pid->sps->c1 = pid->c1;
276  pid->sps->c2 = pid->c2;
277  pid->sps->Umax = pid->Umax;
278  pid->sps->Umin = pid->Umin;
279 }
280 
290 {
291 
292 #ifdef DCL_ERROR_HANDLING_ENABLED
293  uint32_t err_code = dcl_none;
294  err_code |= ((fc >= 1.0f / (2.0f * pid->css->t_sec)) || (fc <= 0.0f)) ? dcl_param_range_err : dcl_none;
295  if (err_code)
296  {
297  DCL_setError(pid,err_code);
298  DCL_getErrorInfo(pid);
299  DCL_runErrorHandler(pid);
300  }
301 #endif
302 
303  float32_t t_sec = pid->css->t_sec;
304  float32_t tau = 1.0f / (2.0f * CONST_PI * fc);
305  pid->sps->c1 = 2.0f / (t_sec + (2.0f * tau));
306  pid->sps->c2 = (t_sec - (2.0f * tau)) / (t_sec + (2.0f * tau));
307 }
308 
319 {
320 
321 #ifdef DCL_ERROR_HANDLING_ENABLED
322  uint32_t err_code = dcl_none;
323  err_code |= ((fc >= 1.0f / (2.0f * t_sec)) || (fc <= 0.0f)) ? dcl_param_range_err : dcl_none;
324  if (err_code)
325  {
326  DCL_setError(pid,err_code);
327  DCL_getErrorInfo(pid);
328  DCL_runErrorHandler(pid);
329  }
330 #endif
331 
332  float32_t tau = 1.0f / (2.0f * CONST_PI * fc);
333  pid->c1 = 2.0f / (t_sec + (2.0f * tau));
334  pid->c2 = (t_sec - (2.0f * tau)) / (t_sec + (2.0f * tau));
335 }
336 
344 {
345  float32_t tau = ((2.0f - pid->c1 * pid->css->t_sec) / (2.0f * pid->c1));
346  return(1.0f / (2.0f * CONST_PI * tau));
347 }
348 
359 {
360 
361 #ifdef DCL_ERROR_HANDLING_ENABLED
362  uint32_t err_code = dcl_none;
363  err_code |= DCL_isZero(cimagf(zpk->z1) + cimagf(zpk->z2)) ? dcl_none : dcl_param_invalid_err;
364  err_code |= DCL_isZero(cimagf(zpk->p2)) ? dcl_none : dcl_param_invalid_err;
365  err_code |= (crealf(zpk->p2) <= DCL_c2Limit) ? dcl_none :dcl_param_invalid_err;
366  err_code |= (zpk->K >= 0.0f) ? dcl_none : dcl_param_range_err;
367  if (err_code)
368  {
369  DCL_setError(pid,err_code);
370  DCL_getErrorInfo(pid);
371  DCL_runErrorHandler(pid);
372  }
373 #endif
374 
375  float32_t beta1 = -(float32_t) crealf(zpk->z1 + zpk->z2);
376  float32_t beta0 = (float32_t) crealf(zpk->z1 * zpk->z2);
377  float32_t alpha1 = -(float32_t) crealf(zpk->p1 + zpk->p2);
378  float32_t alpha0 = (float32_t) crealf(zpk->p1 * zpk->p2);
379  float32_t t_sec = pid->css->t_sec;
380  float32_t a0p = 4.0f + (alpha1 * 2.0f * t_sec) + (alpha0 * t_sec * t_sec);
381  float32_t b0 = zpk->K * (4.0f + (beta1 * 2.0f * t_sec) + (beta0 * t_sec *t_sec)) / a0p;
382  float32_t b1 = zpk->K * (-8.0f + (2.0f * beta0 * t_sec * t_sec)) / a0p;
383  float32_t b2 = zpk->K * (4.0f - (beta1 * 2.0f * t_sec) + (beta0 * t_sec * t_sec)) / a0p;
384  float32_t a2 = (4.0f - (alpha1 * 2.0f * t_sec) + (alpha0 * t_sec * t_sec)) / a0p;
385  float32_t c2 = -a2;
386  float32_t tau = (t_sec / 2.0f) * (1.0f - c2) / (1.0f + c2);
387  pid->sps->c1 = 2.0f / (t_sec + 2.0f * tau);
388  pid->sps->c2 = c2;
389  float32_t det = (c2 + 1.0f);
390  det *= det;
391 
392 #ifdef DCL_ERROR_HANDLING_ENABLED
393  err_code = dcl_none;
394  err_code |= (DCL_isZero(det)) ? dcl_param_invalid_err : dcl_none;
395  if (err_code)
396  {
397  DCL_setError(pid,err_code);
398  DCL_getErrorInfo(pid);
399  DCL_runErrorHandler(pid);
400  }
401 #endif
402 
403  float32_t k1 = ((c2 * b0) - b1 - ((2.0f + c2) * b2)) / det;
404  float32_t k2 = (c2 + 1.0f) * (b0 + b1 + b2) / det;
405  float32_t k3 = ((c2 * c2 * b0) - (c2 * b1) + b2) / det;
406  pid->sps->Kp = k1;
407  pid->sps->Ki = k2 / k1;
408  pid->sps->Kd = k3 / (k1 * pid->sps->c1);
409 
410 #ifdef DCL_TESTPOINTS_ENABLED
411  pid->css->tpt = det;
412 #endif
413 
414 }
415 
426 {
427 #ifdef DCL_ERROR_HANDLING_ENABLED
428  uint32_t err_code = dcl_none;
429  err_code |= DCL_isZero(cimagf(zpk->z1) + cimagf(zpk->z2)) ? dcl_none : dcl_param_invalid_err;
430  err_code |= DCL_isZero(cimagf(zpk->p2)) ? dcl_none : dcl_param_invalid_err;
431  err_code |= (crealf(zpk->p2) <= DCL_c2Limit) ? dcl_none : dcl_param_invalid_err;
432  err_code |= (zpk->K >= 0.0f) ? dcl_none : dcl_param_range_err;
433  if (err_code)
434  {
435  DCL_setError(pid,err_code);
436  DCL_getErrorInfo(pid);
437  DCL_runErrorHandler(pid);
438  }
439 #endif
440 
441  float32_t beta1 = -(float32_t) crealf(zpk->z1 + zpk->z2);
442  float32_t beta0 = (float32_t) crealf(zpk->z1 * zpk->z2);
443  float32_t alpha1 = -(float32_t) crealf(zpk->p1 + zpk->p2);
444  float32_t alpha0 = (float32_t) crealf(zpk->p1 * zpk->p2);
445  float32_t t_sec = pid->css->t_sec;
446  float32_t a0p = 4.0f + (alpha1 * 2.0f * t_sec) + (alpha0 * t_sec * t_sec);
447  float32_t b0 = zpk->K * (4.0f + (beta1 * 2.0f * t_sec) + (beta0 * t_sec * t_sec)) / a0p;
448  float32_t b1 = zpk->K * (-8.0f + (2.0f * beta0 * t_sec * t_sec)) / a0p;
449  float32_t b2 = zpk->K * (4.0f - (beta1 * 2.0f * t_sec) + (beta0 * t_sec * t_sec)) / a0p;
450  float32_t a2 = (4.0f - (alpha1 * 2.0f * t_sec) + (alpha0 * t_sec * t_sec)) / a0p;
451  float32_t c2 = -a2;
452  float32_t tau = (t_sec / 2.0f) * (1.0f - c2) / (1.0f + c2);
453  pid->sps->c1 = 2.0f / (t_sec + 2.0f * tau);
454  pid->sps->c2 = c2;
455  float32_t det = (c2 + 1.0f);
456  det *= det;
457 
458 #ifdef DCL_ERROR_HANDLING_ENABLED
459  err_code = (DCL_isZero(det)) ? dcl_param_invalid_err : dcl_none;
460  if (err_code)
461  {
462  DCL_setError(pid,err_code);
463  DCL_getErrorInfo(pid);
464  DCL_runErrorHandler(pid);
465  }
466 #endif
467 
468  pid->sps->Kp = ((c2 * b0) - b1 - ((2.0f + c2) * b2)) / det;
469  pid->sps->Ki = (c2 + 1.0f) * (b0 + b1 + b2) / det;
470  pid->sps->Kd = ((c2 * c2 * b0) - (c2 * b1) + b2) / (det * pid->sps->c1);
471 
472 #ifdef DCL_TESTPOINTS_ENABLED
473  pid->css->tpt = det;
474 #endif
475 
476 }
477 
488 {
489  float32_t v1, v4, v5, v8, v9, v10, v12;
490 
491  v5 = (pid->Kr * rk) - yk;
492  v8 = ((rk - yk) * pid->Ki * pid->Kp * pid->i14) + pid->i10;
493  pid->i10 = v8;
494  v1 = yk * pid->Kd * pid->c1;
495  v4 = v1 - pid->d2 - pid->d3;
496  pid->d2 = v1;
497  pid->d3 = v4 * pid->c2;
498  v9 = ((v5 - v4) * pid->Kp) + v8;
499  v10 = DCL_runSat(v9, pid->Umax, pid->Umin);
500  v12 = (v10 == v9) ? 1.0f : 0.0f;
501  pid->i14 = v12 * lk;
502 
503 #ifdef DCL_TESTPOINTS_ENABLED
504  pid->css->tpt = v4;
505 #endif
506 
507  return(v10);
508 }
509 
520 {
521  float32_t v1, v4, v5, v6, v8, v9, v10, v12;
522 
523  v5 = rk - yk;
524  v6 = v5 * pid->Kp;
525  v8 = v5 * pid->Ki * pid->i14 + pid->i10;
526  pid->i10 = v8;
527  v1 = v5 * pid->Kd * pid->c1;
528  v4 = v1 - pid->d2 - pid->d3;
529  pid->d2 = v1;
530  pid->d3 = v4 * pid->c2;
531  v9 = v6 + v8 + v4;
532  v10 = DCL_runSat(v9, pid->Umax, pid->Umin);
533  v12 = (v10 == v9) ? 1.0f : 0.0f;
534  pid->i14 = v12 * lk;
535 
536 #ifdef DCL_TESTPOINTS_ENABLED
537  pid->css->tpt = v8;
538 #endif
539 
540  return(v10);
541 }
542 
545 #ifdef __cplusplus
546 }
547 #endif // extern "C"
548 
549 #endif // _DCL_PID_H_
dcl_pid::sps
DCL_PID_SPS * sps
updates controller parameter
Definition: dcl_pid.h:92
DCL_fupdatePID
_DCL_CODE_ACCESS void DCL_fupdatePID(DCL_PID *pid)
Loads PID tuning parameter from its SPS parameter.
Definition: dcl_pid.h:171
DCL_updatePID
_DCL_CODE_ACCESS _DCL_CODE_SECTION bool DCL_updatePID(DCL_PID *pid)
Updates PID parameter from its SPS parameter with interrupt protection.
Definition: dcl_pid.h:206
DCL_PID
_DCL_VOLATILE struct dcl_pid DCL_PID
dcl_pid::c1
float32_t c1
D path filter coefficient 1, default is 1.
Definition: dcl_pid.h:80
DCL_isValue
#define DCL_isValue(x, y)
Determines numerical proximity to specified value.
Definition: dcl_aux.h:72
DCL_setActivePIDfilterBW
_DCL_CODE_ACCESS void DCL_setActivePIDfilterBW(DCL_PID *pid, float32_t fc, float32_t t_sec)
Loads the PID derivative path filter active coefficients Note: Sampling period pid->css->t_sec are us...
Definition: dcl_pid.h:318
CONST_PI
#define CONST_PI
Local definitions of the mathematical constant pi.
Definition: dcl_aux.h:55
dcl_pid::Umin
float32_t Umin
Lower saturation limit
Definition: dcl_pid.h:83
DCL_ZPK3::K
float32_t K
Real gain.
Definition: dcl_zpk3.h:69
DCL_setPIDfilterBW
_DCL_CODE_ACCESS void DCL_setPIDfilterBW(DCL_PID *pid, float32_t fc)
Loads the derivative path filter shadow coefficients. Note: Sampling period pid->css->t_sec are used ...
Definition: dcl_pid.h:289
DCL_updatePIDSPS
_DCL_CODE_ACCESS void DCL_updatePIDSPS(DCL_PID *pid)
Update SPS parameter with active param, userful when needing to update only few active param from SPS...
Definition: dcl_pid.h:269
DCL_PID_SPS::Kp
float32_t Kp
Proportional gain.
Definition: dcl_pid.h:57
DCL_ZPK3::z2
float complex z2
Complex zeros 2.
Definition: dcl_zpk3.h:64
DCL_PID_SPS::Umax
float32_t Umax
Upper saturation limit.
Definition: dcl_pid.h:63
_DCL_CODE_SECTION
#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_clearPendingStatus
#define DCL_clearPendingStatus(p)
Definition: dcl_css.h:129
DCL_ZPK3::p2
float complex p2
Complex poles 2.
Definition: dcl_zpk3.h:67
DCL_PID_SPS
Defines DCL_PID shadow parameter set used for updating controller parameter.
Definition: dcl_pid.h:56
DCL_setUpdateStatus
#define DCL_setUpdateStatus(p)
Macros to set and clear the update-in-progress flag.
Definition: dcl_css.h:116
dcl_pid::Umax
float32_t Umax
Upper saturation limit.
Definition: dcl_pid.h:82
dcl_pid
DCL_PID object for storing PID specific parameters.
Definition: dcl_pid.h:74
DCL_runErrorHandler
#define DCL_runErrorHandler(ptr)
Prototype for basic error handler.
Definition: dcl_error.h:107
DCL_pendingUpdatePID
_DCL_CODE_ACCESS _DCL_CODE_SECTION bool DCL_pendingUpdatePID(DCL_PID *pid)
A conditional update based on the pending-for-update flag. If the pending status is set,...
Definition: dcl_pid.h:253
dcl_param_range_err
@ dcl_param_range_err
Parameter range exceeded.
Definition: dcl_error.h:58
DCL_PID_SPS::Kd
float32_t Kd
Derivative gain.
Definition: dcl_pid.h:59
DCL_runPIDParallel
_DCL_CODE_ACCESS _DCL_CODE_SECTION float32_t DCL_runPIDParallel(DCL_PID *pid, float32_t rk, float32_t yk, float32_t lk)
Executes a parallel form PID controller.
Definition: dcl_pid.h:519
DCL_getUpdateStatus
#define DCL_getUpdateStatus(p)
Determine whether a parameter update-in-progress flag is set.
Definition: dcl_css.h:123
dcl_pid::d3
float32_t d3
D path feedback value (c2)
Definition: dcl_pid.h:87
DCL_clearUpdateStatus
#define DCL_clearUpdateStatus(p)
Definition: dcl_css.h:117
DCL_PID_SPS::c2
float32_t c2
D path filter coefficient 2, default is 0.
Definition: dcl_pid.h:62
_DCL_CODE_ACCESS
#define _DCL_CODE_ACCESS
Defines the scope of dcl functions (static inline/extern inline/none)
Definition: dcl_common.h:55
DCL_ZPK3::p1
float complex p1
Complex poles 1.
Definition: dcl_zpk3.h:66
DCL_resetPID
_DCL_CODE_ACCESS void DCL_resetPID(DCL_PID *pid)
Resets PID internal storage data with interrupt protection.
Definition: dcl_pid.h:158
dcl_pid::Kp
float32_t Kp
Proportional gain.
Definition: dcl_pid.h:76
dcl_none
@ dcl_none
No error.
Definition: dcl_error.h:57
dcl_pid::i14
float32_t i14
I path saturation storage.
Definition: dcl_pid.h:89
dcl_interrupt_t
uint32_t dcl_interrupt_t
Definition: dcl_common.h:96
DCL_getPIDfilterBW
_DCL_CODE_ACCESS float32_t DCL_getPIDfilterBW(DCL_PID *pid)
Calculates the active derivative path filter bandwidth in Hz. Note: Sampling period pid->css->t_sec a...
Definition: dcl_pid.h:343
dcl_pid::Ki
float32_t Ki
Integral gain.
Definition: dcl_pid.h:77
PID_Handle
_DCL_VOLATILE struct dcl_pid * PID_Handle
DCL_isZero
#define DCL_isZero(x)
Determines floating point numerical proximity to zero.
Definition: dcl_aux.h:77
DCL_PID_SPS::Umin
float32_t Umin
Lower saturation limit.
Definition: dcl_pid.h:64
dcl_pid::c2
float32_t c2
D path filter coefficient 2, default is 0.
Definition: dcl_pid.h:81
dcl_pid::Kr
float32_t Kr
Set point weight, default is 1.
Definition: dcl_pid.h:79
DCL_c2Limit
#define DCL_c2Limit
Defines the lower limit on derivative filter coefficient c2 in order for fc to lie below the Nyquist ...
Definition: dcl_aux.h:93
dcl_param_invalid_err
@ dcl_param_invalid_err
Parameter not valid.
Definition: dcl_error.h:59
DCL_loadParallelPIDasZPK
_DCL_CODE_ACCESS void DCL_loadParallelPIDasZPK(DCL_PID *pid, DCL_ZPK3 *zpk)
Configures a parallel PID controller in ZPK form. Note: Sampling period pid->css->t_sec are used in t...
Definition: dcl_pid.h:425
DCL_runSat
#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
DCL_CSS
Defines the controller common support structure.
Definition: dcl_css.h:57
DCL_getPendingStatus
#define DCL_getPendingStatus(p)
Determine whether a parameter pending-for-update flag is set.
Definition: dcl_css.h:135
DCL_restoreInts
#define DCL_restoreInts(v)
Definition: dcl_common.h:95
dcl_pid::i10
float32_t i10
I path feedback value.
Definition: dcl_pid.h:88
DCL_ZPK3
Defines the DCL_ZPK3 controller structure.
Definition: dcl_zpk3.h:62
_DCL_VOLATILE
#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_pid::css
DCL_CSS * css
configuration & debugging
Definition: dcl_pid.h:93
DCL_getErrorInfo
#define DCL_getErrorInfo(ptr)
Macro to store error info in CSS.
Definition: dcl_error.h:97
DCL_PID_SPS::c1
float32_t c1
D path filter coefficient 1, default is 1.
Definition: dcl_pid.h:61
DCL_PID_SPS::Ki
float32_t Ki
Integral gain.
Definition: dcl_pid.h:58
DCL_setError
#define DCL_setError(ptr, code)
Macro to set error code in CSS.
Definition: dcl_error.h:79
DCL_runPIDSeries
_DCL_CODE_ACCESS _DCL_CODE_SECTION float32_t DCL_runPIDSeries(DCL_PID *pid, float32_t rk, float32_t yk, float32_t lk)
Executes an ideal form PID controller.
Definition: dcl_pid.h:487
DCL_loadSeriesPIDasZPK
_DCL_CODE_ACCESS void DCL_loadSeriesPIDasZPK(DCL_PID *pid, DCL_ZPK3 *zpk)
Configures a series PID controller parameter in ZPK form. Note: Sampling period pid->css->t_sec are u...
Definition: dcl_pid.h:358
float32_t
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_pid::d2
float32_t d2
D path feedback value (Kd * c1)
Definition: dcl_pid.h:86
dcl_pid::Kd
float32_t Kd
Derivative gain.
Definition: dcl_pid.h:78
DCL_ZPK3::z1
float complex z1
Complex zeros 1.
Definition: dcl_zpk3.h:63
DCL_disableInts
#define DCL_disableInts()
Define enable and disable interrupt operations.
Definition: dcl_common.h:94
DCL_PID_SPS::Kr
float32_t Kr
Set point weight, default is 1.
Definition: dcl_pid.h:60