MotorWare f2806x Module API Documentation

- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

float/ctrl.c
Go to the documentation of this file.
1
6
7 // **************************************************************************
8 // the includes
9
10 #if !defined(__TMS320C28XX_CLA__)
11 #include <math.h>
12 #endif
13
14
15 // drivers
16
17
18 // modules
19 #include "sw/modules/math/src/float/math.h"
20 #include "sw/modules/ctrl/src/float/ctrl.h"
21
22
23 // solutions
24
25
26 // **************************************************************************
27 // the defines
28
29 #ifdef FLASH
30 #pragma CODE_SECTION(CTRL_computePhasor,"ramfuncs");
31 #pragma CODE_SECTION(CTRL_getCount_isr,"ramfuncs");
32 #pragma CODE_SECTION(CTRL_getNumIsrTicksPerCtrlTick,"ramfuncs");
33 #pragma CODE_SECTION(CTRL_incrCounter_isr,"ramfuncs");
34 #pragma CODE_SECTION(CTRL_isEnabled,"ramfuncs");
35 #pragma CODE_SECTION(CTRL_resetCounter_isr,"ramfuncs");
36 #pragma CODE_SECTION(CTRL_setup,"ramfuncs");
37 #pragma CODE_SECTION(CTRL_run,"ramfuncs");
38 #endif
39
40 #ifdef __TMS320C28XX_CLA__
41 #pragma CODE_SECTION(CTRL_getVersion,"Cla1Prog2");
42 #pragma CODE_SECTION(CTRL_getWaitTimes,"Cla1Prog2");
43 #pragma CODE_SECTION(CTRL_init,"Cla1Prog2");
44 #pragma CODE_SECTION(CTRL_reset,"Cla1Prog2");
45 #pragma CODE_SECTION(CTRL_setParams,"Cla1Prog2");
46 #pragma CODE_SECTION(CTRL_setVersion,"Cla1Prog2");
47 #pragma CODE_SECTION(CTRL_setWaitTimes,"Cla1Prog2");
48 #pragma CODE_SECTION(CTRL_updateState,"Cla1Prog2");
49 #endif
50
51 // **************************************************************************
52 // the globals
53
54
55 // **************************************************************************
56 // the function prototypes
57
58 void CTRL_getVersion(CTRL_Handle handle,CTRL_Version *pVersion)
59 {
60 CTRL_Obj *obj = (CTRL_Obj *)handle;
61
62 pVersion->rsvd = obj->version.rsvd;
63 pVersion->targetProc = obj->version.targetProc;
64 pVersion->major = obj->version.major;
65 pVersion->minor = obj->version.minor;
66
67 return;
68 } // end of CTRL_getVersion() function
69
70
71 void CTRL_getWaitTimes(CTRL_Handle handle,int_least32_t *pWaitTimes)
72 {
73 CTRL_Obj *obj = (CTRL_Obj *)handle;
74 uint_least16_t stateCnt;
75
76 for(stateCnt=0;stateCnt<CTRL_numStates;stateCnt++)
77 {
78 pWaitTimes[stateCnt] = obj->waitTimes[stateCnt];
79 }
80
81 return;
82 } // end of CTRL_getWaitTimes() function
83
84
85 CTRL_Handle CTRL_init(void *pMemory,const size_t numBytes)
86 {
87 CTRL_Handle handle;
88 CTRL_Obj *obj;
89
90
91 if((int16_t)numBytes < (int16_t)sizeof(CTRL_Obj))
92 {
93 /*LDRA_INSPECTED 95 S MR12 11.3 "Below typecasting to NULL has no issues"*/
94 return((CTRL_Handle)NULL);
95 }
96
97 // assign the handle
98 /*LDRA_INSPECTED 94 S MR12 11.3 "Below typecasting to void * has no issues"*/
99 /*LDRA_INSPECTED 95 S MR12 11.3 "Below typecasting to void *has no issues"*/
100 handle = (CTRL_Handle)pMemory;
101
102
103 // set the version
104 /*LDRA_INSPECTED 45 D MR12 D.4.1 "handle points to static object, further '0' is also a valid address;So no need to check for NULL"*/
105 CTRL_setVersion(handle,CTRL_TargetProc_2806x,
106 CTRL_MAJOR_RELEASE_NUMBER,CTRL_MINOR_RELEASE_NUMBER);
107
108
109 // assign the object
110 obj = (CTRL_Obj *)handle;
111
112
113 // initialize the Id PI controller module
114 /*LDRA_INSPECTED 45 D MR12 D.4.1 "handle points to static object, further '0' is also a valid address;So no need to check for NULL"*/
115 obj->piHandle_Id = PI_init(&obj->pi_Id,sizeof(obj->pi_Id));
116
117
118 // initialize the Iq PI controller module
119 obj->piHandle_Iq = PI_init(&obj->pi_Iq,sizeof(obj->pi_Iq));
120
121
122 // initialize the speed PI controller module
123 obj->piHandle_spd = PI_init(&obj->pi_spd,sizeof(obj->pi_spd));
124
125 /*LDRA_INSPECTED 71 S MR12 11.3 "Always, address of a static object is passed, so ok for wider scope"*/
126 return(handle);
127 } // end of CTRL_init() function
128
129
130 void CTRL_reset(CTRL_Handle handle)
131 {
132 CTRL_Obj *obj = (CTRL_Obj *)handle;
133 MATH_vec2 null = {{(float_t)0.0,(float_t)0.0}};
134
135 // reset the integrators
136 PI_setUi(obj->piHandle_spd,(float_t)0.0);
137 PI_setUi(obj->piHandle_Id,(float_t)0.0);
138 PI_setUi(obj->piHandle_Iq,(float_t)0.0);
139
140 // zero internal values
141 CTRL_setSpeed_fb_Hz(handle,(float_t)0.0);
142 CTRL_setSpeed_ref_Hz(handle,(float_t)0.0);
143 CTRL_setSpeed_out_A(handle,(float_t)0.0);
144
145 CTRL_setIdq_A(handle,&null);
146 CTRL_setIdq_offset_A(handle,&null);
147 CTRL_setVdq_offset_V(handle,&null);
148
149 CTRL_setVdq_V(handle,&null);
150
151 return;
152 } // end of CTRL_reset() function
153
154
155 void CTRL_setParams(CTRL_Handle handle,USER_Params *pUserParams)
156 {
157 CTRL_Obj *obj = (CTRL_Obj *)handle;
158
159 MATH_vec2 null = {{(float_t)0.0,(float_t)0.0}};
160
161 float_t Ki,Kp;
162 float_t outMin,outMax;
163
164 float_t Rs_d_Ohm = pUserParams->motor_Rs_d_Ohm;
165 float_t Rs_q_Ohm = pUserParams->motor_Rs_q_Ohm;
166 float_t Rr_d_Ohm = pUserParams->motor_Rr_d_Ohm;
167 float_t Rr_q_Ohm = pUserParams->motor_Rr_q_Ohm;
168 float_t Ls_d_H = pUserParams->motor_Ls_d_H;
169 float_t Ls_q_H = pUserParams->motor_Ls_q_H;
170 float_t RoverL_rps;
171 float_t BWc_rps = pUserParams->BWc_rps;
172 float_t BWdelta = pUserParams->BWdelta;
173 float_t Kctrl_Wb_p_kgm2 = pUserParams->Kctrl_Wb_p_kgm2;
174 float_t currentCtrlPeriod_sec = (float_t)pUserParams->numCtrlTicksPerCurrentTick / pUserParams->ctrlFreq_Hz;
175 float_t speedCtrlPeriod_sec = (float_t)pUserParams->numCtrlTicksPerSpeedTick / pUserParams->ctrlFreq_Hz;
176
177
178 // assign the motor type
179 CTRL_setMotorParams(handle,pUserParams->motor_type,
180 pUserParams->motor_numPolePairs,
181 pUserParams->motor_ratedFlux_Wb,
182 Ls_d_H,Ls_q_H,
183 Rs_d_Ohm,Rs_q_Ohm,
184 Rr_d_Ohm,Rr_q_Ohm);
185
186
187 // assign other controller parameters
188 CTRL_setNumIsrTicksPerCtrlTick(handle,pUserParams->numIsrTicksPerCtrlTick);
189 CTRL_setNumCtrlTicksPerCurrentTick(handle,pUserParams->numCtrlTicksPerCurrentTick);
190 CTRL_setNumCtrlTicksPerSpeedTick(handle,pUserParams->numCtrlTicksPerSpeedTick);
191
192 CTRL_setCtrlFreq_Hz(handle,pUserParams->ctrlFreq_Hz);
193 CTRL_setCtrlPeriod_sec(handle,pUserParams->ctrlPeriod_sec);
194 CTRL_setCurrentCtrlPeriod_sec(handle,currentCtrlPeriod_sec);
195 CTRL_setSpeedCtrlPeriod_sec(handle,speedCtrlPeriod_sec);
196
197 CTRL_setIdq_A(handle,&null);
198 CTRL_setIdq_offset_A(handle,&null);
199 CTRL_setIdq_ref_A(handle,&null);
200
201 CTRL_setVdq_V(handle,&null);
202 CTRL_setVdq_offset_V(handle,&null);
203
204 CTRL_setVd_sf(handle,pUserParams->Vd_sf);
205
206 CTRL_setMaxVsMag_V(handle,pUserParams->maxVsMag_V);
207
208
209 // set the speed reference
210 CTRL_setSpeed_fb_Hz(handle,(float_t)0.0);
211 CTRL_setSpeed_out_A(handle,(float_t)0.0);
212 CTRL_setSpeed_outMax_A(handle,pUserParams->maxCurrent_A);
213 CTRL_setSpeed_outMin_A(handle,-pUserParams->maxCurrent_A);
214 CTRL_setSpeed_ref_Hz(handle,(float_t)0.0);
215
216
217 // reset the counters
218 CTRL_resetCounter_current(handle);
219 CTRL_resetCounter_isr(handle);
220 CTRL_resetCounter_speed(handle);
221 CTRL_resetCounter_state(handle);
222
223
224 // set the wait times for each state
225 CTRL_setWaitTimes(handle,&pUserParams->ctrlWaitTime[0]);
226
227
228 // set flags
229 CTRL_setFlag_enable(handle,false);
230 CTRL_setFlag_enableCurrentCtrl(handle,false);
231 CTRL_setFlag_enableSpeedCtrl(handle,true);
232 CTRL_setFlag_resetInt_Id(handle,false);
233 CTRL_setFlag_resetInt_Iq(handle,false);
234 CTRL_setFlag_resetInt_spd(handle,false);
235 CTRL_setFlag_useZeroIq_ref(handle,false);
236
237
238 // initialize the controller error code
239 CTRL_setErrorCode(handle,CTRL_ErrorCode_NoError);
240
241
242 // set the default controller state
243 CTRL_setState(handle,CTRL_State_Idle);
244
245 CTRL_setBWc_rps(handle,BWc_rps);
246 CTRL_setBWdelta(handle,BWdelta);
247 CTRL_setKctrl_Wb_p_kgm2(handle,Kctrl_Wb_p_kgm2);
248
249 // configure the default speed controller gains
250 Kp = MATH_TWO_PI * BWc_rps / (BWdelta * Kctrl_Wb_p_kgm2);
251 Ki = BWc_rps * speedCtrlPeriod_sec / (BWdelta * BWdelta);
252
253 // set the default speed controller gains
254 CTRL_setGains(handle,CTRL_Type_PI_spd,Kp,Ki);
255
256
257 // configure the default speed controller output minimum/maximum values
258 outMax = pUserParams->maxCurrent_A;
259 outMin = -outMax;
260
261 // set the default speed controller output minimum/maximum values
262 PI_setMinMax(obj->piHandle_spd,outMin,outMax);
263
264
265 // set the Id current controller gain
266 Kp = Ls_d_H * pUserParams->BWc_rps;
267 RoverL_rps = Rs_d_Ohm / Ls_d_H;
268 Ki = RoverL_rps * currentCtrlPeriod_sec;
269 CTRL_setGains(handle,CTRL_Type_PI_Id,Kp,Ki);
270
271
272 // set the Id current controller gain
273 Kp = Ls_q_H * pUserParams->BWc_rps;
274 RoverL_rps = Rs_q_Ohm / Ls_q_H;
275 CTRL_setGains(handle,CTRL_Type_PI_Iq,Kp,Ki);
276
277
278 // configure the default current controller output minimum/maximum values
279 outMax = pUserParams->dcBus_nominal_V;
280 outMin = -outMax;
281
282 // set the default current controller output minimum/maximum values
283 PI_setMinMax(obj->piHandle_Id,outMin,outMax);
284 PI_setMinMax(obj->piHandle_Iq,outMin,outMax);
285
286
287 // reset the integrators
288 CTRL_setUi(handle,CTRL_Type_PI_spd,(float_t)0.0);
289 CTRL_setUi(handle,CTRL_Type_PI_Id,(float_t)0.0);
290 CTRL_setUi(handle,CTRL_Type_PI_Iq,(float_t)0.0);
291
292 return;
293 } // end of CTRL_setParams() function
294
295
296 void CTRL_setVersion(CTRL_Handle handle,const CTRL_TargetProc_e targetProc,
297 const uint16_t majorReleaseNumber,const uint16_t minorReleaseNumber)
298 {
299 CTRL_Obj *obj = (CTRL_Obj *)handle;
300
301 obj->version.rsvd = 107;
302 obj->version.targetProc = (uint16_t)targetProc;
303 obj->version.major = (uint16_t)majorReleaseNumber;
304 obj->version.minor = (uint16_t)minorReleaseNumber;
305
306 return;
307 } // end of CTRL_setVersion() function
308
309
310 void CTRL_setWaitTimes(CTRL_Handle handle,const int_least32_t *pWaitTimes)
311 {
312 CTRL_Obj *obj = (CTRL_Obj *)handle;
313 uint_least16_t stateCnt;
314
315 for(stateCnt=0;stateCnt<CTRL_numStates;stateCnt++)
316 {
317 obj->waitTimes[stateCnt] = pWaitTimes[stateCnt];
318 }
319
320 return;
321 } // end of CTRL_setWaitTimes() function
322
323
324 bool CTRL_updateState(CTRL_Handle handle)
325 {
326 CTRL_State_e state = CTRL_getState(handle);
327 bool flag_enable = CTRL_getFlag_enable(handle);
328 bool stateChanged = false;
329
330
331 if(flag_enable)
332 {
333 int_least32_t counter_state = CTRL_getCount_state(handle);
334 int_least32_t waitTime = CTRL_getWaitTime(handle,state);
335
336
337 // check for errors
338 CTRL_checkForErrors(handle);
339
340
341 if(counter_state >= waitTime)
342 {
343 // reset the counter
344 CTRL_resetCounter_state(handle);
345
346
347 if(state == CTRL_State_Idle)
348 {
349 // set the next controller state
350 CTRL_setState(handle,CTRL_State_OnLine);
351 }
352 } // if(counter_state >= waitTime) loop
353 }
354 else
355 {
356 if(state != CTRL_State_Error)
357 {
358 if(CTRL_isNotIdle(handle))
359 {
360 // reset the controller
361 CTRL_reset(handle);
362
363 // set the next controller state
364 CTRL_setState(handle,CTRL_State_Idle);
365 }
366 }
367 }
368
369
370 // check to see if the state changed
371 if(state != CTRL_getState(handle))
372 {
373 stateChanged = true;
374 }
375
376 return(stateChanged);
377 } // end of CTRL_updateState() function
378
379
380 // end of file
381
CTRL_Type_PI_spd
PI Speed controller.
Definition: float/ctrl_obj.h:86
_CTRL_Version_
Defines the controller (CTRL) version number.
Definition: 32b/ctrl_obj.h:131
CTRL_State_Error
the controller error state
Definition: ctrl_states.h:35
CTRL_MAJOR_RELEASE_NUMBER
#define CTRL_MAJOR_RELEASE_NUMBER
Defines the major release number.
Definition: float/ctrl_obj.h:44
CTRL_resetCounter_state
void CTRL_resetCounter_state(CTRL_Handle handle)
Resets the state counter.
Definition: 32b/ctrl.h:1107
CTRL_setWaitTimes
void CTRL_setWaitTimes(CTRL_Handle handle, const int_least32_t *pWaitTimes)
Sets the wait times for the controller states.
Definition: float/ctrl.c:310
_USER_Params_::motor_Rs_d_Ohm
float_t motor_Rs_d_Ohm
Defines the direct stator resistance, Ohm.
Definition: user/src/float/userParams.h:96
CTRL_setMotorParams
void CTRL_setMotorParams(CTRL_Handle handle, const MOTOR_Type_e motorType, const uint_least16_t numPolePairs, const float_t ratedFlux, const float_t Ls_d, const float_t Ls_q, const float_t Rr, const float_t Rs)
Sets the parameters for the motor in the controller.
Definition: 32b/ctrl.h:1581
_CTRL_Obj_::piHandle_Id
PI_Handle piHandle_Id
the handle for the Id PI controller
Definition: float/ctrl_obj.h:115
CTRL_setVdq_offset_V
static void CTRL_setVdq_offset_V(CTRL_Handle handle, const MATH_vec2 *pVdq_offset_V)
Sets the direct/quadrature offset voltage (Vdq_offset) vector values in the controller.
Definition: float/ctrl.h:1868
math.h
Contains the public interface to the math (MATH) module routines.
_MATH_vec2_
Defines a two element vector.
Definition: 32b/math.h:248
CTRL_numStates
the number of controller states
Definition: ctrl_states.h:39
MATH_TWO_PI
#define MATH_TWO_PI
Defines 2*pi.
Definition: 32b/math.h:109
_USER_Params_::BWc_rps
float_t BWc_rps
Defines the bandwidth of the current controllers, rad/sec.
Definition: user/src/float/userParams.h:109
_CTRL_Version_::major
uint16_t major
the major release number
Definition: 32b/ctrl_obj.h:135
_USER_Params_::ctrlPeriod_sec
float_t ctrlPeriod_sec
Defines the controller execution period, sec.
Definition: fast/src/32b/userParams.h:258
_USER_Params_::maxCurrent_A
float_t maxCurrent_A
Defines the maximum current value, A.
Definition: user/src/float/userParams.h:102
CTRL_getWaitTimes
void CTRL_getWaitTimes(CTRL_Handle handle, int_least32_t *pWaitTimes)
Gets the wait times from the controller.
Definition: float/ctrl.c:71
PI_setUi
static void PI_setUi(PI_Handle handle, const _iq Ui)
Sets the integrator start value in the PI controller.
Definition: 32b/pi.h:348
CTRL_setBWdelta
static void CTRL_setBWdelta(CTRL_Handle handle, const float_t BWdelta)
Sets the bandwidth scale factor used to maximize phase margin.
Definition: float/ctrl.h:1250
CTRL_State_Idle
the controller idle state
Definition: ctrl_states.h:36
_USER_Params_::ctrlWaitTime
uint_least32_t ctrlWaitTime[CTRL_numStates]
Defines the wait times for each controller state, estimator ticks.
Definition: fast/src/32b/userParams.h:248
_USER_Params_::motor_Rs_q_Ohm
float_t motor_Rs_q_Ohm
Defines the quadrature stator resistance, Ohm.
Definition: user/src/float/userParams.h:97
CTRL_setSpeed_outMax_A
static void CTRL_setSpeed_outMax_A(CTRL_Handle handle, const float_t speed_outMax_A)
Sets the maximum output value for the speed controller.
Definition: float/ctrl.h:1739
_CTRL_Obj_
Defines the controller (CTRL) object.
Definition: 32b/ctrl_obj.h:144
_USER_Params_
Defines a structure for the user parameters.
Definition: fast/src/32b/userParams.h:193
_CTRL_Obj_::pi_Id
PI_Obj pi_Id
the Id PI controller object
Definition: float/ctrl_obj.h:116
_CTRL_Obj_::piHandle_Iq
PI_Handle piHandle_Iq
the handle for the Iq PI controller
Definition: float/ctrl_obj.h:118
CTRL_setBWc_rps
static void CTRL_setBWc_rps(CTRL_Handle handle, const float_t BWc_rps)
Sets the current controller bandwidth.
Definition: float/ctrl.h:1237
CTRL_setSpeed_ref_Hz
static void CTRL_setSpeed_ref_Hz(CTRL_Handle handle, const float_t speed_ref_Hz)
Sets the output speed reference value in the controller.
Definition: float/ctrl.h:1765
CTRL_TargetProc_e
CTRL_TargetProc_e
Enumeration for the target processors.
Definition: 32b/ctrl_obj.h:109
CTRL_setIdq_ref_A
static void CTRL_setIdq_ref_A(CTRL_Handle handle, const MATH_vec2 *pIdq_ref_A)
Sets the direct/quadrature current (Idq) reference vector values in the controller.
Definition: float/ctrl.h:1473
CTRL_setFlag_enableSpeedCtrl
void CTRL_setFlag_enableSpeedCtrl(CTRL_Handle handle, const bool state)
Sets the enable speed control value in the estimator.
Definition: 32b/ctrl.h:1284
CTRL_getWaitTime
uint_least32_t CTRL_getWaitTime(CTRL_Handle handle, const CTRL_State_e ctrlState)
Gets the wait time for a given state.
Definition: 32b/ctrl.h:933
CTRL_reset
void CTRL_reset(CTRL_Handle handle)
Resets the controller.
Definition: float/ctrl.c:130
_USER_Params_::numCtrlTicksPerCurrentTick
uint_least16_t numCtrlTicksPerCurrentTick
Defines the number of controller clock ticks per current controller clock tick.
Definition: fast/src/32b/userParams.h:200
CTRL_resetCounter_current
void CTRL_resetCounter_current(CTRL_Handle handle)
Resets the current counter.
Definition: 32b/ctrl.h:1071
CTRL_setFlag_enableCurrentCtrl
static void CTRL_setFlag_enableCurrentCtrl(CTRL_Handle handle, const bool state)
Sets the enable current controllers flag value in the controller.
Definition: 32b/ctrl.h:1227
CTRL_setGains
void CTRL_setGains(CTRL_Handle handle, const CTRL_Type_e ctrlType, const _iq Kp, const _iq Ki, const _iq Kd)
Sets the gain values for the specified controller.
Definition: 32b/ctrl.c:262
CTRL_setSpeed_fb_Hz
static void CTRL_setSpeed_fb_Hz(CTRL_Handle handle, const float_t speed_fb_Hz)
Sets the feedback speed value in the controller.
Definition: float/ctrl.h:1713
CTRL_setState
void CTRL_setState(CTRL_Handle handle, const CTRL_State_e state)
Sets the controller state.
Definition: 32b/ctrl.h:1774
CTRL_init
CTRL_Handle CTRL_init(void *pMemory, const size_t numBytes)
Initializes the controller.
Definition: float/ctrl.c:85
_USER_Params_::maxVsMag_V
float_t maxVsMag_V
Defines the maximum stator voltage magnitude, V.
Definition: user/src/float/userParams.h:107
CTRL_setFlag_resetInt_Id
static void CTRL_setFlag_resetInt_Id(CTRL_Handle handle, const bool state)
Sets the reset Id integrator flag value in the controller.
Definition: float/ctrl.h:1354
CTRL_setIdq_offset_A
static void CTRL_setIdq_offset_A(CTRL_Handle handle, const MATH_vec2 *pIdq_offset_A)
Sets the direct/quadrature current (Idq) offset vector values in the controller.
Definition: float/ctrl.h:1459
CTRL_setParams
void CTRL_setParams(CTRL_Handle handle, USER_Params *pUserParams)
Sets the controller parameters.
Definition: float/ctrl.c:155
_USER_Params_::motor_type
MOTOR_Type_e motor_type
Defines the motor type.
Definition: fast/src/32b/userParams.h:229
CTRL_Type_PI_Iq
PI Iq controller.
Definition: float/ctrl_obj.h:88
CTRL_resetCounter_isr
void CTRL_resetCounter_isr(CTRL_Handle handle)
Resets the isr counter.
Definition: 32b/ctrl.h:1083
_CTRL_Version_::rsvd
uint16_t rsvd
reserved value
Definition: 32b/ctrl_obj.h:133
_USER_Params_::BWdelta
float_t BWdelta
Defines the bandwidth scaling to maximize phase margin.
Definition: user/src/float/userParams.h:110
PI_init
PI_Handle PI_init(void *pMemory, const size_t numBytes)
Initializes the PI controller.
Definition: 32b/pi.c:56
CTRL_setFlag_enable
static void CTRL_setFlag_enable(CTRL_Handle handle, const bool state)
Sets the enable controller flag value in the controller.
Definition: float/ctrl.h:1315
_USER_Params_::Vd_sf
float_t Vd_sf
Defines the Vd scale factor to prevent a Vd only component for the Vdq vector.
Definition: user/src/float/userParams.h:106
CTRL_getState
CTRL_State_e CTRL_getState(CTRL_Handle handle)
Gets the controller state.
Definition: 32b/ctrl.h:767
CTRL_setSpeed_out_A
static void CTRL_setSpeed_out_A(CTRL_Handle handle, const float_t speed_out_A)
Sets the maximum output value for the speed controller.
Definition: float/ctrl.h:1726
CTRL_setCtrlPeriod_sec
void CTRL_setCtrlPeriod_sec(CTRL_Handle handle, const float_t ctrlPeriod_sec)
Sets the controller execution period.
Definition: 32b/ctrl.h:1176
CTRL_setFlag_resetInt_Iq
static void CTRL_setFlag_resetInt_Iq(CTRL_Handle handle, const bool state)
Sets the reset Iq integrator flag value in the controller.
Definition: float/ctrl.h:1367
_CTRL_Obj_::waitTimes
uint_least32_t waitTimes[CTRL_numStates]
an array of wait times for each state, estimator clock counts
Definition: 32b/ctrl_obj.h:191
CTRL_setNumCtrlTicksPerCurrentTick
void CTRL_setNumCtrlTicksPerCurrentTick(CTRL_Handle handle, const uint_least16_t numCtrlTicksPerCurrentTick)
Sets the number of controller clock ticks per current controller clock tick.
Definition: 32b/ctrl.h:1615
CTRL_setFlag_useZeroIq_ref
static void CTRL_setFlag_useZeroIq_ref(CTRL_Handle handle, const bool state)
Sets the use zero Iq reference flag value in the controller.
Definition: float/ctrl.h:1393
CTRL_State_e
CTRL_State_e
Enumeration for the controller states.
Definition: ctrl_states.h:34
CTRL_State_OnLine
the controller online state
Definition: ctrl_states.h:38
_USER_Params_::Kctrl_Wb_p_kgm2
float_t Kctrl_Wb_p_kgm2
Defines the speed controller constant, Wb/(kg*m^2)
Definition: user/src/float/userParams.h:111
CTRL_setErrorCode
void CTRL_setErrorCode(CTRL_Handle handle, const CTRL_ErrorCode_e errorCode)
Sets the error code in the controller.
Definition: 32b/ctrl.h:1189
_CTRL_Obj_::version
CTRL_Version version
the controller version
Definition: 32b/ctrl_obj.h:146
_USER_Params_::numCtrlTicksPerSpeedTick
uint_least16_t numCtrlTicksPerSpeedTick
Defines the number of controller clock ticks per speed controller clock tick.
Definition: fast/src/32b/userParams.h:202
CTRL_getFlag_enable
static bool CTRL_getFlag_enable(CTRL_Handle handle)
Gets the enable controller flag value from the controller.
Definition: float/ctrl.h:302
CTRL_isNotIdle
static bool CTRL_isNotIdle(CTRL_Handle handle)
Determines if the controller is not in the idle state.
Definition: float/ctrl.h:1167
CTRL_MINOR_RELEASE_NUMBER
#define CTRL_MINOR_RELEASE_NUMBER
Defines the major release number.
Definition: float/ctrl_obj.h:49
CTRL_ErrorCode_NoError
no error error code
Definition: 32b/ctrl_obj.h:100
CTRL_updateState
bool CTRL_updateState(CTRL_Handle handle)
Updates the controller state.
Definition: float/ctrl.c:324
_CTRL_Obj_::pi_spd
PI_Obj pi_spd
the speed PI controller object
Definition: float/ctrl_obj.h:122
CTRL_setIdq_A
static void CTRL_setIdq_A(CTRL_Handle handle, const MATH_vec2 *pIdq_A)
Sets the direct/quadrature current (Idq) vector values in the controller.
Definition: float/ctrl.h:1445
_CTRL_Version_::targetProc
CTRL_TargetProc_e targetProc
the target processor
Definition: 32b/ctrl_obj.h:134
_USER_Params_::numIsrTicksPerCtrlTick
uint_least16_t numIsrTicksPerCtrlTick
Defines the number of Interrupt Service Routine (ISR) clock ticks per controller clock tick...
Definition: fast/src/32b/userParams.h:199
CTRL_setVdq_V
static void CTRL_setVdq_V(CTRL_Handle handle, const MATH_vec2 *pVdq_V)
Sets the direct/quadrature voltage (Vdq) vector values in the controller.
Definition: float/ctrl.h:1854
_USER_Params_::motor_Rr_q_Ohm
float_t motor_Rr_q_Ohm
Defines the quadrature rotor resistance, Ohm.
Definition: user/src/float/userParams.h:91
_USER_Params_::motor_ratedFlux_Wb
float_t motor_ratedFlux_Wb
Defines the rated flux of the motor, Wb.
Definition: user/src/float/userParams.h:88
CTRL_setSpeed_outMin_A
static void CTRL_setSpeed_outMin_A(CTRL_Handle handle, const float_t speed_outMin_A)
Sets the minimum output value for the speed controller.
Definition: float/ctrl.h:1752
CTRL_setFlag_resetInt_spd
static void CTRL_setFlag_resetInt_spd(CTRL_Handle handle, const bool state)
Sets the reset speed integrator flag value in the controller.
Definition: float/ctrl.h:1380
_USER_Params_::ctrlFreq_Hz
uint_least32_t ctrlFreq_Hz
Defines the controller frequency, Hz.
Definition: fast/src/32b/userParams.h:253
_USER_Params_::motor_Rr_d_Ohm
float_t motor_Rr_d_Ohm
Defines the direct rotor resistance, Ohm.
Definition: user/src/float/userParams.h:90
PI_setMinMax
static void PI_setMinMax(PI_Handle handle, const _iq outMin, const _iq outMax)
Sets the minimum and maximum output value allowed in the PI controller.
Definition: 32b/pi.h:295
CTRL_setCtrlFreq_Hz
void CTRL_setCtrlFreq_Hz(CTRL_Handle handle, const uint_least32_t ctrlFreq_Hz)
Sets the controller frequency.
Definition: 32b/ctrl.h:1163
_USER_Params_::dcBus_nominal_V
float_t dcBus_nominal_V
Defines the nominal DC bus voltage, V.
Definition: user/src/float/userParams.h:53
_USER_Params_::motor_numPolePairs
uint_least16_t motor_numPolePairs
Defines the number of pole pairs for the motor.
Definition: fast/src/32b/userParams.h:230
CTRL_resetCounter_speed
void CTRL_resetCounter_speed(CTRL_Handle handle)
Resets the speed counter.
Definition: 32b/ctrl.h:1095
CTRL_setCurrentCtrlPeriod_sec
static void CTRL_setCurrentCtrlPeriod_sec(CTRL_Handle handle, const float_t currentCtrlPeriod_sec)
Sets the current controller period value.
Definition: float/ctrl.h:1289
CTRL_checkForErrors
void CTRL_checkForErrors(CTRL_Handle handle)
Checks for any controller errors and, if found, sets the controller state to the error state...
Definition: 32b/ctrl.h:1982
CTRL_setNumCtrlTicksPerSpeedTick
void CTRL_setNumCtrlTicksPerSpeedTick(CTRL_Handle handle, const uint_least16_t numCtrlTicksPerSpeedTick)
Sets the number of controller clock ticks per speed controller clock tick.
Definition: 32b/ctrl.h:1629
CTRL_getVersion
void CTRL_getVersion(CTRL_Handle handle, CTRL_Version *pVersion)
Gets the controller version number.
Definition: float/ctrl.c:58
_CTRL_Version_::minor
uint16_t minor
the minor release number
Definition: 32b/ctrl_obj.h:136
CTRL_setMaxVsMag_V
static void CTRL_setMaxVsMag_V(CTRL_Handle handle, const float_t maxVsMag_V)
Sets the maximum stator voltage magnitude value.
Definition: float/ctrl.h:1614
CTRL_setVersion
void CTRL_setVersion(CTRL_Handle handle, const CTRL_TargetProc_e targetProc, const uint16_t majorReleaseNumber, const uint16_t minorReleaseNumber)
Sets the controller version.
Definition: float/ctrl.c:296
CTRL_getCount_state
uint_least32_t CTRL_getCount_state(CTRL_Handle handle)
Gets the state count.
Definition: 32b/ctrl.h:128
_CTRL_Obj_::piHandle_spd
PI_Handle piHandle_spd
the handle for the speed PI controller
Definition: float/ctrl_obj.h:121
ctrl.h
Contains public interface to various functions related to the controller (CTRL) object.
CTRL_setSpeedCtrlPeriod_sec
static void CTRL_setSpeedCtrlPeriod_sec(CTRL_Handle handle, const float_t speedCtrlPeriod_sec)
Sets the speed controller period value.
Definition: float/ctrl.h:1778
_CTRL_Obj_::pi_Iq
PI_Obj pi_Iq
the Iq PI controller object
Definition: float/ctrl_obj.h:119
CTRL_TargetProc_2806x
2806x processor
Definition: 32b/ctrl_obj.h:111
CTRL_Handle
struct _CTRL_Obj_ * CTRL_Handle
Defines the CTRL handle.
Definition: 32b/ctrl_obj.h:283
_USER_Params_::motor_Ls_d_H
float_t motor_Ls_d_H
Defines the direct stator inductance, H.
Definition: user/src/float/userParams.h:99
CTRL_setVd_sf
static void CTRL_setVd_sf(CTRL_Handle handle, const float_t Vd_sf)
Sets the direct voltage scale factor.
Definition: float/ctrl.h:1841
_USER_Params_::motor_Ls_q_H
float_t motor_Ls_q_H
Defines the quadrature stator inductance, H.
Definition: user/src/float/userParams.h:100
CTRL_setUi
void CTRL_setUi(CTRL_Handle handle, const CTRL_Type_e ctrlType, const _iq Ui)
Sets the integrator (Ui) value in the specified controller.
Definition: 32b/ctrl.h:1815
CTRL_setKctrl_Wb_p_kgm2
static void CTRL_setKctrl_Wb_p_kgm2(CTRL_Handle handle, const float_t Kctrl_Wb_p_kgm2)
Sets the speed controller constant.
Definition: float/ctrl.h:1526
CTRL_setNumIsrTicksPerCtrlTick
void CTRL_setNumIsrTicksPerCtrlTick(CTRL_Handle handle, const uint_least16_t numIsrTicksPerCtrlTick)
Sets the number of Interrupt Service Routine (ISR) clock ticks per controller clock tick...
Definition: 32b/ctrl.h:1657
CTRL_Type_PI_Id
PI Id controller.
Definition: float/ctrl_obj.h:87
float_t
float float_t
Defines the portable data type for 32 bit, signed floating-point data.
Definition: types.h:121