53 #pragma CODE_SECTION(mainISR,"ramfuncs");
62 #define LED_BLINK_FREQ_Hz 5
96 extern uint16_t *RamfuncsLoadStart, *RamfuncsLoadEnd, *RamfuncsRunStart;
110 uint_least8_t estNumber = 0;
113 uint_least8_t ctrlNumber = 0;
122 memCopy((uint16_t *)&RamfuncsLoadStart,(uint16_t *)&RamfuncsLoadEnd,(uint16_t *)&RamfuncsRunStart);
158 controller_obj = (
CTRL_Obj *)ctrlHandle;
247 if(flag_ctrlStateChanged)
252 if(ctrlState == CTRL_State_OffLine)
257 else if(ctrlState == CTRL_State_OnLine)
259 if((estState < EST_State_LockRotor) || (estState > EST_State_MotorIdentified))
278 else if(ctrlState == CTRL_State_Idle)
286 (ctrlState > CTRL_State_Idle) &&
393 CTRL_run(ctrlHandle,halHandle,&gAdcData,&gPwmData);
501 fe_neg_max_pu =
_IQ30(0.0);
503 fe_pos_min_pu =
_IQ30(0.0);
526 if(EstState == EST_State_IdRated)
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)
static void PID_setKi(PID_Handle handle, const _iq Ki)
void recalcKpKi(CTRL_Handle handle)
Recalculate Kp and Ki gains to fix the R/L limitation of 2000.0 and Kp limitation of 0...
void updateGlobalVariables_motor(CTRL_Handle handle)
Updates the global motor variables.
#define LED_BLINK_FREQ_Hz
_iq EST_getSpeed_krpm(EST_Handle handle)
void USER_calcPIgains(CTRL_Handle handle)
Updates Id and Iq PI gains.
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
static void HAL_writePwmData(HAL_Handle handle, HAL_PwmData_t *pPwmData)
void EST_setMaxCurrentSlope_pu(EST_Handle handle, const _iq maxCurrentSlope_pu)
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.
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.
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.
CTRL_Handle ctrlHandle
The controller handle.
void memCopy(uint16_t *srcStartAddr, uint16_t *srcEndAddr, uint16_t *dstAddr)
void CTRL_setKi(CTRL_Handle handle, const CTRL_Type_e ctrlType, const _iq Ki)
bool Flag_enableForceAngle
#define USER_ZEROSPEEDLIMIT
Defines the low speed limit for the flux integrator, pu.
void CTRL_setFlag_enableCtrl(CTRL_Handle handle, const bool state)
void USER_setParams(USER_Params *pUserParams)
Sets the user parameter values.
uint_least8_t EST_computeDirection_qFmt(EST_Handle handle, const float_t flux_max)
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)
uint_least16_t gCounter_updateGlobals
A counter that is denotes when to update the global variables.
USER_Params gUserParams
The user parameters.
void CTRL_setMaxAccel_pu(CTRL_Handle handle, const _iq maxAccel_pu)
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)
HAL_Handle halHandle
The hal 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)
HAL_PwmData_t gPwmData
Defines the PWM data.
CTRL_State_e CTRL_getState(CTRL_Handle handle)
bool Flag_Latch_softwareUpdate
EST_State_e EST_getState(EST_Handle handle)
HAL_AdcData_t gAdcData
Defines the ADC data.
interrupt void mainISR(void)
The main interrupt service (ISR) routine.
void CTRL_setup(CTRL_Handle handle)
#define MOTOR_Vars_INIT
Initialization values of global variables.
void setFeLimitZero(CTRL_Handle handle)
Set electrical frequency limit to zero while identifying an induction motor.
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 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)
CTRL_Obj ctrl
Defines the CTRL object.
#define USER_IQ_FULL_SCALE_CURRENT_A
Defines the full scale current for the IQ variables, A.
static void HAL_readAdcData(HAL_Handle handle, HAL_AdcData_t *pAdcData)
void acim_Dir_qFmtCalc(CTRL_Handle handle)
Calculates Dir_qFmt for ACIM.
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)
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)
volatile MOTOR_Vars_t gMotorVars
#define USER_CTRL_PERIOD_sec
Defines the controller execution period, sec.
void USER_checkForErrors(USER_Params *pUserParams)
Checks for errors in the user parameter values.
CTRL_Obj * controller_obj
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)