MotorWare f2806x Module API Documentation
ctrlQEP.h
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 #ifndef _CTRL_H_
33 #define _CTRL_H_
34 
40 
41 
42 // **************************************************************************
43 // the includes
44 
46 
58 
60 
61 #include "hal_obj.h"
62 
63 
68 
69 
70 
71 #ifdef __cplusplus
72 extern "C" {
73 #endif
74 
75 
76 // **************************************************************************
77 // the function prototypes
78 
82 inline bool CTRL_doCurrentCtrl(CTRL_Handle handle)
83 {
84  CTRL_Obj *obj = (CTRL_Obj *)handle;
85  bool result = false;
86 
88  {
89  result = true;
90  }
91 
92  return(result);
93 } // end of CTRL_doCurrentCtrl() function
94 
95 
99 inline uint_least16_t CTRL_getCount_current(CTRL_Handle handle)
100 {
101  CTRL_Obj *obj = (CTRL_Obj *)handle;
102 
103  return(obj->counter_current);
104 } // end of CTRL_getCount_current() function
105 
106 
110 inline uint_least16_t CTRL_getCount_isr(CTRL_Handle handle)
111 {
112  CTRL_Obj *obj = (CTRL_Obj *)handle;
113 
114  return(obj->counter_isr);
115 } // end of CTRL_getCount_isr() function
116 
117 
121 inline uint_least16_t CTRL_getCount_speed(CTRL_Handle handle)
122 {
123  CTRL_Obj *obj = (CTRL_Obj *)handle;
124 
125  return(obj->counter_speed);
126 } // end of CTRL_getCount_speed() function
127 
128 
132 inline uint_least32_t CTRL_getCount_state(CTRL_Handle handle)
133 {
134  CTRL_Obj *obj = (CTRL_Obj *)handle;
135 
136  return(obj->counter_state);
137 } // end of CTRL_getCount_state() function
138 
139 
143 inline uint_least16_t CTRL_getCount_traj(CTRL_Handle handle)
144 {
145  CTRL_Obj *obj = (CTRL_Obj *)handle;
146 
147  return(obj->counter_traj);
148 } // end of CTRL_getCount_traj() function
149 
150 
154 inline uint_least32_t CTRL_getCtrlFreq(CTRL_Handle handle)
155 {
156  CTRL_Obj *obj = (CTRL_Obj *)handle;
157 
158  return(obj->ctrlFreq_Hz);
159 } // end of CTRL_getCtrlFreq() function
160 
161 
166 {
167  CTRL_Obj *obj = (CTRL_Obj *)handle;
168 
169  return(obj->ctrlPeriod_sec);
170 } // end of CTRL_getCtrlPeriod_sec() function
171 
172 
177 {
178  CTRL_Obj *obj = (CTRL_Obj *)handle;
179 
180  return(obj->errorCode);
181 } // end of CTRL_getErrorCode() function
182 
183 
188 {
189  CTRL_Obj *obj = (CTRL_Obj *)handle;
190 
191  return(obj->estHandle);
192 } // end of CTRL_getEstHandle() function
193 
194 
198 inline bool CTRL_getFlag_enableCtrl(CTRL_Handle handle)
199 {
200  CTRL_Obj *obj = (CTRL_Obj *)handle;
201 
202  return(obj->flag_enableCtrl);
203 } // end of CTRL_getFlag_enableCtrl() function
204 
205 
209 inline bool CTRL_getFlag_enableDcBusComp(CTRL_Handle handle)
210 {
211  CTRL_Obj *obj = (CTRL_Obj *)handle;
212 
213  return(obj->flag_enableDcBusComp);
214 } // end of CTRL_getFlag_enableDcBusComp() function
215 
216 
220 inline bool CTRL_getFlag_enablePowerWarp(CTRL_Handle handle)
221 {
222  CTRL_Obj *obj = (CTRL_Obj *)handle;
223 
224  return(obj->flag_enablePowerWarp);
225 } // end of CTRL_getFlag_enablePowerWarp() function
226 
227 
231 inline bool CTRL_getFlag_enableOffset(CTRL_Handle handle)
232 {
233  CTRL_Obj *obj = (CTRL_Obj *)handle;
234 
235  return(obj->flag_enableOffset);
236 } // end of CTRL_getFlag_enableOffset() function
237 
238 
242 inline bool CTRL_getFlag_enableSpeedCtrl(CTRL_Handle handle)
243 {
244  CTRL_Obj *obj = (CTRL_Obj *)handle;
245 
246  return(obj->flag_enableSpeedCtrl);
247 } // end of CTRL_getFlag_enableSpeedCtrl() function
248 
249 
254 {
255  CTRL_Obj *obj = (CTRL_Obj *)handle;
256 
257  return(obj->flag_enableUserMotorParams);
258 } // end of CTRL_getFlag_enableUserMotorParams() function
259 
260 
267 void CTRL_getGains(CTRL_Handle handle,const CTRL_Type_e ctrlType,
268  _iq *pKp,_iq *pKi,_iq *pKd);
269 
270 
274 void CTRL_getIab_filt_pu(CTRL_Handle handle,MATH_vec2 *pIab_filt_pu);
275 
276 
281 {
282  CTRL_Obj *obj = (CTRL_Obj *)handle;
283 
284  return(&(obj->Iab_filt));
285 } // end of CTRL_getIab_filt_addr() function
286 
287 
292 {
293  CTRL_Obj *obj = (CTRL_Obj *)handle;
294 
295  return(&(obj->Iab_in));
296 } // end of CTRL_getIab_in_addr() function
297 
298 
302 void CTRL_getIab_in_pu(CTRL_Handle handle,MATH_vec2 *pIab_in_pu);
303 
304 
308 inline _iq CTRL_getId_in_pu(CTRL_Handle handle)
309 {
310  CTRL_Obj *obj = (CTRL_Obj *)handle;
311 
312  return(obj->Idq_in.value[0]);
313 } // end of CTRL_getId_in_pu() function
314 
315 
319 inline _iq CTRL_getId_ref_pu(CTRL_Handle handle)
320 {
321  CTRL_Obj *obj = (CTRL_Obj *)handle;
322 
323  return(obj->Idq_ref.value[0]);
324 } // end of CTRL_getId_ref_pu() function
325 
326 
331 {
332  CTRL_Obj *obj = (CTRL_Obj *)handle;
333 
334  return(&(obj->Idq_in));
335 } // end of CTRL_getIdq_in_addr() function
336 
337 
341 void CTRL_getIdq_in_pu(CTRL_Handle handle,MATH_vec2 *pIdq_in_pu);
342 
343 
347 void CTRL_getIdq_ref_pu(CTRL_Handle handle,MATH_vec2 *pIdq_ref_pu);
348 
349 
353 inline _iq CTRL_getIdRated_pu(CTRL_Handle handle)
354 {
355  CTRL_Obj *obj = (CTRL_Obj *)handle;
356 
357  return(obj->IdRated);
358 } // end of CTRL_getIdRated_pu() function
359 
360 
364 inline _iq CTRL_getIq_in_pu(CTRL_Handle handle)
365 {
366  CTRL_Obj *obj = (CTRL_Obj *)handle;
367 
368  return(obj->Idq_in.value[1]);
369 } // end of CTRL_getIq_in_pu() function
370 
371 
375 inline _iq CTRL_getIq_ref_pu(CTRL_Handle handle)
376 {
377  CTRL_Obj *obj = (CTRL_Obj *)handle;
378 
379  return(obj->Idq_ref.value[1]);
380 } // end of CTRL_getIq_ref_pu() function
381 
382 
387 inline _iq CTRL_getKi(CTRL_Handle handle,const CTRL_Type_e ctrlType)
388 {
389  CTRL_Obj *obj = (CTRL_Obj *)handle;
390  _iq Ki = _IQ(0.0);
391 
392  if(ctrlType == CTRL_Type_PID_spd)
393  {
394  Ki = obj->Ki_spd;
395  }
396  else if(ctrlType == CTRL_Type_PID_Id)
397  {
398  Ki = obj->Ki_Id;
399  }
400  else if(ctrlType == CTRL_Type_PID_Iq)
401  {
402  Ki = obj->Ki_Iq;
403  }
404 
405  return(Ki);
406 } // end of CTRL_getKi() function
407 
408 
413 inline _iq CTRL_getKd(CTRL_Handle handle,const CTRL_Type_e ctrlType)
414 {
415  CTRL_Obj *obj = (CTRL_Obj *)handle;
416  _iq Kd = _IQ(0.0);
417 
418  if(ctrlType == CTRL_Type_PID_spd)
419  {
420  Kd = obj->Kd_spd;
421  }
422  else if(ctrlType == CTRL_Type_PID_Id)
423  {
424  Kd = obj->Kd_Id;
425  }
426  else if(ctrlType == CTRL_Type_PID_Iq)
427  {
428  Kd = obj->Kd_Iq;
429  }
430 
431  return(Kd);
432 } // end of CTRL_getKd() function
433 
434 
439 inline _iq CTRL_getKp(CTRL_Handle handle,const CTRL_Type_e ctrlType)
440 {
441  CTRL_Obj *obj = (CTRL_Obj *)handle;
442  _iq Kp = _IQ(0.0);
443 
444  if(ctrlType == CTRL_Type_PID_spd)
445  {
446  Kp = obj->Kp_spd;
447  }
448  else if(ctrlType == CTRL_Type_PID_Id)
449  {
450  Kp = obj->Kp_Id;
451  }
452  else if(ctrlType == CTRL_Type_PID_Iq)
453  {
454  Kp = obj->Kp_Iq;
455  }
456 
457  return(Kp);
458 } // end of CTRL_getKp() function
459 
460 
464 inline float_t CTRL_getLhf(CTRL_Handle handle)
465 {
466  CTRL_Obj *obj = (CTRL_Obj *)handle;
467 
468  return(obj->Lhf);
469 } // end of CTRL_getLhf() function
470 
471 
476 
477 
481 inline _iq CTRL_getMaxVsMag_pu(CTRL_Handle handle)
482 {
483  CTRL_Obj *obj = (CTRL_Obj *)handle;
484 
485  return(obj->maxVsMag_pu);
486 } // end of CTRL_getMaxVsMag_pu() function
487 
488 
493 
494 
499 {
500  CTRL_Obj *obj = (CTRL_Obj *)handle;
501 
502  return(obj->motorParams.ratedFlux_VpHz);
503 } // end of CTRL_getMotorRatedFlux() function
504 
505 
510 {
511  CTRL_Obj *obj = (CTRL_Obj *)handle;
512 
513  return(obj->motorParams.type);
514 } // end of CTRL_getMotorType() function
515 
516 
520 inline uint_least16_t CTRL_getNumCtrlTicksPerCurrentTick(CTRL_Handle handle)
521 {
522  CTRL_Obj *obj = (CTRL_Obj *)handle;
523 
524  return(obj->numCtrlTicksPerCurrentTick);
525 } // end of CTRL_getNumCtrlTicksPerCurrentTick() function
526 
527 
531 inline uint_least16_t CTRL_getNumCtrlTicksPerSpeedTick(CTRL_Handle handle)
532 {
533  CTRL_Obj *obj = (CTRL_Obj *)handle;
534 
535  return(obj->numCtrlTicksPerSpeedTick);
536 } // end of CTRL_getNumCtrlTicksPerSpeedTick() function
537 
538 
542 inline uint_least16_t CTRL_getNumCtrlTicksPerTrajTick(CTRL_Handle handle)
543 {
544  CTRL_Obj *obj = (CTRL_Obj *)handle;
545 
546  return(obj->numCtrlTicksPerTrajTick);
547 } // end of CTRL_getNumCtrlTicksPerTrajTick() function
548 
549 
553 inline uint_least16_t CTRL_getNumIsrTicksPerCtrlTick(CTRL_Handle handle)
554 {
555  CTRL_Obj *obj = (CTRL_Obj *)handle;
556 
557  return(obj->numIsrTicksPerCtrlTick);
558 } // end of CTRL_getNumIsrTicksPerCtrlTick() function
559 
560 
565 inline _iq CTRL_getRefValue_pu(CTRL_Handle handle,const CTRL_Type_e ctrlType)
566 {
567  CTRL_Obj *obj = (CTRL_Obj *)handle;
568  _iq ref = _IQ(0.0);
569 
570  if(ctrlType == CTRL_Type_PID_spd)
571  {
572  ref = PID_getRefValue(obj->pidHandle_spd);
573  }
574  else if(ctrlType == CTRL_Type_PID_Id)
575  {
576  ref = PID_getRefValue(obj->pidHandle_Id);
577  }
578  else if(ctrlType == CTRL_Type_PID_Iq)
579  {
580  ref = PID_getRefValue(obj->pidHandle_Iq);
581  }
582 
583  return(ref);
584 } // end of CTRL_getRefValue_pu() function
585 
586 
590 inline float_t CTRL_getRhf(CTRL_Handle handle)
591 {
592  CTRL_Obj *obj = (CTRL_Obj *)handle;
593 
594  return(obj->Rhf);
595 } // end of CTRL_getRhf() function
596 
597 
601 inline float_t CTRL_getRoverL(CTRL_Handle handle)
602 {
603  CTRL_Obj *obj = (CTRL_Obj *)handle;
604 
605  return(obj->RoverL);
606 } // end of CTRL_getRoverL() function
607 
608 
612 inline _iq CTRL_getSpd_max_pu(CTRL_Handle handle)
613 {
614  CTRL_Obj *obj = (CTRL_Obj *)handle;
615 
616  return(obj->spd_max);
617 } // end of CTRL_getSpd_max_pu() function
618 
619 
623 inline _iq *CTRL_getSpd_out_addr(CTRL_Handle handle)
624 {
625  CTRL_Obj *obj = (CTRL_Obj *)handle;
626 
627  return(&(obj->spd_out));
628 } // end of CTRL_getSpd_out_addr() function
629 
630 
634 inline _iq CTRL_getSpd_out_pu(CTRL_Handle handle)
635 {
636  CTRL_Obj *obj = (CTRL_Obj *)handle;
637 
638  return(obj->spd_out);
639 } // end of CTRL_getSpd_out_pu() function
640 
641 
645 inline _iq CTRL_getSpd_ref_pu(CTRL_Handle handle)
646 {
647  CTRL_Obj *obj = (CTRL_Obj *)handle;
648 
649  return(obj->spd_ref);
650 } // end of CTRL_getSpd_ref_pu() function
651 
652 
657 {
658  CTRL_Obj *obj = (CTRL_Obj *)handle;
659 
660  return(TRAJ_getIntValue(obj->trajHandle_spd));
661 } // end of CTRL_getSpd_int_ref_pu() function
662 
663 
668 {
669  CTRL_Obj *obj = (CTRL_Obj *)handle;
670 
671  return(obj->state);
672 } // end of CTRL_getState() function
673 
674 
678 inline uint_least32_t CTRL_getTrajFreq(CTRL_Handle handle)
679 {
680  CTRL_Obj *obj = (CTRL_Obj *)handle;
681 
682  return(obj->trajFreq_Hz);
683 } // end of CTRL_getTrajFreq() function
684 
685 
690 {
691  CTRL_Obj *obj = (CTRL_Obj *)handle;
692 
693  return(obj->trajPeriod_sec);
694 } // end of CTRL_getTrajPeriod_sec() function
695 
696 
699 void CTRL_getTrajStep(CTRL_Handle handle);
700 
701 
706 inline _iq CTRL_getUi(CTRL_Handle handle,const CTRL_Type_e ctrlType)
707 {
708  CTRL_Obj *obj = (CTRL_Obj *)handle;
709  _iq Ui = _IQ(0.0);
710 
711  if(ctrlType == CTRL_Type_PID_spd)
712  {
713  Ui = obj->Ui_spd;
714  }
715  else if(ctrlType == CTRL_Type_PID_Id)
716  {
717  Ui = obj->Ui_Id;
718  }
719  else if(ctrlType == CTRL_Type_PID_Iq)
720  {
721  Ui = obj->Ui_Iq;
722  }
723 
724  return(Ui);
725 } // end of CTRL_getUi() function
726 
727 
732 {
733  CTRL_Obj *obj = (CTRL_Obj *)handle;
734 
735  return(&(obj->Vab_in));
736 } // end of CTRL_getVab_in_addr() function
737 
738 
742 void CTRL_getVab_in_pu(CTRL_Handle handle,MATH_vec2 *pVab_in_pu);
743 
744 
749 {
750  CTRL_Obj *obj = (CTRL_Obj *)handle;
751 
752  return(&(obj->Vab_out));
753 } // end of CTRL_getVab_out_addr() function
754 
755 
759 void CTRL_getVab_out_pu(CTRL_Handle handle,MATH_vec2 *pVab_out_pu);
760 
761 
765 inline _iq *CTRL_getVd_out_addr(CTRL_Handle handle)
766 {
767  CTRL_Obj *obj = (CTRL_Obj *)handle;
768 
769  return(&(obj->Vdq_out.value[0]));
770 } // end of CTRL_getVd_out_addr() function
771 
772 
776 inline _iq CTRL_getVd_out_pu(CTRL_Handle handle)
777 {
778  CTRL_Obj *obj = (CTRL_Obj *)handle;
779 
780  return(obj->Vdq_out.value[0]);
781 } // end of CTRL_getVd_out_pu() function
782 
783 
788 {
789  CTRL_Obj *obj = (CTRL_Obj *)handle;
790 
791  return(&(obj->Vdq_out));
792 } // end of CTRL_getVdq_out_pu() function
793 
794 
798 void CTRL_getVdq_out_pu(CTRL_Handle handle,MATH_vec2 *pVdq_out_pu);
799 
800 
804 void CTRL_getVersion(CTRL_Handle handle,CTRL_Version *pVersion);
805 
806 
810 inline _iq *CTRL_getVq_out_addr(CTRL_Handle handle)
811 {
812  CTRL_Obj *obj = (CTRL_Obj *)handle;
813 
814  return(&(obj->Vdq_out.value[1]));
815 } // end of CTRL_getVq_out_addr() function
816 
817 
821 inline _iq CTRL_getVq_out_pu(CTRL_Handle handle)
822 {
823  CTRL_Obj *obj = (CTRL_Obj *)handle;
824 
825  return(obj->Vdq_out.value[1]);
826 } // end of CTRL_getVq_out_pu() function
827 
828 
833 inline uint_least32_t CTRL_getWaitTime(CTRL_Handle handle,const CTRL_State_e ctrlState)
834 {
835  CTRL_Obj *obj = (CTRL_Obj *)handle;
836 
837  return(obj->waitTimes[ctrlState]);
838 } // end of CTRL_getWaitTime() function
839 
840 
844 void CTRL_getWaitTimes(CTRL_Handle handle,uint_least32_t *pWaitTimes);
845 
846 
849 inline void CTRL_incrCounter_current(CTRL_Handle handle)
850 {
851  CTRL_Obj *obj = (CTRL_Obj *)handle;
852 
853  uint_least16_t count = obj->counter_current;
854 
855  // increment the count
856  count++;
857 
858  // save the count value
859  obj->counter_current = count;
860 
861  return;
862 } // end of CTRL_incrCounter_current() function
863 
864 
867 inline void CTRL_incrCounter_isr(CTRL_Handle handle)
868 {
869  CTRL_Obj *obj = (CTRL_Obj *)handle;
870 
871  uint_least16_t count = obj->counter_isr;
872 
873  // increment the count
874  count++;
875 
876  // save the count value
877  obj->counter_isr = count;
878 
879  return;
880 } // end of CTRL_incrCounter_isr() function
881 
882 
885 inline void CTRL_incrCounter_speed(CTRL_Handle handle)
886 {
887  CTRL_Obj *obj = (CTRL_Obj *)handle;
888 
889  uint_least16_t count = obj->counter_speed;
890 
891  // increment the count
892  count++;
893 
894  // save the count value
895  obj->counter_speed = count;
896 
897  return;
898 } // end of CTRL_incrCounter_speed() function
899 
900 
903 inline void CTRL_incrCounter_state(CTRL_Handle handle)
904 {
905  CTRL_Obj *obj = (CTRL_Obj *)handle;
906 
907  uint_least32_t count = obj->counter_state;
908 
909  // increment the count
910  count++;
911 
912  // save the count value
913  obj->counter_state = count;
914 
915  return;
916 } // end of CTRL_incrCounter_state() function
917 
918 
921 inline void CTRL_incrCounter_traj(CTRL_Handle handle)
922 {
923  CTRL_Obj *obj = (CTRL_Obj *)handle;
924 
925  uint_least16_t count = obj->counter_traj;
926 
927  // increment the count
928  count++;
929 
930  // save the count value
931  obj->counter_traj = count;
932 
933  return;
934 } // end of CTRL_incrCounter_traj() function
935 
936 
943 #ifdef FAST_ROM_V1p6
944 CTRL_Handle CTRL_initCtrl(const uint_least8_t ctrlNumber, const uint_least8_t estNumber);
945 #else
946 CTRL_Handle CTRL_initCtrl(const uint_least8_t estNumber,void *pMemory,const size_t numBytes);
947 #endif
948 
949 
953 inline bool CTRL_isError(CTRL_Handle handle)
954 {
955  CTRL_State_e ctrlState = CTRL_getState(handle);
956  bool state = false;
957 
958 
959  // check for controller errors
960  if(ctrlState == CTRL_State_Error)
961  {
962  state = true;
963  }
964 
965  return(state);
966 } // end of CTRL_isError() function
967 
968 
971 inline void CTRL_resetCounter_current(CTRL_Handle handle)
972 {
973  CTRL_Obj *obj = (CTRL_Obj *)handle;
974 
975  obj->counter_current = 0;
976 
977  return;
978 } // end of CTRL_resetCounter_current() function
979 
980 
983 inline void CTRL_resetCounter_isr(CTRL_Handle handle)
984 {
985  CTRL_Obj *obj = (CTRL_Obj *)handle;
986 
987  obj->counter_isr = 1;
988 
989  return;
990 } // end of CTRL_resetCounter_isr() function
991 
992 
995 inline void CTRL_resetCounter_speed(CTRL_Handle handle)
996 {
997  CTRL_Obj *obj = (CTRL_Obj *)handle;
998 
999  obj->counter_speed = 0;
1000 
1001  return;
1002 } // end of CTRL_resetCounter_speed() function
1003 
1004 
1007 inline void CTRL_resetCounter_state(CTRL_Handle handle)
1008 {
1009  CTRL_Obj *obj = (CTRL_Obj *)handle;
1010 
1011  obj->counter_state = 0;
1012 
1013  return;
1014 } // end of CTRL_resetCounter_state() function
1015 
1016 
1019 inline void CTRL_resetCounter_traj(CTRL_Handle handle)
1020 {
1021  CTRL_Obj *obj = (CTRL_Obj *)handle;
1022 
1023  obj->counter_traj = 0;
1024 
1025  return;
1026 } // end of CTRL_resetCounter_traj() function
1027 
1028 
1038 void CTRL_run(CTRL_Handle handle,HAL_Handle halHandle,
1039  const HAL_AdcData_t *pAdcData,
1040  HAL_PwmData_t *pPwmData,
1041  uint32_t electricalAngle);
1042 
1043 
1046 void CTRL_runTraj(CTRL_Handle handle);
1047 
1048 
1052 inline void CTRL_setCtrlFreq_Hz(CTRL_Handle handle,const uint_least32_t ctrlFreq_Hz)
1053 {
1054  CTRL_Obj *obj = (CTRL_Obj *)handle;
1055 
1056  obj->ctrlFreq_Hz = ctrlFreq_Hz;
1057 
1058  return;
1059 } // end of CTRL_setCtrlFreq_Hz() function
1060 
1061 
1065 inline void CTRL_setCtrlPeriod_sec(CTRL_Handle handle,const float_t ctrlPeriod_sec)
1066 {
1067  CTRL_Obj *obj = (CTRL_Obj *)handle;
1068 
1070 
1071  return;
1072 } // end of CTRL_setCtrlPeriod_sec() function
1073 
1074 
1078 inline void CTRL_setErrorCode(CTRL_Handle handle,const CTRL_ErrorCode_e errorCode)
1079 {
1080  CTRL_Obj *obj = (CTRL_Obj *)handle;
1081 
1082  obj->errorCode = errorCode;
1083 
1084  return;
1085 } // end of CTRL_setErrorCode() function
1086 
1087 
1094 
1095 
1103 inline void CTRL_setFlag_enableCtrl(CTRL_Handle handle,const bool state)
1104 {
1105  CTRL_Obj *obj = (CTRL_Obj *)handle;
1106 
1107  obj->flag_enableCtrl = state;
1108 
1109  return;
1110 } // end of CTRL_setFlag_enableCtrl() function
1111 
1112 
1118 inline void CTRL_setFlag_enableDcBusComp(CTRL_Handle handle,const bool state)
1119 {
1120  CTRL_Obj *obj = (CTRL_Obj *)handle;
1121 
1122  obj->flag_enableDcBusComp = state;
1123 
1124  return;
1125 } // end of CTRL_setFlag_enableDcBusComp() function
1126 
1127 
1134 inline void CTRL_setFlag_enablePowerWarp(CTRL_Handle handle,const bool state)
1135 {
1136  CTRL_Obj *obj = (CTRL_Obj *)handle;
1137 
1138  obj->flag_enablePowerWarp = state;
1139 
1140  return;
1141 } // end of CTRL_setFlag_enablePowerWarp() function
1142 
1143 
1147 inline void CTRL_setFlag_enableOffset(CTRL_Handle handle,const bool state)
1148 {
1149  CTRL_Obj *obj = (CTRL_Obj *)handle;
1150 
1151  obj->flag_enableOffset = state;
1152 
1153  return;
1154 } // end of CTRL_setFlag_enableOffset() function
1155 
1156 
1160 inline void CTRL_setFlag_enableSpeedCtrl(CTRL_Handle handle,const bool state)
1161 {
1162  CTRL_Obj *obj = (CTRL_Obj *)handle;
1163 
1164  obj->flag_enableSpeedCtrl = state;
1165 
1166  return;
1167 } // end of CTRL_setFlag_enableSpeedCtrl() function
1168 
1169 
1176 inline void CTRL_setFlag_enableUserMotorParams(CTRL_Handle handle,const bool state)
1177 {
1178  CTRL_Obj *obj = (CTRL_Obj *)handle;
1179 
1181 
1182  return;
1183 } // end of CTRL_setFlag_enableUserMotorParams() function
1184 
1185 
1192 void CTRL_setGains(CTRL_Handle handle,const CTRL_Type_e ctrlType,
1193  const _iq Kp,const _iq Ki,const _iq Kd);
1194 
1195 
1199 inline void CTRL_setIab_in_pu(CTRL_Handle handle,const MATH_vec2 *pIab_in_pu)
1200 {
1201  CTRL_Obj *obj = (CTRL_Obj *)handle;
1202 
1203  obj->Iab_in.value[0] = pIab_in_pu->value[0];
1204  obj->Iab_in.value[1] = pIab_in_pu->value[1];
1205 
1206  return;
1207 } // end of CTRL_setIab_in_pu() function
1208 
1209 
1213 void CTRL_setIab_filt_pu(CTRL_Handle handle,const MATH_vec2 *pIab_filt_pu);
1214 
1215 
1219 inline void CTRL_setId_ref_pu(CTRL_Handle handle,const _iq Id_ref_pu)
1220 {
1221  CTRL_Obj *obj = (CTRL_Obj *)handle;
1222 
1223  obj->Idq_ref.value[0] = Id_ref_pu;
1224 
1225  return;
1226 } // end of CTRL_setId_ref_pu() function
1227 
1228 
1232 inline void CTRL_setIdq_in_pu(CTRL_Handle handle,const MATH_vec2 *pIdq_in_pu)
1233 {
1234  CTRL_Obj *obj = (CTRL_Obj *)handle;
1235 
1236  obj->Idq_in.value[0] = pIdq_in_pu->value[0];
1237  obj->Idq_in.value[1] = pIdq_in_pu->value[1];
1238 
1239  return;
1240 } // end of CTRL_setIdq_in_pu() function
1241 
1242 
1246 inline void CTRL_setIdq_ref_pu(CTRL_Handle handle,const MATH_vec2 *pIdq_ref_pu)
1247 {
1248  CTRL_Obj *obj = (CTRL_Obj *)handle;
1249 
1250  obj->Idq_ref.value[0] = pIdq_ref_pu->value[0];
1251  obj->Idq_ref.value[1] = pIdq_ref_pu->value[1];
1252 
1253  return;
1254 } // end of CTRL_setIdq_ref_pu() function
1255 
1256 
1260 inline void CTRL_setIdRated_pu(CTRL_Handle handle,const _iq IdRated_pu)
1261 {
1262  CTRL_Obj *obj = (CTRL_Obj *)handle;
1263 
1264  obj->IdRated = IdRated_pu;
1265 
1266  return;
1267 } // end of CTRL_setIdRated_pu() function
1268 
1269 
1273 inline void CTRL_setIq_ref_pu(CTRL_Handle handle,const _iq IqRef_pu)
1274 {
1275  CTRL_Obj *obj = (CTRL_Obj *)handle;
1276 
1277  obj->Idq_ref.value[1] = IqRef_pu;
1278 
1279  return;
1280 } // end of CTRL_setIq_ref_pu() function
1281 
1282 
1287 inline void CTRL_setKd(CTRL_Handle handle,const CTRL_Type_e ctrlType,const _iq Kd)
1288 {
1289  CTRL_Obj *obj = (CTRL_Obj *)handle;
1290 
1291  if(ctrlType == CTRL_Type_PID_spd)
1292  {
1293  obj->Kd_spd = Kd;
1294  }
1295  else if(ctrlType == CTRL_Type_PID_Id)
1296  {
1297  obj->Kd_Id = Kd;
1298  }
1299  else if(ctrlType == CTRL_Type_PID_Iq)
1300  {
1301  obj->Kd_Iq = Kd;
1302  }
1303 
1304  return;
1305 } // end of CTRL_setKd() function
1306 
1307 
1312 inline void CTRL_setKi(CTRL_Handle handle,const CTRL_Type_e ctrlType,const _iq Ki)
1313 {
1314  CTRL_Obj *obj = (CTRL_Obj *)handle;
1315 
1316  if(ctrlType == CTRL_Type_PID_spd)
1317  {
1318  obj->Ki_spd = Ki;
1319  }
1320  else if(ctrlType == CTRL_Type_PID_Id)
1321  {
1322  obj->Ki_Id = Ki;
1323  }
1324  else if(ctrlType == CTRL_Type_PID_Iq)
1325  {
1326  obj->Ki_Iq = Ki;
1327  }
1328 
1329  return;
1330 } // end of CTRL_setKi() function
1331 
1332 
1337 inline void CTRL_setKp(CTRL_Handle handle,const CTRL_Type_e ctrlType,const _iq Kp)
1338 {
1339  CTRL_Obj *obj = (CTRL_Obj *)handle;
1340 
1341  if(ctrlType == CTRL_Type_PID_spd)
1342  {
1343  obj->Kp_spd = Kp;
1344  }
1345  else if(ctrlType == CTRL_Type_PID_Id)
1346  {
1347  obj->Kp_Id = Kp;
1348  }
1349  else if(ctrlType == CTRL_Type_PID_Iq)
1350  {
1351  obj->Kp_Iq = Kp;
1352  }
1353 
1354  return;
1355 } // end of CTRL_setKp() function
1356 
1357 
1361 inline void CTRL_setLhf(CTRL_Handle handle,const float_t Lhf)
1362 {
1363  CTRL_Obj *obj = (CTRL_Obj *)handle;
1364 
1365  obj->Lhf = Lhf;
1366 
1367  return;
1368 } // end of CTRL_setLhf() function
1369 
1370 
1374 void CTRL_setMagCurrent_pu(CTRL_Handle handle,const _iq magCurrent_pu);
1375 
1376 
1380 inline void CTRL_setMaxVsMag_pu(CTRL_Handle handle,const _iq maxVsMag)
1381 {
1382  CTRL_Obj *obj = (CTRL_Obj *)handle;
1383 
1384  obj->maxVsMag_pu = maxVsMag;
1385 
1386  return;
1387 } // end of CTRL_setmaxVsMag_pu() function
1388 
1389 
1394 inline void CTRL_setMaxAccel_pu(CTRL_Handle handle,const _iq maxAccel_pu)
1395 {
1396  CTRL_Obj *obj = (CTRL_Obj *)handle;
1397 
1398  obj->traj_spd.maxDelta = maxAccel_pu;
1399 
1400  return;
1401 } // end of CTRL_setMaxAccel_pu() function
1402 
1403 
1407 void CTRL_setMaximumSpeed_pu(CTRL_Handle handle,const _iq maxSpeed_pu);
1408 
1409 
1419 inline void CTRL_setMotorParams(CTRL_Handle handle,
1420  const MOTOR_Type_e motorType,
1421  const uint_least16_t numPolePairs,
1422  const float_t ratedFlux,
1423  const float_t Ls_d,
1424  const float_t Ls_q,
1425  const float_t Rr,
1426  const float_t Rs)
1427 {
1428  CTRL_Obj *obj = (CTRL_Obj *)handle;
1429 
1430  obj->motorParams.type = motorType;
1431  obj->motorParams.numPolePairs = numPolePairs;
1432  obj->motorParams.ratedFlux_VpHz = ratedFlux;
1433  obj->motorParams.Ls_d_H = Ls_d;
1434  obj->motorParams.Ls_q_H = Ls_q;
1435  obj->motorParams.Rr_Ohm = Rr;
1436  obj->motorParams.Rs_Ohm = Rs;
1437 
1438  return;
1439 } // end of CTRL_setMotorParams() function
1440 
1441 
1447 void CTRL_setParams(CTRL_Handle handle,USER_Params *pUserParams);
1448 
1449 
1454  const uint_least16_t numCtrlTicksPerCurrentTick)
1455 {
1456  CTRL_Obj *obj = (CTRL_Obj *)handle;
1457 
1459 
1460  return;
1461 } // end of CTRL_setNumCtrlTicksPerCurrentTick() function
1462 
1463 
1468  const uint_least16_t numCtrlTicksPerSpeedTick)
1469 {
1470  CTRL_Obj *obj = (CTRL_Obj *)handle;
1471 
1473 
1474  return;
1475 } // end of CTRL_setNumCtrlTicksPerSpeedTick() function
1476 
1477 
1481 inline void CTRL_setNumCtrlTicksPerTrajTick(CTRL_Handle handle,
1482  const uint_least16_t numCtrlTicksPerTrajTick)
1483 {
1484  CTRL_Obj *obj = (CTRL_Obj *)handle;
1485 
1487 
1488  return;
1489 } // end of CTRL_setNumCtrlTicksPerTrajTick() function
1490 
1491 
1495 inline void CTRL_setNumIsrTicksPerCtrlTick(CTRL_Handle handle,
1496  const uint_least16_t numIsrTicksPerCtrlTick)
1497 {
1498  CTRL_Obj *obj = (CTRL_Obj *)handle;
1499 
1501 
1502  return;
1503 } // end of CTRL_setNumIsrTicksPerCtrlTick() function
1504 
1505 
1509 inline void CTRL_setRhf(CTRL_Handle handle,const float_t Rhf)
1510 {
1511  CTRL_Obj *obj = (CTRL_Obj *)handle;
1512 
1513  obj->Rhf = Rhf;
1514 
1515  return;
1516 } // end of CTRL_setRhf() function
1517 
1518 
1522 inline void CTRL_setRoverL(CTRL_Handle handle,const float_t RoverL)
1523 {
1524  CTRL_Obj *obj = (CTRL_Obj *)handle;
1525 
1526  obj->RoverL = RoverL;
1527 
1528  return;
1529 } // end of CTRL_setRoverL() function
1530 
1531 
1535 inline void CTRL_setSpd_max_pu(CTRL_Handle handle,const _iq maxSpd_pu)
1536 {
1537  CTRL_Obj *obj = (CTRL_Obj *)handle;
1538 
1539  obj->spd_max = maxSpd_pu;
1540 
1541  return;
1542 } // end of CTRL_setSpd_max_pu() function
1543 
1544 
1548 inline void CTRL_setSpd_out_pu(CTRL_Handle handle,const _iq spd_out_pu)
1549 {
1550  CTRL_Obj *obj = (CTRL_Obj *)handle;
1551 
1552  obj->spd_out = spd_out_pu;
1553 
1554  return;
1555 } // end of CTRL_setSpd_out_pu() function
1556 
1557 
1561 void CTRL_setSpd_ref_pu(CTRL_Handle handle,const _iq spd_ref_pu);
1562 
1563 
1567 void CTRL_setSpd_ref_krpm(CTRL_Handle handle,const _iq spd_ref_krpm);
1568 
1569 
1573 inline void CTRL_setState(CTRL_Handle handle,const CTRL_State_e state)
1574 {
1575  CTRL_Obj *obj = (CTRL_Obj *)handle;
1576 
1577  obj->prevState = obj->state;
1578  obj->state = state;
1579 
1580  return;
1581 } // end of CTRL_setState() function
1582 
1583 
1587 inline void CTRL_setTrajFreq_Hz(CTRL_Handle handle,const uint_least32_t trajFreq_Hz)
1588 {
1589  CTRL_Obj *obj = (CTRL_Obj *)handle;
1590 
1591  obj->trajFreq_Hz = trajFreq_Hz;
1592 
1593  return;
1594 } // end of CTRL_setTrajFreq_Hz() function
1595 
1596 
1600 inline void CTRL_setTrajPeriod_sec(CTRL_Handle handle,const _iq trajPeriod_sec)
1601 {
1602  CTRL_Obj *obj = (CTRL_Obj *)handle;
1603 
1605 
1606  return;
1607 } // end of CTRL_setTrajPeriod_sec() function
1608 
1609 
1614 inline void CTRL_setUi(CTRL_Handle handle,const CTRL_Type_e ctrlType,const _iq Ui)
1615 {
1616  CTRL_Obj *obj = (CTRL_Obj *)handle;
1617 
1618  if(ctrlType == CTRL_Type_PID_spd)
1619  {
1620  obj->Ui_spd = Ui;
1621  }
1622  else if(ctrlType == CTRL_Type_PID_Id)
1623  {
1624  obj->Ui_Id = Ui;
1625  }
1626  else if(ctrlType == CTRL_Type_PID_Iq)
1627  {
1628  obj->Ui_Iq = Ui;
1629  }
1630 
1631  return;
1632 } // end of CTRL_setUi() function
1633 
1634 
1640 void CTRL_setupClarke_I(CTRL_Handle handle,uint_least8_t numCurrentSensors);
1641 
1642 
1648 void CTRL_setupClarke_V(CTRL_Handle handle,uint_least8_t numVoltageSensors);
1649 
1650 
1653 void CTRL_setupEstIdleState(CTRL_Handle handle);
1654 
1655 
1659 
1660 
1664 
1665 
1669 inline void CTRL_setVab_in_pu(CTRL_Handle handle,const MATH_vec2 *pVab_in_pu)
1670 {
1671  CTRL_Obj *obj = (CTRL_Obj *)handle;
1672 
1673  obj->Vab_in.value[0] = pVab_in_pu->value[0];
1674  obj->Vab_in.value[1] = pVab_in_pu->value[1];
1675 
1676  return;
1677 } // end of CTRL_setVab_in_pu() function
1678 
1679 
1683 inline void CTRL_setVab_out_pu(CTRL_Handle handle,const MATH_vec2 *pVab_out_pu)
1684 {
1685  CTRL_Obj *obj = (CTRL_Obj *)handle;
1686 
1687  obj->Vab_out.value[0] = pVab_out_pu->value[0];
1688  obj->Vab_out.value[1] = pVab_out_pu->value[1];
1689 
1690  return;
1691 } // end of CTRL_setVab_out_pu() function
1692 
1693 
1697 inline void CTRL_setVdq_out_pu(CTRL_Handle handle,const MATH_vec2 *pVdq_out_pu)
1698 {
1699  CTRL_Obj *obj = (CTRL_Obj *)handle;
1700 
1701  obj->Vdq_out.value[0] = pVdq_out_pu->value[0];
1702  obj->Vdq_out.value[1] = pVdq_out_pu->value[1];
1703 
1704  return;
1705 } // end of CTRL_setVdq_out_pu() function
1706 
1707 
1711 void CTRL_setWaitTimes(CTRL_Handle handle,const uint_least32_t *pWaitTimes);
1712 
1713 
1718 void CTRL_setup(CTRL_Handle handle);
1719 
1720 
1723 void CTRL_setupCtrl(CTRL_Handle handle);
1724 
1725 
1728 void CTRL_setupEst(CTRL_Handle handle);
1729 
1730 
1733 void CTRL_setupTraj(CTRL_Handle handle);
1734 
1735 
1739 bool CTRL_updateState(CTRL_Handle handle);
1740 
1741 
1745 inline bool CTRL_useZeroIq_ref(CTRL_Handle handle)
1746 {
1747  CTRL_Obj *obj = (CTRL_Obj *)handle;
1748 
1749  return(EST_useZeroIq_ref(obj->estHandle));
1750 } // end of CTRL_useZeroIq_ref() function
1751 
1752 
1755 inline void CTRL_checkForErrors(CTRL_Handle handle)
1756 {
1757  CTRL_Obj *obj = (CTRL_Obj *)handle;
1758 
1759  // check for estimator errors
1760  if(EST_isError(obj->estHandle))
1761  {
1762  // set the next controller state
1764 
1765  // set the error code
1767  }
1768 
1769  return;
1770 } // end of CTRL_checkForErrors() function
1771 
1772 
1776 inline void CTRL_computePhasor(const _iq angle_pu,MATH_vec2 *pPhasor)
1777 {
1778 
1779  pPhasor->value[0] = _IQcosPU(angle_pu);
1780  pPhasor->value[1] = _IQsinPU(angle_pu);
1781 
1782  return;
1783 } // end of CTRL_computePhasor() function
1784 
1785 
1789 inline bool CTRL_doSpeedCtrl(CTRL_Handle handle)
1790 {
1791  CTRL_Obj *obj = (CTRL_Obj *)handle;
1792  bool result = false;
1793 
1794  if(CTRL_getFlag_enableSpeedCtrl(handle) &&
1795  (obj->counter_speed >= obj->numCtrlTicksPerSpeedTick))
1796  {
1797  result = true;
1798  }
1799 
1800  return(result);
1801 } // end of CTRL_doSpeedCtrl() function
1802 
1803 
1809 inline void CTRL_runOffLine(CTRL_Handle handle,HAL_Handle halHandle,
1810  const HAL_AdcData_t *pAdcData,HAL_PwmData_t *pPwmData)
1811 {
1812 
1813  // run offset estimation
1814  HAL_runOffsetEst(halHandle,pAdcData);
1815 
1816  // create PWM data
1817  pPwmData->Tabc.value[0] = _IQ(0.0);
1818  pPwmData->Tabc.value[1] = _IQ(0.0);
1819  pPwmData->Tabc.value[2] = _IQ(0.0);
1820 
1821  return;
1822 } // end of CTRL_runOffLine() function
1823 
1824 
1828 inline void CTRL_setSpdMax(CTRL_Handle handle, const _iq spdMax)
1829 {
1830  CTRL_Obj *obj = (CTRL_Obj *)handle;
1831 
1832  // set the maximum output of the speed controller, or Maximum Iq reference
1833  TRAJ_setIntValue(obj->trajHandle_spdMax, spdMax);
1834 
1835  return;
1836 } // end of CTRL_setSpdMax() function
1837 
1838 
1846 inline _iq CTRL_angleDelayComp(CTRL_Handle handle, const _iq angle_pu)
1847 {
1848  CTRL_Obj *obj = (CTRL_Obj *)handle;
1849  _iq angleDelta_pu = _IQmpy(EST_getFm_pu(obj->estHandle),_IQ(USER_IQ_FULL_SCALE_FREQ_Hz/(USER_PWM_FREQ_kHz*1000.0)));
1850  _iq angleUncomp_pu = angle_pu;
1851  _iq angleCompFactor = _IQ(1.0 + (float_t)USER_NUM_PWM_TICKS_PER_ISR_TICK * (float_t)USER_NUM_ISR_TICKS_PER_CTRL_TICK * ((float_t)USER_NUM_CTRL_TICKS_PER_EST_TICK - 0.5));
1852  _iq angleDeltaComp_pu = _IQmpy(angleDelta_pu, angleCompFactor);
1853  uint32_t angleMask = ((uint32_t)0xFFFFFFFF >> (32 - GLOBAL_Q));
1854  _iq angleTmp_pu;
1855  _iq angleComp_pu;
1856 
1857  // increment the angle
1858  angleTmp_pu = angleUncomp_pu + angleDeltaComp_pu;
1859 
1860  // mask the angle for wrap around
1861  // note: must account for the sign of the angle
1862  angleComp_pu = _IQabs(angleTmp_pu) & angleMask;
1863 
1864  // account for sign
1865  if(angleTmp_pu < 0)
1866  {
1867  angleComp_pu = -angleComp_pu;
1868  }
1869 
1870  return(angleComp_pu);
1871 }
1872 
1873 
1878 inline void CTRL_runOnLine(CTRL_Handle handle,
1879  const HAL_AdcData_t *pAdcData,HAL_PwmData_t *pPwmData)
1880 {
1881  CTRL_Obj *obj = (CTRL_Obj *)handle;
1882 
1883  _iq angle_pu;
1884 
1885  MATH_vec2 phasor;
1886 
1887 
1888  // run Clarke transform on current
1889  CLARKE_run(obj->clarkeHandle_I,&pAdcData->I,CTRL_getIab_in_addr(handle));
1890 
1891 
1892  // run Clarke transform on voltage
1893  CLARKE_run(obj->clarkeHandle_V,&pAdcData->V,CTRL_getVab_in_addr(handle));
1894 
1895 
1896  // run the estimator
1898  pAdcData->dcBus,TRAJ_getIntValue(obj->trajHandle_spd));
1899 
1900 
1901  // generate the motor electrical angle
1902  angle_pu = EST_getAngle_pu(obj->estHandle);
1903 
1904 
1905  // compute the sin/cos phasor
1906  CTRL_computePhasor(angle_pu,&phasor);
1907 
1908 
1909  // set the phasor in the Park transform
1910  PARK_setPhasor(obj->parkHandle,&phasor);
1911 
1912 
1913  // run the Park transform
1915 
1916 
1917  // when appropriate, run the PID speed controller
1918  if(EST_doSpeedCtrl(obj->estHandle))
1919  {
1920  if(CTRL_doSpeedCtrl(handle))
1921  {
1922  _iq refValue = TRAJ_getIntValue(obj->trajHandle_spd);
1923  _iq fbackValue = EST_getFm_pu(obj->estHandle);
1924  _iq outMax = TRAJ_getIntValue(obj->trajHandle_spdMax);
1925  _iq outMin = -outMax;
1926 
1927  // reset the speed count
1928  CTRL_resetCounter_speed(handle);
1929 
1930  PID_setMinMax(obj->pidHandle_spd,outMin,outMax);
1931 
1932  PID_run_spd(obj->pidHandle_spd,refValue,fbackValue,CTRL_getSpd_out_addr(handle));
1933  }
1934  }
1935  else
1936  {
1937  // zero the speed command
1938  CTRL_setSpd_out_pu(handle,_IQ(0.0));
1939 
1940  // reset the integrator
1941  PID_setUi(obj->pidHandle_spd,_IQ(0.0));
1942  }
1943 
1944 
1945  // when appropriate, run the PID Id and Iq controllers
1946  if(CTRL_doCurrentCtrl(handle) && EST_doCurrentCtrl(obj->estHandle))
1947  {
1950  _iq refValue;
1951  _iq fbackValue;
1952  _iq outMin,outMax;
1953 
1954  _iq maxVsMag = CTRL_getMaxVsMag_pu(handle);
1955 
1956  // reset the current count
1957  CTRL_resetCounter_current(handle);
1958 
1959  // ***********************************
1960  // configure and run the Id controller
1961 
1962  // compute the Kp gain
1963  // Scale Kp instead of output to prevent saturation issues
1964  if(CTRL_getFlag_enableDcBusComp(handle))
1965  {
1966  Kp_Id = _IQmpy(Kp_Id,EST_getOneOverDcBus_pu(obj->estHandle));
1967  }
1968 
1969  PID_setKp(obj->pidHandle_Id,Kp_Id);
1970 
1971  // compute the reference value
1972  refValue = TRAJ_getIntValue(obj->trajHandle_Id) + CTRL_getId_ref_pu(handle);
1973 
1974  // update the Id reference value
1975  EST_updateId_ref_pu(obj->estHandle,&refValue);
1976 
1977  // get the feedback value
1978  fbackValue = CTRL_getId_in_pu(handle);
1979 
1980  // set minimum and maximum for Id controller output
1981  outMax = maxVsMag;
1982  outMin = -outMax;
1983 
1984  // set the minimum and maximum values
1985  PID_setMinMax(obj->pidHandle_Id,outMin,outMax);
1986 
1987  // run the Id PID controller
1988  PID_run(obj->pidHandle_Id,refValue,fbackValue,CTRL_getVd_out_addr(handle));
1989 
1990  // set the Id reference value in the estimator
1991  EST_setId_ref_pu(obj->estHandle,refValue);
1992 
1993  // ***********************************
1994  // configure and run the Iq controller
1995 
1996  // compute the Kp gain
1997  // Scale Kp instead of output to prevent saturation issues
1998  if(CTRL_getFlag_enableDcBusComp(handle))
1999  {
2000  Kp_Iq = _IQmpy(Kp_Iq,EST_getOneOverDcBus_pu(obj->estHandle));
2001  }
2002 
2003  PID_setKp(obj->pidHandle_Iq,Kp_Iq);
2004 
2005  // get the reference value
2006  if(CTRL_getFlag_enableSpeedCtrl(handle))
2007  {
2008  if(!CTRL_useZeroIq_ref(handle))
2009  {
2010  refValue = CTRL_getSpd_out_pu(handle);
2011  }
2012  else
2013  {
2014  refValue = _IQ(0.0);
2015  }
2016  }
2017  else
2018  {
2019  // get the Iq reference value
2020  refValue = CTRL_getIq_ref_pu(handle);
2021  }
2022 
2023  // get the feedback value
2024  fbackValue = CTRL_getIq_in_pu(handle);
2025 
2026  // generate the Iq PID output limits without square root
2027  outMax = maxVsMag - _IQabs(CTRL_getVd_out_pu(handle));
2028  outMin = -outMax;
2029 
2030  // set the minimum and maximum values
2031  PID_setMinMax(obj->pidHandle_Iq,outMin,outMax);
2032 
2033  // run the Iq PID controller
2034  PID_run(obj->pidHandle_Iq,refValue,fbackValue,CTRL_getVq_out_addr(handle));
2035 
2036  // set the Iq reference value in the estimator
2037  EST_setIq_ref_pu(obj->estHandle,refValue);
2038  }
2039 
2040 
2041  // set the phasor in the inverse Park transform
2042  IPARK_setPhasor(obj->iparkHandle,&phasor);
2043 
2044 
2045  // run the inverse Park module
2047 
2048 
2049  // run the space Vector Generator (SVGEN) module
2050  SVGEN_run(obj->svgenHandle,CTRL_getVab_out_addr(handle),&(pPwmData->Tabc));
2051 
2052  return;
2053 } // end of CTRL_runOnLine() function
2054 
2055 
2065  const HAL_AdcData_t *pAdcData,HAL_PwmData_t *pPwmData,
2066  uint32_t electricalAngle)
2067 {
2068  CTRL_Obj *obj = (CTRL_Obj *)handle;
2069 
2070  _iq angle_pu;
2071 
2072  MATH_vec2 phasor;
2073 
2074 
2075  // run Clarke transform on current
2076  CLARKE_run(obj->clarkeHandle_I,&pAdcData->I,CTRL_getIab_in_addr(handle));
2077 
2078 
2079  // run Clarke transform on voltage
2080  CLARKE_run(obj->clarkeHandle_V,&pAdcData->V,CTRL_getVab_in_addr(handle));
2081 
2082 
2083  // run the estimator
2085  pAdcData->dcBus,TRAJ_getIntValue(obj->trajHandle_spd));
2086 
2087 
2088  // generate the motor electrical angle
2089  angle_pu = EST_getAngle_pu(obj->estHandle);
2090 
2091  // Update electrical angle from the sensor
2092  angle_pu = electricalAngle;
2093 
2094  // compute the sin/cos phasor
2095  CTRL_computePhasor(angle_pu,&phasor);
2096 
2097 
2098  // set the phasor in the Park transform
2099  PARK_setPhasor(obj->parkHandle,&phasor);
2100 
2101 
2102  // run the Park transform
2104 
2105 
2106  // when appropriate, run the PID speed controller
2107  if(CTRL_doSpeedCtrl(handle))
2108  {
2109  _iq refValue = TRAJ_getIntValue(obj->trajHandle_spd);
2110  _iq fbackValue = EST_getFm_pu(obj->estHandle);
2111  _iq outMax = TRAJ_getIntValue(obj->trajHandle_spdMax);
2112  _iq outMin = -outMax;
2113 
2114  // reset the speed count
2115  CTRL_resetCounter_speed(handle);
2116 
2117  PID_setMinMax(obj->pidHandle_spd,outMin,outMax);
2118 
2119  PID_run_spd(obj->pidHandle_spd,refValue,fbackValue,CTRL_getSpd_out_addr(handle));
2120  }
2121 
2122 
2123  // when appropriate, run the PID Id and Iq controllers
2124  if(CTRL_doCurrentCtrl(handle))
2125  {
2126  _iq Kp_Id = CTRL_getKp(handle,CTRL_Type_PID_Id);
2127  _iq Kp_Iq = CTRL_getKp(handle,CTRL_Type_PID_Iq);
2128  _iq refValue;
2129  _iq fbackValue;
2130  _iq outMin,outMax;
2131 
2132  // read max voltage vector to set proper limits to current controllers
2133  _iq maxVsMag = CTRL_getMaxVsMag_pu(handle);
2134 
2135 
2136  // reset the current count
2137  CTRL_resetCounter_current(handle);
2138 
2139  // ***********************************
2140  // configure and run the Id controller
2141 
2142  // compute the Kp gain
2143  // Scale Kp instead of output to prevent saturation issues
2144  if(CTRL_getFlag_enableDcBusComp(handle))
2145  {
2146  Kp_Id = _IQmpy(Kp_Id,EST_getOneOverDcBus_pu(obj->estHandle));
2147  }
2148 
2149  PID_setKp(obj->pidHandle_Id,Kp_Id);
2150 
2151  // compute the reference value
2152  refValue = TRAJ_getIntValue(obj->trajHandle_Id) + CTRL_getId_ref_pu(handle);
2153 
2154  // update the Id reference value
2155  EST_updateId_ref_pu(obj->estHandle,&refValue);
2156 
2157  // get the feedback value
2158  fbackValue = CTRL_getId_in_pu(handle);
2159 
2160  // set minimum and maximum for Id controller output
2161  outMax = maxVsMag;
2162  outMin = -outMax;
2163 
2164  // set the minimum and maximum values
2165  PID_setMinMax(obj->pidHandle_Id,outMin,outMax);
2166 
2167  // run the Id PID controller
2168  PID_run(obj->pidHandle_Id,refValue,fbackValue,CTRL_getVd_out_addr(handle));
2169 
2170  // ***********************************
2171  // configure and run the Iq controller
2172 
2173  // compute the Kp gain
2174  // Scale Kp instead of output to prevent saturation issues
2175  if(CTRL_getFlag_enableDcBusComp(handle))
2176  {
2177  Kp_Iq = _IQmpy(Kp_Iq,EST_getOneOverDcBus_pu(obj->estHandle));
2178  }
2179 
2180  PID_setKp(obj->pidHandle_Iq,Kp_Iq);
2181 
2182  // get the reference value
2183  if(CTRL_getFlag_enableSpeedCtrl(handle))
2184  {
2185  refValue = CTRL_getSpd_out_pu(handle);
2186  }
2187  else
2188  {
2189  // get the Iq reference value
2190  refValue = CTRL_getIq_ref_pu(handle);
2191  }
2192 
2193  // get the feedback value
2194  fbackValue = CTRL_getIq_in_pu(handle);
2195 
2196  // set minimum and maximum for Id controller output
2197  outMax = _IQsqrt(_IQmpy(maxVsMag,maxVsMag) - _IQmpy(CTRL_getVd_out_pu(handle),CTRL_getVd_out_pu(handle)));
2198  outMin = -outMax;
2199 
2200  // set the minimum and maximum values
2201  PID_setMinMax(obj->pidHandle_Iq,outMin,outMax);
2202 
2203  // run the Iq PID controller
2204  PID_run(obj->pidHandle_Iq,refValue,fbackValue,CTRL_getVq_out_addr(handle));
2205  }
2206 
2207  {
2208  _iq angleComp_pu;
2209 
2210 
2211  // compensate angle delay
2212  angleComp_pu = CTRL_angleDelayComp(handle, angle_pu);
2213 
2214 
2215  // compute the sin/cos phasor
2216  CTRL_computePhasor(angleComp_pu,&phasor);
2217  }
2218 
2219 
2220  // set the phasor in the inverse Park transform
2221  IPARK_setPhasor(obj->iparkHandle,&phasor);
2222 
2223 
2224  // run the inverse Park module
2226 
2227 
2228  // run the space Vector Generator (SVGEN) module
2229  SVGEN_run(obj->svgenHandle,CTRL_getVab_out_addr(handle),&(pPwmData->Tabc));
2230 
2231  return;
2232 } // end of CTRL_runOnLine_User() function
2233 
2234 
2235 #ifdef __cplusplus
2236 }
2237 #endif // extern "C"
2238 
2240 #endif // end of _CTRL_H_ definition
2241 
2242 
2243 
2244 
bool EST_isError(EST_Handle handle)
Determines if there is an estimator error.
PID Speed controller.
Definition: 32b/ctrl_obj.h:123
_iq maxVsMag_pu
the maximum voltage vector that is allowed, pu
Definition: 32b/ctrl_obj.h:211
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: 32b/ctrl.c:78
Defines the controller (CTRL) version number.
Definition: 32b/ctrl_obj.h:131
CTRL_ErrorCode_e errorCode
the error code for the controller
Definition: 32b/ctrl_obj.h:152
the controller error state
Definition: ctrl_states.h:35
void CTRL_incrCounter_isr(CTRL_Handle handle)
Increments the isr counter.
Definition: 32b/ctrl.h:967
MATH_vec2 * CTRL_getIab_in_addr(CTRL_Handle handle)
Gets the alpha/beta current input vector memory address from the controller.
Definition: 32b/ctrl.h:308
_iq CTRL_getIq_ref_pu(CTRL_Handle handle)
Gets the quadrature current (Iq) reference value from the controller.
Definition: 32b/ctrl.h:414
#define _IQsinPU(A)
static _iq PID_getRefValue(PID_Handle handle)
Gets the reference value in the PID controller.
Definition: 32b/pid.h:200
void CTRL_setupEstOnLineState(CTRL_Handle handle)
Sets up the controller and trajectory generator for the estimator online state.
IPARK_Handle iparkHandle
the handle for the inverse Park transform
Definition: 32b/ctrl_obj.h:174
Contains the public interface to the types definitions.
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: 32b/ctrl.c:123
bool CTRL_getFlag_enableDcBusComp(CTRL_Handle handle)
Gets the enable DC bus compensation flag value from the estimator.
Definition: 32b/ctrl.h:226
MATH_vec2 Vab_in
the Vab input values
Definition: 32b/ctrl_obj.h:219
MATH_vec2 Idq_ref
the Idq reference values, pu
Definition: 32b/ctrl_obj.h:247
uint_least16_t numCtrlTicksPerSpeedTick
Defines the number of controller clock ticks per speed controller clock tick.
Definition: 32b/ctrl_obj.h:199
_iq Kd_Id
the desired Kd_Id value
Definition: 32b/ctrl_obj.h:239
float_t RoverL
the R/L value
Definition: 32b/ctrl_obj.h:229
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: 32b/ctrl.c:90
_iq Ki_Iq
the desired Ki_Iq value
Definition: 32b/ctrl_obj.h:236
CLARKE_Handle clarkeHandle_I
the handle for the current Clarke transform
Definition: 32b/ctrl_obj.h:154
#define _IQ(A)
void CTRL_resetCounter_state(CTRL_Handle handle)
Resets the state counter.
Definition: 32b/ctrl.h:1107
_iq maxDelta
the maximum delta value for the trajectory generator
Definition: 32b/traj.h:73
MOTOR_Type_e type
Defines the motor type.
Definition: 32b/motor.h:82
float_t ratedFlux_VpHz
Defines the rated flux, V/Hz.
Definition: 32b/motor.h:95
static void PID_setUi(PID_Handle handle, const _iq Ui)
Sets the integrator start value in the PID controller.
Definition: 32b/pid.h:409
void CTRL_setupClarke_V(CTRL_Handle handle, uint_least8_t numVoltageSensors)
Sets the number of voltage sensors.
Definition: 32b/ctrl.c:544
void EST_setId_ref_pu(EST_Handle handle, const _iq Id_ref_pu)
Sets the direct current (Id) reference value in the estimator in per unit (pu), IQ24.
static void PARK_setPhasor(PARK_Handle handle, const MATH_vec2 *pPhasor)
Sets the cosine/sine phasor for the inverse Park transform.
Definition: 32b/park.h:171
void CTRL_setEstParams(EST_Handle estHandle, USER_Params *pUserParams)
Sets the default estimator parameters.
CTRL_ErrorCode_e CTRL_getErrorCode(CTRL_Handle handle)
Gets the error code from the controller (CTRL) object.
Definition: 32b/ctrl.h:172
void EST_setIq_ref_pu(EST_Handle handle, const _iq Iq_ref_pu)
Sets the quadrature current (Iq) reference value in the estimator in per unit (pu), IQ24.
_iq CTRL_getUi(CTRL_Handle handle, const CTRL_Type_e ctrlType)
Gets the integrator (Ui) value from the specified controller.
Definition: 32b/ctrl.h:806
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
static _iq TRAJ_getIntValue(TRAJ_Handle handle)
Gets the intermediate value for the trajectory.
Definition: 32b/traj.h:92
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
_iq Ki_Id
the desired Ki_Id value
Definition: 32b/ctrl_obj.h:235
_iq spd_ref
the speed reference, pu
Definition: 32b/ctrl_obj.h:251
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: 32b/ctrl.c:170
uint_least16_t numCtrlTicksPerTrajTick
Defines the number of controller clock ticks per trajectory clock tick.
Definition: 32b/ctrl_obj.h:201
Defines a two element vector.
Definition: 32b/math.h:248
_iq CTRL_getTrajPeriod_sec(CTRL_Handle handle)
Gets the trajectory execution period.
Definition: 32b/ctrl.h:789
Contains the public interface to the offset (OFFSET) module routines.
_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
_iq value[3]
Definition: 32b/math.h:261
float_t CTRL_getLhf(CTRL_Handle handle)
Gets the high frequency inductance (Lhf) value from the controller.
Definition: 32b/ctrl.h:524
_iq angle_pu
the angle value, pu
Definition: 32b/ctrl_obj.h:273
_iq Kp_spd
the desired Kp_spd value
Definition: 32b/ctrl_obj.h:233
_iq spd_max
the maximum speed, pu
Definition: 32b/ctrl_obj.h:253
void CTRL_incrCounter_current(CTRL_Handle handle)
Increments the current counter.
Definition: 32b/ctrl.h:949
struct _EST_Obj_ * EST_Handle
Defines the estimator (EST) handle.
Definition: 32b/est.h:52
TRAJ_Handle trajHandle_Id
the handle for the Id trajectory generator
Definition: 32b/ctrl_obj.h:180
_iq CTRL_getId_in_pu(CTRL_Handle handle)
Gets the direct current input value from the controller.
Definition: 32b/ctrl.h:325
uint_least16_t CTRL_getNumCtrlTicksPerTrajTick(CTRL_Handle handle)
Gets the number of controller clock ticks per trajectory clock tick.
Definition: 32b/ctrl.h:602
bool CTRL_isError(CTRL_Handle handle)
Determines if there is a controller error.
Definition: 32b/ctrl.h:1053
Contains the public interface to the Proportional-Integral-Derivative (PID) controller module routine...
float_t CTRL_getCtrlPeriod_sec(CTRL_Handle handle)
Gets the controller execution period.
Definition: 32b/ctrl.h:161
_iq * CTRL_getVd_out_addr(CTRL_Handle handle)
Gets the direct voltage output value memory address from the controller.
Definition: 32b/ctrl.h:865
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
TRAJ_Handle trajHandle_spd
the handle for the speed trajectory generator
Definition: 32b/ctrl_obj.h:183
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
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
_iq CTRL_getSpd_out_pu(CTRL_Handle handle)
Gets the output speed value from the controller.
Definition: 32b/ctrl.h:723
MATH_vec2 Vab_out
the Vab output values
Definition: 32b/ctrl_obj.h:223
PID_Handle pidHandle_Id
the handle for the Id PID controller
Definition: 32b/ctrl_obj.h:165
CTRL_ErrorCode_e
Enumeration for the error codes.
Definition: 32b/ctrl_obj.h:98
float_t ctrlPeriod_sec
Defines the controller period, sec.
Definition: 32b/ctrl_obj.h:209
EST_Handle CTRL_getEstHandle(CTRL_Handle handle)
Gets the estimator handle for a given controller.
Definition: 32b/ctrl.h:183
Defines the controller (CTRL) object.
Definition: 32b/ctrl_obj.h:144
void CTRL_setTrajPeriod_sec(CTRL_Handle handle, const _iq trajPeriod_sec)
Sets the trajectory execution period.
Definition: 32b/ctrl.h:1801
void CTRL_setMagCurrent_pu(CTRL_Handle handle, const _iq magCurrent_pu)
Sets the magnetizing current value in the controller.
Definition: 32b/ctrl.c:274
#define _IQcosPU(A)
Defines a structure for the user parameters.
_iq Kp_Id
the desired Kp_Id value
Definition: 32b/ctrl_obj.h:231
uint_least16_t CTRL_getCount_traj(CTRL_Handle handle)
Gets the trajectory loop count.
Definition: 32b/ctrl.h:139
_iq CTRL_getSpd_ref_pu(CTRL_Handle handle)
Gets the output speed reference value from the controller.
Definition: 32b/ctrl.h:734
_iq CTRL_angleDelayComp(CTRL_Handle handle, const _iq angle_pu)
Runs angle delay compensation.
Definition: 32b/ctrl.h:2126
estimator error code
Definition: 32b/ctrl_obj.h:102
Contains the public interface to the estimator (EST) module routines.
EST_Handle estHandle
the handle for the parameter estimator
Definition: 32b/ctrl_obj.h:160
void CTRL_getTrajStep(CTRL_Handle handle)
Gets the trajectory step size.
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
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
static void SVGEN_run(SVGEN_Handle handle, const MATH_vec2 *pVab, MATH_vec3 *pT)
Implements a SVM that saturates at the level of MaxModulation.
Definition: 32b/svgen.h:124
void CTRL_setFlag_enableCtrl(CTRL_Handle handle, const bool state)
Sets the enable controller flag value in the estimator.
Definition: 32b/ctrl.h:1214
Defines the structures for the CTRL object.
void CTRL_setFlag_enableSpeedCtrl(CTRL_Handle handle, const bool state)
Sets the enable speed control value in the estimator.
Definition: 32b/ctrl.h:1284
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: 32b/ctrl.c:101
float_t CTRL_getMotorRatedFlux(CTRL_Handle handle)
Gets the motor rated flux from the controller.
Definition: 32b/ctrl.h:558
bool flag_enableDcBusComp
a flag to enable the DC bus compensation in the controller
Definition: 32b/ctrl_obj.h:264
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
void CTRL_runTraj(CTRL_Handle handle)
Runs the trajectory.
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
long _iq
MATH_vec2 * CTRL_getVab_out_addr(CTRL_Handle handle)
Gets the alpha/beta voltage output vector memory address from the controller.
Definition: 32b/ctrl.h:848
MATH_vec2 * CTRL_getIdq_in_addr(CTRL_Handle handle)
Gets the direct/quadrature current input vector memory address from the controller.
Definition: 32b/ctrl.h:347
bool CTRL_doSpeedCtrl(CTRL_Handle handle)
Determines if the speed controller should be executed.
Definition: 32b/ctrl.h:2070
_iq Kd_Iq
the desired Kd_Iq value
Definition: 32b/ctrl_obj.h:240
void CTRL_resetCounter_current(CTRL_Handle handle)
Resets the current counter.
Definition: 32b/ctrl.h:1071
uint_least16_t CTRL_getCount_isr(CTRL_Handle handle)
Gets the isr count.
Definition: 32b/ctrl.h:106
bool flag_enableOffset
a flag to enable offset estimation after idle state
Definition: 32b/ctrl_obj.h:266
TRAJ_Handle trajHandle_spdMax
the handle for the maximum speed trajectory generator
Definition: 32b/ctrl_obj.h:186
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
_iq Ui_spd
the desired Ui_spd value
Definition: 32b/ctrl_obj.h:245
float_t CTRL_getRhf(CTRL_Handle handle)
Gets the high frequency resistance (Rhf) value from the controller.
Definition: 32b/ctrl.h:679
void CTRL_setupTraj(CTRL_Handle handle)
Sets up the trajectory (TRAJ) object.
void CTRL_setMaxAccel_pu(CTRL_Handle handle, const _iq maxAccel_pu)
Sets the maximum acceleration of the speed controller.
Definition: 32b/ctrl.h:1556
void CTRL_setState(CTRL_Handle handle, const CTRL_State_e state)
Sets the controller state.
Definition: 32b/ctrl.h:1774
_iq CTRL_getIq_in_pu(CTRL_Handle handle)
Gets the quadrature current input value from the controller.
Definition: 32b/ctrl.h:392
static void TRAJ_setIntValue(TRAJ_Handle handle, const _iq intValue)
Sets the intermediate value for the trajectory.
Definition: 32b/traj.h:154
uint_least16_t numPolePairs
Defines the number of pole pairs.
Definition: 32b/motor.h:84
MATH_vec3 Tabc
the PWM time-durations for each motor phase
_iq * CTRL_getVq_out_addr(CTRL_Handle handle)
Gets the quadrature voltage output value memory address from the controller.
Definition: 32b/ctrl.h:910
MOTOR_Type_e
Enumeration for the motor types.
Definition: 32b/motor.h:71
uint_least32_t counter_state
the state counter
Definition: 32b/ctrl_obj.h:193
void CTRL_setParams(CTRL_Handle handle, USER_Params *pUserParams)
Sets the controller parameters.
Definition: 32b/ctrl.c:292
bool CTRL_getFlag_enableSpeedCtrl(CTRL_Handle handle)
Gets the enable speed control flag value from the controller.
Definition: 32b/ctrl.h:259
#define _IQmpy(A, B)
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: 32b/ctrl.c:112
void CTRL_setWaitTimes(CTRL_Handle handle, const uint_least32_t *pWaitTimes)
Sets the wait times for the controller states.
Definition: 32b/ctrl.c:628
bool CTRL_useZeroIq_ref(CTRL_Handle handle)
Determines if a zero Iq current reference should be used in the controller.
Definition: 32b/ctrl.h:1972
_iq CTRL_getSpd_max_pu(CTRL_Handle handle)
Gets the maximum speed value from the controller.
Definition: 32b/ctrl.h:701
CTRL_State_e state
the current state of the controller
Definition: 32b/ctrl_obj.h:148
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
uint_least16_t counter_isr
the isr counter
Definition: 32b/ctrl_obj.h:257
void CTRL_incrCounter_speed(CTRL_Handle handle)
Increments the speed counter.
Definition: 32b/ctrl.h:985
void CTRL_resetCounter_isr(CTRL_Handle handle)
Resets the isr counter.
Definition: 32b/ctrl.h:1083
_iq Kd_spd
the desired Kd_spd value
Definition: 32b/ctrl_obj.h:241
_iq value[2]
Definition: 32b/math.h:251
bool EST_doSpeedCtrl(EST_Handle handle)
Determines if speed control should be performed during motor identification.
_iq * CTRL_getSpd_out_addr(CTRL_Handle handle)
Gets the output speed memory address from the controller.
Definition: 32b/ctrl.h:712
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
MATH_vec2 Idq_in
the Idq input values
Definition: 32b/ctrl_obj.h:217
bool flag_enablePowerWarp
a flag to enable PowerWarp
Definition: 32b/ctrl_obj.h:265
PID_Handle pidHandle_spd
the handle for the speed PID controller
Definition: 32b/ctrl_obj.h:171
_iq trajPeriod_sec
Defines the trajectory period, sec.
Definition: 32b/ctrl_obj.h:207
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
void HAL_runOffsetEst(HAL_Handle handle, const HAL_AdcData_t *pAdcData)
Runs offset estimation.
_iq EST_getOneOverDcBus_pu(EST_Handle handle)
Gets the inverse of the DC bus voltage in per unit (pu), IQ24.
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
bool CTRL_getFlag_enableUserMotorParams(CTRL_Handle handle)
Gets the enable user motor parameters flag value from the controller.
Definition: 32b/ctrl.h:270
void CTRL_incrCounter_state(CTRL_Handle handle)
Increments the state counter.
Definition: 32b/ctrl.h:1003
void CTRL_setupEstIdleState(CTRL_Handle handle)
Sets up the controller and trajectory generator for the estimator idle state.
CTRL_State_e prevState
the previous state of the controller
Definition: 32b/ctrl_obj.h:150
CTRL_State_e CTRL_getState(CTRL_Handle handle)
Gets the controller state.
Definition: 32b/ctrl.h:767
void CTRL_setUserMotorParams(CTRL_Handle handle)
Sets the controller and estimator with motor parameters from the user.h file.
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
void CTRL_setCtrlPeriod_sec(CTRL_Handle handle, const float_t ctrlPeriod_sec)
Sets the controller execution period.
Definition: 32b/ctrl.h:1176
static void IPARK_run(IPARK_Handle handle, const MATH_vec2 *pInVec, MATH_vec2 *pOutVec)
Runs the inverse Park transform module.
Definition: 32b/ipark.h:137
uint_least32_t CTRL_getCtrlFreq(CTRL_Handle handle)
Gets the controller execution frequency.
Definition: 32b/ctrl.h:150
_iq Kp_Iq
the desired Kp_Iq value
Definition: 32b/ctrl_obj.h:232
PARK_Handle parkHandle
the handle for the Park object
Definition: 32b/ctrl_obj.h:162
_iq CTRL_getMaximumSpeed_pu(CTRL_Handle handle)
Gets the maximum speed value from the controller.
Definition: 32b/ctrl.c:141
MATH_vec2 Iab_filt
the Iab filtered values
Definition: 32b/ctrl_obj.h:215
bool CTRL_doCurrentCtrl(CTRL_Handle handle)
Determines if the current controllers should be run.
Definition: 32b/ctrl.h:2053
_iq EST_getFm_pu(EST_Handle handle)
Gets the mechanical frequency of the motor in per unit (pu), IQ24.
uint_least16_t counter_current
the isr counter
Definition: 32b/ctrl_obj.h:255
MATH_vec2 Vdq_out
the Vdq output values
Definition: 32b/ctrl_obj.h:225
uint_least32_t waitTimes[CTRL_numStates]
an array of wait times for each state, estimator clock counts
Definition: 32b/ctrl_obj.h:191
bool EST_useZeroIq_ref(EST_Handle handle)
Determines if a zero Iq current reference should be used in the controller.
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
_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
void CTRL_setup(CTRL_Handle handle)
Sets up the controller (CTRL) object and all of the subordinate objects.
Definition: 32b/ctrl.c:489
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: 32b/ctrl.c:159
void CTRL_setSpd_ref_pu(CTRL_Handle handle, const _iq spd_ref_pu)
Sets the output speed reference value in the controller.
Definition: 32b/ctrl.c:465
_iq CTRL_getVd_out_pu(CTRL_Handle handle)
Gets the direct voltage output value from the controller.
Definition: 32b/ctrl.h:876
CTRL_State_e
Enumeration for the controller states.
Definition: ctrl_states.h:34
#define _IQabs(A)
_iq spd_out
the speed output value
Definition: 32b/ctrl_obj.h:221
CLARKE_Handle clarkeHandle_V
the handle for the voltage Clarke transform
Definition: 32b/ctrl_obj.h:157
MATH_vec2 * CTRL_getVdq_out_addr(CTRL_Handle handle)
Gets the direct/quadrature voltage output vector memory address from the controller.
Definition: 32b/ctrl.h:887
void CTRL_setTrajFreq_Hz(CTRL_Handle handle, const uint_least32_t trajFreq_Hz)
Sets the trajectory execution frequency.
Definition: 32b/ctrl.h:1788
_iq CTRL_getMaxVsMag_pu(CTRL_Handle handle)
Gets the maximum voltage vector.
Definition: 32b/ctrl.h:541
uint_least16_t counter_traj
the traj counter
Definition: 32b/ctrl_obj.h:261
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
MOTOR_Params motorParams
the motor parameters
Definition: 32b/ctrl_obj.h:189
void CTRL_setSpdMax(CTRL_Handle handle, const _iq spdMax)
Sets maximum speed controller output.
Definition: 32b/ctrl.h:2108
uint_least16_t counter_speed
the speed counter
Definition: 32b/ctrl_obj.h:259
void CTRL_setErrorCode(CTRL_Handle handle, const CTRL_ErrorCode_e errorCode)
Sets the error code in the controller.
Definition: 32b/ctrl.h:1189
CTRL_Handle CTRL_initCtrl(const uint_least8_t estNumber, void *pMemory, const size_t numBytes)
Initializes a specified controller.
MATH_vec2 * CTRL_getIab_filt_addr(CTRL_Handle handle)
Gets the alpha/beta filtered current vector memory address from the controller.
Definition: 32b/ctrl.h:297
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
void CTRL_setMaxVsMag_pu(CTRL_Handle handle, const _iq maxVsMag)
Sets the maximum voltage vector in the controller.
Definition: 32b/ctrl.h:1542
Contains the public interface to the encoder module routines.
float_t Ls_q_H
Defines the quadrature stator inductance, H.
Definition: 32b/motor.h:89
_iq CTRL_getId_ref_pu(CTRL_Handle handle)
Gets the direct current (Id) reference value from the controller.
Definition: 32b/ctrl.h:336
void CTRL_resetCounter_traj(CTRL_Handle handle)
Resets the trajectory counter.
Definition: 32b/ctrl.h:1119
bool EST_doCurrentCtrl(EST_Handle handle)
Determines if current control should be performed during motor identification.
PID_Handle pidHandle_Iq
the handle for the Iq PID controller
Definition: 32b/ctrl_obj.h:168
_iq IdRated
the Id rated current, pu
Definition: 32b/ctrl_obj.h:249
_iq CTRL_getIdRated_pu(CTRL_Handle handle)
Gets the Id rated current value from the controller.
Definition: 32b/ctrl.h:381
void CTRL_setFlag_enablePowerWarp(CTRL_Handle handle, const bool state)
Sets the PowerWarp enable flag value in the estimator.
Definition: 32b/ctrl.h:1258
static void IPARK_setPhasor(IPARK_Handle handle, const MATH_vec2 *pPhasor)
Sets the cosine/sine phasor for the inverse Park transform.
Definition: 32b/ipark.h:171
Contains public interface to various functions related to the trajectory (TRAJ) object.
bool CTRL_updateState(CTRL_Handle handle)
Updates the controller state.
Definition: 32b/ctrl.c:642
void CTRL_setIab_filt_pu(CTRL_Handle handle, const MATH_vec2 *pIab_filt_pu)
Sets the alpha/beta filtered current vector values in the controller.
_iq EST_getAngle_pu(EST_Handle handle)
Gets the angle value from the estimator in per unit (pu), IQ24.
CTRL_Type_e
Enumeration for the controller (CTRL) types.
Definition: 32b/ctrl_obj.h:121
_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
void CTRL_getWaitTimes(CTRL_Handle handle, uint_least32_t *pWaitTimes)
Gets the wait times from the estimator.
Definition: 32b/ctrl.c:181
bool CTRL_getFlag_enableCtrl(CTRL_Handle handle)
Gets the enable controller flag value from the estimator.
Definition: 32b/ctrl.h:204
float_t Ls_d_H
Defines the direct stator inductance, H.
Definition: 32b/motor.h:88
bool flag_enableCtrl
a flag to enable the controller
Definition: 32b/ctrl_obj.h:263
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
_iq Ui_Iq
the desired Ui_Iq value
Definition: 32b/ctrl_obj.h:244
void CTRL_setFlag_enableOffset(CTRL_Handle handle, const bool state)
Sets the enable offset flag value in the estimator.
Definition: 32b/ctrl.h:1271
static void CLARKE_run(CLARKE_Handle handle, const MATH_vec3 *pInVec, MATH_vec2 *pOutVec)
Runs the Clarke transform module for three inputs.
Definition: 32b/clarke.h:119
uint_least32_t ctrlFreq_Hz
Defines the controller frequency, Hz.
Definition: 32b/ctrl_obj.h:203
float_t Rs_Ohm
Defines the stator resistance, Ohm.
Definition: 32b/motor.h:93
static void PARK_run(PARK_Handle handle, const MATH_vec2 *pInVec, MATH_vec2 *pOutVec)
Runs the Park transform module.
Definition: 32b/park.h:137
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
#define _IQsqrt(A)
uint_least16_t CTRL_getCount_speed(CTRL_Handle handle)
Gets the speed loop count.
Definition: 32b/ctrl.h:117
PID Iq controller.
Definition: 32b/ctrl_obj.h:125
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
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
_iq CTRL_getMagCurrent_pu(CTRL_Handle handle)
Gets the magnetizing current value from the controller.
Definition: 32b/ctrl.c:134
uint_least16_t CTRL_getCount_current(CTRL_Handle handle)
Gets the current loop count.
Definition: 32b/ctrl.h:95
Contains the public interface to the Park transform module routines.
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
bool flag_enableUserMotorParams
a flag to use known motor parameters from user.h file
Definition: 32b/ctrl_obj.h:268
void CTRL_setIq_ref_pu(CTRL_Handle handle, const _iq IqRef_pu)
Sets the quadrature current (Iq) reference value in the controller.
Definition: 32b/ctrl.h:1435
static void PID_run_spd(PID_Handle handle, const _iq refValue, const _iq fbackValue, _iq *pOutValue)
Runs the PID controller for speed.
Definition: 32b/pid.h:260
void CTRL_setCtrlFreq_Hz(CTRL_Handle handle, const uint_least32_t ctrlFreq_Hz)
Sets the controller frequency.
Definition: 32b/ctrl.h:1163
PID Id controller.
Definition: 32b/ctrl_obj.h:124
uint_least32_t trajFreq_Hz
Defines the trajectory frequency, Hz.
Definition: 32b/ctrl_obj.h:205
void CTRL_resetCounter_speed(CTRL_Handle handle)
Resets the speed counter.
Definition: 32b/ctrl.h:1095
uint_least32_t CTRL_getTrajFreq(CTRL_Handle handle)
Gets the trajectory execution frequency.
Definition: 32b/ctrl.h:778
_iq CTRL_getSpd_int_ref_pu(CTRL_Handle handle)
Gets the output speed intermediate reference value from the controller.
Definition: 32b/ctrl.h:745
float_t Rr_Ohm
Defines the rotor resistance, Ohm.
Definition: 32b/motor.h:91
void CTRL_setId_ref_pu(CTRL_Handle handle, const _iq Id_ref_pu)
Sets the direct current (Id) reference value in the controller.
Definition: 32b/ctrl.h:1343
Contains the public interface to the Clarke transform (CLARKE) module routines.
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
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: 32b/ctrl.c:148
Contains the public interface to the inverse Park transform (IPARK) module routines.
void CTRL_setMaximumSpeed_pu(CTRL_Handle handle, const _iq maxSpeed_pu)
Sets the maximum speed value in the controller.
Definition: 32b/ctrl.c:283
uint_least16_t CTRL_getNumCtrlTicksPerSpeedTick(CTRL_Handle handle)
Gets the number of controller clock ticks per speed controller clock tick.
Definition: 32b/ctrl.h:591
Contains the public interface to the Space Vector Generator (SVGEN) module routines.
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
void CTRL_getVersion(CTRL_Handle handle, CTRL_Version *pVersion)
Gets the controller version number.
Definition: float/ctrl.c:58
float_t CTRL_getRoverL(CTRL_Handle handle)
Gets the R/L value from the controller.
Definition: 32b/ctrl.h:690
MATH_vec2 Iab_in
the Iab input values
Definition: 32b/ctrl_obj.h:213
uint_least16_t numCtrlTicksPerCurrentTick
Defines the number of controller clock ticks per current controller clock tick.
Definition: 32b/ctrl_obj.h:197
uint_least32_t CTRL_getCount_state(CTRL_Handle handle)
Gets the state count.
Definition: 32b/ctrl.h:128
void CTRL_setupEst(CTRL_Handle handle)
Sets up the estimator (CTRL) object.
void CTRL_computePhasor(const _iq angle_pu, MATH_vec2 *pPhasor)
Computes a phasor for a given angle.
Definition: 32b/ctrl.h:2040
void EST_updateId_ref_pu(EST_Handle handle, _iq *pId_ref_pu)
Updates the Id reference value used for online stator resistance estimation in per unit (pu)...
uint_least16_t numIsrTicksPerCtrlTick
Defines the number of isr clock ticks per controller clock tick.
Definition: 32b/ctrl_obj.h:195
MOTOR_Type_e CTRL_getMotorType(CTRL_Handle handle)
Gets the motor type from the controller.
Definition: 32b/ctrl.h:569
_iq CTRL_getRefValue_pu(CTRL_Handle handle, const CTRL_Type_e ctrlType)
Gets the reference value from the specified controller.
Definition: 32b/ctrl.h:625
float_t Rhf
the Rhf value
Definition: 32b/ctrl_obj.h:227
void CTRL_setRoverL(CTRL_Handle handle, const float_t RoverL)
Sets the R/L value in the controller.
Definition: 32b/ctrl.h:1684
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
_iq Ki_spd
the desired Ki_spd value
Definition: 32b/ctrl_obj.h:237
TRAJ_Obj traj_spd
the speed trajectory generator object
Definition: 32b/ctrl_obj.h:184
float_t Lhf
the Lhf value
Definition: 32b/ctrl_obj.h:228
bool CTRL_getFlag_enablePowerWarp(CTRL_Handle handle)
Gets the PowerWarp enable flag value from the estimator.
Definition: 32b/ctrl.h:237
void CTRL_runOnLine_User(CTRL_Handle handle, const HAL_AdcData_t *pAdcData, HAL_PwmData_t *pPwmData, uint32_t electricalAngle)
Runs the online user controller.
Definition: ctrlQEP.h:2064
void CTRL_incrCounter_traj(CTRL_Handle handle)
Increments the trajectory counter.
Definition: 32b/ctrl.h:1021
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
_iq Ui_Id
the desired Ui_Id value
Definition: 32b/ctrl_obj.h:243
bool flag_enableSpeedCtrl
a flag to enable the speed controller
Definition: 32b/ctrl_obj.h:267
_iq CTRL_getVq_out_pu(CTRL_Handle handle)
Gets the quadrature voltage output value from the controller.
Definition: 32b/ctrl.h:921
uint_least16_t CTRL_getNumCtrlTicksPerCurrentTick(CTRL_Handle handle)
Gets the number of controller clock ticks per current controller clock tick.
Definition: 32b/ctrl.h:580
#define GLOBAL_Q
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
void CTRL_setSpd_ref_krpm(CTRL_Handle handle, const _iq spd_ref_krpm)
Sets the output speed reference value in the controller.
Definition: 32b/ctrl.c:475
static void PID_setKp(PID_Handle handle, const _iq Kp)
Sets the proportional gain in the PID controller.
Definition: 32b/pid.h:342
void CTRL_setupClarke_I(CTRL_Handle handle, uint_least8_t numCurrentSensors)
Sets the number of current sensors.
Definition: 32b/ctrl.c:513
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
float float_t
Defines the portable data type for 32 bit, signed floating-point data.
Definition: types.h:121
void CTRL_setupCtrl(CTRL_Handle handle)
Sets up the controllers.
Defines the hardware abstraction layer (HAL) data.
void CTRL_runOnLine(CTRL_Handle handle, const HAL_AdcData_t *pAdcData, HAL_PwmData_t *pPwmData)
Runs the online controller.
Definition: 32b/ctrl.h:2158
MATH_vec2 * CTRL_getVab_in_addr(CTRL_Handle handle)
Gets the alpha/beta voltage input vector memory address from the controller.
Definition: 32b/ctrl.h:831
static void PID_run(PID_Handle handle, const _iq refValue, const _iq fbackValue, _iq *pOutValue)
Runs the PID controller.
Definition: 32b/pid.h:231
void EST_run(EST_Handle handle, const MATH_vec2 *pIab_pu, const MATH_vec2 *pVab_pu, const _iq dcBus_pu, const _iq speed_ref_pu)
Runs the estimator.
SVGEN_Handle svgenHandle
the handle for the space vector generator
Definition: 32b/ctrl_obj.h:177
bool CTRL_getFlag_enableOffset(CTRL_Handle handle)
Gets the enable offset flag value from the controller.
Definition: 32b/ctrl.h:248