53 #pragma CODE_SECTION(mainISR,"ramfuncs");
62 #define LED_BLINK_FREQ_Hz 5
75 #pragma DATA_SECTION(halHandle,"rom_accessed_data");
80 #pragma DATA_SECTION(gUserParams,"rom_accessed_data");
94 #pragma DATA_SECTION(ctrl,"rom_accessed_data");
105 extern uint16_t *RamfuncsLoadStart, *RamfuncsLoadEnd, *RamfuncsRunStart;
108 extern uint16_t *econst_start, *econst_end, *econst_ram_load;
109 extern uint16_t *switch_start, *switch_end, *switch_ram_load;
138 uint_least8_t estNumber = 0;
141 uint_least8_t ctrlNumber = 0;
150 memCopy((uint16_t *)&RamfuncsLoadStart,(uint16_t *)&RamfuncsLoadEnd,(uint16_t *)&RamfuncsRunStart);
154 if(*econst_end - *econst_start)
156 memCopy((uint16_t *)&econst_start,(uint16_t *)&econst_end,(uint16_t *)&econst_ram_load);
160 if(*switch_end - *switch_start)
162 memCopy((uint16_t *)&switch_start,(uint16_t *)&switch_end,(uint16_t *)&switch_ram_load);
201 controller_obj = (
CTRL_Obj *)ctrlHandle;
306 if(flag_ctrlStateChanged)
310 if(ctrlState == CTRL_State_OffLine)
315 else if(ctrlState == CTRL_State_OnLine)
333 else if(ctrlState == CTRL_State_Idle)
341 (ctrlState > CTRL_State_Idle) &&
440 CTRL_run(ctrlHandle,halHandle,&gAdcData,&gPwmData);
float_t EST_getFlux_VpHz(EST_Handle handle)
void EST_setFlag_enableForceAngle(EST_Handle handle, const bool state)
#define MAX_ACCEL_KRPMPS_SF
Defines the speed acceleration scale factor.
void HAL_enableGlobalInts(HAL_Handle handle)
void HAL_enableAdcInts(HAL_Handle handle)
USER_ErrorCode_e UserErrorCode
bool Flag_MotorIdentified
void CTRL_run(CTRL_Handle handle, HAL_Handle halHandle, const HAL_AdcData_t *pAdcData, HAL_PwmData_t *pPwmData)
_iq USER_computeFlux_pu_to_VpHz_sf(void)
Computes the scale factor needed to convert from per unit to V/Hz.
_iq EST_getSpeed_krpm(EST_Handle handle)
void USER_calcPIgains(CTRL_Handle handle)
Updates Id and Iq PI gains.
USER_Params gUserParams
The user parameters.
bool Flag_enablePowerWarp
static void HAL_writePwmData(HAL_Handle handle, HAL_PwmData_t *pPwmData)
void EST_setMaxCurrentSlope_pu(EST_Handle handle, const _iq maxCurrentSlope_pu)
HAL_AdcData_t gAdcData
Defines the ADC data.
#define NUM_MAIN_TICKS_FOR_GLOBAL_VARIABLE_UPDATE
Defines the number of main iterations before global variables are updated.
void HAL_writeDrvData(HAL_Handle handle, DRV_SPI_8301_Vars_t *Spi_8301_Vars)
bool CTRL_isError(CTRL_Handle handle)
_iq gTorque_Flux_Iq_pu_to_Nm_sf
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)
_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.
void memCopy(uint16_t *srcStartAddr, uint16_t *srcEndAddr, uint16_t *dstAddr)
bool Flag_enableForceAngle
void CTRL_setFlag_enableCtrl(CTRL_Handle handle, const bool state)
interrupt void mainISR(void)
The main interrupt service (ISR) routine.
void USER_setParams(USER_Params *pUserParams)
Sets the user parameter values.
volatile MOTOR_Vars_t gMotorVars
Defines the structures, global initialization, and functions used in MAIN.
void CTRL_setMaxAccel_pu(CTRL_Handle handle, const _iq maxAccel_pu)
_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)
float_t EST_getLs_d_H(EST_Handle handle)
static void HAL_enablePwm(HAL_Handle handle)
void CTRL_setParams(CTRL_Handle handle, USER_Params *pUserParams)
USER_ErrorCode_e USER_getErrorCode(USER_Params *pUserParams)
Gets the error code in the user parameters.
void HAL_enableDrv(HAL_Handle handle)
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)
bool Flag_enableUserParams
EST_State_e EST_getState(EST_Handle handle)
_iq gTorque_Ls_Id_Iq_pu_to_Nm_sf
void CTRL_setup(CTRL_Handle handle)
#define MOTOR_Vars_INIT
Initialization values of global variables.
_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...
float_t EST_getIdRated(EST_Handle handle)
float_t EST_getRs_Ohm(EST_Handle handle)
CTRL_Handle CTRL_initCtrl(const uint_least8_t estNumber, void *pMemory, const size_t numBytes)
void CTRL_setFlag_enablePowerWarp(CTRL_Handle handle, const bool state)
#define USER_ISR_FREQ_Hz
Defines the Interrupt Service Routine (ISR) frequency, Hz.
bool CTRL_updateState(CTRL_Handle handle)
static void HAL_disablePwm(HAL_Handle handle)
bool Flag_Latch_softwareUpdate
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.
HAL_Handle HAL_init(void *pMemory, const size_t numBytes)
HAL_PwmData_t gPwmData
Defines the PWM data.
CTRL_Handle ctrlHandle
The controller handle.
HAL_Handle halHandle
The hal handle.
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)
static void HAL_readAdcData(HAL_Handle handle, HAL_AdcData_t *pAdcData)
static _iq HAL_getBias(HAL_Handle handle, const HAL_SensorType_e sensorType, uint_least8_t sensorNumber)
_iq CTRL_getSpd_int_ref_pu(CTRL_Handle handle)
static void HAL_initIntVectorTable(HAL_Handle handle)
static void HAL_updateAdcBias(HAL_Handle handle)
void CTRL_getVersion(CTRL_Handle handle, CTRL_Version *pVersion)
uint_least16_t gCounter_updateGlobals
A counter that is denotes when to update the global variables.
void updateGlobalVariables_motor(CTRL_Handle handle)
Updates the global motor variables.
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
#define LED_BLINK_FREQ_Hz
_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.
CTRL_Obj ctrl
Defines the CTRL object.