instaspin_foc
Modules | Functions | Variables
PROJ_LAB11

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...
 

Variables

CLARKE_Handle clarkeHandle_I
 
CLARKE_Obj clarke_I
 the current Clarke transform object More...
 
CLARKE_Handle clarkeHandle_V
 
CLARKE_Obj clarke_V
 the voltage Clarke transform object More...
 
EST_Handle estHandle
 the handle for the estimator More...
 
PID_Obj pid [3]
 
PID_Handle pidHandle [3]
 
uint16_t pidCntSpeed
 
IPARK_Handle iparkHandle
 
IPARK_Obj ipark
 the inverse Park transform object More...
 
SVGEN_Handle svgenHandle
 the handle for the space vector generator More...
 
SVGEN_Obj svgen
 the space vector generator object More...
 
HAL_Handle halHandle
 The hal handle. 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...
 
MATH_vec3 gOffsets_I_pu = {_IQ(0.0),_IQ(0.0),_IQ(0.0)}
 the offsets for the current feedback More...
 
MATH_vec3 gOffsets_V_pu = {_IQ(0.0),_IQ(0.0),_IQ(0.0)}
 the offsets for the voltage feedback More...
 
MATH_vec2 gIdq_ref_pu = {_IQ(0.0),_IQ(0.0)}
 Iq references. More...
 
MATH_vec2 gVdq_out_pu = {_IQ(0.0),_IQ(0.0)}
 Vd and Vq from the current controllers. More...
 
MATH_vec2 gIdq_pu = {_IQ(0.0),_IQ(0.0)}
 measured values More...
 
USER_Params gUserParams
 The user parameters. More...
 
volatile MOTOR_Vars_t gMotorVars = MOTOR_Vars_INIT
 
_iq gFlux_pu_to_Wb_sf
 
_iq gFlux_pu_to_VpHz_sf
 
_iq gTorque_Ls_Id_Iq_pu_to_Nm_sf
 
_iq gTorque_Flux_Iq_pu_to_Nm_sf
 
_iq gSpeed_krpm_to_pu_sf
 
_iq gSpeed_hz_to_krpm_sf
 

Detailed Description

Function Documentation

_iq angleDelayComp ( const _iq  fm_pu,
const _iq  angleUncomp_pu 
)

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  )
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.

Parameters
[in]handleThe clarke (CLARKE) handle
[in]numCurrentSensorsThe 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.

Parameters
[in]handleThe clarke (CLARKE) handle
[in]numVoltageSensorsThe 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)

Variable Documentation

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.

Referenced by main(), and mainISR().

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().

MATH_vec2 gIdq_pu = {_IQ(0.0),_IQ(0.0)}

measured values

contains the Id and Iq

Definition at line 114 of file proj_lab11.c.

MATH_vec2 gIdq_ref_pu = {_IQ(0.0),_IQ(0.0)}

Iq references.

contains the Id and

Definition at line 108 of file proj_lab11.c.

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.

MATH_vec3 gOffsets_I_pu = {_IQ(0.0),_IQ(0.0),_IQ(0.0)}

the offsets for the current feedback

contains

Definition at line 102 of file proj_lab11.c.

MATH_vec3 gOffsets_V_pu = {_IQ(0.0),_IQ(0.0),_IQ(0.0)}

the offsets for the voltage feedback

contains

Definition at line 105 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
Initial value:
/ 1000.0)
#define _IQ(A)
#define USER_MOTOR_NUM_POLE_PAIRS
Definition: user.h:398
float float_t

Definition at line 159 of file proj_lab11.c.

_iq gSpeed_krpm_to_pu_sf
Initial value:
#define _IQ(A)
#define USER_MOTOR_NUM_POLE_PAIRS
Definition: user.h:398
#define USER_IQ_FULL_SCALE_FREQ_Hz
CURRENTS AND VOLTAGES.
Definition: user.h:78
float float_t

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.

MATH_vec2 gVdq_out_pu = {_IQ(0.0),_IQ(0.0)}

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.

Referenced by main(), and mainISR().

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.