instaspin_foc
|
Modules | |
Project Overview | |
Macros | |
#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 | CTRL_resetLs_qFmt (CTRL_Handle handle, const uint_least8_t Ls_qFmt) |
Reset Ls Q format to a higher value when Ls identification starts. More... | |
void | recalcKpKiPmsm (CTRL_Handle handle) |
Recalculate Kp and Ki gains to fix the R/L limitation of 2000.0 and Kp limitation of 0.11. More... | |
void | CTRL_calcMax_Ls_qFmt (CTRL_Handle handle, uint_least8_t *pLs_qFmt) |
Calculates the maximum qFmt value for Ls identification, to get a more accurate Ls per unit. More... | |
void | recalcKpKi (CTRL_Handle handle) |
Recalculate Kp and Ki gains to fix the R/L limitation of 2000.0 and Kp limitation of 0.11. More... | |
void | setFeLimitZero (CTRL_Handle handle) |
Set electrical frequency limit to zero while identifying an induction motor. More... | |
void | acim_Dir_qFmtCalc (CTRL_Handle handle) |
Calculates Dir_qFmt for ACIM. 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 | gLs_pu = _IQ30(0.0) |
uint_least8_t | gLs_qFmt = 0 |
uint_least8_t | gMax_Ls_qFmt = 0 |
#define LED_BLINK_FREQ_Hz 5 |
Definition at line 62 of file proj_lab02c.c.
Referenced by mainISR().
void acim_Dir_qFmtCalc | ( | CTRL_Handle | handle | ) |
Calculates Dir_qFmt for ACIM.
Definition at line 674 of file proj_lab02c.c.
References EST_computeDirection_qFmt(), EST_getState(), EST_setDir_qFmt(), and _CTRL_Obj_::estHandle.
Referenced by main().
void CTRL_calcMax_Ls_qFmt | ( | CTRL_Handle | handle, |
uint_least8_t * | pLs_qFmt | ||
) |
Calculates the maximum qFmt value for Ls identification, to get a more accurate Ls per unit.
Definition at line 594 of file proj_lab02c.c.
References _IQ30toF(), CTRL_getLhf(), EST_getLs_coarse_max_pu(), EST_getState(), EST_isMotorIdentified(), _CTRL_Obj_::estHandle, USER_IQ_FULL_SCALE_CURRENT_A, USER_IQ_FULL_SCALE_VOLTAGE_V, and USER_VOLTAGE_FILTER_POLE_rps.
Referenced by main().
void CTRL_resetLs_qFmt | ( | CTRL_Handle | handle, |
const uint_least8_t | Ls_qFmt | ||
) |
Reset Ls Q format to a higher value when Ls identification starts.
Definition at line 516 of file proj_lab02c.c.
References _IQ30, EST_getLs_d_pu(), EST_getState(), EST_setLs_qFmt(), and _CTRL_Obj_::estHandle.
Referenced by mainISR().
void main | ( | void | ) |
Definition at line 131 of file proj_lab02c.c.
References _IQmpy, acim_Dir_qFmtCalc(), CTRL_calcMax_Ls_qFmt(), CTRL_getFlag_enableUserMotorParams(), CTRL_getMotorType(), CTRL_getState(), CTRL_getVersion(), CTRL_initCtrl(), CTRL_isError(), CTRL_setFlag_enableCtrl(), CTRL_setFlag_enableDcBusComp(), CTRL_setFlag_enablePowerWarp(), CTRL_setMaxAccel_pu(), CTRL_setParams(), CTRL_setSpd_ref_krpm(), CTRL_updateState(), _MOTOR_Vars_t_::CtrlVersion, EST_getLs_d_pu(), EST_getLs_qFmt(), EST_getMaxCurrentSlope_pu(), EST_getState(), EST_isMotorIdentified(), EST_setFlag_enableForceAngle(), EST_setMaxCurrentSlope_pu(), _CTRL_Obj_::estHandle, _MOTOR_Vars_t_::Flag_enableForceAngle, _MOTOR_Vars_t_::Flag_enablePowerWarp, _MOTOR_Vars_t_::Flag_enableSys, Flag_Latch_softwareUpdate, _MOTOR_Vars_t_::Flag_MotorIdentified, _MOTOR_Vars_t_::Flag_Run_Identify, gCounter_updateGlobals, gLs_pu, gLs_qFmt, gMax_Ls_qFmt, gMaxCurrentSlope, hal, HAL_disablePwm(), HAL_enableAdcInts(), HAL_enableDebugInt(), HAL_enableDrv(), HAL_enableGlobalInts(), HAL_enablePwm(), HAL_getBias(), HAL_init(), HAL_initIntVectorTable(), HAL_readDrvData(), HAL_setParams(), HAL_setupDrvSpi(), HAL_setupFaults(), HAL_updateAdcBias(), HAL_writeDrvData(), _MOTOR_Vars_t_::I_bias, MAX_ACCEL_KRPMPS_SF, _MOTOR_Vars_t_::MaxAccel_krpmps, memCopy(), _CTRL_Version_::minor, NUM_MAIN_TICKS_FOR_GLOBAL_VARIABLE_UPDATE, recalcKpKi(), recalcKpKiPmsm(), setFeLimitZero(), _MOTOR_Vars_t_::SpeedRef_krpm, updateGlobalVariables_motor(), USER_calcPIgains(), USER_checkForErrors(), USER_getErrorCode(), USER_setParams(), USER_softwareUpdate1p6(), _MOTOR_Vars_t_::UserErrorCode, _MOTOR_Vars_t_::V_bias, and _MATH_vec3_::value.
interrupt void mainISR | ( | void | ) |
The main interrupt service (ISR) routine.
Definition at line 435 of file proj_lab02c.c.
References CTRL_getMotorType(), CTRL_resetLs_qFmt(), CTRL_run(), CTRL_setup(), gLEDcnt, gMax_Ls_qFmt, HAL_acqAdcInt(), HAL_readAdcData(), HAL_toggleLed, HAL_writePwmData(), LED_BLINK_FREQ_Hz, and USER_ISR_FREQ_Hz.
void recalcKpKi | ( | CTRL_Handle | handle | ) |
Recalculate Kp and Ki gains to fix the R/L limitation of 2000.0 and Kp limitation of 0.11.
Definition at line 612 of file proj_lab02c.c.
References _IQ, CTRL_getLhf(), CTRL_getRhf(), CTRL_setKi(), CTRL_setKp(), CTRL_setRoverL(), EST_getState(), EST_isMotorIdentified(), _CTRL_Obj_::estHandle, PID_setKi(), _CTRL_Obj_::pidHandle_Id, _CTRL_Obj_::pidHandle_Iq, USER_CTRL_PERIOD_sec, USER_IQ_FULL_SCALE_CURRENT_A, and USER_IQ_FULL_SCALE_VOLTAGE_V.
Referenced by main().
void recalcKpKiPmsm | ( | CTRL_Handle | handle | ) |
Recalculate Kp and Ki gains to fix the R/L limitation of 2000.0 and Kp limitation of 0.11.
as well as recalculates gains based on estimator state to allow low inductance pmsm to id
Definition at line 539 of file proj_lab02c.c.
References _IQ, CTRL_getLhf(), CTRL_getRhf(), CTRL_setKi(), CTRL_setKp(), CTRL_setRoverL(), EST_getState(), EST_isMotorIdentified(), _CTRL_Obj_::estHandle, PID_setKi(), PID_setKp(), _CTRL_Obj_::pidHandle_Id, _CTRL_Obj_::pidHandle_Iq, _CTRL_Obj_::pidHandle_spd, TRAJ_setTargetValue(), _CTRL_Obj_::trajHandle_spdMax, USER_CTRL_PERIOD_sec, USER_IQ_FULL_SCALE_CURRENT_A, USER_IQ_FULL_SCALE_FREQ_Hz, USER_IQ_FULL_SCALE_VOLTAGE_V, USER_MOTOR_MAX_CURRENT, and USER_MOTOR_RES_EST_CURRENT.
Referenced by main().
void setFeLimitZero | ( | CTRL_Handle | handle | ) |
Set electrical frequency limit to zero while identifying an induction motor.
Definition at line 645 of file proj_lab02c.c.
References _IQ30, CTRL_getMotorType(), EST_getState(), EST_isMotorIdentified(), EST_setFe_neg_max_pu(), EST_setFe_pos_min_pu(), _CTRL_Obj_::estHandle, and USER_ZEROSPEEDLIMIT.
Referenced by main().
void updateGlobalVariables_motor | ( | CTRL_Handle | handle | ) |
Updates the global motor variables.
Definition at line 475 of file proj_lab02c.c.
References _IQ, _IQmpy, CTRL_getSpd_int_ref_pu(), CTRL_getState(), _MOTOR_Vars_t_::CtrlState, _HAL_AdcData_t_::dcBus, EST_get_pu_to_krpm_sf(), EST_getFlux_VpHz(), EST_getIdRated(), EST_getLs_d_H(), EST_getLs_q_H(), EST_getRr_Ohm(), EST_getRs_Ohm(), EST_getSpeed_krpm(), EST_getState(), _CTRL_Obj_::estHandle, _MOTOR_Vars_t_::EstState, _MOTOR_Vars_t_::Flux_VpHz, _MOTOR_Vars_t_::Lsd_H, _MOTOR_Vars_t_::Lsq_H, _MOTOR_Vars_t_::MagnCurr_A, _MOTOR_Vars_t_::Rr_Ohm, _MOTOR_Vars_t_::Rs_Ohm, _MOTOR_Vars_t_::Speed_krpm, _MOTOR_Vars_t_::SpeedTraj_krpm, USER_IQ_FULL_SCALE_VOLTAGE_V, and _MOTOR_Vars_t_::VdcBus_kV.
Referenced by main().
CTRL_Obj ctrl |
CTRL_Handle ctrlHandle |
bool Flag_Latch_softwareUpdate = true |
Definition at line 70 of file proj_lab02c.c.
Referenced by main().
HAL_AdcData_t gAdcData |
Defines the ADC data.
Definition at line 86 of file proj_lab02c.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_lab02c.c.
Referenced by main().
uint16_t gLEDcnt = 0 |
Definition at line 99 of file proj_lab02c.c.
Referenced by mainISR().
Definition at line 114 of file proj_lab02c.c.
Referenced by main().
uint_least8_t gLs_qFmt = 0 |
Definition at line 115 of file proj_lab02c.c.
Referenced by main().
uint_least8_t gMax_Ls_qFmt = 0 |
Definition at line 116 of file proj_lab02c.c.
Definition at line 88 of file proj_lab02c.c.
Referenced by main().
volatile MOTOR_Vars_t gMotorVars = MOTOR_Vars_INIT |
Definition at line 101 of file proj_lab02c.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_lab02c.c.
USER_Params gUserParams |
The user parameters.
Definition at line 82 of file proj_lab02c.c.
HAL_Handle halHandle |