![Logo](ti_logo.svg) |
AM263x Motor Control SDK
09.02.00
|
|
Go to the documentation of this file.
33 #ifndef _DCL_REFGEN_H_
34 #define _DCL_REFGEN_H_
49 #include "../dcl_common.h"
53 #define DCL_REFGEN_MIN_INC 1.0e-06f
57 typedef enum dcl_rgen_modes
99 #define DCL_REFGEN_DEFAULTS { 0.0f, 0.0f, \
102 0.0f, 1.0f, 1.0f, 1.0f, -1.0f, \
103 0.0f, 0.0f, 0.0f, 0.0f, \
105 REFGEN_OFF, &(DCL_CSS)DCL_CSS_DEFAULTS }
136 #ifdef DCL_ERROR_HANDLING_ENABLED
148 tr = (tr < p->css->T) ? p->css->T : tr;
150 p->rinc = p->css->T * (tgt - p->yr) / tr;
155 #ifdef DCL_ERROR_HANDLING_ENABLED
160 if (signbit(p->rinc))
180 #ifdef DCL_ERROR_HANDLING_ENABLED
192 tr = (tr < p->css->T) ? p->css->T : tr;
194 p->aminc = p->css->T * (ampl - p->ampl) / tr;
199 #ifdef DCL_ERROR_HANDLING_ENABLED
204 if (signbit(p->aminc))
224 #ifdef DCL_ERROR_HANDLING_ENABLED
236 tr = (tr < p->css->T) ? p->css->T : tr;
238 p->fminc = p->css->T * (freq - p->freq) / tr;
243 #ifdef DCL_ERROR_HANDLING_ENABLED
248 if (signbit(p->fminc))
267 #ifdef DCL_ERROR_HANDLING_ENABLED
290 #ifdef DCL_ERROR_HANDLING_ENABLED
324 #ifdef DCL_ERROR_HANDLING_ENABLED
331 if (fabsf(p->rinc) > fabsf(p->rtgt - p->yr))
340 #ifdef DCL_ERROR_HANDLING_ENABLED
344 #ifdef DCL_ERROR_HANDLING_ENABLED
360 if (fabsf(p->aminc) > fabsf(p->amtgt - p->ampl))
367 #ifdef DCL_ERROR_HANDLING_ENABLED
371 #ifdef DCL_ERROR_HANDLING_ENABLED
385 if (fabsf(p->fminc) > fabsf(p->fmtgt - p->freq))
392 #ifdef DCL_ERROR_HANDLING_ENABLED
396 #ifdef DCL_ERROR_HANDLING_ENABLED
410 p->thinc = p->css->T * p->freq;
413 #ifdef DCL_ERROR_HANDLING_ENABLED
426 p->theta += p->thinc;
427 p->theta -= (p->theta >= 1.0f) ? 1.0f : 0.0f;
445 p->ya = (p->theta > 0.5f) ? 1.0f : 0.0f;
459 p->ya = 2.0f * p->theta;
463 p->ya = 1.0f - 2.0f * (p->theta - 0.5f);
470 p->ya = (p->theta > p->duty) ? 0.0f : 1.0f;
482 p->thetb = p->theta + 0.3333333333333f;
483 p->thetc = p->theta + 0.6666666666667f;
484 p->thetb -= (p->thetb >= 1.0f) ? 1.0f : 0.0f;
485 p->thetc -= (p->thetc >= 1.0f) ? 1.0f : 0.0f;
500 p->ya =
DCL_runSat(p->ampl * p->ya + p->yr, p->umax, p->umin);
501 p->yb =
DCL_runSat(p->ampl * p->yb + p->yr, p->umax, p->umin);
502 p->yc =
DCL_runSat(p->ampl * p->yc + p->yr, p->umax, p->umin);
544 #endif // _DCL_REFGEN_H_
uint32_t mode
Operating mode.
Definition: dcl_refgen.h:93
_DCL_CODE_ACCESS void DCL_resetRefgen(DCL_REFGEN *p)
Resets DCL_REFGEN dynamic data.
Definition: dcl_refgen.h:112
#define CONST_2PI
Definition: dcl_macro.h:56
@ REFGEN_TRIANGLE
Definition: dcl_refgen.h:64
_DCL_CODE_ACCESS void DCL_setRefgenClamp(DCL_REFGEN *p, float32_t max, float32_t min)
Loads the REFGEN output clam limits.
Definition: dcl_refgen.h:288
float32_t theta
Normalized angle - phase A.
Definition: dcl_refgen.h:87
#define CONST_PI
Local definitions of the mathematical constant pi.
Definition: dcl_macro.h:55
float32_t thetb
Normalized angle - phase B.
Definition: dcl_refgen.h:88
_DCL_CODE_ACCESS void DCL_setRefgenMode(DCL_REFGEN *p, int16_t mode)
Sets the REFGEN operating mode.
Definition: dcl_refgen.h:312
@ REFGEN_PULSE
Definition: dcl_refgen.h:65
float32_t freq
Dynamic frequency.
Definition: dcl_refgen.h:86
@ REFGEN_STATIC
Definition: dcl_refgen.h:60
_DCL_CODE_ACCESS float32_t DCL_getRefgenPhaseB(DCL_REFGEN *p)
Returns the phase reference output.
Definition: dcl_refgen.h:522
#define DCL_REFGEN_MIN_INC
Defines the minimum normalized increment.
Definition: dcl_refgen.h:53
_DCL_CODE_ACCESS void DCL_setRefgenFreq(DCL_REFGEN *p, float32_t freq, float32_t tr)
Loads the REFGEN frequency.
Definition: dcl_refgen.h:222
_DCL_CODE_ACCESS void DCL_setRefgenRamp(DCL_REFGEN *p, float32_t tgt, float32_t tr)
Loads the REFGEN ramp parameters.
Definition: dcl_refgen.h:134
#define DCL_setUpdateStatus(p)
Macros to set and clear the update-in-progress flag.
Definition: dcl_css.h:115
@ dcl_none
No error.
Definition: dcl_error.h:57
float32_t yc
Phase C output.
Definition: dcl_refgen.h:92
#define DCL_runErrorHandler(ptr)
Prototype for basic error handler.
Definition: dcl_error.h:108
DCL_CSS * css
Pointer to the common support structure.
Definition: dcl_refgen.h:94
float32_t yr
Ramp generator output.
Definition: dcl_refgen.h:84
@ REFGEN_OFF
Definition: dcl_refgen.h:59
#define DCL_clearUpdateStatus(p)
Definition: dcl_css.h:116
float32_t fminc
Frequency increment.
Definition: dcl_refgen.h:79
@ REFGEN_SQUARE
Definition: dcl_refgen.h:62
#define _DCL_CODE_ACCESS
Defines the scope of dcl functions.
Definition: dcl_common.h:63
float32_t ampl
Dynamic amplitude.
Definition: dcl_refgen.h:85
float32_t aminc
Amplitude increment.
Definition: dcl_refgen.h:77
_DCL_CODE_ACCESS void DCL_setRefgenDuty(DCL_REFGEN *p, float32_t duty)
Loads the REFGEN pulse duty cycle.
Definition: dcl_refgen.h:265
DCL_refgen_modes
Defines the REFGEN operating modes.
Definition: dcl_refgen.h:58
Defines the DCL_REFGEN structure.
Definition: dcl_refgen.h:73
float32_t thinc
Angular increment.
Definition: dcl_refgen.h:80
float32_t fmtgt
Frequency ramp value.
Definition: dcl_refgen.h:78
float32_t umin
Minimum allowable output.
Definition: dcl_refgen.h:83
float32_t thetc
Normalized angle - phase C.
Definition: dcl_refgen.h:89
@ REFGEN_SINE3
Definition: dcl_refgen.h:67
_DCL_VOLATILE struct dcl_refgen DCL_REFGEN
float32_t umax
Maximum allowable output.
Definition: dcl_refgen.h:82
float32_t yb
Phase B output.
Definition: dcl_refgen.h:91
#define DCL_isZero(x)
Determines floating point numerical proximity to zero.
Definition: dcl_macro.h:77
_DCL_CODE_ACCESS float32_t DCL_getRefgenPhaseA(DCL_REFGEN *p)
Returns the phase reference output.
Definition: dcl_refgen.h:511
@ dcl_param_range_err
Parameter range exceeded.
Definition: dcl_error.h:58
float32_t duty
Pulse duty cycle.
Definition: dcl_refgen.h:81
#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
@ REFGEN_SINE
Definition: dcl_refgen.h:61
Defines the controller common support structure.
Definition: dcl_css.h:57
_DCL_CODE_ACCESS void DCL_setRefgenAmpl(DCL_REFGEN *p, float32_t ampl, float32_t tr)
Loads the REFGEN dynamic amplitude.
Definition: dcl_refgen.h:178
#define _DCL_VOLATILE
Defines volatile for DCL strctures.
Definition: dcl_common.h:79
_DCL_CODE_ACCESS float32_t DCL_getRefgenPhaseC(DCL_REFGEN *p)
Returns the phase reference output.
Definition: dcl_refgen.h:533
Defines a 32-bit floating-point data logger strcture and related functions.
float32_t rtgt
Target ramp value.
Definition: dcl_refgen.h:74
#define DCL_getErrorInfo(ptr)
Macro to store error info in CSS.
Definition: dcl_error.h:98
float32_t amtgt
Target amplitude value.
Definition: dcl_refgen.h:76
#define DCL_setError(ptr, code)
Macro to set error code in CSS.
Definition: dcl_error.h:80
@ REFGEN_SINE2
Definition: dcl_refgen.h:66
@ REFGEN_SAW
Definition: dcl_refgen.h:63
@ dcl_comp_err
Computation error.
Definition: dcl_error.h:66
float32_t ya
Phase A output.
Definition: dcl_refgen.h:90
float float32_t
Definition: dcl_common.h:58
float32_t rinc
Ramp increment.
Definition: dcl_refgen.h:75
_DCL_CODE_ACCESS void DCL_runRefgen(DCL_REFGEN *p)
Runs the REFGEN module.
Definition: dcl_refgen.h:322