instaspin_foc
|
Modules | |
Project Overview | |
Functions | |
void | main (void) |
interrupt void | mainISR (void) |
The main ISR that implements the motor control. More... | |
_iq | angleDelayComp (const _iq fm_pu, const _iq angleUncomp_pu) |
The angleDelayComp function compensates for the delay introduced. More... | |
void | softwareUpdate1p6 (EST_Handle handle) |
Call this function to fix 1p6. This is only used for F2806xF/M. More... | |
void | setupClarke_I (CLARKE_Handle handle, const uint_least8_t numCurrentSensors) |
Setup the Clarke transform for either 2 or 3 sensors. More... | |
void | setupClarke_V (CLARKE_Handle handle, const uint_least8_t numVoltageSensors) |
Setup the Clarke transform for either 2 or 3 sensors. More... | |
void | updateGlobalVariables (EST_Handle handle) |
Update the global variables (gMotorVars). More... | |
The angleDelayComp function compensates for the delay introduced.
from the time when the system inputs are sampled to when the PWM voltages are applied to the motor windings.
Definition at line 704 of file proj_lab11.c.
References _IQ, _IQabs, _IQmpy, GLOBAL_Q, USER_IQ_FULL_SCALE_FREQ_Hz, USER_NUM_PWM_TICKS_PER_ISR_TICK, and USER_PWM_FREQ_kHz.
Referenced by mainISR().
void main | ( | void | ) |
Definition at line 164 of file proj_lab11.c.
References _IQ, _IQmpy, CLARKE_init(), CTRL_init(), CTRL_setParams(), CTRL_setupEstIdleState(), CTRL_setUserMotorParams(), ctrlHandle, EST_init(), EST_setEstParams(), EST_setFlag_enableForceAngle(), EST_setFlag_enableRsRecalc(), EST_setIdle(), EST_setupEstIdleState(), EST_updateState(), _CTRL_Obj_::estHandle, estHandle, _MOTOR_Vars_t_::Flag_enableForceAngle, _MOTOR_Vars_t_::Flag_enableSys, _MOTOR_Vars_t_::Flag_Run_Identify, gFlux_pu_to_VpHz_sf, gFlux_pu_to_Wb_sf, gSpeed_krpm_to_pu_sf, 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_init(), HAL_initIntVectorTable(), HAL_readDrvData(), HAL_setParams(), HAL_setupDrvSpi(), HAL_setupFaults(), HAL_writeDrvData(), I_A_offset, I_B_offset, I_C_offset, IPARK_init(), memCopy(), PID_init(), PID_setGains(), PID_setMinMax(), PID_setUi(), pidCntSpeed, setupClarke_I(), setupClarke_V(), softwareUpdate1p6(), _MOTOR_Vars_t_::SpeedRef_krpm, _MOTOR_Vars_t_::SpeedRef_pu, SVGEN_init(), updateGlobalVariables(), 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_EST_HANDLE_ADDRESS, USER_getErrorCode(), USER_IQ_FULL_SCALE_CURRENT_A, USER_IQ_FULL_SCALE_VOLTAGE_V, USER_ISR_FREQ_Hz, USER_MAX_VS_MAG_PU, USER_MOTOR_Ls_d, USER_MOTOR_Ls_q, USER_MOTOR_MAX_CURRENT, USER_MOTOR_Rs, USER_NUM_CURRENT_SENSORS, USER_NUM_VOLTAGE_SENSORS, USER_setParams(), USER_VD_SF, _MOTOR_Vars_t_::UserErrorCode, V_A_offset, V_B_offset, V_C_offset, _MATH_vec2_::value, and _MATH_vec3_::value.
interrupt void mainISR | ( | void | ) |
The main ISR that implements the motor control.
The main interrupt service (ISR) routine.
Definition at line 537 of file proj_lab11.c.
References _IQ, _IQcosPU, _IQmpy, _IQsinPU, _IQsqrt, angleDelayComp(), CLARKE_run(), _HAL_AdcData_t_::dcBus, EST_getAngle_pu(), EST_getFm_pu(), EST_getIdq_pu(), EST_getOneOverDcBus_pu(), EST_run(), estHandle, _MOTOR_Vars_t_::Flag_Run_Identify, HAL_acqAdcInt(), HAL_disablePwm(), HAL_readAdcDataWithOffsets(), HAL_writePwmData(), _HAL_AdcData_t_::I, IPARK_run(), IPARK_setPhasor(), PID_run(), PID_run_spd(), PID_setMinMax(), pidCntSpeed, _MOTOR_Vars_t_::SpeedRef_pu, SVGEN_run(), _HAL_PwmData_t_::Tabc, USER_MAX_VS_MAG_PU, USER_NUM_CTRL_TICKS_PER_SPEED_TICK, _HAL_AdcData_t_::V, _MATH_vec3_::value, and _MATH_vec2_::value.
void setupClarke_I | ( | CLARKE_Handle | handle, |
const uint_least8_t | numCurrentSensors | ||
) |
Setup the Clarke transform for either 2 or 3 sensors.
Sets up the Clarke transform for current.
Sets the number of current sensors.
[in] | handle | The clarke (CLARKE) handle |
[in] | numCurrentSensors | The number of current sensors |
Definition at line 761 of file proj_lab11.c.
References _IQ, CLARKE_setNumSensors(), CLARKE_setScaleFactors(), MATH_ONE_OVER_SQRT_THREE, and MATH_ONE_OVER_THREE.
Referenced by main().
void setupClarke_V | ( | CLARKE_Handle | handle, |
const uint_least8_t | numVoltageSensors | ||
) |
Setup the Clarke transform for either 2 or 3 sensors.
Sets up the Clarke transform for voltage.
Sets the number of voltage sensors.
[in] | handle | The clarke (CLARKE) handle |
[in] | numVoltageSensors | The number of voltage sensors |
Definition at line 793 of file proj_lab11.c.
References _IQ, CLARKE_setNumSensors(), CLARKE_setScaleFactors(), MATH_ONE_OVER_SQRT_THREE, and MATH_ONE_OVER_THREE.
Referenced by main().
void softwareUpdate1p6 | ( | EST_Handle | handle | ) |
Call this function to fix 1p6. This is only used for F2806xF/M.
Updates version 1p6 of library.
implementation of InstaSPIN (version 1.6 of ROM) since the inductance calculation is not done correctly in ROM, so this function fixes that ROM bug.
Definition at line 736 of file proj_lab11.c.
References _IQ30, _IQ30toF(), EST_getLs_coarse_max_pu(), EST_setLs_d_pu(), EST_setLs_q_pu(), EST_setLs_qFmt(), USER_IQ_FULL_SCALE_CURRENT_A, USER_IQ_FULL_SCALE_VOLTAGE_V, USER_MOTOR_Ls_d, USER_MOTOR_Ls_q, and USER_VOLTAGE_FILTER_POLE_rps.
Referenced by main().
void updateGlobalVariables | ( | EST_Handle | handle | ) |
Update the global variables (gMotorVars).
Updates the global variables.
[in] | handle | The estimator (EST) handle |
Definition at line 820 of file proj_lab11.c.
References _IQ, _IQ30toIQ, _IQmpy, _IQsqrt, _HAL_AdcData_t_::dcBus, EST_getFlux_pu(), EST_getFlux_VpHz(), EST_getIdRated(), EST_getLs_d_H(), EST_getLs_d_pu(), EST_getLs_q_H(), EST_getLs_q_pu(), EST_getRr_Ohm(), EST_getRs_Ohm(), EST_getSpeed_krpm(), EST_getState(), _MOTOR_Vars_t_::EstState, _MOTOR_Vars_t_::Flux_VpHz, _MOTOR_Vars_t_::Flux_Wb, gFlux_pu_to_Wb_sf, gTorque_Flux_Iq_pu_to_Nm_sf, gTorque_Ls_Id_Iq_pu_to_Nm_sf, _MOTOR_Vars_t_::Id_A, _MOTOR_Vars_t_::Iq_A, _MOTOR_Vars_t_::Is_A, _MOTOR_Vars_t_::Lsd_H, _MOTOR_Vars_t_::Lsq_H, _MOTOR_Vars_t_::MagnCurr_A, PID_getFbackValue(), _MOTOR_Vars_t_::Rr_Ohm, _MOTOR_Vars_t_::Rs_Ohm, _MOTOR_Vars_t_::Speed_krpm, _MOTOR_Vars_t_::Torque_Nm, USER_IQ_FULL_SCALE_CURRENT_A, USER_IQ_FULL_SCALE_VOLTAGE_V, _MATH_vec2_::value, _MOTOR_Vars_t_::Vd, _MOTOR_Vars_t_::VdcBus_kV, _MOTOR_Vars_t_::Vq, and _MOTOR_Vars_t_::Vs.
Referenced by main().
CLARKE_Obj clarke_I |
the current Clarke transform object
Definition at line 67 of file proj_lab11.c.
CLARKE_Obj clarke_V |
the voltage Clarke transform object
Definition at line 71 of file proj_lab11.c.
CLARKE_Handle clarkeHandle_I |
the handle for the current Clarke transform
Definition at line 65 of file proj_lab11.c.
CLARKE_Handle clarkeHandle_V |
the handle for the voltage Clarke transform
Definition at line 69 of file proj_lab11.c.
EST_Handle estHandle |
the handle for the estimator
Definition at line 73 of file proj_lab11.c.
HAL_AdcData_t gAdcData |
Defines the ADC data.
contains three current values, three voltage values and one DC buss value
Definition at line 99 of file proj_lab11.c.
_iq gFlux_pu_to_VpHz_sf |
Definition at line 150 of file proj_lab11.c.
Referenced by main().
_iq gFlux_pu_to_Wb_sf |
Definition at line 148 of file proj_lab11.c.
Referenced by main(), and updateGlobalVariables().
volatile MOTOR_Vars_t gMotorVars = MOTOR_Vars_INIT |
the global motor variables that are defined in main.h and used for display in the debugger's watch window
Definition at line 122 of file proj_lab11.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%
Definition at line 95 of file proj_lab11.c.
_iq gSpeed_hz_to_krpm_sf |
Definition at line 159 of file proj_lab11.c.
_iq gSpeed_krpm_to_pu_sf |
Definition at line 156 of file proj_lab11.c.
Referenced by main().
_iq gTorque_Flux_Iq_pu_to_Nm_sf |
Definition at line 154 of file proj_lab11.c.
Referenced by main(), and updateGlobalVariables().
_iq gTorque_Ls_Id_Iq_pu_to_Nm_sf |
Definition at line 152 of file proj_lab11.c.
Referenced by main(), and updateGlobalVariables().
USER_Params gUserParams |
The user parameters.
Definition at line 120 of file proj_lab11.c.
Vd and Vq from the current controllers.
contains the output
Definition at line 111 of file proj_lab11.c.
HAL_Handle halHandle |
The hal handle.
the handle for the hardware abstraction layer (HAL)
Definition at line 92 of file proj_lab11.c.
IPARK_Obj ipark |
the inverse Park transform object
Definition at line 84 of file proj_lab11.c.
IPARK_Handle iparkHandle |
the handle for the inverse Park transform
Definition at line 82 of file proj_lab11.c.
PID_Obj pid[3] |
three objects for PID controllers 0 - Speed, 1 - Id, 2 - Iq
Definition at line 75 of file proj_lab11.c.
uint16_t pidCntSpeed |
count variable to decimate the execution of the speed PID controller
Definition at line 79 of file proj_lab11.c.
PID_Handle pidHandle[3] |
three handles for PID controllers 0 - Speed, 1 - Id, 2 - Iq
Definition at line 77 of file proj_lab11.c.
SVGEN_Obj svgen |
the space vector generator object
Definition at line 87 of file proj_lab11.c.
SVGEN_Handle svgenHandle |
the handle for the space vector generator
Definition at line 86 of file proj_lab11.c.