instaspin_foc
proj_lab02b.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--*/
36 
38 
39 
44 
45 // **************************************************************************
46 // the includes
47 
48 // system includes
49 #include <math.h>
50 #include "main.h"
51 
52 #ifdef FLASH
53 #pragma CODE_SECTION(mainISR,"ramfuncs");
54 #endif
55 
56 // Include header files used in the main function
57 
58 
59 // **************************************************************************
60 // the defines
61 
62 #define LED_BLINK_FREQ_Hz 5
63 
64 
65 // **************************************************************************
66 // the globals
67 
68 uint_least16_t gCounter_updateGlobals = 0;
69 
71 
73 
74 #ifdef F2802xF
75 #pragma DATA_SECTION(halHandle,"rom_accessed_data");
76 #endif
78 
79 #ifdef F2802xF
80 #pragma DATA_SECTION(gUserParams,"rom_accessed_data");
81 #endif
83 
84 HAL_PwmData_t gPwmData = {_IQ(0.0), _IQ(0.0), _IQ(0.0)};
85 
87 
89 
90 #ifdef FAST_ROM_V1p6
92 #else
93 #ifdef F2802xF
94 #pragma DATA_SECTION(ctrl,"rom_accessed_data");
95 #endif
96 CTRL_Obj ctrl; //v1p7 format
97 #endif
98 
99 uint16_t gLEDcnt = 0;
100 
102 
103 #ifdef FLASH
104 // Used for running BackGround in flash, and ISR in RAM
105 extern uint16_t *RamfuncsLoadStart, *RamfuncsLoadEnd, *RamfuncsRunStart;
106 
107 #ifdef F2802xF
108 extern uint16_t *econst_start, *econst_end, *econst_ram_load;
109 extern uint16_t *switch_start, *switch_end, *switch_ram_load;
110 #endif
111 
112 #endif
113 
114 
115 #ifdef DRV8301_SPI
116 // Watch window interface to the 8301 SPI
117 DRV_SPI_8301_Vars_t gDrvSpi8301Vars;
118 #endif
119 
120 #ifdef DRV8305_SPI
121 // Watch window interface to the 8305 SPI
122 DRV_SPI_8305_Vars_t gDrvSpi8305Vars;
123 #endif
124 
125 // **************************************************************************
126 // the functions
127 
128 void main(void)
129 {
130  uint_least8_t estNumber = 0;
131 
132 #ifdef FAST_ROM_V1p6
133  uint_least8_t ctrlNumber = 0;
134 #endif
135 
136  // Only used if running from FLASH
137  // Note that the variable FLASH is defined by the project
138  #ifdef FLASH
139  // Copy time critical code and Flash setup code to RAM
140  // The RamfuncsLoadStart, RamfuncsLoadEnd, and RamfuncsRunStart
141  // symbols are created by the linker. Refer to the linker files.
142  memCopy((uint16_t *)&RamfuncsLoadStart,(uint16_t *)&RamfuncsLoadEnd,(uint16_t *)&RamfuncsRunStart);
143 
144  #ifdef F2802xF
145  //copy .econst to unsecure RAM
146  if(*econst_end - *econst_start)
147  {
148  memCopy((uint16_t *)&econst_start,(uint16_t *)&econst_end,(uint16_t *)&econst_ram_load);
149  }
150 
151  //copy .switch ot unsecure RAM
152  if(*switch_end - *switch_start)
153  {
154  memCopy((uint16_t *)&switch_start,(uint16_t *)&switch_end,(uint16_t *)&switch_ram_load);
155  }
156  #endif
157 
158  #endif
159 
160  // initialize the hardware abstraction layer
161  halHandle = HAL_init(&hal,sizeof(hal));
162 
163 
164  // check for errors in user parameters
165  USER_checkForErrors(&gUserParams);
166 
167 
168  // store user parameter error in global variable
169  gMotorVars.UserErrorCode = USER_getErrorCode(&gUserParams);
170 
171 
172  // do not allow code execution if there is a user parameter error
173  if(gMotorVars.UserErrorCode != USER_ErrorCode_NoError)
174  {
175  for(;;)
176  {
177  gMotorVars.Flag_enableSys = false;
178  }
179  }
180 
181 
182  // initialize the user parameters
183  USER_setParams(&gUserParams);
184 
185 
186  // set the hardware abstraction layer parameters
187  HAL_setParams(halHandle,&gUserParams);
188 
189 
190  // initialize the controller
191 #ifdef FAST_ROM_V1p6
192  ctrlHandle = CTRL_initCtrl(ctrlNumber, estNumber); //v1p6 format (06xF and 06xM devices)
193  controller_obj = (CTRL_Obj *)ctrlHandle;
194 #else
195  ctrlHandle = CTRL_initCtrl(estNumber,&ctrl,sizeof(ctrl)); //v1p7 format default
196 #endif
197 
198 
199  {
200  CTRL_Version version;
201 
202  // get the version number
203  CTRL_getVersion(ctrlHandle,&version);
204 
205  gMotorVars.CtrlVersion = version;
206  }
207 
208 
209  // set the default controller parameters
210  CTRL_setParams(ctrlHandle,&gUserParams);
211 
212 
213  // setup faults
214  HAL_setupFaults(halHandle);
215 
216 
217  // initialize the interrupt vector table
218  HAL_initIntVectorTable(halHandle);
219 
220 
221  // enable the ADC interrupts
222  HAL_enableAdcInts(halHandle);
223 
224 
225  // enable global interrupts
226  HAL_enableGlobalInts(halHandle);
227 
228 
229  // enable debug interrupts
230  HAL_enableDebugInt(halHandle);
231 
232 
233  // disable the PWM
234  HAL_disablePwm(halHandle);
235 
236 
237 #ifdef DRV8301_SPI
238  // turn on the DRV8301 if present
239  HAL_enableDrv(halHandle);
240  // initialize the DRV8301 interface
241  HAL_setupDrvSpi(halHandle,&gDrvSpi8301Vars);
242 #endif
243 
244 #ifdef DRV8305_SPI
245  // turn on the DRV8305 if present
246  HAL_enableDrv(halHandle);
247  // initialize the DRV8305 interface
248  HAL_setupDrvSpi(halHandle,&gDrvSpi8305Vars);
249 #endif
250 
251 
252  // enable DC bus compensation
253  CTRL_setFlag_enableDcBusComp(ctrlHandle, true);
254 
255 
256  for(;;)
257  {
258  // Waiting for enable system flag to be set
259  while(!(gMotorVars.Flag_enableSys));
260 
261  // loop while the enable system flag is true
262  while(gMotorVars.Flag_enableSys)
263  {
264  CTRL_Obj *obj = (CTRL_Obj *)ctrlHandle;
265 
266  // increment counters
268 
269 
270  if(CTRL_isError(ctrlHandle))
271  {
272  // set the enable controller flag to false
273  CTRL_setFlag_enableCtrl(ctrlHandle,false);
274 
275  // set the enable system flag to false
276  gMotorVars.Flag_enableSys = false;
277 
278  // disable the PWM
279  HAL_disablePwm(halHandle);
280  }
281  else
282  {
283  // update the controller state
284  bool flag_ctrlStateChanged = CTRL_updateState(ctrlHandle);
285 
286  // enable or disable the control
287  CTRL_setFlag_enableCtrl(ctrlHandle, gMotorVars.Flag_Run_Identify);
288 
289  if(flag_ctrlStateChanged)
290  {
291  CTRL_State_e ctrlState = CTRL_getState(ctrlHandle);
292  EST_State_e estState = EST_getState(obj->estHandle);
293 
294  if(ctrlState == CTRL_State_OffLine)
295  {
296  // enable the PWM
297  HAL_enablePwm(halHandle);
298  }
299  else if(ctrlState == CTRL_State_OnLine)
300  {
301  if((estState < EST_State_LockRotor) || (estState > EST_State_MotorIdentified))
302  {
303  // update the ADC bias values
304  HAL_updateAdcBias(halHandle);
305  }
306 
307  // Return the bias value for currents
308  gMotorVars.I_bias.value[0] = HAL_getBias(halHandle,HAL_SensorType_Current,0);
309  gMotorVars.I_bias.value[1] = HAL_getBias(halHandle,HAL_SensorType_Current,1);
310  gMotorVars.I_bias.value[2] = HAL_getBias(halHandle,HAL_SensorType_Current,2);
311 
312  // Return the bias value for voltages
313  gMotorVars.V_bias.value[0] = HAL_getBias(halHandle,HAL_SensorType_Voltage,0);
314  gMotorVars.V_bias.value[1] = HAL_getBias(halHandle,HAL_SensorType_Voltage,1);
315  gMotorVars.V_bias.value[2] = HAL_getBias(halHandle,HAL_SensorType_Voltage,2);
316 
317  // enable the PWM
318  HAL_enablePwm(halHandle);
319  }
320  else if(ctrlState == CTRL_State_Idle)
321  {
322  // disable the PWM
323  HAL_disablePwm(halHandle);
324  gMotorVars.Flag_Run_Identify = false;
325  }
326 
327  if((CTRL_getFlag_enableUserMotorParams(ctrlHandle) == true) &&
328  (ctrlState > CTRL_State_Idle) &&
329  (gMotorVars.CtrlVersion.minor == 6))
330  {
331  // call this function to fix 1p6
332  USER_softwareUpdate1p6(ctrlHandle);
333  }
334 
335  }
336  }
337 
338 
340  {
341  // set the current ramp
343  gMotorVars.Flag_MotorIdentified = true;
344 
345  // set the speed reference
346  CTRL_setSpd_ref_krpm(ctrlHandle,gMotorVars.SpeedRef_krpm);
347 
348  // set the speed acceleration
350 
352  {
354 
355  USER_calcPIgains(ctrlHandle);
356  }
357 
358  }
359  else
360  {
362 
363  // the estimator sets the maximum current slope during identification
365  }
366 
367 
368  // when appropriate, update the global variables
370  {
371  // reset the counter
373 
374  updateGlobalVariables_motor(ctrlHandle);
375  }
376 
377  // recalculate Kp and Ki gains to fix the R/L limitation of 2000.0, and Kp limit to 0.11
378  recalcKpKi(ctrlHandle);
379 
380  if(CTRL_getMotorType(ctrlHandle) == MOTOR_Type_Induction)
381  {
382  // set electrical frequency limit to zero while identifying an induction motor
383  setFeLimitZero(ctrlHandle);
384 
385  // calculate Dir_qFmt for acim motors
386  acim_Dir_qFmtCalc(ctrlHandle);
387  }
388 
389  // enable/disable the forced angle
391 
392  // enable or disable power warp
393  CTRL_setFlag_enablePowerWarp(ctrlHandle,gMotorVars.Flag_enablePowerWarp);
394 
395 #ifdef DRV8301_SPI
396  HAL_writeDrvData(halHandle,&gDrvSpi8301Vars);
397 
398  HAL_readDrvData(halHandle,&gDrvSpi8301Vars);
399 #endif
400 #ifdef DRV8305_SPI
401  HAL_writeDrvData(halHandle,&gDrvSpi8305Vars);
402 
403  HAL_readDrvData(halHandle,&gDrvSpi8305Vars);
404 #endif
405  } // end of while(gFlag_enableSys) loop
406 
407 
408  // disable the PWM
409  HAL_disablePwm(halHandle);
410 
411  // set the default controller parameters (Reset the control to re-identify the motor)
412  CTRL_setParams(ctrlHandle,&gUserParams);
413  gMotorVars.Flag_Run_Identify = false;
414 
415  } // end of for(;;) loop
416 
417 } // end of main() function
418 
419 
420 interrupt void mainISR(void)
421 {
422  // toggle status LED
423  if(gLEDcnt++ > (uint_least32_t)(USER_ISR_FREQ_Hz / LED_BLINK_FREQ_Hz))
424  {
425  HAL_toggleLed(halHandle,(GPIO_Number_e)HAL_Gpio_LED2);
426  gLEDcnt = 0;
427  }
428 
429 
430  // acknowledge the ADC interrupt
431  HAL_acqAdcInt(halHandle,ADC_IntNumber_1);
432 
433 
434  // convert the ADC data
435  HAL_readAdcData(halHandle,&gAdcData);
436 
437 
438  // run the controller
439  CTRL_run(ctrlHandle,halHandle,&gAdcData,&gPwmData);
440 
441 
442  // write the PWM compare values
443  HAL_writePwmData(halHandle,&gPwmData);
444 
445 
446  // setup the controller
447  CTRL_setup(ctrlHandle);
448 
449 
450  return;
451 } // end of mainISR() function
452 
453 
455 {
456  CTRL_Obj *obj = (CTRL_Obj *)handle;
457 
458  // get the speed estimate
459  gMotorVars.Speed_krpm = EST_getSpeed_krpm(obj->estHandle);
460 
461  // get the real time speed reference coming out of the speed trajectory generator
463 
464  // get the magnetizing current
465  gMotorVars.MagnCurr_A = EST_getIdRated(obj->estHandle);
466 
467  // get the rotor resistance
468  gMotorVars.Rr_Ohm = EST_getRr_Ohm(obj->estHandle);
469 
470  // get the stator resistance
471  gMotorVars.Rs_Ohm = EST_getRs_Ohm(obj->estHandle);
472 
473  // get the stator inductance in the direct coordinate direction
474  gMotorVars.Lsd_H = EST_getLs_d_H(obj->estHandle);
475 
476  // get the stator inductance in the quadrature coordinate direction
477  gMotorVars.Lsq_H = EST_getLs_q_H(obj->estHandle);
478 
479  // get the flux
480  gMotorVars.Flux_VpHz = EST_getFlux_VpHz(obj->estHandle);
481 
482  // get the controller state
483  gMotorVars.CtrlState = CTRL_getState(handle);
484 
485  // get the estimator state
486  gMotorVars.EstState = EST_getState(obj->estHandle);
487 
488  // Get the DC buss voltage
489  gMotorVars.VdcBus_kV = _IQmpy(gAdcData.dcBus,_IQ(USER_IQ_FULL_SCALE_VOLTAGE_V/1000.0));
490 
491  return;
492 } // end of updateGlobalVariables_motor() function
493 
494 
496 {
497  CTRL_Obj *obj = (CTRL_Obj *)handle;
498  EST_State_e EstState = EST_getState(obj->estHandle);
499 
500  if((EST_isMotorIdentified(obj->estHandle) == false) && (EstState == EST_State_Rs))
501  {
502  float_t Lhf = CTRL_getLhf(handle);
503  float_t Rhf = CTRL_getRhf(handle);
504  float_t RhfoverLhf = Rhf/Lhf;
506  _iq Ki = _IQ(RhfoverLhf*USER_CTRL_PERIOD_sec);
507 
508  // set Rhf/Lhf
509  CTRL_setRoverL(handle,RhfoverLhf);
510 
511  // set the controller proportional gains
512  CTRL_setKp(handle,CTRL_Type_PID_Id,Kp);
513  CTRL_setKp(handle,CTRL_Type_PID_Iq,Kp);
514 
515  // set the Id controller gains
516  CTRL_setKi(handle,CTRL_Type_PID_Id,Ki);
517  PID_setKi(obj->pidHandle_Id,Ki);
518 
519  // set the Iq controller gains
520  CTRL_setKi(handle,CTRL_Type_PID_Iq,Ki);
521  PID_setKi(obj->pidHandle_Iq,Ki);
522  }
523 
524  return;
525 } // end of recalcKpKi() function
526 
527 
529 {
530  CTRL_Obj *obj = (CTRL_Obj *)handle;
531  EST_State_e EstState = EST_getState(obj->estHandle);
532 
533  _iq fe_neg_max_pu;
534  _iq fe_pos_min_pu;
535 
536  if((EST_isMotorIdentified(obj->estHandle) == false) && (CTRL_getMotorType(handle) == MOTOR_Type_Induction))
537  {
538  fe_neg_max_pu = _IQ30(0.0);
539 
540  fe_pos_min_pu = _IQ30(0.0);
541  }
542  else
543  {
544  fe_neg_max_pu = _IQ30(-USER_ZEROSPEEDLIMIT);
545 
546  fe_pos_min_pu = _IQ30(USER_ZEROSPEEDLIMIT);
547  }
548 
549  EST_setFe_neg_max_pu(obj->estHandle, fe_neg_max_pu);
550 
551  EST_setFe_pos_min_pu(obj->estHandle, fe_pos_min_pu);
552 
553  return;
554 } // end of setFeLimitZero() function
555 
556 
558 {
559  CTRL_Obj *obj = (CTRL_Obj *)handle;
560  EST_State_e EstState = EST_getState(obj->estHandle);
561 
562  if(EstState == EST_State_IdRated)
563  {
565  }
566 
567  return;
568 } // end of acim_Dir_qFmtCalc() function
569 
570 
572 // end of file
573 
574 
575 
float_t EST_getFlux_VpHz(EST_Handle handle)
void EST_setFlag_enableForceAngle(EST_Handle handle, const bool state)
_iq gMaxCurrentSlope
Definition: proj_lab02b.c:88
#define MAX_ACCEL_KRPMPS_SF
Defines the speed acceleration scale factor.
Definition: float/main.h:37
void HAL_enableGlobalInts(HAL_Handle handle)
void HAL_enableAdcInts(HAL_Handle handle)
USER_ErrorCode_e UserErrorCode
Definition: main.h:150
bool Flag_MotorIdentified
Definition: main.h:138
void CTRL_run(CTRL_Handle handle, HAL_Handle halHandle, const HAL_AdcData_t *pAdcData, HAL_PwmData_t *pPwmData)
float_t Lsq_H
Definition: main.h:172
static void PID_setKi(PID_Handle handle, const _iq Ki)
#define _IQ(A)
void acim_Dir_qFmtCalc(CTRL_Handle handle)
Calculates Dir_qFmt for ACIM.
Definition: proj_lab02b.c:557
bool Flag_Run_Identify
Definition: main.h:137
_iq EST_getSpeed_krpm(EST_Handle handle)
void USER_calcPIgains(CTRL_Handle handle)
Updates Id and Iq PI gains.
CTRL_State_e CtrlState
Definition: main.h:147
void EST_setFe_pos_min_pu(EST_Handle handle, const _iq fe_pos_min_pu)
void EST_setFe_neg_max_pu(EST_Handle handle, const _iq fe_neg_max_pu)
bool Flag_enablePowerWarp
Definition: main.h:144
static void HAL_writePwmData(HAL_Handle handle, HAL_PwmData_t *pPwmData)
void EST_setMaxCurrentSlope_pu(EST_Handle handle, const _iq maxCurrentSlope_pu)
_iq value[3]
float_t CTRL_getLhf(CTRL_Handle handle)
#define NUM_MAIN_TICKS_FOR_GLOBAL_VARIABLE_UPDATE
Defines the number of main iterations before global variables are updated.
Definition: float/main.h:48
void HAL_writeDrvData(HAL_Handle handle, DRV_SPI_8301_Vars_t *Spi_8301_Vars)
bool CTRL_isError(CTRL_Handle handle)
void USER_softwareUpdate1p6(CTRL_Handle handle)
Recalculates Inductances with the correct Q Format.
PID_Handle pidHandle_Id
static void HAL_acqAdcInt(HAL_Handle handle, const ADC_IntNumber_e intNumber)
_iq EST_get_pu_to_krpm_sf(EST_Handle handle)
#define USER_IQ_FULL_SCALE_VOLTAGE_V
Defines full scale value for the IQ30 variable of Voltage inside the system.
Definition: user.h:88
HAL_AdcData_t gAdcData
Defines the ADC data.
Definition: proj_lab02b.c:86
void memCopy(uint16_t *srcStartAddr, uint16_t *srcEndAddr, uint16_t *dstAddr)
EST_Handle estHandle
void CTRL_setKi(CTRL_Handle handle, const CTRL_Type_e ctrlType, const _iq Ki)
bool Flag_enableForceAngle
Definition: main.h:139
#define USER_ZEROSPEEDLIMIT
Defines the low speed limit for the flux integrator, pu.
Definition: user.h:244
void CTRL_setFlag_enableCtrl(CTRL_Handle handle, const bool state)
long _iq
void USER_setParams(USER_Params *pUserParams)
Sets the user parameter values.
EST_State_e EstState
Definition: main.h:148
uint_least8_t EST_computeDirection_qFmt(EST_Handle handle, const float_t flux_max)
float_t Rs_Ohm
Definition: main.h:169
#define HAL_toggleLed
float_t CTRL_getRhf(CTRL_Handle handle)
Defines the structures, global initialization, and functions used in MAIN.
void EST_setDir_qFmt(EST_Handle handle, const uint_least8_t dir_qFmt)
void CTRL_setMaxAccel_pu(CTRL_Handle handle, const _iq maxAccel_pu)
void updateGlobalVariables_motor(CTRL_Handle handle)
Updates the global motor variables.
Definition: proj_lab02b.c:454
void HAL_setupFaults(HAL_Handle handle)
float_t EST_getLs_d_H(EST_Handle handle)
#define LED_BLINK_FREQ_Hz
Definition: proj_lab02b.c:62
static void HAL_enablePwm(HAL_Handle handle)
void CTRL_setParams(CTRL_Handle handle, USER_Params *pUserParams)
#define _IQmpy(A, B)
EST_State_e
USER_ErrorCode_e USER_getErrorCode(USER_Params *pUserParams)
Gets the error code in the user parameters.
void HAL_enableDrv(HAL_Handle handle)
_iq VdcBus_kV
Definition: main.h:192
volatile MOTOR_Vars_t gMotorVars
Definition: proj_lab02b.c:101
_iq SpeedRef_krpm
Definition: main.h:157
void setFeLimitZero(CTRL_Handle handle)
Set electrical frequency limit to zero while identifying an induction motor.
Definition: proj_lab02b.c:528
USER_Params gUserParams
The user parameters.
Definition: proj_lab02b.c:82
void HAL_setupDrvSpi(HAL_Handle handle, DRV_SPI_8301_Vars_t *Spi_8301_Vars)
float_t EST_getLs_q_H(EST_Handle handle)
bool CTRL_getFlag_enableUserMotorParams(CTRL_Handle handle)
void HAL_enableDebugInt(HAL_Handle handle)
CTRL_State_e CTRL_getState(CTRL_Handle handle)
float_t Flux_VpHz
Definition: main.h:173
EST_State_e EST_getState(EST_Handle handle)
void CTRL_setup(CTRL_Handle handle)
MATH_vec3 V_bias
Definition: main.h:199
#define MOTOR_Vars_INIT
Initialization values of global variables.
Definition: main.h:76
CTRL_State_e
void recalcKpKi(CTRL_Handle handle)
Recalculate Kp and Ki gains to fix the R/L limitation of 2000.0 and Kp limitation of 0...
Definition: proj_lab02b.c:495
_iq Speed_krpm
Definition: main.h:160
float_t EST_getIdRated(EST_Handle handle)
float_t Rr_Ohm
Definition: main.h:168
float_t EST_getRs_Ohm(EST_Handle handle)
CTRL_Handle CTRL_initCtrl(const uint_least8_t estNumber, void *pMemory, const size_t numBytes)
float_t Lsd_H
Definition: main.h:171
#define _IQ30(A)
PID_Handle pidHandle_Iq
void CTRL_setFlag_enablePowerWarp(CTRL_Handle handle, const bool state)
#define USER_ISR_FREQ_Hz
Defines the Interrupt Service Routine (ISR) frequency, Hz.
Definition: user.h:173
bool CTRL_updateState(CTRL_Handle handle)
static void HAL_disablePwm(HAL_Handle handle)
bool EST_isMotorIdentified(EST_Handle handle)
HAL_Handle HAL_init(void *pMemory, const size_t numBytes)
void CTRL_setFlag_enableDcBusComp(CTRL_Handle handle, const bool state)
CTRL_Handle ctrlHandle
The controller handle.
Definition: proj_lab02b.c:72
_iq EST_getMaxCurrentSlope_pu(EST_Handle handle)
_iq SpeedTraj_krpm
Definition: main.h:158
#define USER_IQ_FULL_SCALE_CURRENT_A
Defines the full scale current for the IQ variables, A.
Definition: user.h:102
float_t MagnCurr_A
Definition: main.h:167
static void HAL_readAdcData(HAL_Handle handle, HAL_AdcData_t *pAdcData)
HAL_Obj hal
static _iq HAL_getBias(HAL_Handle handle, const HAL_SensorType_e sensorType, uint_least8_t sensorNumber)
bool Flag_enableSys
Definition: main.h:136
_iq MaxAccel_krpmps
Definition: main.h:159
HAL_PwmData_t gPwmData
Defines the PWM data.
Definition: proj_lab02b.c:84
_iq CTRL_getSpd_int_ref_pu(CTRL_Handle handle)
bool Flag_Latch_softwareUpdate
Definition: proj_lab02b.c:70
MATH_vec3 I_bias
Definition: main.h:198
void main(void)
Definition: proj_lab02b.c:128
static void HAL_initIntVectorTable(HAL_Handle handle)
interrupt void mainISR(void)
The main interrupt service (ISR) routine.
Definition: proj_lab02b.c:420
static void HAL_updateAdcBias(HAL_Handle handle)
CTRL_Obj ctrl
Defines the CTRL object.
Definition: proj_lab02b.c:96
void CTRL_getVersion(CTRL_Handle handle, CTRL_Version *pVersion)
uint16_t minor
CTRL_Version CtrlVersion
Definition: main.h:152
uint_least16_t gCounter_updateGlobals
A counter that is denotes when to update the global variables.
Definition: proj_lab02b.c:68
float_t EST_getRr_Ohm(EST_Handle handle)
void HAL_setParams(HAL_Handle handle, const USER_Params *pUserParams)
MOTOR_Type_e CTRL_getMotorType(CTRL_Handle handle)
void HAL_readDrvData(HAL_Handle handle, DRV_SPI_8301_Vars_t *Spi_8301_Vars)
void CTRL_setRoverL(CTRL_Handle handle, const float_t RoverL)
#define USER_CTRL_PERIOD_sec
Defines the controller execution period, sec.
Definition: user.h:231
void USER_checkForErrors(USER_Params *pUserParams)
Checks for errors in the user parameter values.
CTRL_Obj * controller_obj
Definition: proj_lab10c.c:84
GPIO_Number_e
void CTRL_setSpd_ref_krpm(CTRL_Handle handle, const _iq spd_ref_krpm)
HAL_Handle halHandle
The hal handle.
Definition: proj_lab02b.c:77
void CTRL_setKp(CTRL_Handle handle, const CTRL_Type_e ctrlType, const _iq Kp)
float float_t
uint16_t gLEDcnt
Definition: proj_lab02b.c:99