instaspin_foc
proj_lab04a.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 
106 
108 
110 
112 
113 // **************************************************************************
114 // the functions
115 
116 void main(void)
117 {
118  uint_least8_t estNumber = 0;
119 
120 #ifdef FAST_ROM_V1p6
121  uint_least8_t ctrlNumber = 0;
122 #endif
123 
124  // Only used if running from FLASH
125  // Note that the variable FLASH is defined by the project
126  #ifdef FLASH
127  // Copy time critical code and Flash setup code to RAM
128  // The RamfuncsLoadStart, RamfuncsLoadEnd, and RamfuncsRunStart
129  // symbols are created by the linker. Refer to the linker files.
130  memCopy((uint16_t *)&RamfuncsLoadStart,(uint16_t *)&RamfuncsLoadEnd,(uint16_t *)&RamfuncsRunStart);
131  #endif
132 
133  // initialize the hardware abstraction layer
134  halHandle = HAL_init(&hal,sizeof(hal));
135 
136 
137  // check for errors in user parameters
138  USER_checkForErrors(&gUserParams);
139 
140 
141  // store user parameter error in global variable
142  gMotorVars.UserErrorCode = USER_getErrorCode(&gUserParams);
143 
144 
145  // do not allow code execution if there is a user parameter error
146  if(gMotorVars.UserErrorCode != USER_ErrorCode_NoError)
147  {
148  for(;;)
149  {
150  gMotorVars.Flag_enableSys = false;
151  }
152  }
153 
154 
155  // initialize the user parameters
156  USER_setParams(&gUserParams);
157 
158 
159  // set the hardware abstraction layer parameters
160  HAL_setParams(halHandle,&gUserParams);
161 
162 
163  // initialize the controller
164 #ifdef FAST_ROM_V1p6
165  ctrlHandle = CTRL_initCtrl(ctrlNumber, estNumber); //v1p6 format (06xF and 06xM devices)
166  controller_obj = (CTRL_Obj *)ctrlHandle;
167 #else
168  ctrlHandle = CTRL_initCtrl(estNumber,&ctrl,sizeof(ctrl)); //v1p7 format default
169 #endif
170 
171 
172  {
173  CTRL_Version version;
174 
175  // get the version number
176  CTRL_getVersion(ctrlHandle,&version);
177 
178  gMotorVars.CtrlVersion = version;
179  }
180 
181 
182  // set the default controller parameters
183  CTRL_setParams(ctrlHandle,&gUserParams);
184 
185 
186  // setup faults
187  HAL_setupFaults(halHandle);
188 
189 
190  // initialize the interrupt vector table
191  HAL_initIntVectorTable(halHandle);
192 
193 
194  // enable the ADC interrupts
195  HAL_enableAdcInts(halHandle);
196 
197 
198  // enable global interrupts
199  HAL_enableGlobalInts(halHandle);
200 
201 
202  // enable debug interrupts
203  HAL_enableDebugInt(halHandle);
204 
205 
206  // disable the PWM
207  HAL_disablePwm(halHandle);
208 
209 
210 #ifdef DRV8301_SPI
211  // turn on the DRV8301 if present
212  HAL_enableDrv(halHandle);
213  // initialize the DRV8301 interface
214  HAL_setupDrvSpi(halHandle,&gDrvSpi8301Vars);
215 #endif
216 
217 
218  // enable DC bus compensation
219  CTRL_setFlag_enableDcBusComp(ctrlHandle, true);
220 
221 
222  // compute scaling factors for flux and torque calculations
227 
228 
229  for(;;)
230  {
231  // Waiting for enable system flag to be set
232  while(!(gMotorVars.Flag_enableSys));
233 
234  // Dis-able the Library internal PI. Iq has no reference now
235  CTRL_setFlag_enableSpeedCtrl(ctrlHandle, false);
236 
237  // loop while the enable system flag is true
238  while(gMotorVars.Flag_enableSys)
239  {
240  CTRL_Obj *obj = (CTRL_Obj *)ctrlHandle;
241 
242  // increment counters
244 
245  // enable/disable the use of motor parameters being loaded from user.h
247 
248  // enable/disable Rs recalibration during motor startup
250 
251  // enable/disable automatic calculation of bias values
252  CTRL_setFlag_enableOffset(ctrlHandle,gMotorVars.Flag_enableOffsetcalc);
253 
254 
255  if(CTRL_isError(ctrlHandle))
256  {
257  // set the enable controller flag to false
258  CTRL_setFlag_enableCtrl(ctrlHandle,false);
259 
260  // set the enable system flag to false
261  gMotorVars.Flag_enableSys = false;
262 
263  // disable the PWM
264  HAL_disablePwm(halHandle);
265  }
266  else
267  {
268  // update the controller state
269  bool flag_ctrlStateChanged = CTRL_updateState(ctrlHandle);
270 
271  // enable or disable the control
272  CTRL_setFlag_enableCtrl(ctrlHandle, gMotorVars.Flag_Run_Identify);
273 
274  if(flag_ctrlStateChanged)
275  {
276  CTRL_State_e ctrlState = CTRL_getState(ctrlHandle);
277 
278  if(ctrlState == CTRL_State_OffLine)
279  {
280  // enable the PWM
281  HAL_enablePwm(halHandle);
282  }
283  else if(ctrlState == CTRL_State_OnLine)
284  {
285  if(gMotorVars.Flag_enableOffsetcalc == true)
286  {
287  // update the ADC bias values
288  HAL_updateAdcBias(halHandle);
289  }
290  else
291  {
292  // set the current bias
293  HAL_setBias(halHandle,HAL_SensorType_Current,0,_IQ(I_A_offset));
294  HAL_setBias(halHandle,HAL_SensorType_Current,1,_IQ(I_B_offset));
295  HAL_setBias(halHandle,HAL_SensorType_Current,2,_IQ(I_C_offset));
296 
297  // set the voltage bias
298  HAL_setBias(halHandle,HAL_SensorType_Voltage,0,_IQ(V_A_offset));
299  HAL_setBias(halHandle,HAL_SensorType_Voltage,1,_IQ(V_B_offset));
300  HAL_setBias(halHandle,HAL_SensorType_Voltage,2,_IQ(V_C_offset));
301  }
302 
303  // Return the bias value for currents
304  gMotorVars.I_bias.value[0] = HAL_getBias(halHandle,HAL_SensorType_Current,0);
305  gMotorVars.I_bias.value[1] = HAL_getBias(halHandle,HAL_SensorType_Current,1);
306  gMotorVars.I_bias.value[2] = HAL_getBias(halHandle,HAL_SensorType_Current,2);
307 
308  // Return the bias value for voltages
309  gMotorVars.V_bias.value[0] = HAL_getBias(halHandle,HAL_SensorType_Voltage,0);
310  gMotorVars.V_bias.value[1] = HAL_getBias(halHandle,HAL_SensorType_Voltage,1);
311  gMotorVars.V_bias.value[2] = HAL_getBias(halHandle,HAL_SensorType_Voltage,2);
312 
313  // enable the PWM
314  HAL_enablePwm(halHandle);
315  }
316  else if(ctrlState == CTRL_State_Idle)
317  {
318  // disable the PWM
319  HAL_disablePwm(halHandle);
320  gMotorVars.Flag_Run_Identify = false;
321  }
322 
323  if((CTRL_getFlag_enableUserMotorParams(ctrlHandle) == true) &&
324  (ctrlState > CTRL_State_Idle) &&
325  (gMotorVars.CtrlVersion.minor == 6))
326  {
327  // call this function to fix 1p6
328  USER_softwareUpdate1p6(ctrlHandle);
329  }
330 
331  }
332  }
333 
334 
336  {
337  // set the current ramp
339  gMotorVars.Flag_MotorIdentified = true;
340 
341 
343  {
345 
346  USER_calcPIgains(ctrlHandle);
347  }
348 
349  }
350  else
351  {
353 
354  // the estimator sets the maximum current slope during identification
356  }
357 
358 
359  // when appropriate, update the global variables
361  {
362  // reset the counter
364 
365  updateGlobalVariables_motor(ctrlHandle);
366  }
367 
368  // update Iq reference
369  updateIqRef(ctrlHandle);
370 
371  // enable/disable the forced angle
373 
374  // enable or disable power warp
375  CTRL_setFlag_enablePowerWarp(ctrlHandle,gMotorVars.Flag_enablePowerWarp);
376 
377 #ifdef DRV8301_SPI
378  HAL_writeDrvData(halHandle,&gDrvSpi8301Vars);
379 
380  HAL_readDrvData(halHandle,&gDrvSpi8301Vars);
381 #endif
382 
383  } // end of while(gFlag_enableSys) loop
384 
385 
386  // disable the PWM
387  HAL_disablePwm(halHandle);
388 
389  // set the default controller parameters (Reset the control to re-identify the motor)
390  CTRL_setParams(ctrlHandle,&gUserParams);
391  gMotorVars.Flag_Run_Identify = false;
392 
393  } // end of for(;;) loop
394 
395 } // end of main() function
396 
397 
398 interrupt void mainISR(void)
399 {
400  // toggle status LED
401  if(gLEDcnt++ > (uint_least32_t)(USER_ISR_FREQ_Hz / LED_BLINK_FREQ_Hz))
402  {
403  HAL_toggleLed(halHandle,(GPIO_Number_e)HAL_Gpio_LED2);
404  gLEDcnt = 0;
405  }
406 
407 
408  // acknowledge the ADC interrupt
409  HAL_acqAdcInt(halHandle,ADC_IntNumber_1);
410 
411 
412  // convert the ADC data
413  HAL_readAdcData(halHandle,&gAdcData);
414 
415 
416  // run the controller
417  CTRL_run(ctrlHandle,halHandle,&gAdcData,&gPwmData);
418 
419 
420  // write the PWM compare values
421  HAL_writePwmData(halHandle,&gPwmData);
422 
423 
424  // setup the controller
425  CTRL_setup(ctrlHandle);
426 
427 
428  return;
429 } // end of mainISR() function
430 
431 
433 {
434  CTRL_Obj *obj = (CTRL_Obj *)handle;
435  int32_t tmp;
436 
437  // get the speed estimate
438  gMotorVars.Speed_krpm = EST_getSpeed_krpm(obj->estHandle);
439 
440  // get the torque estimate
442 
443  // when calling EST_ functions that return a float, and fpu32 is enabled, an integer is needed as a return
444  // so that the compiler reads the returned value from the accumulator instead of fpu32 registers
445  // get the magnetizing current
446  tmp = EST_getIdRated(obj->estHandle);
447  gMotorVars.MagnCurr_A = *((float_t *)&tmp);
448 
449  // get the rotor resistance
450  tmp = EST_getRr_Ohm(obj->estHandle);
451  gMotorVars.Rr_Ohm = *((float_t *)&tmp);
452 
453  // get the stator resistance
454  tmp = EST_getRs_Ohm(obj->estHandle);
455  gMotorVars.Rs_Ohm = *((float_t *)&tmp);
456 
457  // get the stator inductance in the direct coordinate direction
458  tmp = EST_getLs_d_H(obj->estHandle);
459  gMotorVars.Lsd_H = *((float_t *)&tmp);
460 
461  // get the stator inductance in the quadrature coordinate direction
462  tmp = EST_getLs_q_H(obj->estHandle);
463  gMotorVars.Lsq_H = *((float_t *)&tmp);
464 
465  // get the flux in V/Hz in floating point
466  tmp = EST_getFlux_VpHz(obj->estHandle);
467  gMotorVars.Flux_VpHz = *((float_t *)&tmp);
468 
469  // get the flux in Wb in fixed point
470  gMotorVars.Flux_Wb = USER_computeFlux(handle, gFlux_pu_to_Wb_sf);
471 
472  // get the controller state
473  gMotorVars.CtrlState = CTRL_getState(handle);
474 
475  // get the estimator state
476  gMotorVars.EstState = EST_getState(obj->estHandle);
477 
478  // Get the DC buss voltage
479  gMotorVars.VdcBus_kV = _IQmpy(gAdcData.dcBus,_IQ(USER_IQ_FULL_SCALE_VOLTAGE_V/1000.0));
480 
481  return;
482 } // end of updateGlobalVariables_motor() function
483 
484 
486 {
487  _iq iq_ref = _IQmpy(gMotorVars.IqRef_A,_IQ(1.0/USER_IQ_FULL_SCALE_CURRENT_A));
488 
489  // set the speed reference so that the forced angle rotates in the correct direction for startup
490  if(_IQabs(gMotorVars.Speed_krpm) < _IQ(0.01))
491  {
492  if(iq_ref < _IQ(0.0))
493  {
494  CTRL_setSpd_ref_krpm(handle,_IQ(-0.01));
495  }
496  else if(iq_ref > _IQ(0.0))
497  {
498  CTRL_setSpd_ref_krpm(handle,_IQ(0.01));
499  }
500  }
501 
502  // Set the Iq reference that use to come out of the PI speed control
503  CTRL_setIq_ref_pu(handle, iq_ref);
504 
505  return;
506 } // end of updateIqRef() function
507 
508 
510 // end of file
511 
512 
513 
float_t EST_getFlux_VpHz(EST_Handle handle)
void EST_setFlag_enableForceAngle(EST_Handle handle, const bool state)
#define LED_BLINK_FREQ_Hz
Definition: proj_lab04a.c:62
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
_iq USER_computeFlux_pu_to_VpHz_sf(void)
Computes the scale factor needed to convert from per unit to V/Hz.
#define _IQ(A)
interrupt void mainISR(void)
The main interrupt service (ISR) routine.
Definition: proj_lab04a.c:398
bool Flag_Run_Identify
Definition: main.h:137
CTRL_Obj ctrl
Defines the CTRL object.
Definition: proj_lab04a.c:87
_iq EST_getSpeed_krpm(EST_Handle handle)
uint_least16_t gCounter_updateGlobals
A counter that is denotes when to update the global variables.
Definition: proj_lab04a.c:68
_iq gTorque_Flux_Iq_pu_to_Nm_sf
Definition: proj_lab04a.c:111
void USER_calcPIgains(CTRL_Handle handle)
Updates Id and Iq PI gains.
CTRL_State_e CtrlState
Definition: main.h:147
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]
#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)
USER_Params gUserParams
The user parameters.
Definition: proj_lab04a.c:76
void USER_softwareUpdate1p6(CTRL_Handle handle)
Recalculates Inductances with the correct Q Format.
static void HAL_acqAdcInt(HAL_Handle handle, const ADC_IntNumber_e intNumber)
#define USER_IQ_FULL_SCALE_VOLTAGE_V
Defines full scale value for the IQ30 variable of Voltage inside the system.
Definition: user.h:88
uint16_t gLEDcnt
Definition: proj_lab04a.c:90
void memCopy(uint16_t *srcStartAddr, uint16_t *srcEndAddr, uint16_t *dstAddr)
EST_Handle estHandle
bool Flag_enableForceAngle
Definition: main.h:139
void CTRL_setFlag_enableCtrl(CTRL_Handle handle, const bool state)
void CTRL_setFlag_enableSpeedCtrl(CTRL_Handle handle, const bool state)
#define V_B_offset
Definition: user.h:133
long _iq
void USER_setParams(USER_Params *pUserParams)
Sets the user parameter values.
EST_State_e EstState
Definition: main.h:148
float_t Rs_Ohm
Definition: main.h:169
#define HAL_toggleLed
#define V_A_offset
ADC voltage offsets for A, B, and C phases.
Definition: user.h:132
#define I_A_offset
ADC current offsets for A, B, and C phases.
Definition: user.h:125
Defines the structures, global initialization, and functions used in MAIN.
_iq gTorque_Ls_Id_Iq_pu_to_Nm_sf
Definition: proj_lab04a.c:109
_iq USER_computeFlux(CTRL_Handle handle, const _iq sf)
Computes Flux in Wb or V/Hz depending on the scale factor sent as parameter.
void HAL_setupFaults(HAL_Handle handle)
void updateIqRef(CTRL_Handle handle)
Updates Iq reference and also sets the right sign to the speed reference for correct force angle...
Definition: proj_lab04a.c:485
float_t EST_getLs_d_H(EST_Handle handle)
void EST_setFlag_enableRsRecalc(EST_Handle handle, const bool state)
static void HAL_enablePwm(HAL_Handle handle)
void CTRL_setParams(CTRL_Handle handle, USER_Params *pUserParams)
#define _IQmpy(A, B)
USER_ErrorCode_e USER_getErrorCode(USER_Params *pUserParams)
Gets the error code in the user parameters.
void HAL_enableDrv(HAL_Handle handle)
_iq IqRef_A
Definition: main.h:155
_iq VdcBus_kV
Definition: main.h:192
_iq Torque_Nm
Definition: main.h:165
bool Flag_Latch_softwareUpdate
Definition: proj_lab04a.c:70
_iq gMaxCurrentSlope
Definition: proj_lab04a.c:82
void main(void)
Definition: proj_lab04a.c:116
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)
#define I_C_offset
Definition: user.h:127
float_t Flux_VpHz
Definition: main.h:173
bool Flag_enableUserParams
Definition: main.h:142
EST_State_e EST_getState(EST_Handle handle)
bool Flag_enableOffsetcalc
Definition: main.h:143
HAL_Handle halHandle
The hal handle.
Definition: proj_lab04a.c:74
#define I_B_offset
Definition: user.h:126
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
#define _IQabs(A)
CTRL_Handle ctrlHandle
The controller handle.
Definition: proj_lab04a.c:72
#define V_C_offset
Definition: user.h:134
_iq USER_computeTorque_Flux_Iq_pu_to_Nm_sf(void)
Computes the scale factor needed to convert from torque created by flux and Iq, from per unit to Nm...
_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
void updateGlobalVariables_motor(CTRL_Handle handle)
Updates the global motor variables.
Definition: proj_lab04a.c:432
void CTRL_setFlag_enablePowerWarp(CTRL_Handle handle, const bool state)
HAL_PwmData_t gPwmData
Defines the PWM data.
Definition: proj_lab04a.c:78
_iq gFlux_pu_to_VpHz_sf
Definition: proj_lab04a.c:107
#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)
HAL_AdcData_t gAdcData
Defines the ADC data.
Definition: proj_lab04a.c:80
bool EST_isMotorIdentified(EST_Handle handle)
_iq USER_computeTorque_Nm(CTRL_Handle handle, const _iq torque_Flux_sf, const _iq torque_Ls_sf)
Computes Torque in Nm.
void CTRL_setFlag_enableOffset(CTRL_Handle handle, const bool state)
HAL_Handle HAL_init(void *pMemory, const size_t numBytes)
volatile MOTOR_Vars_t gMotorVars
Definition: proj_lab04a.c:92
void CTRL_setFlag_enableDcBusComp(CTRL_Handle handle, const bool state)
_iq EST_getMaxCurrentSlope_pu(EST_Handle handle)
void CTRL_setFlag_enableUserMotorParams(CTRL_Handle handle, const bool state)
#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
void CTRL_setIq_ref_pu(CTRL_Handle handle, const _iq IqRef_pu)
static _iq HAL_getBias(HAL_Handle handle, const HAL_SensorType_e sensorType, uint_least8_t sensorNumber)
bool Flag_enableSys
Definition: main.h:136
MATH_vec3 I_bias
Definition: main.h:198
bool Flag_enableRsRecalc
Definition: main.h:141
static void HAL_initIntVectorTable(HAL_Handle handle)
static void HAL_setBias(HAL_Handle handle, const HAL_SensorType_e sensorType, uint_least8_t sensorNumber, const _iq bias)
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)
void HAL_setParams(HAL_Handle handle, const USER_Params *pUserParams)
void HAL_readDrvData(HAL_Handle handle, DRV_SPI_8301_Vars_t *Spi_8301_Vars)
void USER_checkForErrors(USER_Params *pUserParams)
Checks for errors in the user parameter values.
CTRL_Obj * controller_obj
Definition: proj_lab10c.c:84
_iq Flux_Wb
Definition: main.h:164
GPIO_Number_e
_iq USER_computeTorque_Ls_Id_Iq_pu_to_Nm_sf(void)
Computes the scale factor needed to convert from torque created by Ld, Lq, Id and Iq...
void CTRL_setSpd_ref_krpm(CTRL_Handle handle, const _iq spd_ref_krpm)
_iq USER_computeFlux_pu_to_Wb_sf(void)
Computes the scale factor needed to convert from per unit to Wb.
float float_t
_iq gFlux_pu_to_Wb_sf
Definition: proj_lab04a.c:105