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