instaspin_foc
|
Macros | |
#define | MAX_ACCEL_KRPMPS_SF (USER_MOTOR_NUM_POLE_PAIRS*1000.0/USER_TRAJ_FREQ_Hz/60.0) |
Defines the speed acceleration scale factor. More... | |
#define | NUM_EST_DATA_BUFFERS 4 |
Defines the number of estimator data buffers NOTE: Must be a multiple of two. More... | |
#define | NUM_MAIN_TICKS_FOR_GLOBAL_VARIABLE_UPDATE 100 |
Defines the number of main iterations before global variables are updated. More... | |
Functions | |
void | calcGains (CTRL_Handle handle, EST_Handle estHandle) |
Calculates controller gains. More... | |
void | calcGainsUser (CTRL_Handle handle, USER_Params *pUserParams) |
Calculates controller gains with input directly from userParams. More... | |
static void | incrCount_isr (void) |
Increments the ISR counter. More... | |
static void | incrBufferIndex_est (void) |
Increments the estimation buffer index. More... | |
static void | incrBufferIndex_setup (void) |
Increments the setup buffer index. More... | |
interrupt void | led2ISR (void) |
The interrupt service (ISR) to turn LED2 on and off. More... | |
interrupt void | led3OffISR (void) |
The interrupt service (ISR) to turn LED3 off. More... | |
interrupt void | led3OnISR (void) |
The interrupt service (ISR) to turn LED3 on. More... | |
interrupt void | mainISR (void) |
The main interrupt service (ISR) routine. More... | |
void | setupClarke_I (CLARKE_Handle handle, const uint_least8_t numCurrentSensors) |
Sets the number of current sensors. More... | |
void | setupClarke_V (CLARKE_Handle handle, const uint_least8_t numVoltageSensors) |
Sets the number of voltage sensors. More... | |
void | updateCPUusage (CTRL_Handle handle) |
Updates CPU usage. More... | |
void | updateGlobalVariables_motor (CTRL_Handle ctrlHandle, EST_Handle estHandle) |
Updates the global motor variables. More... | |
Variables | |
int_least32_t | gCounter_enableSys |
A counter that is incremented while waiting for the enable system flag to be set. More... | |
int_least32_t | gCounter_isr |
A counter that is incremented by each call to the mainISR() function. More... | |
int_least32_t | gCounter_main |
A counter that is incremented by each iteration of the main() function. More... | |
int_least16_t | gCounter_updateGlobals |
A counter that is denotes when to update the global variables. More... | |
CTRL_State_e | gCtrlState |
Global variable for the controller state. More... | |
EST_State_e | gEstState |
Global variable for the estimator state. More... | |
uint_least16_t | gBufferIndex_est |
A counter that to denote the buffer index for the estimation. More... | |
uint_least16_t | gBufferIndex_setup |
A counter that to denote the buffer index for the setup. More... | |
volatile bool | gFlag_enableSys |
Global flag to enable/disable the system. More... | |
bool | gFlag_traj |
Global flag to enable/disable the trajectory generation. More... | |
float_t | gFlux_VpHz |
Global variable for the rotor flux estimate, VpHz. More... | |
float_t | gFlux_Wb |
Global variable for the rotor flux estimate, Wb. More... | |
float_t | gFullScaleFlux_VpHz |
Global variable for the full scale flux estimate. More... | |
float_t | gIdRated_A |
Global variable for the rated Id current current, A. More... | |
float_t | gLs_d_H |
Global variable for the stator inductance in the direct coordinate direction, Henry. More... | |
float_t | gLs_q_H |
Global variable for the stator inductance in the quadrature coordinate direction, Henry. More... | |
float_t | gLmag_H |
Global variable for the magnetizing inductance, Henry. More... | |
float_t | gRoverL_rps |
Global variable for the R/L value used for the current controller. More... | |
float_t | gRs_a_Ohm |
Global variable for the stator resistance in the alpha coordinate direction, Ohm. More... | |
float_t | gRs_b_Ohm |
Global variable for the stator resistance in the beta coordinate direction, Ohm. More... | |
float_t | gRs_d_Ohm |
Global variable for the stator resistance in the direct coordinate direction, Ohm. More... | |
float_t | gRs_q_Ohm |
Global variable for the stator resistance in the quadrature coordinate direction, Ohm. More... | |
float_t | gRr_d_Ohm |
Global variable for the rotor resistance in the direct coordinate direction, Ohm. More... | |
float_t | gSpeed_krpm |
Defines the estimated speed, krpm. More... | |
float_t | gTorque_Nm |
Global variable for the estimated torque, N*m. More... | |
CTRL_Version | gVersion |
Global variable for the controller version. More... | |
CTRL_Handle | ctrlHandle |
The controller handle. More... | |
HAL_Handle | halHandle |
The hal handle. More... | |
CTRL_Obj | ctrl [CTRL_NUM_CONTROLLERS] |
Defines the CTRL object. More... | |
USER_Params | gUserParams |
The user parameters. More... | |
HAL_AdcData_t | gAdcData |
Defines the ADC data. More... | |
HAL_DacData_t | gDacData |
Defines the DAC data. More... | |
HAL_PwmData_t | gPwmData |
Defines the PWM data. More... | |
#define MAX_ACCEL_KRPMPS_SF (USER_MOTOR_NUM_POLE_PAIRS*1000.0/USER_TRAJ_FREQ_Hz/60.0) |
Defines the speed acceleration scale factor.
Definition at line 37 of file float/main.h.
Referenced by main().
#define NUM_EST_DATA_BUFFERS 4 |
Defines the number of estimator data buffers NOTE: Must be a multiple of two.
Definition at line 43 of file float/main.h.
Referenced by incrBufferIndex_est(), and incrBufferIndex_setup().
#define NUM_MAIN_TICKS_FOR_GLOBAL_VARIABLE_UPDATE 100 |
Defines the number of main iterations before global variables are updated.
Definition at line 48 of file float/main.h.
Referenced by main().
void calcGains | ( | CTRL_Handle | handle, |
EST_Handle | estHandle | ||
) |
Calculates controller gains.
[in] | handle | The controller (CTRL) handle |
[in] | estHandle | The estimator (EST) handle |
Definition at line 702 of file proj_enc_fast.c.
References CTRL_getBWc_rps(), CTRL_getCurrentCtrlPeriod_sec(), CTRL_setGains(), EST_getLs_d_H(), EST_getLs_q_H(), and EST_getRs_Ohm().
Referenced by main().
void calcGainsUser | ( | CTRL_Handle | handle, |
USER_Params * | pUserParams | ||
) |
Calculates controller gains with input directly from userParams.
[in] | handle | The controller (CTRL) handle |
[in] | *pUserParams | Pointer to userParams |
|
inlinestatic |
Increments the estimation buffer index.
Definition at line 232 of file float/main.h.
References gBufferIndex_est, and NUM_EST_DATA_BUFFERS.
Referenced by mainISR().
|
inlinestatic |
Increments the setup buffer index.
Definition at line 243 of file float/main.h.
References gBufferIndex_setup, and NUM_EST_DATA_BUFFERS.
Referenced by mainISR().
|
inlinestatic |
Increments the ISR counter.
Definition at line 214 of file float/main.h.
References gCounter_isr.
Referenced by mainISR().
interrupt void led2ISR | ( | void | ) |
The interrupt service (ISR) to turn LED2 on and off.
interrupt void led3OffISR | ( | void | ) |
The interrupt service (ISR) to turn LED3 off.
interrupt void led3OnISR | ( | void | ) |
The interrupt service (ISR) to turn LED3 on.
interrupt void mainISR | ( | void | ) |
The main interrupt service (ISR) routine.
The main interrupt service (ISR) routine.
Definition at line 512 of file proj_lab20.c.
void setupClarke_I | ( | CLARKE_Handle | handle, |
const uint_least8_t | numCurrentSensors | ||
) |
Sets the number of current sensors.
[in] | handle | The Clarke (CLARKE) handle |
[in] | numCurrentSensors | The number of current sensors |
Sets the number of current sensors.
[in] | handle | The clarke (CLARKE) handle |
[in] | numCurrentSensors | The number of current sensors |
[in] | handle | The Clarke (CLARKE) handle |
[in] | numCurrentSensors | The number of current sensors |
Sets the number of current sensors.
[in] | handle | The clarke (CLARKE) handle |
[in] | numCurrentSensors | The number of current sensors |
Definition at line 392 of file fast_obs_im.c.
void setupClarke_V | ( | CLARKE_Handle | handle, |
const uint_least8_t | numVoltageSensors | ||
) |
Sets the number of voltage sensors.
[in] | handle | The Clarke (CLARKE) handle |
[in] | numVoltageSensors | The number of voltage sensors |
Sets the number of voltage sensors.
[in] | handle | The clarke (CLARKE) handle |
[in] | numVoltageSensors | The number of voltage sensors |
[in] | handle | The Clarke (CLARKE) handle |
[in] | numVoltageSensors | The number of voltage sensors |
Sets the number of voltage sensors.
[in] | handle | The clarke (CLARKE) handle |
[in] | numVoltageSensors | The number of voltage sensors |
Definition at line 421 of file fast_obs_im.c.
void updateCPUusage | ( | CTRL_Handle | handle | ) |
Updates CPU usage.
[in] | ctrlHandle | The controller (CTRL) handle |
Definition at line 1243 of file proj_enc_fast.c.
References CPU_USAGE_getAvgDeltaCntObserved(), CPU_USAGE_getMaxDeltaCntObserved(), CPU_USAGE_getMinDeltaCntObserved(), gCpuUsagePercentageAvg, gCpuUsagePercentageMax, gCpuUsagePercentageMin, HAL_readPwmPeriod(), and USER_NUM_PWM_TICKS_PER_ISR_TICK.
Referenced by main().
void updateGlobalVariables_motor | ( | CTRL_Handle | ctrlHandle, |
EST_Handle | estHandle | ||
) |
Updates the global motor variables.
[in] | ctrlHandle | The controller (CTRL) handle |
[in] | estHandle | The estimator (EST) handle |
Definition at line 1184 of file proj_enc_fast.c.
References CAL_getState(), CTRL_getState(), EST_computeLmag_H(), EST_computeTorque_Nm(), EST_getFe_Hz(), EST_getFlux_Wb(), EST_getIdRated_A(), EST_getIdRated_indEst_A(), EST_getLs_d_H(), EST_getLs_q_H(), EST_getRoverL_rps(), EST_getRr_d_Ohm(), EST_getRr_q_Ohm(), EST_getRs_a_Ohm(), EST_getRs_b_Ohm(), EST_getRs_d_Ohm(), EST_getRs_q_Ohm(), EST_getRsOnLine_Ohm(), EST_getState(), EST_getTrajState(), gCalState, gCtrlState, gEstState, gFlux_Wb, gIdRated_A, gLmag_H, gLs_d_H, gLs_q_H, gRoverL_rps, gRr_d_Ohm, gRr_q_Ohm, gRs_a_Ohm, gRs_b_Ohm, gRs_d_Ohm, gRs_q_Ohm, gRsOnLine_Ohm, gSpeed_Hz, gTorque_Nm, and gTrajState.
Referenced by main().
CTRL_Obj ctrl[CTRL_NUM_CONTROLLERS] |
CTRL_Handle ctrlHandle |
The controller handle.
The controller handle.
Definition at line 171 of file proj_enc_fast.c.
Referenced by main().
HAL_AdcData_t gAdcData |
Defines the ADC data.
contains three current values, three voltage values and one DC buss value
Defines the ADC data.
Definition at line 55 of file fast_obs_im.c.
uint_least16_t gBufferIndex_est |
A counter that to denote the buffer index for the estimation.
Definition at line 81 of file proj_enc_fast.c.
Referenced by incrBufferIndex_est(), and mainISR().
uint_least16_t gBufferIndex_setup |
A counter that to denote the buffer index for the setup.
Definition at line 83 of file proj_enc_fast.c.
Referenced by incrBufferIndex_setup(), and mainISR().
int_least32_t gCounter_enableSys |
A counter that is incremented while waiting for the enable system flag to be set.
Definition at line 41 of file proj_enc_fast.c.
Referenced by main().
int_least32_t gCounter_isr |
A counter that is incremented by each call to the mainISR() function.
Definition at line 43 of file proj_enc_fast.c.
Referenced by incrCount_isr(), and mainISR().
int_least32_t gCounter_main |
A counter that is incremented by each iteration of the main() function.
Definition at line 45 of file proj_enc_fast.c.
Referenced by main().
int_least16_t gCounter_updateGlobals |
A counter that is denotes when to update the global variables.
Definition at line 68 of file proj_lab02a.c.
Referenced by main().
CTRL_State_e gCtrlState |
Global variable for the controller state.
Definition at line 49 of file proj_enc_fast.c.
Referenced by updateGlobalVariables_motor().
HAL_DacData_t gDacData |
Defines the DAC data.
Definition at line 57 of file fast_obs_im.c.
EST_State_e gEstState |
Global variable for the estimator state.
Definition at line 21 of file fast_obs_im.c.
Referenced by updateGlobalVariables_motor().
volatile bool gFlag_enableSys |
Global flag to enable/disable the system.
Definition at line 23 of file fast_obs_im.c.
Referenced by main().
bool gFlag_traj |
Global flag to enable/disable the trajectory generation.
float_t gFlux_VpHz |
Global variable for the rotor flux estimate, VpHz.
float_t gFlux_Wb |
Global variable for the rotor flux estimate, Wb.
Definition at line 33 of file fast_obs_im.c.
Referenced by updateGlobalVariables_motor().
float_t gFullScaleFlux_VpHz |
Global variable for the full scale flux estimate.
float_t gIdRated_A |
Global variable for the rated Id current current, A.
Definition at line 31 of file fast_obs_im.c.
Referenced by updateGlobalVariables_motor().
float_t gLmag_H |
Global variable for the magnetizing inductance, Henry.
Definition at line 95 of file proj_enc_fast.c.
Referenced by updateGlobalVariables_motor().
float_t gLs_d_H |
Global variable for the stator inductance in the direct coordinate direction, Henry.
Definition at line 35 of file fast_obs_im.c.
Referenced by updateGlobalVariables_motor().
float_t gLs_q_H |
Global variable for the stator inductance in the quadrature coordinate direction, Henry.
Definition at line 37 of file fast_obs_im.c.
Referenced by updateGlobalVariables_motor().
HAL_PwmData_t gPwmData |
Defines the PWM data.
contains the pwm values for each phase. -1.0 is 0%, 1.0 is 100%
Defines the PWM data.
Definition at line 59 of file fast_obs_im.c.
float_t gRoverL_rps |
Global variable for the R/L value used for the current controller.
Definition at line 97 of file proj_enc_fast.c.
Referenced by updateGlobalVariables_motor().
float_t gRr_d_Ohm |
Global variable for the rotor resistance in the direct coordinate direction, Ohm.
Global variable for the rotor resistance in the quadrature coordinate direction, Ohm.
Definition at line 153 of file float/main.h.
Referenced by updateGlobalVariables_motor().
float_t gRs_a_Ohm |
Global variable for the stator resistance in the alpha coordinate direction, Ohm.
Definition at line 101 of file proj_enc_fast.c.
Referenced by updateGlobalVariables_motor().
float_t gRs_b_Ohm |
Global variable for the stator resistance in the beta coordinate direction, Ohm.
Definition at line 103 of file proj_enc_fast.c.
Referenced by updateGlobalVariables_motor().
float_t gRs_d_Ohm |
Global variable for the stator resistance in the direct coordinate direction, Ohm.
Definition at line 105 of file proj_enc_fast.c.
Referenced by updateGlobalVariables_motor().
float_t gRs_q_Ohm |
Global variable for the stator resistance in the quadrature coordinate direction, Ohm.
Definition at line 107 of file proj_enc_fast.c.
Referenced by updateGlobalVariables_motor().
float_t gSpeed_krpm |
Defines the estimated speed, krpm.
float_t gTorque_Nm |
Global variable for the estimated torque, N*m.
Definition at line 65 of file fast_obs_im.c.
Referenced by updateGlobalVariables_motor().
USER_Params gUserParams |
The user parameters.
Definition at line 67 of file fast_obs_im.c.
CTRL_Version gVersion |
Global variable for the controller version.
Definition at line 149 of file proj_enc_fast.c.
HAL_Handle halHandle |
The hal handle.
The hal handle.
the handle for the hardware abstraction layer (HAL)
Definition at line 79 of file fast_obs_im.c.