 |
AM261x Motor Control SDK
10.02.00
|
|
Go to the documentation of this file.
32 #ifndef _DCL_REFGEN_H_
33 #define _DCL_REFGEN_H_
48 #include "../dcl_common.h"
52 #define DCL_REFGEN_MIN_INC 1.0e-06f
56 typedef enum dcl_rgen_modes
98 #define DCL_REFGEN_DEFAULTS { 0.0f, 0.0f, \
101 0.0f, 1.0f, 1.0f, 1.0f, -1.0f, \
102 0.0f, 0.0f, 0.0f, 0.0f, \
104 REFGEN_OFF, &(DCL_CSS)DCL_CSS_DEFAULTS }
135 #ifdef DCL_ERROR_HANDLING_ENABLED
147 tr = (tr < p->css->T) ? p->css->T : tr;
149 p->rinc = p->css->T * (tgt - p->yr) / tr;
154 #ifdef DCL_ERROR_HANDLING_ENABLED
159 if (signbit(p->rinc))
179 #ifdef DCL_ERROR_HANDLING_ENABLED
191 tr = (tr < p->css->T) ? p->css->T : tr;
193 p->aminc = p->css->T * (ampl - p->ampl) / tr;
198 #ifdef DCL_ERROR_HANDLING_ENABLED
203 if (signbit(p->aminc))
223 #ifdef DCL_ERROR_HANDLING_ENABLED
235 tr = (tr < p->css->T) ? p->css->T : tr;
237 p->fminc = p->css->T * (freq - p->freq) / tr;
242 #ifdef DCL_ERROR_HANDLING_ENABLED
247 if (signbit(p->fminc))
266 #ifdef DCL_ERROR_HANDLING_ENABLED
289 #ifdef DCL_ERROR_HANDLING_ENABLED
323 #ifdef DCL_ERROR_HANDLING_ENABLED
330 if (fabsf(p->rinc) > fabsf(p->rtgt - p->yr))
339 #ifdef DCL_ERROR_HANDLING_ENABLED
343 #ifdef DCL_ERROR_HANDLING_ENABLED
359 if (fabsf(p->aminc) > fabsf(p->amtgt - p->ampl))
366 #ifdef DCL_ERROR_HANDLING_ENABLED
370 #ifdef DCL_ERROR_HANDLING_ENABLED
384 if (fabsf(p->fminc) > fabsf(p->fmtgt - p->freq))
391 #ifdef DCL_ERROR_HANDLING_ENABLED
395 #ifdef DCL_ERROR_HANDLING_ENABLED
409 p->thinc = p->css->T * p->freq;
412 #ifdef DCL_ERROR_HANDLING_ENABLED
425 p->theta += p->thinc;
426 p->theta -= (p->theta >= 1.0f) ? 1.0f : 0.0f;
444 p->ya = (p->theta > 0.5f) ? 1.0f : 0.0f;
458 p->ya = 2.0f * p->theta;
462 p->ya = 1.0f - 2.0f * (p->theta - 0.5f);
469 p->ya = (p->theta > p->duty) ? 0.0f : 1.0f;
481 p->thetb = p->theta + 0.3333333333333f;
482 p->thetc = p->theta + 0.6666666666667f;
483 p->thetb -= (p->thetb >= 1.0f) ? 1.0f : 0.0f;
484 p->thetc -= (p->thetc >= 1.0f) ? 1.0f : 0.0f;
499 p->ya =
DCL_runSat(p->ampl * p->ya + p->yr, p->umax, p->umin);
500 p->yb =
DCL_runSat(p->ampl * p->yb + p->yr, p->umax, p->umin);
501 p->yc =
DCL_runSat(p->ampl * p->yc + p->yr, p->umax, p->umin);
543 #endif // _DCL_REFGEN_H_
uint32_t mode
Operating mode.
Definition: dcl_refgen.h:92
_DCL_CODE_ACCESS void DCL_resetRefgen(DCL_REFGEN *p)
Resets DCL_REFGEN dynamic data.
Definition: dcl_refgen.h:111
#define CONST_2PI
Definition: dcl_macro.h:54
@ REFGEN_TRIANGLE
Definition: dcl_refgen.h:63
_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:287
float32_t theta
Normalized angle - phase A.
Definition: dcl_refgen.h:86
#define CONST_PI
Local definitions of the mathematical constant pi.
Definition: dcl_macro.h:53
float32_t thetb
Normalized angle - phase B.
Definition: dcl_refgen.h:87
_DCL_CODE_ACCESS void DCL_setRefgenMode(DCL_REFGEN *p, int16_t mode)
Sets the REFGEN operating mode.
Definition: dcl_refgen.h:311
@ REFGEN_PULSE
Definition: dcl_refgen.h:64
float32_t freq
Dynamic frequency.
Definition: dcl_refgen.h:85
@ REFGEN_STATIC
Definition: dcl_refgen.h:59
_DCL_CODE_ACCESS float32_t DCL_getRefgenPhaseB(DCL_REFGEN *p)
Returns the phase reference output.
Definition: dcl_refgen.h:521
#define DCL_REFGEN_MIN_INC
Defines the minimum normalized increment.
Definition: dcl_refgen.h:52
_DCL_CODE_ACCESS void DCL_setRefgenFreq(DCL_REFGEN *p, float32_t freq, float32_t tr)
Loads the REFGEN frequency.
Definition: dcl_refgen.h:221
_DCL_CODE_ACCESS void DCL_setRefgenRamp(DCL_REFGEN *p, float32_t tgt, float32_t tr)
Loads the REFGEN ramp parameters.
Definition: dcl_refgen.h:133
#define DCL_setUpdateStatus(p)
Macros to set and clear the update-in-progress flag.
Definition: dcl_css.h:114
@ dcl_none
No error.
Definition: dcl_error.h:57
float32_t yc
Phase C output.
Definition: dcl_refgen.h:91
#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:93
float32_t yr
Ramp generator output.
Definition: dcl_refgen.h:83
@ REFGEN_OFF
Definition: dcl_refgen.h:58
#define DCL_clearUpdateStatus(p)
Definition: dcl_css.h:115
float32_t fminc
Frequency increment.
Definition: dcl_refgen.h:78
@ REFGEN_SQUARE
Definition: dcl_refgen.h:61
#define _DCL_CODE_ACCESS
Defines the scope of dcl functions.
Definition: dcl_common.h:63
float32_t ampl
Dynamic amplitude.
Definition: dcl_refgen.h:84
float32_t aminc
Amplitude increment.
Definition: dcl_refgen.h:76
_DCL_CODE_ACCESS void DCL_setRefgenDuty(DCL_REFGEN *p, float32_t duty)
Loads the REFGEN pulse duty cycle.
Definition: dcl_refgen.h:264
DCL_refgen_modes
Defines the REFGEN operating modes.
Definition: dcl_refgen.h:57
Defines the DCL_REFGEN structure.
Definition: dcl_refgen.h:72
float32_t thinc
Angular increment.
Definition: dcl_refgen.h:79
float32_t fmtgt
Frequency ramp value.
Definition: dcl_refgen.h:77
float32_t umin
Minimum allowable output.
Definition: dcl_refgen.h:82
float32_t thetc
Normalized angle - phase C.
Definition: dcl_refgen.h:88
@ REFGEN_SINE3
Definition: dcl_refgen.h:66
_DCL_VOLATILE struct dcl_refgen DCL_REFGEN
float32_t umax
Maximum allowable output.
Definition: dcl_refgen.h:81
float32_t yb
Phase B output.
Definition: dcl_refgen.h:90
#define DCL_isZero(x)
Determines floating point numerical proximity to zero.
Definition: dcl_macro.h:75
_DCL_CODE_ACCESS float32_t DCL_getRefgenPhaseA(DCL_REFGEN *p)
Returns the phase reference output.
Definition: dcl_refgen.h:510
@ dcl_param_range_err
Parameter range exceeded.
Definition: dcl_error.h:58
float32_t duty
Pulse duty cycle.
Definition: dcl_refgen.h:80
#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:90
@ REFGEN_SINE
Definition: dcl_refgen.h:60
Defines the controller common support structure.
Definition: dcl_css.h:56
_DCL_CODE_ACCESS void DCL_setRefgenAmpl(DCL_REFGEN *p, float32_t ampl, float32_t tr)
Loads the REFGEN dynamic amplitude.
Definition: dcl_refgen.h:177
#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:75
_DCL_CODE_ACCESS float32_t DCL_getRefgenPhaseC(DCL_REFGEN *p)
Returns the phase reference output.
Definition: dcl_refgen.h:532
Defines a 32-bit floating-point data logger strcture and related functions.
float32_t rtgt
Target ramp value.
Definition: dcl_refgen.h:73
#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:75
#define DCL_setError(ptr, code)
Macro to set error code in CSS.
Definition: dcl_error.h:80
@ REFGEN_SINE2
Definition: dcl_refgen.h:65
@ REFGEN_SAW
Definition: dcl_refgen.h:62
@ dcl_comp_err
Computation error.
Definition: dcl_error.h:66
float32_t ya
Phase A output.
Definition: dcl_refgen.h:89
float float32_t
Definition: dcl_common.h:58
float32_t rinc
Ramp increment.
Definition: dcl_refgen.h:74
_DCL_CODE_ACCESS void DCL_runRefgen(DCL_REFGEN *p)
Runs the REFGEN module.
Definition: dcl_refgen.h:321