instaspin_foc
Modules | Macros | Functions | Variables
PROJ_LAB05b

Modules

 Project Overview
 

Macros

#define LED_BLINK_FREQ_Hz   5
 
#define LED_BLINK_FREQ_Hz   5
 
#define LED_BLINK_FREQ_Hz   5
 

Functions

void main (void)
 
interrupt void mainISR (void)
 The main interrupt service (ISR) routine. More...
 
void updateGlobalVariables_motor (CTRL_Handle handle)
 Updates the global motor variables. More...
 
void updateKpKiGains (CTRL_Handle handle)
 Updates Kp and Ki gains in the controller object. More...
 
void setupClarke_I (CLARKE_Handle handle, const uint_least8_t numCurrentSensors)
 Sets the number of current sensors. More...
 
void setupClarke_V (CLARKE_Handle handle, const uint_least8_t numVoltageSensors)
 Sets the number of voltage sensors. More...
 

Variables

uint_least16_t gCounter_updateGlobals = 0
 A counter that is denotes when to update the global variables. More...
 
bool Flag_Latch_softwareUpdate = true
 
CTRL_Handle ctrlHandle
 The controller handle. More...
 
HAL_Handle halHandle
 The hal handle. More...
 
USER_Params gUserParams
 The user parameters. More...
 
HAL_PwmData_t gPwmData = {_IQ(0.0), _IQ(0.0), _IQ(0.0)}
 Defines the PWM data. More...
 
HAL_AdcData_t gAdcData
 Defines the ADC data. More...
 
_iq gMaxCurrentSlope = _IQ(0.0)
 
CTRL_Obj ctrl
 Defines the CTRL object. More...
 
uint16_t gLEDcnt = 0
 
volatile MOTOR_Vars_t gMotorVars = MOTOR_Vars_INIT
 
_iq gFlux_pu_to_Wb_sf
 
_iq gFlux_pu_to_VpHz_sf
 
_iq gTorque_Ls_Id_Iq_pu_to_Nm_sf
 
_iq gTorque_Flux_Iq_pu_to_Nm_sf
 
uint_least16_t gCounter_updateGlobals = 0
 A counter that is denotes when to update the global variables. More...
 
bool Flag_Latch_softwareUpdate = true
 
MATH_vec3 gAdcBiasI
 
MATH_vec3 gAdcBiasV
 
CTRL_Handle ctrlHandle
 The controller handle. More...
 
CLARKE_Handle clarkeHandle_I
 the handle for the current Clarke transform More...
 
CLARKE_Obj clarke_I
 the current Clarke transform object More...
 
CLARKE_Handle clarkeHandle_V
 the handle for the voltage Clarke transform More...
 
CLARKE_Obj clarke_V
 the voltage Clarke transform object More...
 
EST_Handle estHandle
 the handle for the estimator More...
 
IPARK_Handle iparkHandle
 the handle for the inverse Park transform More...
 
IPARK_Obj ipark
 the inverse Park transform object More...
 
PARK_Handle parkHandle
 the handle for the Park object More...
 
PARK_Obj park
 the Park transform object More...
 
SVGEN_Handle svgenHandle
 the handle for the space vector generator More...
 
SVGEN_Obj svgen
 the space vector generator object More...
 
HAL_Handle halHandle
 The hal handle. More...
 
USER_Params gUserParams
 The user parameters. More...
 
HAL_PwmData_t gPwmData = {_IQ(0.0), _IQ(0.0), _IQ(0.0)}
 Defines the PWM data. More...
 
HAL_AdcData_t gAdcData
 Defines the ADC data. More...
 
_iq gMaxCurrentSlope = _IQ(0.0)
 
CTRL_Obj ctrl
 Defines the CTRL object. More...
 
uint16_t gLEDcnt = 0
 
volatile MOTOR_Vars_t gMotorVars = MOTOR_Vars_INIT
 
_iq gFlux_pu_to_Wb_sf
 
_iq gFlux_pu_to_VpHz_sf
 
_iq gTorque_Ls_Id_Iq_pu_to_Nm_sf
 
_iq gTorque_Flux_Iq_pu_to_Nm_sf
 
uint_least16_t gCounter_updateGlobals = 0
 A counter that is denotes when to update the global variables. More...
 
bool Flag_Latch_softwareUpdate = true
 
MATH_vec3 gAdcBiasI
 
MATH_vec3 gAdcBiasV
 
CTRL_Handle ctrlHandle
 The controller handle. More...
 
CLARKE_Handle clarkeHandle_I
 the handle for the current Clarke transform More...
 
CLARKE_Obj clarke_I
 the current Clarke transform object More...
 
CLARKE_Handle clarkeHandle_V
 the handle for the voltage Clarke transform More...
 
CLARKE_Obj clarke_V
 the voltage Clarke transform object More...
 
EST_Handle estHandle
 the handle for the estimator More...
 
IPARK_Handle iparkHandle
 the handle for the inverse Park transform More...
 
IPARK_Obj ipark
 the inverse Park transform object More...
 
PARK_Handle parkHandle
 the handle for the Park object More...
 
PARK_Obj park
 the Park transform object More...
 
SVGEN_Handle svgenHandle
 the handle for the space vector generator More...
 
SVGEN_Obj svgen
 the space vector generator object More...
 
IPD_HFI_Handle ipdHandle
 the handle for the ipd algorithm More...
 
AFSEL_Handle afselHandle
 the handle for the afselect general algorithm More...
 
FStart_Handle fstartHandle
 the handle for the flying start algorithm More...
 
TRAJ_Handle trajHandle_Iq
 the trajectory handle for the Iq current reference More...
 
TRAJ_Obj traj_Iq
 the trajectory for Iq current reference More...
 
HAL_Handle halHandle
 The hal handle. More...
 
USER_Params gUserParams
 The user parameters. More...
 
HAL_PwmData_t gPwmData = {_IQ(0.0), _IQ(0.0), _IQ(0.0)}
 Defines the PWM data. More...
 
HAL_AdcData_t gAdcData
 Defines the ADC data. More...
 
_iq gMaxCurrentSlope = _IQ(0.0)
 
CTRL_Obj ctrl
 Defines the CTRL object. More...
 
uint16_t gLEDcnt = 0
 
volatile MOTOR_Vars_t gMotorVars = MOTOR_Vars_INIT
 
_iq gFlux_pu_to_Wb_sf
 
_iq gFlux_pu_to_VpHz_sf
 
_iq gTorque_Ls_Id_Iq_pu_to_Nm_sf
 
_iq gTorque_Flux_Iq_pu_to_Nm_sf
 
_iq gUi = _IQ(0.0)
 
_iq gThrottle_Result = _IQ(0.0)
 
bool flag_update_ipd = false
 

Detailed Description

Macro Definition Documentation

#define LED_BLINK_FREQ_Hz   5

Definition at line 62 of file proj_lab05b.c.

Referenced by mainISR().

#define LED_BLINK_FREQ_Hz   5

Definition at line 64 of file proj_lab20.c.

Referenced by mainISR().

#define LED_BLINK_FREQ_Hz   5

Definition at line 67 of file proj_lab21.c.

Function Documentation

void main ( void  )

Definition at line 136 of file proj_lab05b.c.

References _IQ, _IQmpy, CTRL_getFlag_enableUserMotorParams(), CTRL_getKi(), CTRL_getKp(), CTRL_getState(), CTRL_getVersion(), CTRL_initCtrl(), CTRL_isError(), CTRL_setFlag_enableCtrl(), CTRL_setFlag_enableDcBusComp(), CTRL_setFlag_enableOffset(), CTRL_setFlag_enablePowerWarp(), CTRL_setFlag_enableSpeedCtrl(), CTRL_setFlag_enableUserMotorParams(), CTRL_setMaxAccel_pu(), CTRL_setParams(), CTRL_setSpd_ref_krpm(), CTRL_updateState(), _MOTOR_Vars_t_::CtrlVersion, EST_getMaxCurrentSlope_pu(), EST_isMotorIdentified(), EST_setFlag_enableForceAngle(), EST_setFlag_enableRsRecalc(), EST_setMaxCurrentSlope_pu(), _CTRL_Obj_::estHandle, _MOTOR_Vars_t_::Flag_enableForceAngle, _MOTOR_Vars_t_::Flag_enableOffsetcalc, _MOTOR_Vars_t_::Flag_enablePowerWarp, _MOTOR_Vars_t_::Flag_enableRsRecalc, _MOTOR_Vars_t_::Flag_enableSys, _MOTOR_Vars_t_::Flag_enableUserParams, Flag_Latch_softwareUpdate, _MOTOR_Vars_t_::Flag_MotorIdentified, _MOTOR_Vars_t_::Flag_Run_Identify, gCounter_updateGlobals, gFlux_pu_to_VpHz_sf, gFlux_pu_to_Wb_sf, gMaxCurrentSlope, gTorque_Flux_Iq_pu_to_Nm_sf, gTorque_Ls_Id_Iq_pu_to_Nm_sf, hal, HAL_disablePwm(), HAL_enableAdcInts(), HAL_enableDebugInt(), HAL_enableDrv(), HAL_enableGlobalInts(), HAL_enablePwm(), HAL_getBias(), HAL_init(), HAL_initIntVectorTable(), HAL_readDrvData(), HAL_setBias(), HAL_setParams(), HAL_setupDrvSpi(), HAL_setupFaults(), HAL_updateAdcBias(), HAL_writeDrvData(), I_A_offset, I_B_offset, _MOTOR_Vars_t_::I_bias, I_C_offset, _MOTOR_Vars_t_::Ki_Idq, _MOTOR_Vars_t_::Ki_spd, _MOTOR_Vars_t_::Kp_Idq, _MOTOR_Vars_t_::Kp_spd, MAX_ACCEL_KRPMPS_SF, _MOTOR_Vars_t_::MaxAccel_krpmps, memCopy(), _CTRL_Version_::minor, NUM_MAIN_TICKS_FOR_GLOBAL_VARIABLE_UPDATE, _MOTOR_Vars_t_::SpeedRef_krpm, updateGlobalVariables_motor(), updateKpKiGains(), USER_calcPIgains(), USER_checkForErrors(), USER_computeFlux_pu_to_VpHz_sf(), USER_computeFlux_pu_to_Wb_sf(), USER_computeTorque_Flux_Iq_pu_to_Nm_sf(), USER_computeTorque_Ls_Id_Iq_pu_to_Nm_sf(), USER_getErrorCode(), USER_setParams(), USER_softwareUpdate1p6(), _MOTOR_Vars_t_::UserErrorCode, V_A_offset, V_B_offset, _MOTOR_Vars_t_::V_bias, V_C_offset, and _MATH_vec3_::value.

interrupt void mainISR ( void  )

The main interrupt service (ISR) routine.

Definition at line 457 of file proj_lab05b.c.

References CTRL_run(), CTRL_setup(), gLEDcnt, HAL_acqAdcInt(), HAL_readAdcData(), HAL_toggleLed, HAL_writePwmData(), LED_BLINK_FREQ_Hz, and USER_ISR_FREQ_Hz.

void setupClarke_I ( CLARKE_Handle  handle,
const uint_least8_t  numCurrentSensors 
)

Sets the number of current sensors.

Sets up the Clarke transform for current.

Parameters
[in]handleThe Clarke (CLARKE) handle
[in]numCurrentSensorsThe number of current sensors

Sets the number of current sensors.

Parameters
[in]handleThe clarke (CLARKE) handle
[in]numCurrentSensorsThe number of current sensors

Definition at line 647 of file proj_lab20.c.

References _IQ, CLARKE_setNumSensors(), CLARKE_setScaleFactors(), MATH_ONE_OVER_SQRT_THREE, and MATH_ONE_OVER_THREE.

void setupClarke_V ( CLARKE_Handle  handle,
const uint_least8_t  numVoltageSensors 
)

Sets the number of voltage sensors.

Sets up the Clarke transform for voltage.

Parameters
[in]handleThe Clarke (CLARKE) handle
[in]numVoltageSensorsThe number of voltage sensors

Sets the number of voltage sensors.

Parameters
[in]handleThe clarke (CLARKE) handle
[in]numVoltageSensorsThe number of voltage sensors

Definition at line 677 of file proj_lab20.c.

References _IQ, CLARKE_setNumSensors(), CLARKE_setScaleFactors(), MATH_ONE_OVER_SQRT_THREE, and MATH_ONE_OVER_THREE.

void updateGlobalVariables_motor ( CTRL_Handle  handle)
void updateKpKiGains ( CTRL_Handle  handle)

Variable Documentation

AFSEL_Handle afselHandle

the handle for the afselect general algorithm

Definition at line 100 of file proj_lab21.c.

CLARKE_Obj clarke_I

the current Clarke transform object

Definition at line 79 of file proj_lab20.c.

CLARKE_Obj clarke_I

the current Clarke transform object

Definition at line 82 of file proj_lab21.c.

CLARKE_Obj clarke_V

the voltage Clarke transform object

Definition at line 82 of file proj_lab20.c.

CLARKE_Obj clarke_V

the voltage Clarke transform object

Definition at line 85 of file proj_lab21.c.

CLARKE_Handle clarkeHandle_I

the handle for the current Clarke transform

Definition at line 78 of file proj_lab20.c.

CLARKE_Handle clarkeHandle_I

the handle for the current Clarke transform

Definition at line 81 of file proj_lab21.c.

CLARKE_Handle clarkeHandle_V

the handle for the voltage Clarke transform

Definition at line 81 of file proj_lab20.c.

CLARKE_Handle clarkeHandle_V

the handle for the voltage Clarke transform

Definition at line 84 of file proj_lab21.c.

CTRL_Obj ctrl

Defines the CTRL object.

Defines the CTRL object.

Definition at line 96 of file proj_lab05b.c.

CTRL_Obj ctrl

Defines the CTRL object.

Defines the CTRL object.

Definition at line 117 of file proj_lab20.c.

CTRL_Obj ctrl

Defines the CTRL object.

Defines the CTRL object.

Definition at line 120 of file proj_lab21.c.

CTRL_Handle ctrlHandle

The controller handle.

The controller handle.

Definition at line 72 of file proj_lab05b.c.

CTRL_Handle ctrlHandle

The controller handle.

The controller handle.

Definition at line 76 of file proj_lab20.c.

CTRL_Handle ctrlHandle

The controller handle.

The controller handle.

Definition at line 79 of file proj_lab21.c.

Referenced by main().

EST_Handle estHandle

the handle for the estimator

Definition at line 84 of file proj_lab20.c.

Referenced by mainISR().

EST_Handle estHandle

the handle for the estimator

Definition at line 87 of file proj_lab21.c.

bool Flag_Latch_softwareUpdate = true

Definition at line 70 of file proj_lab05b.c.

Referenced by main(), and updateKpKiGains().

bool Flag_Latch_softwareUpdate = true

Definition at line 72 of file proj_lab20.c.

Referenced by updateKpKiGains().

bool Flag_Latch_softwareUpdate = true

Definition at line 75 of file proj_lab21.c.

bool flag_update_ipd = false

Definition at line 149 of file proj_lab21.c.

FStart_Handle fstartHandle

the handle for the flying start algorithm

Definition at line 102 of file proj_lab21.c.

MATH_vec3 gAdcBiasI

Definition at line 74 of file proj_lab20.c.

MATH_vec3 gAdcBiasI

Definition at line 77 of file proj_lab21.c.

MATH_vec3 gAdcBiasV

Definition at line 75 of file proj_lab20.c.

MATH_vec3 gAdcBiasV

Definition at line 78 of file proj_lab21.c.

HAL_AdcData_t gAdcData

Defines the ADC data.

Definition at line 86 of file proj_lab05b.c.

HAL_AdcData_t gAdcData

Defines the ADC data.

contains three current values, three voltage values and one DC buss value

Defines the ADC data.

Definition at line 107 of file proj_lab20.c.

HAL_AdcData_t gAdcData

Defines the ADC data.

contains three current values, three voltage values and one DC buss value

Defines the ADC data.

Definition at line 113 of file proj_lab21.c.

uint_least16_t gCounter_updateGlobals = 0

A counter that is denotes when to update the global variables.

Definition at line 68 of file proj_lab05b.c.

Referenced by main().

uint_least16_t gCounter_updateGlobals = 0

A counter that is denotes when to update the global variables.

Definition at line 70 of file proj_lab20.c.

uint_least16_t gCounter_updateGlobals = 0

A counter that is denotes when to update the global variables.

Definition at line 73 of file proj_lab21.c.

_iq gFlux_pu_to_VpHz_sf

Definition at line 127 of file proj_lab05b.c.

Referenced by main().

_iq gFlux_pu_to_VpHz_sf

Definition at line 140 of file proj_lab21.c.

_iq gFlux_pu_to_VpHz_sf

Definition at line 148 of file proj_lab20.c.

_iq gFlux_pu_to_Wb_sf

Definition at line 125 of file proj_lab05b.c.

Referenced by main(), and updateGlobalVariables_motor().

_iq gFlux_pu_to_Wb_sf

Definition at line 138 of file proj_lab21.c.

_iq gFlux_pu_to_Wb_sf

Definition at line 146 of file proj_lab20.c.

Referenced by updateGlobalVariables_motor().

uint16_t gLEDcnt = 0

Definition at line 99 of file proj_lab05b.c.

Referenced by mainISR().

uint16_t gLEDcnt = 0

Definition at line 120 of file proj_lab20.c.

Referenced by mainISR().

uint16_t gLEDcnt = 0

Definition at line 123 of file proj_lab21.c.

_iq gMaxCurrentSlope = _IQ(0.0)

Definition at line 88 of file proj_lab05b.c.

Referenced by main().

_iq gMaxCurrentSlope = _IQ(0.0)

Definition at line 109 of file proj_lab20.c.

_iq gMaxCurrentSlope = _IQ(0.0)

Definition at line 115 of file proj_lab21.c.

volatile MOTOR_Vars_t gMotorVars = MOTOR_Vars_INIT

Definition at line 101 of file proj_lab05b.c.

volatile MOTOR_Vars_t gMotorVars = MOTOR_Vars_INIT

Definition at line 122 of file proj_lab20.c.

volatile MOTOR_Vars_t gMotorVars = MOTOR_Vars_INIT

Definition at line 125 of file proj_lab21.c.

HAL_PwmData_t gPwmData = {_IQ(0.0), _IQ(0.0), _IQ(0.0)}

Defines the PWM data.

Definition at line 84 of file proj_lab05b.c.

HAL_PwmData_t gPwmData = {_IQ(0.0), _IQ(0.0), _IQ(0.0)}

Defines the PWM data.

contains the pwm values for each phase. -1.0 is 0%, 1.0 is 100%

Defines the PWM data.

Definition at line 105 of file proj_lab20.c.

HAL_PwmData_t gPwmData = {_IQ(0.0), _IQ(0.0), _IQ(0.0)}

Defines the PWM data.

contains the pwm values for each phase. -1.0 is 0%, 1.0 is 100%

Defines the PWM data.

Definition at line 111 of file proj_lab21.c.

_iq gThrottle_Result = _IQ(0.0)

Definition at line 147 of file proj_lab21.c.

_iq gTorque_Flux_Iq_pu_to_Nm_sf

Definition at line 131 of file proj_lab05b.c.

Referenced by main(), and updateGlobalVariables_motor().

_iq gTorque_Flux_Iq_pu_to_Nm_sf

Definition at line 144 of file proj_lab21.c.

_iq gTorque_Flux_Iq_pu_to_Nm_sf

Definition at line 152 of file proj_lab20.c.

Referenced by updateGlobalVariables_motor().

_iq gTorque_Ls_Id_Iq_pu_to_Nm_sf

Definition at line 129 of file proj_lab05b.c.

Referenced by main(), and updateGlobalVariables_motor().

_iq gTorque_Ls_Id_Iq_pu_to_Nm_sf

Definition at line 142 of file proj_lab21.c.

_iq gTorque_Ls_Id_Iq_pu_to_Nm_sf

Definition at line 150 of file proj_lab20.c.

Referenced by updateGlobalVariables_motor().

_iq gUi = _IQ(0.0)

Definition at line 146 of file proj_lab21.c.

USER_Params gUserParams

The user parameters.

Definition at line 82 of file proj_lab05b.c.

USER_Params gUserParams

The user parameters.

Definition at line 103 of file proj_lab20.c.

USER_Params gUserParams

The user parameters.

Definition at line 109 of file proj_lab21.c.

HAL_Handle halHandle

The hal handle.

The hal handle.

Definition at line 77 of file proj_lab05b.c.

HAL_Handle halHandle

The hal handle.

The hal handle.

the handle for the hardware abstraction layer (HAL)

Definition at line 98 of file proj_lab20.c.

HAL_Handle halHandle

The hal handle.

The hal handle.

the handle for the hardware abstraction layer (HAL)

Definition at line 107 of file proj_lab21.c.

IPARK_Obj ipark

the inverse Park transform object

Definition at line 87 of file proj_lab20.c.

IPARK_Obj ipark

the inverse Park transform object

Definition at line 90 of file proj_lab21.c.

IPARK_Handle iparkHandle

the handle for the inverse Park transform

Definition at line 86 of file proj_lab20.c.

IPARK_Handle iparkHandle

the handle for the inverse Park transform

Definition at line 89 of file proj_lab21.c.

IPD_HFI_Handle ipdHandle

the handle for the ipd algorithm

Definition at line 98 of file proj_lab21.c.

PARK_Obj park

the Park transform object

Definition at line 90 of file proj_lab20.c.

PARK_Obj park

the Park transform object

Definition at line 93 of file proj_lab21.c.

PARK_Handle parkHandle

the handle for the Park object

Definition at line 89 of file proj_lab20.c.

PARK_Handle parkHandle

the handle for the Park object

Definition at line 92 of file proj_lab21.c.

SVGEN_Obj svgen

the space vector generator object

Definition at line 93 of file proj_lab20.c.

SVGEN_Obj svgen

the space vector generator object

Definition at line 96 of file proj_lab21.c.

SVGEN_Handle svgenHandle

the handle for the space vector generator

Definition at line 92 of file proj_lab20.c.

SVGEN_Handle svgenHandle

the handle for the space vector generator

Definition at line 95 of file proj_lab21.c.

TRAJ_Obj traj_Iq

the trajectory for Iq current reference

Definition at line 105 of file proj_lab21.c.

TRAJ_Handle trajHandle_Iq

the trajectory handle for the Iq current reference

Definition at line 104 of file proj_lab21.c.