MotorWare f2806x Module API Documentation

- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

ctrlQEP.c
Go to the documentation of this file.
1 /* --COPYRIGHT--,BSD
2 * Copyright (c) 2012, Texas Instruments Incorporated
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * * Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the 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 "AS IS"
21 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 * --/COPYRIGHT--*/
32
33
34
39
40
41 // **************************************************************************
42 // the includes
43
44 #include <math.h>
45
46
47 // drivers
48
49
50 // modules
51 #include "sw/modules/dlog/src/32b/dlog4ch.h"
52 #include "sw/modules/math/src/32b/math.h"
53
54
55 // platforms
56 #include "ctrlQEP.h"
57 #include "hal.h"
58 #include "user.h"
59
60
61 #ifdef FLASH
62 #pragma CODE_SECTION(CTRL_run,"ramfuncs");
63 #pragma CODE_SECTION(CTRL_setup,"ramfuncs");
64 #endif
65
66
67 // **************************************************************************
68 // the defines
69
70
71 // **************************************************************************
72 // the globals
73
74
75 // **************************************************************************
76 // the function prototypes
77
78 void CTRL_getGains(CTRL_Handle handle,const CTRL_Type_e ctrlType,
79 _iq *pKp,_iq *pKi,_iq *pKd)
80 {
81
82 *pKp = CTRL_getKp(handle,ctrlType);
83 *pKi = CTRL_getKi(handle,ctrlType);
84 *pKd = CTRL_getKd(handle,ctrlType);
85
86 return;
87 } // end of CTRL_getGains() function
88
89
90 void CTRL_getIab_filt_pu(CTRL_Handle handle,MATH_vec2 *pIab_filt_pu)
91 {
92 CTRL_Obj *obj = (CTRL_Obj *)handle;
93
94 pIab_filt_pu->value[0] = obj->Iab_filt.value[0];
95 pIab_filt_pu->value[1] = obj->Iab_filt.value[1];
96
97 return;
98 } // end of CTRL_getIab_filt_pu() function
99
100
101 void CTRL_getIab_in_pu(CTRL_Handle handle,MATH_vec2 *pIab_in_pu)
102 {
103 CTRL_Obj *obj = (CTRL_Obj *)handle;
104
105 pIab_in_pu->value[0] = obj->Iab_in.value[0];
106 pIab_in_pu->value[1] = obj->Iab_in.value[1];
107
108 return;
109 } // end of CTRL_getIab_in_pu() function
110
111
112 void CTRL_getIdq_in_pu(CTRL_Handle handle,MATH_vec2 *pIdq_in_pu)
113 {
114 CTRL_Obj *obj = (CTRL_Obj *)handle;
115
116 pIdq_in_pu->value[0] = obj->Idq_in.value[0];
117 pIdq_in_pu->value[1] = obj->Idq_in.value[1];
118
119 return;
120 } // end of CTRL_getIdq_in_pu() function
121
122
123 void CTRL_getIdq_ref_pu(CTRL_Handle handle,MATH_vec2 *pIdq_ref_pu)
124 {
125 CTRL_Obj *obj = (CTRL_Obj *)handle;
126
127 pIdq_ref_pu->value[0] = obj->Idq_ref.value[0];
128 pIdq_ref_pu->value[1] = obj->Idq_ref.value[1];
129
130 return;
131 } // end of CTRL_getIdq_ref_pu() function
132
133
134 _iq CTRL_getMagCurrent_pu(CTRL_Handle handle)
135 {
136
137 return(CTRL_getIdRated_pu(handle));
138 } // end of CTRL_getMagCurrent_pu() function
139
140
141 _iq CTRL_getMaximumSpeed_pu(CTRL_Handle handle)
142 {
143
144 return(CTRL_getSpd_max_pu(handle));
145 } // end of CTRL_getMaximumSpeed_pu() function
146
147
148 void CTRL_getVab_in_pu(CTRL_Handle handle,MATH_vec2 *pVab_in_pu)
149 {
150 CTRL_Obj *obj = (CTRL_Obj *)handle;
151
152 pVab_in_pu->value[0] = obj->Vab_in.value[0];
153 pVab_in_pu->value[1] = obj->Vab_in.value[1];
154
155 return;
156 } // end of CTRL_getVab_in_pu() function
157
158
159 void CTRL_getVab_out_pu(CTRL_Handle handle,MATH_vec2 *pVab_out_pu)
160 {
161 CTRL_Obj *obj = (CTRL_Obj *)handle;
162
163 pVab_out_pu->value[0] = obj->Vab_out.value[0];
164 pVab_out_pu->value[1] = obj->Vab_out.value[1];
165
166 return;
167 } // end of CTRL_getVab_out_pu() function
168
169
170 void CTRL_getVdq_out_pu(CTRL_Handle handle,MATH_vec2 *pVdq_out_pu)
171 {
172 CTRL_Obj *obj = (CTRL_Obj *)handle;
173
174 pVdq_out_pu->value[0] = obj->Vdq_out.value[0];
175 pVdq_out_pu->value[1] = obj->Vdq_out.value[1];
176
177 return;
178 } // end of CTRL_getVdq_out_pu() function
179
180
181 void CTRL_getWaitTimes(CTRL_Handle handle,uint_least32_t *pWaitTimes)
182 {
183 CTRL_Obj *obj = (CTRL_Obj *)handle;
184 uint_least16_t stateCnt;
185
186 for(stateCnt=0;stateCnt<CTRL_numStates;stateCnt++)
187 {
188 pWaitTimes[stateCnt] = obj->waitTimes[stateCnt];
189 }
190
191 return;
192 } // end of CTRL_getWaitTimes() function
193
194
195 void CTRL_run(CTRL_Handle handle,HAL_Handle halHandle,
196 const HAL_AdcData_t *pAdcData,
197 HAL_PwmData_t *pPwmData,
198 uint32_t electricalAngle)
199 {
200 uint_least16_t count_isr = CTRL_getCount_isr(handle);
201 uint_least16_t numIsrTicksPerCtrlTick = CTRL_getNumIsrTicksPerCtrlTick(handle);
202
203
204 // if needed, run the controller
205 if(count_isr >= numIsrTicksPerCtrlTick)
206 {
207 CTRL_State_e ctrlState = CTRL_getState(handle);
208
209 // reset the isr count
210 CTRL_resetCounter_isr(handle);
211
212 // increment the state counter
213 CTRL_incrCounter_state(handle);
214
215 // increment the trajectory count
216 CTRL_incrCounter_traj(handle);
217
218 // run the appropriate controller
219 if(ctrlState == CTRL_State_OnLine)
220 {
221 CTRL_Obj *obj = (CTRL_Obj *)handle;
222
223 // increment the current count
224 CTRL_incrCounter_current(handle);
225
226 // increment the speed count
227 CTRL_incrCounter_speed(handle);
228
229 if(EST_getState(obj->estHandle) >= EST_State_MotorIdentified)
230 {
231 // run the online controller
232 CTRL_runOnLine_User(handle,pAdcData,pPwmData,electricalAngle);
233 }
234 else
235 {
236 // run the online controller
237 CTRL_runOnLine(handle,pAdcData,pPwmData);
238 }
239 }
240 else if(ctrlState == CTRL_State_OffLine)
241 {
242 // run the offline controller
243 CTRL_runOffLine(handle,halHandle,pAdcData,pPwmData);
244 }
245 else if(ctrlState == CTRL_State_Idle)
246 {
247 // set all pwm outputs to zero
248 pPwmData->Tabc.value[0] = _IQ(0.0);
249 pPwmData->Tabc.value[1] = _IQ(0.0);
250 pPwmData->Tabc.value[2] = _IQ(0.0);
251 }
252 }
253 else
254 {
255 // increment the isr count
256 CTRL_incrCounter_isr(handle);
257 }
258
259 return;
260 } // end of CTRL_run() function
261
262
263 void CTRL_setGains(CTRL_Handle handle,const CTRL_Type_e ctrlType,
264 const _iq Kp,const _iq Ki,const _iq Kd)
265 {
266
267 CTRL_setKp(handle,ctrlType,Kp);
268 CTRL_setKi(handle,ctrlType,Ki);
269 CTRL_setKd(handle,ctrlType,Kd);
270
271 return;
272 } // end of CTRL_setGains() function
273
274
275 void CTRL_setMagCurrent_pu(CTRL_Handle handle,const _iq magCurrent_pu)
276 {
277
278 CTRL_setIdRated_pu(handle,magCurrent_pu);
279
280 return;
281 } // end of CTRL_setMagCurrent_pu() function
282
283
284 void CTRL_setMaximumSpeed_pu(CTRL_Handle handle,const _iq maxSpeed_pu)
285 {
286
287 CTRL_setSpd_max_pu(handle,maxSpeed_pu);
288
289 return;
290 } // end of CTRL_setMaximumSpeed_pu() function
291
292
293 void CTRL_setParams(CTRL_Handle handle,USER_Params *pUserParams)
294 {
295 CTRL_Obj *obj = (CTRL_Obj *)handle;
296
297 _iq Kp,Ki,Kd;
298 _iq outMin,outMax;
299 _iq maxModulation;
300
301 MATH_vec2 Iab_out_pu = {_IQ(0.0),_IQ(0.0)};
302 MATH_vec2 Idq_out_pu = {_IQ(0.0),_IQ(0.0)};
303 MATH_vec2 Idq_ref_pu = {_IQ(0.0),_IQ(0.0)};
304 MATH_vec2 Vab_in_pu = {_IQ(0.0),_IQ(0.0)};
305 MATH_vec2 Vab_out_pu = {_IQ(0.0),_IQ(0.0)};
306 MATH_vec2 Vdq_out_pu = {_IQ(0.0),_IQ(0.0)};
307
308
309 // assign the motor type
310 CTRL_setMotorParams(handle,pUserParams->motor_type,
311 pUserParams->motor_numPolePairs,
312 pUserParams->motor_ratedFlux,
313 pUserParams->motor_Ls_d,
314 pUserParams->motor_Ls_q,
315 pUserParams->motor_Rr,
316 pUserParams->motor_Rs);
317
318
319 // assign other controller parameters
320 CTRL_setNumIsrTicksPerCtrlTick(handle,pUserParams->numIsrTicksPerCtrlTick);
321 CTRL_setNumCtrlTicksPerCurrentTick(handle,pUserParams->numCtrlTicksPerCurrentTick);
322 CTRL_setNumCtrlTicksPerSpeedTick(handle,pUserParams->numCtrlTicksPerSpeedTick);
323 CTRL_setNumCtrlTicksPerTrajTick(handle,pUserParams->numCtrlTicksPerTrajTick);
324
325 CTRL_setCtrlFreq_Hz(handle,pUserParams->ctrlFreq_Hz);
326 CTRL_setTrajFreq_Hz(handle,pUserParams->trajFreq_Hz);
327 CTRL_setTrajPeriod_sec(handle,_IQ(1.0/pUserParams->trajFreq_Hz));
328
329 CTRL_setCtrlPeriod_sec(handle,pUserParams->ctrlPeriod_sec);
330
331 CTRL_setMaxVsMag_pu(handle,_IQ(pUserParams->maxVsMag_pu));
332
333 CTRL_setIab_in_pu(handle,&Iab_out_pu);
334 CTRL_setIdq_in_pu(handle,&Idq_out_pu);
335 CTRL_setIdq_ref_pu(handle,&Idq_ref_pu);
336
337 CTRL_setIdRated_pu(handle,_IQ(pUserParams->IdRated/pUserParams->iqFullScaleCurrent_A));
338
339 CTRL_setVab_in_pu(handle,&Vab_in_pu);
340 CTRL_setVab_out_pu(handle,&Vab_out_pu);
341 CTRL_setVdq_out_pu(handle,&Vdq_out_pu);
342
343 CTRL_setSpd_out_pu(handle,_IQ(0.0));
344
345 CTRL_setRhf(handle,0.0);
346 CTRL_setLhf(handle,0.0);
347 CTRL_setRoverL(handle,0.0);
348
349
350 // reset the counters
351 CTRL_resetCounter_current(handle);
352 CTRL_resetCounter_isr(handle);
353 CTRL_resetCounter_speed(handle);
354 CTRL_resetCounter_state(handle);
355 CTRL_resetCounter_traj(handle);
356
357
358 // set the wait times for each state
359 CTRL_setWaitTimes(handle,&pUserParams->ctrlWaitTime[0]);
360
361
362 // set flags
363 CTRL_setFlag_enablePowerWarp(handle,false);
364 CTRL_setFlag_enableCtrl(handle,false);
365 CTRL_setFlag_enableOffset(handle,true);
366 CTRL_setFlag_enableSpeedCtrl(handle,true);
367 CTRL_setFlag_enableUserMotorParams(handle,false);
368 CTRL_setFlag_enableDcBusComp(handle,true);
369
370
371 // initialize the controller error code
372 CTRL_setErrorCode(handle,CTRL_ErrorCode_NoError);
373
374
375 // set the default controller state
376 CTRL_setState(handle,CTRL_State_Idle);
377
378
379 // set the number of current sensors
380 CTRL_setupClarke_I(handle,pUserParams->numCurrentSensors);
381
382
383 // set the number of voltage sensors
384 CTRL_setupClarke_V(handle,pUserParams->numVoltageSensors);
385
386
387 // set the default Id PID controller parameters
388 Kp = _IQ(0.1);
389 Ki = _IQ(pUserParams->ctrlPeriod_sec/0.004);
390 Kd = _IQ(0.0);
391 outMin = _IQ(-0.95);
392 outMax = _IQ(0.95);
393
394 PID_setGains(obj->pidHandle_Id,Kp,Ki,Kd);
395 PID_setUi(obj->pidHandle_Id,_IQ(0.0));
396 PID_setMinMax(obj->pidHandle_Id,outMin,outMax);
397 CTRL_setGains(handle,CTRL_Type_PID_Id,Kp,Ki,Kd);
398
399
400 // set the default the Iq PID controller parameters
401 Kp = _IQ(0.1);
402 Ki = _IQ(pUserParams->ctrlPeriod_sec/0.004);
403 Kd = _IQ(0.0);
404 outMin = _IQ(-0.95);
405 outMax = _IQ(0.95);
406
407 PID_setGains(obj->pidHandle_Iq,Kp,Ki,Kd);
408 PID_setUi(obj->pidHandle_Iq,_IQ(0.0));
409 PID_setMinMax(obj->pidHandle_Iq,outMin,outMax);
410 CTRL_setGains(handle,CTRL_Type_PID_Iq,Kp,Ki,Kd);
411
412
413 // set the default speed PID controller parameters
414 Kp = _IQ(0.02*pUserParams->maxCurrent*pUserParams->iqFullScaleFreq_Hz/pUserParams->iqFullScaleCurrent_A);
415 Ki = _IQ(2.0*pUserParams->maxCurrent*pUserParams->iqFullScaleFreq_Hz*pUserParams->ctrlPeriod_sec/pUserParams->iqFullScaleCurrent_A);
416 Kd = _IQ(0.0);
417 outMin = _IQ(-1.0);
418 outMax = _IQ(1.0);
419
420 PID_setGains(obj->pidHandle_spd,Kp,Ki,Kd);
421 PID_setUi(obj->pidHandle_spd,_IQ(0.0));
422 PID_setMinMax(obj->pidHandle_spd,outMin,outMax);
423 CTRL_setGains(handle,CTRL_Type_PID_spd,Kp,Ki,Kd);
424
425
426 // set the speed reference
427 CTRL_setSpd_ref_pu(handle,_IQ(0.0));
428
429
430 // set the default Id current trajectory module parameters
431 TRAJ_setIntValue(obj->trajHandle_Id,_IQ(0.0));
432 TRAJ_setTargetValue(obj->trajHandle_Id,_IQ(0.0));
433 TRAJ_setMinValue(obj->trajHandle_Id,_IQ(0.0));
434 TRAJ_setMaxValue(obj->trajHandle_Id,_IQ(0.0));
435 TRAJ_setMaxDelta(obj->trajHandle_Id,_IQ(0.0));
436
437
438 // set the default the speed trajectory module parameters
439 TRAJ_setIntValue(obj->trajHandle_spd,_IQ(0.0));
440 TRAJ_setTargetValue(obj->trajHandle_spd,_IQ(0.0));
441 TRAJ_setMinValue(obj->trajHandle_spd,_IQ(0.0));
442 TRAJ_setMaxValue(obj->trajHandle_spd,_IQ(0.0));
443 TRAJ_setMaxDelta(obj->trajHandle_spd,_IQ(0.0));
444
445
446 // set the default maximum speed trajectory module parameters
447 TRAJ_setIntValue(obj->trajHandle_spdMax,_IQ(0.0));
448 TRAJ_setTargetValue(obj->trajHandle_spdMax,_IQ(0.0));
449 TRAJ_setMinValue(obj->trajHandle_spdMax,_IQ(0.0)); // not used
450 TRAJ_setMaxValue(obj->trajHandle_spdMax,_IQ(0.0)); // not used
451 TRAJ_setMaxDelta(obj->trajHandle_spdMax,_IQ(0.0)); // not used
452
453
454 // set the default estimator parameters
455 CTRL_setEstParams(obj->estHandle,pUserParams);
456
457
458 // set the maximum modulation for the SVGEN module
459 maxModulation = _IQ(MATH_TWO_OVER_THREE);
460 SVGEN_setMaxModulation(obj->svgenHandle,maxModulation);
461
462 return;
463 } // end of CTRL_setParams() function
464
465
466 void CTRL_setSpd_ref_pu(CTRL_Handle handle,const _iq spd_ref_pu)
467 {
468 CTRL_Obj *obj = (CTRL_Obj *)handle;
469
470 obj->spd_ref = spd_ref_pu;
471
472 return;
473 } // end of CTRL_setSpd_ref_pu() function
474
475
476 void CTRL_setSpd_ref_krpm(CTRL_Handle handle,const _iq spd_ref_krpm)
477 {
478 CTRL_Obj *obj = (CTRL_Obj *)handle;
479
480 _iq krpm_to_pu_sf = EST_get_krpm_to_pu_sf(obj->estHandle);
481
482 _iq spd_ref_pu = _IQmpy(spd_ref_krpm,krpm_to_pu_sf);
483
484 obj->spd_ref = spd_ref_pu;
485
486 return;
487 } // end of CTRL_setSpd_ref_krpm() function
488
489
490 void CTRL_setup(CTRL_Handle handle)
491 {
492 CTRL_Obj *obj = (CTRL_Obj *)handle;
493
494 uint_least16_t count_traj = CTRL_getCount_traj(handle);
495 uint_least16_t numCtrlTicksPerTrajTick = CTRL_getNumCtrlTicksPerTrajTick(handle);
496
497
498 // as needed, update the trajectory
499 if(count_traj >= numCtrlTicksPerTrajTick)
500 {
501 _iq intValue_Id = TRAJ_getIntValue(obj->trajHandle_Id);
502
503 // reset the trajectory count
504 CTRL_resetCounter_traj(handle);
505
506 // run the trajectories
507 CTRL_runTraj(handle);
508 } // end of if(gFlag_traj) block
509
510 return;
511 } // end of CTRL_setup() function
512
513
514 void CTRL_setupClarke_I(CTRL_Handle handle,uint_least8_t numCurrentSensors)
515 {
516 CTRL_Obj *obj = (CTRL_Obj *)handle;
517 _iq alpha_sf,beta_sf;
518
519
520 // initialize the Clarke transform module for current
521 if(numCurrentSensors == 3)
522 {
523 alpha_sf = _IQ(MATH_ONE_OVER_THREE);
524 beta_sf = _IQ(MATH_ONE_OVER_SQRT_THREE);
525 }
526 else if(numCurrentSensors == 2)
527 {
528 alpha_sf = _IQ(1.0);
529 beta_sf = _IQ(MATH_ONE_OVER_SQRT_THREE);
530 }
531 else
532 {
533 alpha_sf = _IQ(0.0);
534 beta_sf = _IQ(0.0);
535 }
536
537 // set the parameters
538 CLARKE_setScaleFactors(obj->clarkeHandle_I,alpha_sf,beta_sf);
539 CLARKE_setNumSensors(obj->clarkeHandle_I,numCurrentSensors);
540
541 return;
542 } // end of CTRL_setupClarke_I() function
543
544
545 void CTRL_setupClarke_V(CTRL_Handle handle,uint_least8_t numVoltageSensors)
546 {
547 CTRL_Obj *obj = (CTRL_Obj *)handle;
548 _iq alpha_sf,beta_sf;
549
550
551 // initialize the Clarke transform module for current
552 if(numVoltageSensors == 3)
553 {
554 alpha_sf = _IQ(MATH_ONE_OVER_THREE);
555 beta_sf = _IQ(MATH_ONE_OVER_SQRT_THREE);
556 }
557 else
558 {
559 alpha_sf = _IQ(0.0);
560 beta_sf = _IQ(0.0);
561 }
562
563 // set the parameters
564 CLARKE_setScaleFactors(obj->clarkeHandle_V,alpha_sf,beta_sf);
565 CLARKE_setNumSensors(obj->clarkeHandle_V,numVoltageSensors);
566
567 return;
568 } // end of CTRL_setupClarke_V() function
569
570
571 void CTRL_setWaitTimes(CTRL_Handle handle,const uint_least32_t *pWaitTimes)
572 {
573 CTRL_Obj *obj = (CTRL_Obj *)handle;
574 uint_least16_t stateCnt;
575
576 for(stateCnt=0;stateCnt<CTRL_numStates;stateCnt++)
577 {
578 obj->waitTimes[stateCnt] = pWaitTimes[stateCnt];
579 }
580
581 return;
582 } // end of CTRL_setWaitTimes() function
583
584
585 bool CTRL_updateState(CTRL_Handle handle)
586 {
587 CTRL_State_e ctrlState = CTRL_getState(handle);
588 bool flag_enableCtrl = CTRL_getFlag_enableCtrl(handle);
589 bool stateChanged = false;
590
591
592 if(flag_enableCtrl)
593 {
594 uint_least32_t waitTime = CTRL_getWaitTime(handle,ctrlState);
595 uint_least32_t counter_ctrlState = CTRL_getCount_state(handle);
596
597
598 // check for errors
599 CTRL_checkForErrors(handle);
600
601
602 if(counter_ctrlState >= waitTime)
603 {
604 // reset the counter
605 CTRL_resetCounter_state(handle);
606
607
608 if(ctrlState == CTRL_State_OnLine)
609 {
610 CTRL_Obj *obj = (CTRL_Obj *)handle;
611 _iq Id_target = TRAJ_getTargetValue(obj->trajHandle_Id);
612
613 // update the estimator state
614 bool flag_estStateChanged = EST_updateState(obj->estHandle,Id_target);
615
616 if(flag_estStateChanged)
617 {
618 // setup the controller
619 CTRL_setupCtrl(handle);
620
621 // setup the trajectory
622 CTRL_setupTraj(handle);
623 }
624
625 if(EST_isOnLine(obj->estHandle))
626 {
627 // setup the estimator for online state
628 CTRL_setupEstOnLineState(handle);
629 }
630
631 if(EST_isLockRotor(obj->estHandle) ||
632 (EST_isIdle(obj->estHandle) && EST_isMotorIdentified(obj->estHandle)))
633 {
634 // set the enable controller flag to false
635 CTRL_setFlag_enableCtrl(handle,false);
636
637 // set the next controller state
638 CTRL_setState(handle,CTRL_State_Idle);
639 }
640 }
641 else if(ctrlState == CTRL_State_OffLine)
642 {
643 // set the next controller state
644 CTRL_setState(handle,CTRL_State_OnLine);
645 }
646 else if(ctrlState == CTRL_State_Idle)
647 {
648 CTRL_Obj *obj = (CTRL_Obj *)handle;
649 bool flag_enableUserMotorParams = CTRL_getFlag_enableUserMotorParams(handle);
650
651 if(flag_enableUserMotorParams)
652 {
653 // initialize the motor parameters using values from the user.h file
654 CTRL_setUserMotorParams(handle);
655 }
656
657 if(EST_isIdle(obj->estHandle))
658 {
659 // setup the estimator for idle state
660 CTRL_setupEstIdleState(handle);
661
662 if(EST_isMotorIdentified(obj->estHandle))
663 {
664 if(CTRL_getFlag_enableOffset(handle))
665 {
666 // set the next controller state
667 CTRL_setState(handle,CTRL_State_OffLine);
668 }
669 else
670 {
671 // set the next controller state
672 CTRL_setState(handle,CTRL_State_OnLine);
673 }
674 }
675 else
676 {
677 // set the next controller state
678 CTRL_setState(handle,CTRL_State_OffLine);
679 }
680 }
681 else if(EST_isLockRotor(obj->estHandle))
682 {
683 // set the next controller state
684 CTRL_setState(handle,CTRL_State_OnLine);
685 }
686 }
687 } // if(counter_ctrlState >= waitTime) loop
688 }
689 else
690 {
691 CTRL_Obj *obj = (CTRL_Obj *)handle;
692
693 // set the next controller state
694 CTRL_setState(handle,CTRL_State_Idle);
695
696 // set the estimator to idle
697 if(!EST_isLockRotor(obj->estHandle))
698 {
699 if(EST_isMotorIdentified(obj->estHandle))
700 {
701 EST_setIdle(obj->estHandle);
702 }
703 else
704 {
705 EST_setIdle_all(obj->estHandle);
706
707 EST_setRs_pu(obj->estHandle,_IQ30(0.0));
708 }
709 }
710 }
711
712
713 // check to see if the state changed
714 if(ctrlState != CTRL_getState(handle))
715 {
716 stateChanged = true;
717 }
718
719 return(stateChanged);
720 } // end of CTRL_updateState() function
721
722 // end of file
CTRL_Type_PID_spd
PID Speed controller.
Definition: 32b/ctrl_obj.h:123
CTRL_getGains
void CTRL_getGains(CTRL_Handle handle, const CTRL_Type_e ctrlType, _iq *pKp, _iq *pKi, _iq *pKd)
Gets the gain values for the specified controller.
Definition: ctrlQEP.c:78
CTRL_incrCounter_isr
void CTRL_incrCounter_isr(CTRL_Handle handle)
Increments the isr counter.
Definition: 32b/ctrl.h:967
TRAJ_setTargetValue
static void TRAJ_setTargetValue(TRAJ_Handle handle, const _iq targetValue)
Sets the target value for the trajectory.
Definition: 32b/traj.h:206
_USER_Params_::motor_Ls_q
float_t motor_Ls_q
Defines the quadrature stator inductance, H.
Definition: fast/src/32b/userParams.h:236
CTRL_setupEstOnLineState
void CTRL_setupEstOnLineState(CTRL_Handle handle)
Sets up the controller and trajectory generator for the estimator online state.
CTRL_getIdq_ref_pu
void CTRL_getIdq_ref_pu(CTRL_Handle handle, MATH_vec2 *pIdq_ref_pu)
Gets the direct/quadrature current reference vector values from the controller.
Definition: ctrlQEP.c:123
_CTRL_Obj_::Vab_in
MATH_vec2 Vab_in
the Vab input values
Definition: 32b/ctrl_obj.h:219
_CTRL_Obj_::Idq_ref
MATH_vec2 Idq_ref
the Idq reference values, pu
Definition: 32b/ctrl_obj.h:247
CTRL_getIab_filt_pu
void CTRL_getIab_filt_pu(CTRL_Handle handle, MATH_vec2 *pIab_filt_pu)
Gets the alpha/beta filtered current vector values from the controller.
Definition: ctrlQEP.c:90
_CTRL_Obj_::clarkeHandle_I
CLARKE_Handle clarkeHandle_I
the handle for the current Clarke transform
Definition: 32b/ctrl_obj.h:154
_IQ
#define _IQ(A)
Definition: 32b/IQmathLib.h:319
TRAJ_setMaxDelta
static void TRAJ_setMaxDelta(TRAJ_Handle handle, const _iq maxDelta)
Sets the maximum delta value for the trajectory.
Definition: 32b/traj.h:167
CTRL_resetCounter_state
void CTRL_resetCounter_state(CTRL_Handle handle)
Resets the state counter.
Definition: 32b/ctrl.h:1107
_USER_Params_::iqFullScaleCurrent_A
float_t iqFullScaleCurrent_A
Defines the full scale current for the IQ variables, A.
Definition: fast/src/32b/userParams.h:195
_USER_Params_::IdRated
float_t IdRated
Defines the Id rated current value, A.
Definition: fast/src/32b/userParams.h:242
EST_State_MotorIdentified
motor identified state
Definition: est_states.h:68
PID_setUi
static void PID_setUi(PID_Handle handle, const _iq Ui)
Sets the integrator start value in the PID controller.
Definition: 32b/pid.h:409
CTRL_setupClarke_V
void CTRL_setupClarke_V(CTRL_Handle handle, uint_least8_t numVoltageSensors)
Sets the number of voltage sensors.
Definition: ctrlQEP.c:545
CTRL_setEstParams
void CTRL_setEstParams(EST_Handle estHandle, USER_Params *pUserParams)
Sets the default estimator parameters.
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
MATH_TWO_OVER_THREE
#define MATH_TWO_OVER_THREE
Defines 2/3.
Definition: 32b/math.h:77
TRAJ_getIntValue
static _iq TRAJ_getIntValue(TRAJ_Handle handle)
Gets the intermediate value for the trajectory.
Definition: 32b/traj.h:92
CTRL_setIab_in_pu
void CTRL_setIab_in_pu(CTRL_Handle handle, const MATH_vec2 *pIab_in_pu)
Sets the alpha/beta current (Iab) input vector values in the controller.
Definition: 32b/ctrl.h:1323
_CTRL_Obj_::spd_ref
_iq spd_ref
the speed reference, pu
Definition: 32b/ctrl_obj.h:251
CTRL_getVdq_out_pu
void CTRL_getVdq_out_pu(CTRL_Handle handle, MATH_vec2 *pVdq_out_pu)
Gets the direct/quadrature voltage output vector values from the controller.
Definition: ctrlQEP.c:170
_CTRL_Obj_::numCtrlTicksPerTrajTick
uint_least16_t numCtrlTicksPerTrajTick
Defines the number of controller clock ticks per trajectory clock tick.
Definition: 32b/ctrl_obj.h:201
_USER_Params_::motor_Rr
float_t motor_Rr
Defines the rotor resistance, ohm.
Definition: fast/src/32b/userParams.h:233
_MATH_vec2_
Defines a two element vector.
Definition: 32b/math.h:248
CTRL_numStates
the number of controller states
Definition: ctrl_states.h:39
EST_isOnLine
bool EST_isOnLine(EST_Handle handle)
Determines if the estimator is ready for online control.
CTRL_getKd
_iq CTRL_getKd(CTRL_Handle handle, const CTRL_Type_e ctrlType)
Gets the derivative gain (Kd) value from the specified controller.
Definition: 32b/ctrl.h:473
_MATH_vec3_::value
_iq value[3]
Definition: 32b/math.h:261
CTRL_incrCounter_current
void CTRL_incrCounter_current(CTRL_Handle handle)
Increments the current counter.
Definition: 32b/ctrl.h:949
_USER_Params_::ctrlPeriod_sec
float_t ctrlPeriod_sec
Defines the controller execution period, sec.
Definition: fast/src/32b/userParams.h:258
_CTRL_Obj_::trajHandle_Id
TRAJ_Handle trajHandle_Id
the handle for the Id trajectory generator
Definition: 32b/ctrl_obj.h:180
EST_setIdle
void EST_setIdle(EST_Handle handle)
Sets the estimator to idle.
CTRL_getNumCtrlTicksPerTrajTick
uint_least16_t CTRL_getNumCtrlTicksPerTrajTick(CTRL_Handle handle)
Gets the number of controller clock ticks per trajectory clock tick.
Definition: 32b/ctrl.h:602
CTRL_getNumIsrTicksPerCtrlTick
uint_least16_t CTRL_getNumIsrTicksPerCtrlTick(CTRL_Handle handle)
Gets the number of Interrupt Service Routine (ISR) clock ticks per controller clock tick...
Definition: 32b/ctrl.h:613
_CTRL_Obj_::trajHandle_spd
TRAJ_Handle trajHandle_spd
the handle for the speed trajectory generator
Definition: 32b/ctrl_obj.h:183
CTRL_setVab_in_pu
void CTRL_setVab_in_pu(CTRL_Handle handle, const MATH_vec2 *pVab_in_pu)
Sets the alpha/beta voltage input vector values in the controller.
Definition: 32b/ctrl.h:1882
CTRL_setSpd_max_pu
void CTRL_setSpd_max_pu(CTRL_Handle handle, const _iq maxSpd_pu)
Sets the maximum speed value in the controller.
Definition: 32b/ctrl.h:1710
_CTRL_Obj_::Vab_out
MATH_vec2 Vab_out
the Vab output values
Definition: 32b/ctrl_obj.h:223
CTRL_State_Idle
the controller idle state
Definition: ctrl_states.h:36
_CTRL_Obj_::pidHandle_Id
PID_Handle pidHandle_Id
the handle for the Id PID controller
Definition: 32b/ctrl_obj.h:165
_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
_CTRL_Obj_
Defines the controller (CTRL) object.
Definition: 32b/ctrl_obj.h:144
CTRL_setTrajPeriod_sec
void CTRL_setTrajPeriod_sec(CTRL_Handle handle, const _iq trajPeriod_sec)
Sets the trajectory execution period.
Definition: 32b/ctrl.h:1801
CTRL_setMagCurrent_pu
void CTRL_setMagCurrent_pu(CTRL_Handle handle, const _iq magCurrent_pu)
Sets the magnetizing current value in the controller.
Definition: ctrlQEP.c:275
_USER_Params_
Defines a structure for the user parameters.
Definition: fast/src/32b/userParams.h:193
_USER_Params_::numCurrentSensors
uint_least8_t numCurrentSensors
Defines the number of current sensors.
Definition: fast/src/32b/userParams.h:204
CTRL_getCount_traj
uint_least16_t CTRL_getCount_traj(CTRL_Handle handle)
Gets the trajectory loop count.
Definition: 32b/ctrl.h:139
_CTRL_Obj_::estHandle
EST_Handle estHandle
the handle for the parameter estimator
Definition: 32b/ctrl_obj.h:160
CTRL_setKi
void CTRL_setKi(CTRL_Handle handle, const CTRL_Type_e ctrlType, const _iq Ki)
Sets the integral gain (Ki) value for the specified controller.
Definition: 32b/ctrl.h:1474
PID_setMinMax
static void PID_setMinMax(PID_Handle handle, const _iq outMin, const _iq outMax)
Sets the minimum and maximum output value allowed in the PID controller.
Definition: 32b/pid.h:356
CTRL_setFlag_enableCtrl
void CTRL_setFlag_enableCtrl(CTRL_Handle handle, const bool state)
Sets the enable controller flag value in the estimator.
Definition: 32b/ctrl.h:1214
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_getIab_in_pu
void CTRL_getIab_in_pu(CTRL_Handle handle, MATH_vec2 *pIab_in_pu)
Gets the alpha/beta current input vector values from the controller.
Definition: ctrlQEP.c:101
_USER_Params_::maxCurrent
float_t maxCurrent
Defines the maximum current value, A.
Definition: fast/src/32b/userParams.h:237
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_runTraj
void CTRL_runTraj(CTRL_Handle handle)
Runs the trajectory.
CTRL_setIdq_ref_pu
void CTRL_setIdq_ref_pu(CTRL_Handle handle, const MATH_vec2 *pIdq_ref_pu)
Sets the direct/quadrature current (Idq) reference vector values in the controller.
Definition: 32b/ctrl.h:1384
_iq
long _iq
Definition: 32b/IQmathLib.h:223
_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
MATH_ONE_OVER_THREE
#define MATH_ONE_OVER_THREE
Defines 1/3.
Definition: 32b/math.h:81
CTRL_resetCounter_current
void CTRL_resetCounter_current(CTRL_Handle handle)
Resets the current counter.
Definition: 32b/ctrl.h:1071
CTRL_getCount_isr
uint_least16_t CTRL_getCount_isr(CTRL_Handle handle)
Gets the isr count.
Definition: 32b/ctrl.h:106
_CTRL_Obj_::trajHandle_spdMax
TRAJ_Handle trajHandle_spdMax
the handle for the maximum speed trajectory generator
Definition: 32b/ctrl_obj.h:186
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: ctrlQEP.c:263
CLARKE_setScaleFactors
static void CLARKE_setScaleFactors(CLARKE_Handle handle, const _iq alpha_sf, const _iq beta_sf)
Sets the scale factors.
Definition: 32b/clarke.h:180
CTRL_setupTraj
void CTRL_setupTraj(CTRL_Handle handle)
Sets up the trajectory (TRAJ) object.
CTRL_setState
void CTRL_setState(CTRL_Handle handle, const CTRL_State_e state)
Sets the controller state.
Definition: 32b/ctrl.h:1774
_HAL_PwmData_t_
Defines the PWM data.
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal_obj.h:116
TRAJ_getTargetValue
static _iq TRAJ_getTargetValue(TRAJ_Handle handle)
Gets the target value for the trajectory.
Definition: 32b/traj.h:136
TRAJ_setIntValue
static void TRAJ_setIntValue(TRAJ_Handle handle, const _iq intValue)
Sets the intermediate value for the trajectory.
Definition: 32b/traj.h:154
_HAL_PwmData_t_::Tabc
MATH_vec3 Tabc
the PWM time-durations for each motor phase
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal_obj.h:118
PID_setGains
static void PID_setGains(PID_Handle handle, const _iq Kp, const _iq Ki, const _iq Kd)
Sets the gains in the PID controller.
Definition: 32b/pid.h:301
CTRL_setParams
void CTRL_setParams(CTRL_Handle handle, USER_Params *pUserParams)
Sets the controller parameters.
Definition: ctrlQEP.c:293
_USER_Params_::motor_type
MOTOR_Type_e motor_type
Defines the motor type.
Definition: fast/src/32b/userParams.h:229
_IQmpy
#define _IQmpy(A, B)
Definition: 32b/IQmathLib.h:809
CTRL_getIdq_in_pu
void CTRL_getIdq_in_pu(CTRL_Handle handle, MATH_vec2 *pIdq_in_pu)
Gets the direct/quadrature current input vector values from the controller.
Definition: ctrlQEP.c:112
CTRL_setWaitTimes
void CTRL_setWaitTimes(CTRL_Handle handle, const uint_least32_t *pWaitTimes)
Sets the wait times for the controller states.
Definition: ctrlQEP.c:571
CTRL_getSpd_max_pu
_iq CTRL_getSpd_max_pu(CTRL_Handle handle)
Gets the maximum speed value from the controller.
Definition: 32b/ctrl.h:701
CTRL_setVdq_out_pu
void CTRL_setVdq_out_pu(CTRL_Handle handle, const MATH_vec2 *pVdq_out_pu)
Sets the direct/quadrature voltage output vector values in the controller.
Definition: 32b/ctrl.h:1924
CTRL_incrCounter_speed
void CTRL_incrCounter_speed(CTRL_Handle handle)
Increments the speed counter.
Definition: 32b/ctrl.h:985
CTRL_resetCounter_isr
void CTRL_resetCounter_isr(CTRL_Handle handle)
Resets the isr counter.
Definition: 32b/ctrl.h:1083
_MATH_vec2_::value
_iq value[2]
Definition: 32b/math.h:251
CTRL_runOnLine_User
void CTRL_runOnLine_User(CTRL_Handle handle, const HAL_AdcData_t *pAdcData, HAL_PwmData_t *pPwmData)
Runs the online user controller.
Definition: 32b/ctrl.h:2343
CTRL_setNumCtrlTicksPerTrajTick
void CTRL_setNumCtrlTicksPerTrajTick(CTRL_Handle handle, const uint_least16_t numCtrlTicksPerTrajTick)
Sets the number of controller clock ticks per trajectory clock tick.
Definition: 32b/ctrl.h:1643
_CTRL_Obj_::Idq_in
MATH_vec2 Idq_in
the Idq input values
Definition: 32b/ctrl_obj.h:217
_CTRL_Obj_::pidHandle_spd
PID_Handle pidHandle_spd
the handle for the speed PID controller
Definition: 32b/ctrl_obj.h:171
CTRL_setIdq_in_pu
void CTRL_setIdq_in_pu(CTRL_Handle handle, const MATH_vec2 *pIdq_in_pu)
Sets the direct/quadrature current (Idq) input vector values in the controller.
Definition: 32b/ctrl.h:1356
_USER_Params_::trajFreq_Hz
uint_least32_t trajFreq_Hz
Defines the trajectory frequency, Hz.
Definition: fast/src/32b/userParams.h:256
CTRL_setSpd_out_pu
void CTRL_setSpd_out_pu(CTRL_Handle handle, const _iq spd_out_pu)
Sets the output speed value in the controller.
Definition: 32b/ctrl.h:1723
_USER_Params_::numVoltageSensors
uint_least8_t numVoltageSensors
Defines the number of voltage sensors.
Definition: fast/src/32b/userParams.h:205
CTRL_getFlag_enableUserMotorParams
bool CTRL_getFlag_enableUserMotorParams(CTRL_Handle handle)
Gets the enable user motor parameters flag value from the controller.
Definition: 32b/ctrl.h:270
CTRL_incrCounter_state
void CTRL_incrCounter_state(CTRL_Handle handle)
Increments the state counter.
Definition: 32b/ctrl.h:1003
CTRL_setupEstIdleState
void CTRL_setupEstIdleState(CTRL_Handle handle)
Sets up the controller and trajectory generator for the estimator idle state.
ctrlQEP.h
CTRL_getState
CTRL_State_e CTRL_getState(CTRL_Handle handle)
Gets the controller state.
Definition: 32b/ctrl.h:767
CTRL_setUserMotorParams
void CTRL_setUserMotorParams(CTRL_Handle handle)
Sets the controller and estimator with motor parameters from the user.h file.
CTRL_setLhf
void CTRL_setLhf(CTRL_Handle handle, const float_t Lhf)
Sets the high frequency inductance (Lhf) value in the controller.
Definition: 32b/ctrl.h:1523
math.h
Contains the public interface to the math (MATH) module routines.
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
SVGEN_setMaxModulation
static void SVGEN_setMaxModulation(SVGEN_Handle handle, const _iq maxModulation)
Sets the maximum modulation in the space vector generator module.
Definition: 32b/svgen.h:174
EST_getState
EST_State_e EST_getState(EST_Handle handle)
Gets the state of the estimator.
CTRL_getMaximumSpeed_pu
_iq CTRL_getMaximumSpeed_pu(CTRL_Handle handle)
Gets the maximum speed value from the controller.
Definition: ctrlQEP.c:141
_CTRL_Obj_::Iab_filt
MATH_vec2 Iab_filt
the Iab filtered values
Definition: 32b/ctrl_obj.h:215
_CTRL_Obj_::Vdq_out
MATH_vec2 Vdq_out
the Vdq output values
Definition: 32b/ctrl_obj.h:225
_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_getKp
_iq CTRL_getKp(CTRL_Handle handle, const CTRL_Type_e ctrlType)
Gets the proportional gain (Kp) value from the specified controller.
Definition: 32b/ctrl.h:499
CTRL_setup
void CTRL_setup(CTRL_Handle handle)
Sets up the controller (CTRL) object and all of the subordinate objects.
Definition: ctrlQEP.c:490
CTRL_getVab_out_pu
void CTRL_getVab_out_pu(CTRL_Handle handle, MATH_vec2 *pVab_out_pu)
Gets the alpha/beta voltage output vector values from the controller.
Definition: ctrlQEP.c:159
CTRL_setSpd_ref_pu
void CTRL_setSpd_ref_pu(CTRL_Handle handle, const _iq spd_ref_pu)
Sets the output speed reference value in the controller.
Definition: ctrlQEP.c:466
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
_CTRL_Obj_::clarkeHandle_V
CLARKE_Handle clarkeHandle_V
the handle for the voltage Clarke transform
Definition: 32b/ctrl_obj.h:157
CTRL_setTrajFreq_Hz
void CTRL_setTrajFreq_Hz(CTRL_Handle handle, const uint_least32_t trajFreq_Hz)
Sets the trajectory execution frequency.
Definition: 32b/ctrl.h:1788
CTRL_runOffLine
void CTRL_runOffLine(CTRL_Handle handle, HAL_Handle halHandle, const HAL_AdcData_t *pAdcData, HAL_PwmData_t *pPwmData)
Runs the offline controller.
Definition: 32b/ctrl.h:2089
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
CLARKE_setNumSensors
static void CLARKE_setNumSensors(CLARKE_Handle handle, const uint_least8_t numSensors)
Sets the number of sensors.
Definition: 32b/clarke.h:166
CTRL_setVab_out_pu
void CTRL_setVab_out_pu(CTRL_Handle handle, const MATH_vec2 *pVab_out_pu)
Sets the alpha/beta current output vector values in the controller.
Definition: 32b/ctrl.h:1896
CTRL_setMaxVsMag_pu
void CTRL_setMaxVsMag_pu(CTRL_Handle handle, const _iq maxVsMag)
Sets the maximum voltage vector in the controller.
Definition: 32b/ctrl.h:1542
CTRL_resetCounter_traj
void CTRL_resetCounter_traj(CTRL_Handle handle)
Resets the trajectory counter.
Definition: 32b/ctrl.h:1119
_IQ30
#define _IQ30(A)
Definition: 32b/IQmathLib.h:269
_USER_Params_::numCtrlTicksPerTrajTick
uint_least16_t numCtrlTicksPerTrajTick
Defines the number of controller clock ticks per trajectory clock tick.
Definition: fast/src/32b/userParams.h:203
_CTRL_Obj_::pidHandle_Iq
PID_Handle pidHandle_Iq
the handle for the Iq PID controller
Definition: 32b/ctrl_obj.h:168
_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_getIdRated_pu
_iq CTRL_getIdRated_pu(CTRL_Handle handle)
Gets the Id rated current value from the controller.
Definition: 32b/ctrl.h:381
CTRL_setFlag_enablePowerWarp
void CTRL_setFlag_enablePowerWarp(CTRL_Handle handle, const bool state)
Sets the PowerWarp enable flag value in the estimator.
Definition: 32b/ctrl.h:1258
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: ctrlQEP.c:585
CTRL_Type_e
CTRL_Type_e
Enumeration for the controller (CTRL) types.
Definition: 32b/ctrl_obj.h:121
CTRL_getKi
_iq CTRL_getKi(CTRL_Handle handle, const CTRL_Type_e ctrlType)
Gets the integral gain (Ki) value from the specified controller.
Definition: 32b/ctrl.h:447
CTRL_getWaitTimes
void CTRL_getWaitTimes(CTRL_Handle handle, uint_least32_t *pWaitTimes)
Gets the wait times from the estimator.
Definition: ctrlQEP.c:181
TRAJ_setMaxValue
static void TRAJ_setMaxValue(TRAJ_Handle handle, const _iq maxValue)
Sets the maximum value for the trajectory.
Definition: 32b/traj.h:180
CTRL_getFlag_enableCtrl
bool CTRL_getFlag_enableCtrl(CTRL_Handle handle)
Gets the enable controller flag value from the estimator.
Definition: 32b/ctrl.h:204
EST_isMotorIdentified
bool EST_isMotorIdentified(EST_Handle handle)
Determines if the motor has been identified.
_CTRL_Obj_::flag_enableCtrl
bool flag_enableCtrl
a flag to enable the controller
Definition: 32b/ctrl_obj.h:263
CTRL_setRhf
void CTRL_setRhf(CTRL_Handle handle, const float_t Rhf)
Sets the high frequency resistance (Rhf) value in the controller.
Definition: 32b/ctrl.h:1671
CTRL_setFlag_enableOffset
void CTRL_setFlag_enableOffset(CTRL_Handle handle, const bool state)
Sets the enable offset flag value in the estimator.
Definition: 32b/ctrl.h:1271
_USER_Params_::motor_Rs
float_t motor_Rs
Defines the stator resistance, ohm.
Definition: fast/src/32b/userParams.h:234
EST_isLockRotor
bool EST_isLockRotor(EST_Handle handle)
Determines if the estimator is waiting for the rotor to be locked.
_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_setFlag_enableDcBusComp
void CTRL_setFlag_enableDcBusComp(CTRL_Handle handle, const bool state)
Sets the enable DC bus compensation flag value in the estimator.
Definition: 32b/ctrl.h:1242
EST_setRs_pu
void EST_setRs_pu(EST_Handle handle, const _iq Rs_pu)
Sets the stator resistance value used in the estimator in per unit (pu), IQ30.
CTRL_Type_PID_Iq
PID Iq controller.
Definition: 32b/ctrl_obj.h:125
CTRL_setFlag_enableUserMotorParams
void CTRL_setFlag_enableUserMotorParams(CTRL_Handle handle, const bool state)
Sets the enable user motor parameters flag value in the estimator.
Definition: 32b/ctrl.h:1300
CTRL_setKd
void CTRL_setKd(CTRL_Handle handle, const CTRL_Type_e ctrlType, const _iq Kd)
Sets the derivative gain (Kd) value for the specified controller.
Definition: 32b/ctrl.h:1449
CTRL_getMagCurrent_pu
_iq CTRL_getMagCurrent_pu(CTRL_Handle handle)
Gets the magnetizing current value from the controller.
Definition: ctrlQEP.c:134
_USER_Params_::ctrlFreq_Hz
uint_least32_t ctrlFreq_Hz
Defines the controller frequency, Hz.
Definition: fast/src/32b/userParams.h:253
CTRL_setIdRated_pu
void CTRL_setIdRated_pu(CTRL_Handle handle, const _iq IdRated_pu)
Sets the Id rated current value in the controller.
Definition: 32b/ctrl.h:1398
_CTRL_Obj_::flag_enableUserMotorParams
bool flag_enableUserMotorParams
a flag to use known motor parameters from user.h file
Definition: 32b/ctrl_obj.h:268
EST_get_krpm_to_pu_sf
_iq EST_get_krpm_to_pu_sf(EST_Handle handle)
Gets the krpm to pu scale factor in per unit (pu), IQ24.
EST_isIdle
bool EST_isIdle(EST_Handle handle)
Determines if the estimator is idle.
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
CTRL_Type_PID_Id
PID Id controller.
Definition: 32b/ctrl_obj.h:124
_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
MATH_ONE_OVER_SQRT_THREE
#define MATH_ONE_OVER_SQRT_THREE
Defines 1/sqrt(3)
Definition: 32b/math.h:89
_HAL_AdcData_t_
Defines the ADC data.
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal_obj.h:88
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_getVab_in_pu
void CTRL_getVab_in_pu(CTRL_Handle handle, MATH_vec2 *pVab_in_pu)
Gets the alpha/beta voltage input vector values from the controller.
Definition: ctrlQEP.c:148
CTRL_setMaximumSpeed_pu
void CTRL_setMaximumSpeed_pu(CTRL_Handle handle, const _iq maxSpeed_pu)
Sets the maximum speed value in the controller.
Definition: ctrlQEP.c:284
EST_setIdle_all
void EST_setIdle_all(EST_Handle handle)
Sets the estimator and all of the subordinate estimators to idle.
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_Obj_::Iab_in
MATH_vec2 Iab_in
the Iab input values
Definition: 32b/ctrl_obj.h:213
CTRL_getCount_state
uint_least32_t CTRL_getCount_state(CTRL_Handle handle)
Gets the state count.
Definition: 32b/ctrl.h:128
EST_updateState
bool EST_updateState(EST_Handle handle, const _iq Id_target_pu)
Updates the estimator state.
_CTRL_Obj_::numIsrTicksPerCtrlTick
uint_least16_t numIsrTicksPerCtrlTick
Defines the number of isr clock ticks per controller clock tick.
Definition: 32b/ctrl_obj.h:195
dlog4ch.h
Contains the public interface to the data logging (DLOG) module routines.
CTRL_setRoverL
void CTRL_setRoverL(CTRL_Handle handle, const float_t RoverL)
Sets the R/L value in the controller.
Definition: 32b/ctrl.h:1684
CTRL_run
void CTRL_run(CTRL_Handle handle, HAL_Handle halHandle, const HAL_AdcData_t *pAdcData, HAL_PwmData_t *pPwmData, uint32_t electricalAngle)
Runs the controller.
Definition: ctrlQEP.c:195
CTRL_State_OffLine
the controller offline state
Definition: ctrl_states.h:37
CTRL_incrCounter_traj
void CTRL_incrCounter_traj(CTRL_Handle handle)
Increments the trajectory counter.
Definition: 32b/ctrl.h:1021
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
_USER_Params_::iqFullScaleFreq_Hz
float_t iqFullScaleFreq_Hz
Defines the full scale frequency for IQ variable, Hz.
Definition: fast/src/32b/userParams.h:197
CTRL_setSpd_ref_krpm
void CTRL_setSpd_ref_krpm(CTRL_Handle handle, const _iq spd_ref_krpm)
Sets the output speed reference value in the controller.
Definition: ctrlQEP.c:476
CTRL_setupClarke_I
void CTRL_setupClarke_I(CTRL_Handle handle, uint_least8_t numCurrentSensors)
Sets the number of current sensors.
Definition: ctrlQEP.c:514
CTRL_setKp
void CTRL_setKp(CTRL_Handle handle, const CTRL_Type_e ctrlType, const _iq Kp)
Sets the proportional gain (Kp) value for the specified controller.
Definition: 32b/ctrl.h:1499
CTRL_setupCtrl
void CTRL_setupCtrl(CTRL_Handle handle)
Sets up the controllers.
_USER_Params_::motor_Ls_d
float_t motor_Ls_d
Defines the direct stator inductance, H.
Definition: fast/src/32b/userParams.h:235
_HAL_Obj_
Defines the hardware abstraction layer (HAL) data.
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal_obj.h:128
_USER_Params_::motor_ratedFlux
float_t motor_ratedFlux
Defines the rated flux of the motor, V/Hz.
Definition: fast/src/32b/userParams.h:232
CTRL_runOnLine
void CTRL_runOnLine(CTRL_Handle handle, const HAL_AdcData_t *pAdcData, HAL_PwmData_t *pPwmData)
Runs the online controller.
Definition: 32b/ctrl.h:2158
TRAJ_setMinValue
static void TRAJ_setMinValue(TRAJ_Handle handle, const _iq minValue)
Sets the minimum value for the trajectory.
Definition: 32b/traj.h:193
_CTRL_Obj_::svgenHandle
SVGEN_Handle svgenHandle
the handle for the space vector generator
Definition: 32b/ctrl_obj.h:177
_USER_Params_::maxVsMag_pu
float_t maxVsMag_pu
Defines the maximum voltage magnitude, pu.
Definition: fast/src/32b/userParams.h:226
CTRL_getFlag_enableOffset
bool CTRL_getFlag_enableOffset(CTRL_Handle handle)
Gets the enable offset flag value from the controller.
Definition: 32b/ctrl.h:248