53 #pragma CODE_SECTION(mainISR,"ramfuncs");
62 #define LED_BLINK_FREQ_Hz 5
96 extern uint16_t *RamfuncsLoadStart, *RamfuncsLoadEnd, *RamfuncsRunStart;
118 uint_least8_t estNumber = 0;
121 uint_least8_t ctrlNumber = 0;
130 memCopy((uint16_t *)&RamfuncsLoadStart,(uint16_t *)&RamfuncsLoadEnd,(uint16_t *)&RamfuncsRunStart);
166 controller_obj = (
CTRL_Obj *)ctrlHandle;
274 if(flag_ctrlStateChanged)
278 if(ctrlState == CTRL_State_OffLine)
283 else if(ctrlState == CTRL_State_OnLine)
316 else if(ctrlState == CTRL_State_Idle)
324 (ctrlState > CTRL_State_Idle) &&
417 CTRL_run(ctrlHandle,halHandle,&gAdcData,&gPwmData);
492 if(iq_ref <
_IQ(0.0))
496 else if(iq_ref >
_IQ(0.0))
float_t EST_getFlux_VpHz(EST_Handle handle)
void EST_setFlag_enableForceAngle(EST_Handle handle, const bool state)
#define LED_BLINK_FREQ_Hz
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.
interrupt void mainISR(void)
The main interrupt service (ISR) routine.
CTRL_Obj ctrl
Defines the CTRL object.
_iq EST_getSpeed_krpm(EST_Handle handle)
uint_least16_t gCounter_updateGlobals
A counter that is denotes when to update the global variables.
_iq gTorque_Flux_Iq_pu_to_Nm_sf
void USER_calcPIgains(CTRL_Handle handle)
Updates Id and Iq PI gains.
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)
#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)
USER_Params gUserParams
The user parameters.
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.
void memCopy(uint16_t *srcStartAddr, uint16_t *srcEndAddr, uint16_t *dstAddr)
bool Flag_enableForceAngle
void CTRL_setFlag_enableCtrl(CTRL_Handle handle, const bool state)
void CTRL_setFlag_enableSpeedCtrl(CTRL_Handle handle, const bool state)
void USER_setParams(USER_Params *pUserParams)
Sets the user parameter values.
#define V_A_offset
ADC voltage offsets for A, B, and C phases.
#define I_A_offset
ADC current offsets for A, B, and C phases.
Defines the structures, global initialization, and functions used in MAIN.
_iq gTorque_Ls_Id_Iq_pu_to_Nm_sf
_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...
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)
USER_ErrorCode_e USER_getErrorCode(USER_Params *pUserParams)
Gets the error code in the user parameters.
void HAL_enableDrv(HAL_Handle handle)
bool Flag_Latch_softwareUpdate
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)
bool Flag_enableOffsetcalc
HAL_Handle halHandle
The hal handle.
void CTRL_setup(CTRL_Handle handle)
#define MOTOR_Vars_INIT
Initialization values of global variables.
CTRL_Handle ctrlHandle
The controller handle.
_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 updateGlobalVariables_motor(CTRL_Handle handle)
Updates the global motor variables.
void CTRL_setFlag_enablePowerWarp(CTRL_Handle handle, const bool state)
HAL_PwmData_t gPwmData
Defines the PWM data.
#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)
HAL_AdcData_t gAdcData
Defines the ADC data.
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
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.
static void HAL_readAdcData(HAL_Handle handle, HAL_AdcData_t *pAdcData)
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)
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)
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
_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.