AM263x Motor Control SDK  09.02.00
dcl_nlpid.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2024 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 EXPRESS 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_NLPID_H_
34 #define _DCL_NLPID_H_
35 
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39 
48 #include <math.h>
49 #include "../dcl_common.h"
50 
53 #define DCL_DELTA_MIN 1.0e-04f
54 
58 #define DCL_GAMMA_MAX 100
59 
62 typedef struct dcl_nlpid_sps
63 {
81 
84 #define NLPID_SPS_DEFAULTS { 1.0f, 0.0f, 0.0f, \
85  1.0f, 1.0f, 1.0f, \
86  0.1f, 0.1f, 0.1f, \
87  1.0f, 1.0f, 1.0f, \
88  1.0f, 0.0f, \
89  1.0f, -1.0f }
90 
93 typedef _DCL_VOLATILE struct dcl_nlpid
94 {
95  /* controller parameter */
112 
113  /* internal storage */
118 
120 
121  /* miscellaneous */
125 
128 #define NLPID_DEFAULTS { 1.0f, 0.0f, 0.0f, \
129  1.0f, 1.0f, 1.0f, \
130  0.1f, 0.1f, 0.1f, \
131  1.0f, 1.0f, 1.0f, \
132  1.0f, 0.0f, \
133  0.0f, 0.0f, \
134  0.0f, 1.0f, 0.0f, 1.0f, 0.0f, \
135  &(DCL_NLPID_SPS)NLPID_SPS_DEFAULTS, &(DCL_CSS)DCL_CSS_DEFAULTS }
136 
143 {
144  dcl_interrupt_t ints;
145  ints = DCL_disableInts();
146  pid->d2 = pid->d3 = pid->i7 = 0.0f;
147  pid->i16 = 1.0f;
148  DCL_restoreInts(ints);
149 }
150 
157 {
158  pid->Kp = pid->sps->Kp;
159  pid->Ki = pid->sps->Ki;
160  pid->Kd = pid->sps->Kd;
161  pid->alpha_p = pid->sps->alpha_p;
162  pid->alpha_i = pid->sps->alpha_i;
163  pid->alpha_d = pid->sps->alpha_d;
164  pid->delta_p = pid->sps->delta_p;
165  pid->delta_i = pid->sps->delta_i;
166  pid->delta_d = pid->sps->delta_d;
167  pid->gamma_p = pid->sps->gamma_p;
168  pid->gamma_i = pid->sps->gamma_i;
169  pid->gamma_d = pid->sps->gamma_d;
170  pid->c1 = pid->sps->c1;
171  pid->c2 = pid->sps->c2;
172  pid->Umax = pid->sps->Umax;
173  pid->Umin = pid->sps->Umin;
174 }
175 
182 {
183 
184 #ifdef DCL_ERROR_HANDLING_ENABLED
185  float32_t tau = (2.0f - pid->sps->c1 * pid->css->T) / (2.0f * pid->sps->c1);
186  float32_t ec2 = pid->sps->c1 * (pid->css->T - 2.0f * tau) / 2.0f;
187  uint32_t err_code = dcl_none;
188  err_code |= ((pid->sps->c2 < (ec2 - DCL_FPU32_TOL)) || (pid->sps->c2 > (ec2 + DCL_FPU32_TOL))) ? dcl_param_invalid_err : dcl_none;
189  err_code |= (pid->sps->delta_p < DCL_DELTA_MIN) ? dcl_param_range_err : dcl_none;
190  err_code |= (pid->sps->delta_i < DCL_DELTA_MIN) ? dcl_param_range_err : dcl_none;
191  err_code |= (pid->sps->delta_d < DCL_DELTA_MIN) ? dcl_param_range_err : dcl_none;
192  err_code |= (pid->sps->Umax <= pid->sps->Umin) ? dcl_param_invalid_err : dcl_none;
193  err_code |= (pid->css->T <= 0.0f) ? dcl_param_range_err : dcl_none;
194  err_code |= ((pid->sps->Kp < 0.0f) || (pid->sps->Ki < 0.0f) || (pid->sps->Kd < 0.0f)) ? dcl_param_range_err : dcl_none;
195  if (err_code)
196  {
197  DCL_setError(pid,err_code);
198  DCL_getErrorInfo(pid);
199  DCL_runErrorHandler(pid);
200  }
201 #endif
202 
203  dcl_interrupt_t ints;
204  ints = DCL_disableInts();
205  pid->Kp = pid->sps->Kp;
206  pid->Ki = pid->sps->Ki;
207  pid->Kd = pid->sps->Kd;
208  pid->alpha_p = pid->sps->alpha_p;
209  pid->alpha_i = pid->sps->alpha_i;
210  pid->alpha_d = pid->sps->alpha_d;
211  pid->delta_p = pid->sps->delta_p;
212  pid->delta_i = pid->sps->delta_i;
213  pid->delta_d = pid->sps->delta_d;
214  pid->gamma_p = pid->sps->gamma_p;
215  pid->gamma_i = pid->sps->gamma_i;
216  pid->gamma_d = pid->sps->gamma_d;
217  pid->c1 = pid->sps->c1;
218  pid->c2 = pid->sps->c2;
219  pid->Umax = pid->sps->Umax;
220  pid->Umin = pid->sps->Umin;
221  DCL_restoreInts(ints);
222 }
223 
234 {
235  if (DCL_getUpdateStatus(pid))
236  {
239  return true;
240  }
241  return false;
242 }
243 
252 {
253  float32_t tau = 1.0f / (2.0f * CONST_PI * fc);
254 
255 #ifdef DCL_ERROR_HANDLING_ENABLED
256  uint32_t err_code = dcl_none;
257  err_code |= ((fc >= 1.0f / (2.0f * pid->css->T)) || (fc <= 0.0f)) ? dcl_param_range_err : dcl_none;
258  if (err_code)
259  {
260  DCL_setError(pid,err_code);
261  DCL_getErrorInfo(pid);
262  DCL_runErrorHandler(pid);
263  }
264 #endif
265 
266  pid->sps->c1 = 2.0f / (pid->css->T + 2.0f * tau);
267  pid->sps->c2 = (pid->css->T - 2.0f * tau) / (pid->css->T + 2.0f * tau);
268 }
269 
280 {
281  float32_t tau;
282 
283 #ifdef DCL_ERROR_HANDLING_ENABLED
284  uint32_t err_code = dcl_none;
285  err_code |= ((fc >= 1.0f / (2.0f * T)) || (fc <= 0.0f)) ? dcl_param_range_err : dcl_none;
286  if (err_code)
287  {
288  DCL_setError(pid,err_code);
289  DCL_getErrorInfo(pid);
290  DCL_runErrorHandler(pid);
291  }
292 #endif
293 
294  tau = 1.0f / (2.0f * CONST_PI * fc);
295  pid->c1 = 2.0f / (T + 2.0f * tau);
296  pid->c2 = (T - 2.0f * tau) / (T + 2.0f * tau);
297 }
298 
306 {
307  float32_t tau = ((2.0f - pid->c1 * pid->css->T) / (2.0f * pid->c1));
308  return(1.0f / (2.0f * CONST_PI * tau));
309 }
310 
319 {
320  return((float32_t) powf(delta, (alpha - 1.0f)));
321 }
322 
331 {
332  return((float32_t) powf(gamma, (1.0f / (alpha - 1.0f))));
333 }
334 
342 {
343  float32_t xP = (float32_t) powf(pid->sps->delta_p, (pid->sps->alpha_p - 1.0f));
344  float32_t xI = (float32_t) powf(pid->sps->delta_i, (pid->sps->alpha_i - 1.0f));
345  float32_t xD = (float32_t) powf(pid->sps->delta_d, (pid->sps->alpha_d - 1.0f));
346 
347 
348 #ifdef DCL_ERROR_HANDLING_ENABLED
349  uint32_t err_code = dcl_none;
350  err_code |= ((pid->sps->delta_p > 1.0f) || (pid->sps->delta_p > 1.0f) || (pid->sps->delta_p > 1.0f)) ? dcl_param_range_err : dcl_none;
351  err_code |= (pid->sps->delta_p < DCL_DELTA_MIN) ? dcl_param_range_err : dcl_none;
352  err_code |= (pid->sps->delta_i < DCL_DELTA_MIN) ? dcl_param_range_err : dcl_none;
353  err_code |= (pid->sps->delta_d < DCL_DELTA_MIN) ? dcl_param_range_err : dcl_none;
354  err_code |= ((xP > DCL_GAMMA_MAX) || (xI > DCL_GAMMA_MAX) || (xD > DCL_GAMMA_MAX)) ? dcl_param_range_err : dcl_none;
355  if (err_code)
356  {
357  DCL_setError(pid,err_code);
358  DCL_getErrorInfo(pid);
359  DCL_runErrorHandler(pid);
360  }
361 #endif
362 
363  pid->sps->gamma_p = xP;
364  pid->sps->gamma_i = xI;
365  pid->sps->gamma_d = xD;
366 }
367 
375 {
376  float32_t xP = (float32_t) powf(pid->delta_p, (pid->alpha_p - 1.0f));
377  float32_t xI = (float32_t) powf(pid->delta_i, (pid->alpha_i - 1.0f));
378  float32_t xD = (float32_t) powf(pid->delta_d, (pid->alpha_d - 1.0f));
379 
380 #ifdef DCL_ERROR_HANDLING_ENABLED
381  uint32_t err_code = dcl_none;
382  err_code |= ((pid->delta_p > 1.0f) || (pid->delta_p > 1.0f) || (pid->delta_p > 1.0f)) ? dcl_param_range_err : dcl_none;
383  err_code |= (pid->delta_p < DCL_DELTA_MIN) ? dcl_param_range_err : dcl_none;
384  err_code |= (pid->delta_i < DCL_DELTA_MIN) ? dcl_param_range_err : dcl_none;
385  err_code |= (pid->delta_d < DCL_DELTA_MIN) ? dcl_param_range_err : dcl_none;
386  err_code |= ((xP > DCL_GAMMA_MAX) || (xI > DCL_GAMMA_MAX) || (xD > DCL_GAMMA_MAX)) ? dcl_param_range_err : dcl_none;
387  if (err_code)
388  {
389  DCL_setError(pid,err_code);
390  DCL_getErrorInfo(pid);
391  DCL_runErrorHandler(pid);
392  }
393 #endif
394 
395  pid->gamma_p = xP;
396  pid->gamma_i = xI;
397  pid->gamma_d = xD;
398 }
399 
410 {
411  float32_t v1, v2, v3, v4, v5, v8, v9, v10, v12, v13, v14, v15;
412 
413 #ifdef DCL_ERROR_HANDLING_ENABLED
414  uint32_t err_code = dcl_none;
415  err_code |= (DCL_getControllerStatus(pid)) ? dcl_controller_err : dcl_none;
416  if (err_code)
417  {
418  DCL_setError(pid,err_code);
419  DCL_getErrorInfo(pid);
420  DCL_runErrorHandler(pid);
421  }
423 #endif
424 
425  // pre-conditioning block
426  v1 = (rk - yk) * 0.5f;
427  v2 = (v1 < 0.0f) ? -1.0f : 1.0f;
428  v3 = fabsf(v1);
429 
430 #ifdef DCL_ERROR_HANDLING_ENABLED
431  err_code |= ((pid->alpha_p >= 2.0f) || (pid->alpha_p <= 0.0f)) ? dcl_param_range_err : dcl_none;
432  err_code |= ((pid->alpha_i >= 2.0f) || (pid->alpha_i <= 0.0f)) ? dcl_param_range_err : dcl_none;
433  err_code |= ((pid->alpha_d >= 2.0f) || (pid->alpha_d <= 0.0f)) ? dcl_param_range_err : dcl_none;
434  err_code |= (v3 > 1.0f) ? dcl_input_range_err : dcl_none;
435  if (err_code)
436  {
437  DCL_setError(pid,err_code);
438  DCL_getErrorInfo(pid);
439  DCL_runErrorHandler(pid);
440  }
441 #endif
442 
443  // non-linear modules
444  v4 = ((v3 > pid->delta_p) ? (v2 * (float32_t) powf(v3, pid->alpha_p)) : (v1 * pid->gamma_p));
445  v5 = ((v3 > pid->delta_i) ? (v2 * (float32_t) powf(v3, pid->alpha_i)) : (v1 * pid->gamma_i));
446  v9 = ((v3 > pid->delta_d) ? (v2 * (float32_t) powf(v3, pid->alpha_d)) : (v1 * pid->gamma_d));
447 
448  // integral path
449  v8 = (v5 * pid->Kp * pid->Ki * pid->i16) + pid->i7;
450  pid->i7 = v8;
451 
452  // derivative path
453  v10 = v9 * pid->Kd * pid->c1;
454  v12 = v10 - pid->d2 - pid->d3;
455  pid->d2 = v10;
456  pid->d3 = v12 * pid->c2;
457 
458  // output sum & clamp
459  v13 = (pid->Kp * (v4 + v12)) + v8;
460  v14 = DCL_runSat(v13, pid->Umax, pid->Umin);
461  v15 = (v14 == v13) ? 1.0f : 0.0f;
462  pid->i16 = v15 * lk;
463 
464 #ifdef DCL_TESTPOINTS_ENABLED
465  pid->css->tpt = v14;
466 #endif
467 
468 #ifdef DCL_ERROR_HANDLING_ENABLED
470 #endif
471 
472  return(v14);
473 }
474 
485 {
486  float32_t v1, v2, vd2, v3, vd3, v4, v5, v6, v8, v9, v12, v15, v16, v17;
487 
488 #ifdef DCL_ERROR_HANDLING_ENABLED
489  uint32_t err_code = dcl_none;
490  err_code |= (DCL_getControllerStatus(pid)) ? dcl_controller_err : dcl_none;
491  if (err_code)
492  {
493  DCL_setError(pid,err_code);
494  DCL_getErrorInfo(pid);
495  DCL_runErrorHandler(pid);
496  }
498 #endif
499 
500  // pre-conditioning block for P & I
501  v1 = (rk - yk) * 0.5f;
502  v2 = (v1 < 0.0f) ? -1.0f : 1.0f;
503  v3 = fabsf(v1);
504 
505 #ifdef DCL_ERROR_HANDLING_ENABLED
506  err_code |= ((pid->alpha_p >= 2.0f) || (pid->alpha_p <= 0.0f)) ? dcl_param_range_err : dcl_none;
507  err_code |= ((pid->alpha_i >= 2.0f) || (pid->alpha_i <= 0.0f)) ? dcl_param_range_err : dcl_none;
508  err_code |= (v3 > 1.0f) ? dcl_input_range_err : dcl_none;
509  if (err_code)
510  {
511  DCL_setError(pid,err_code);
512  DCL_getErrorInfo(pid);
513  DCL_runErrorHandler(pid);
514  }
515 #endif
516 
517  // P & I non-linear modules
518  v4 = ((v3 > pid->delta_p) ? (v2 * (float32_t) powf(v3, pid->alpha_p)) : (v1 * pid->gamma_p));
519  v5 = ((v3 > pid->delta_i) ? (v2 * (float32_t) powf(v3, pid->alpha_i)) : (v1 * pid->gamma_i));
520 
521  // D path non-linear block
522  vd2 = (yk < 0.0f) ? -1.0f : 1.0f;
523  vd3 = fabsf(yk);
524 
525 #ifdef DCL_ERROR_HANDLING_ENABLED
526  err_code |= ((pid->alpha_d >= 2.0f) || (pid->alpha_d <= 0.0f)) ? dcl_param_range_err : dcl_none;
527  err_code |= (vd3 > 1.0f) ? dcl_input_range_err : dcl_none;
528  if (err_code)
529  {
530  DCL_setError(pid,err_code);
531  DCL_getErrorInfo(pid);
532  DCL_runErrorHandler(pid);
533  }
534 #endif
535 
536  v6 = ((vd3 > pid->delta_d) ? (vd2 * (float32_t) powf(vd3, pid->alpha_d)) : (yk * pid->gamma_d));
537 
538  // integral path
539  v8 = (v5 * pid->Kp * pid->Ki * pid->i16) + pid->i7;
540  pid->i7 = v8;
541 
542  // derivative path
543  v15 = v6 * pid->Kd * pid->c1;
544  v16 = v15 - pid->d2 - pid->d3;
545  pid->d2 = v15;
546  pid->d3 = v16 * pid->c2;
547 
548  // output sum & clamp
549  v9 = (pid->Kp * (v4 - v16)) + v8;
550  v17 = DCL_runSat(v9, pid->Umax, pid->Umin);
551  v12 = (v17 == v9) ? 1.0f : 0.0f;
552  pid->i16 = v12 * lk;
553 
554 #ifdef DCL_TESTPOINTS_ENABLED
555  pid->css->tpt = v17;
556 #endif
557 
558 #ifdef DCL_ERROR_HANDLING_ENABLED
560 #endif
561 
562  return(v17);
563 }
564 
565 //--- Basic non-linear function ----------------------------------------------
566 
576 {
577  float32_t v2 = (x < 0.0f) ? -1.0f : 1.0f;
578  float32_t v3 = fabsf(x);
579 
580  return((v3 > delta) ? (v2 * (float32_t) powf(v3, alpha)) : (x * powf(delta, (alpha - 1.0f))));
581 }
582 
585 #ifdef __cplusplus
586 }
587 #endif // extern "C"
588 
589 #endif // _DCL_NLPID_H_
DCL_runNLF
_DCL_CRIT_ACCESS float32_t DCL_runNLF(float32_t x, float32_t alpha, float32_t delta)
Executes a basic non-linear control function.
Definition: dcl_nlpid.h:575
DCL_NLPID_SPS::Umin
float32_t Umin
Lower saturation limit.
Definition: dcl_nlpid.h:79
DCL_NLPID_SPS::delta_i
float32_t delta_i
I path linearized range, default is 0.1.
Definition: dcl_nlpid.h:71
dcl_nlpid::delta_d
float32_t delta_d
D path linearized range, default is 0.1.
Definition: dcl_nlpid.h:104
DCL_NLPID_SPS::alpha_i
float32_t alpha_i
I path non-linear exponent, default is 1.
Definition: dcl_nlpid.h:68
DCL_NLPID_SPS::Ki
float32_t Ki
Linear integral gain.
Definition: dcl_nlpid.h:65
dcl_nlpid::delta_p
float32_t delta_p
P path linearized range, default is 0.1.
Definition: dcl_nlpid.h:102
CONST_PI
#define CONST_PI
Local definitions of the mathematical constant pi.
Definition: dcl_macro.h:55
DCL_NLPID_SPS::Kp
float32_t Kp
Linear proportional gain.
Definition: dcl_nlpid.h:64
DCL_updateNLPID
_DCL_CODE_ACCESS bool DCL_updateNLPID(DCL_NLPID *pid)
A conditional update based on the update flag. If the update status is set, the function will update ...
Definition: dcl_nlpid.h:233
DCL_resetNLPID
_DCL_CODE_ACCESS void DCL_resetNLPID(DCL_NLPID *pid)
Resets NLPID internal storage data with interrupt protection.
Definition: dcl_nlpid.h:142
DCL_NLPID_SPS
Defines the shadow DCL_NLPID controller structure.
Definition: dcl_nlpid.h:63
DCL_setActiveNLPIDgamma
_DCL_CODE_ACCESS void DCL_setActiveNLPIDgamma(DCL_NLPID *pid)
Computes the linearized gains for each path and loads the parameters in the active NLPID structure.
Definition: dcl_nlpid.h:374
DCL_updateNLPIDNoCheck
_DCL_CODE_ACCESS void DCL_updateNLPIDNoCheck(DCL_NLPID *pid)
Loads PID tuning parameter from its SPS parameter with interrupt protection.
Definition: dcl_nlpid.h:181
dcl_none
@ dcl_none
No error.
Definition: dcl_error.h:57
DCL_NLPID_SPS::delta_p
float32_t delta_p
P path linearized range, default is 0.1.
Definition: dcl_nlpid.h:70
DCL_NLPID_SPS::Umax
float32_t Umax
Upper saturation limit.
Definition: dcl_nlpid.h:78
DCL_getNLPIDfilterBW
_DCL_CODE_ACCESS float32_t DCL_getNLPIDfilterBW(DCL_NLPID *pid)
Returns the derivative LP filter bandwidth in Hz.
Definition: dcl_nlpid.h:305
DCL_setActiveNLPIDfilterBW
_DCL_CODE_ACCESS void DCL_setActiveNLPIDfilterBW(DCL_NLPID *pid, float32_t fc, float32_t T)
Loads the NLPID derivative path filter active coefficients.
Definition: dcl_nlpid.h:279
DCL_runErrorHandler
#define DCL_runErrorHandler(ptr)
Prototype for basic error handler.
Definition: dcl_error.h:108
DCL_getUpdateStatus
#define DCL_getUpdateStatus(p)
Determine whether a parameter update-in-progress flag is set.
Definition: dcl_css.h:122
DCL_GAMMA_MAX
#define DCL_GAMMA_MAX
Sets an upper bound on allowable controller gain, and therefore fixes the minimum linear region semi-...
Definition: dcl_nlpid.h:58
dcl_nlpid::gamma_d
float32_t gamma_d
D path gain limit, default is 1.
Definition: dcl_nlpid.h:107
DCL_runNLPIDParallel
_DCL_CRIT_ACCESS float32_t DCL_runNLPIDParallel(DCL_NLPID *pid, float32_t rk, float32_t yk, float32_t lk)
Executes a parallel form non-linear PID controller.
Definition: dcl_nlpid.h:409
DCL_clearUpdateStatus
#define DCL_clearUpdateStatus(p)
Definition: dcl_css.h:116
dcl_nlpid
Defines the active DCL_NLPID controller structure.
Definition: dcl_nlpid.h:94
_DCL_CODE_ACCESS
#define _DCL_CODE_ACCESS
Defines the scope of dcl functions.
Definition: dcl_common.h:63
dcl_nlpid::alpha_i
float32_t alpha_i
I path non-linear exponent, default is 1.
Definition: dcl_nlpid.h:100
dcl_nlpid::delta_i
float32_t delta_i
I path linearized range, default is 0.1.
Definition: dcl_nlpid.h:103
DCL_NLPID_SPS::gamma_p
float32_t gamma_p
P path gain limit, default is 1.
Definition: dcl_nlpid.h:73
DCL_NLPID_SPS::c2
float32_t c2
D path low-pass filter coefficient 2, default is 0.
Definition: dcl_nlpid.h:77
dcl_controller_err
@ dcl_controller_err
Controller operation not completed.
Definition: dcl_error.h:64
DCL_setNLPIDfilterBW
_DCL_CODE_ACCESS void DCL_setNLPIDfilterBW(DCL_NLPID *pid, float32_t fc)
Loads the shadow derivative LP filter coefficients.
Definition: dcl_nlpid.h:251
dcl_nlpid::Kd
float32_t Kd
Linear derivative gain.
Definition: dcl_nlpid.h:98
dcl_nlpid::Kp
float32_t Kp
Linear proportional gain.
Definition: dcl_nlpid.h:96
dcl_nlpid::css
DCL_CSS * css
Pointer to controller support structure.
Definition: dcl_nlpid.h:123
DCL_NLPID_SPS::gamma_i
float32_t gamma_i
I path gain limit, default is 1.
Definition: dcl_nlpid.h:74
dcl_nlpid::Umax
float32_t Umax
Upper saturation limit.
Definition: dcl_nlpid.h:110
dcl_interrupt_t
uint32_t dcl_interrupt_t
Definition: dcl_common.h:107
DCL_runNLPIDSeries
_DCL_CRIT_ACCESS float32_t DCL_runNLPIDSeries(DCL_NLPID *pid, float32_t rk, float32_t yk, float32_t lk)
Executes a series form non-linear PID controller.
Definition: dcl_nlpid.h:484
dcl_nlpid::Umin
float32_t Umin
Lower saturation limit.
Definition: dcl_nlpid.h:111
DCL_NLPID_SPS::alpha_d
float32_t alpha_d
D path non-linear exponent, default is 1.
Definition: dcl_nlpid.h:69
DCL_setNLPIDgamma
_DCL_CODE_ACCESS void DCL_setNLPIDgamma(DCL_NLPID *pid)
Computes the linearized gains for each path Note: active coefficients not update DCL_updateNLPID() ca...
Definition: dcl_nlpid.h:341
dcl_nlpid::c1
float32_t c1
D path low-pass filter coefficient 1, default is 1.
Definition: dcl_nlpid.h:108
DCL_getControllerStatus
#define DCL_getControllerStatus(p)
Determine whether a controller operation-in-progress flag is set.
Definition: dcl_css.h:136
DCL_NLPID_SPS::Kd
float32_t Kd
Linear derivative gain.
Definition: dcl_nlpid.h:66
dcl_param_range_err
@ dcl_param_range_err
Parameter range exceeded.
Definition: dcl_error.h:58
dcl_nlpid::alpha_d
float32_t alpha_d
D path non-linear exponent, default is 1.
Definition: dcl_nlpid.h:101
DCL_DELTA_MIN
#define DCL_DELTA_MIN
Sets the lower bound on the linear region semi-width.
Definition: dcl_nlpid.h:53
dcl_nlpid::i18
float32_t i18
No longer needed.
Definition: dcl_nlpid.h:119
DCL_getNLPIDgamma
_DCL_CODE_ACCESS float32_t DCL_getNLPIDgamma(float32_t alpha, float32_t delta)
Returns the linearized region gain for specified (alpha,delta)
Definition: dcl_nlpid.h:318
dcl_nlpid::Ki
float32_t Ki
Linear integral gain.
Definition: dcl_nlpid.h:97
DCL_NLPID_SPS::alpha_p
float32_t alpha_p
P path non-linear exponent, default is 1.
Definition: dcl_nlpid.h:67
dcl_nlpid::d2
float32_t d2
D path low-pass filter storage (Kd * c1)
Definition: dcl_nlpid.h:114
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_nlpid::sps
DCL_NLPID_SPS * sps
Pointer to shadow parameter structure.
Definition: dcl_nlpid.h:122
DCL_FPU32_TOL
#define DCL_FPU32_TOL
Define the acceptable FPU numerical tolerances.
Definition: dcl_macro.h:62
DCL_NLPID_SPS::c1
float32_t c1
D path low-pass filter coefficient 1, default is 1.
Definition: dcl_nlpid.h:76
DCL_CSS
Defines the controller common support structure.
Definition: dcl_css.h:57
dcl_input_range_err
@ dcl_input_range_err
Input range exceeded.
Definition: dcl_error.h:61
dcl_nlpid::d3
float32_t d3
D path low-pass filter storage (c2)
Definition: dcl_nlpid.h:115
DCL_NLPID_SPS::delta_d
float32_t delta_d
D path linearized range, default is 0.1.
Definition: dcl_nlpid.h:72
DCL_restoreInts
#define DCL_restoreInts(v)
Definition: dcl_common.h:106
dcl_nlpid::alpha_p
float32_t alpha_p
P path non-linear exponent, default is 1.
Definition: dcl_nlpid.h:99
dcl_param_invalid_err
@ dcl_param_invalid_err
Parameter not valid.
Definition: dcl_error.h:59
_DCL_VOLATILE
#define _DCL_VOLATILE
Defines volatile for DCL strctures.
Definition: dcl_common.h:79
DCL_setControllerStatus
#define DCL_setControllerStatus(p)
Macros placed at the beginning and end of the controller so that other functions know a control opera...
Definition: dcl_css.h:129
dcl_nlpid::i16
float32_t i16
Saturation multiplier, ranges between 1*lk ~ 0, where 0 means fully saturated.
Definition: dcl_nlpid.h:117
dcl_nlpid::c2
float32_t c2
D path low-pass filter coefficient 2, default is 0.
Definition: dcl_nlpid.h:109
DCL_NLPID
_DCL_VOLATILE struct dcl_nlpid DCL_NLPID
DCL_clearControllerStatus
#define DCL_clearControllerStatus(p)
Definition: dcl_css.h:130
dcl_nlpid::gamma_i
float32_t gamma_i
I path gain limit, default is 1.
Definition: dcl_nlpid.h:106
dcl_nlpid::gamma_p
float32_t gamma_p
P path gain limit, default is 1.
Definition: dcl_nlpid.h:105
DCL_getErrorInfo
#define DCL_getErrorInfo(ptr)
Macro to store error info in CSS.
Definition: dcl_error.h:98
DCL_setError
#define DCL_setError(ptr, code)
Macro to set error code in CSS.
Definition: dcl_error.h:80
_DCL_CRIT_ACCESS
#define _DCL_CRIT_ACCESS
Defines the scope of critical dcl functions.
Definition: dcl_common.h:70
DCL_getNLPIDdelta
_DCL_CODE_ACCESS float32_t DCL_getNLPIDdelta(float32_t alpha, float32_t gamma)
Returns the semi-width of the linear gain region for specified (alpha,gamma)
Definition: dcl_nlpid.h:330
float32_t
float float32_t
Definition: dcl_common.h:58
dcl_nlpid::i7
float32_t i7
I path feedback storage.
Definition: dcl_nlpid.h:116
DCL_NLPID_SPS::gamma_d
float32_t gamma_d
D path gain limit, default is 1.
Definition: dcl_nlpid.h:75
DCL_forceUpdateNLPID
_DCL_CODE_ACCESS void DCL_forceUpdateNLPID(DCL_NLPID *pid)
Loads NLPID tuning parameter from its SPS parameter without interrupt protection.
Definition: dcl_nlpid.h:156
DCL_disableInts
#define DCL_disableInts()
Define enable and disable interrupt operations.
Definition: dcl_common.h:105