instaspin_foc
Functions | Variables
proj_lab11b.c File Reference
#include <math.h>
#include "main.h"
#include "sw/modules/vib_comp/src/32b/vib_comp.h"

Go to the source code of this file.

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 runCurrentIgnore (void)
 
void runCurrentReconstruction (void)
 
void runFieldWeakening (void)
 
void runOffsetsCalculation (void)
 
void softwareUpdate1p6 (EST_Handle handle)
 Updates version 1p6 of library. More...
 
void runSetTrigger (void)
 
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...
 
void updateCPUusage (void)
 Updates CPU usage. More...
 
_iq getAbsElecAngle (const _iq angle_pu)
 Calculates the absolute electrical angle. More...
 
_iq getAbsMechAngle (_iq *pAngle_mech_poles, _iq *pAngle_z1_pu, const _iq angle_pu)
 Calculates mechanical angle from electrical angle. More...
 

Variables

CLARKE_Handle clarkeHandle_I
 the handle for the current Clarke transform More...
 
CLARKE_Obj clarke_I
 the current Clarke transform object More...
 
CLARKE_Handle clarkeHandle_V
 the handle for the voltage Clarke transform More...
 
CLARKE_Obj clarke_V
 the voltage Clarke transform object More...
 
CPU_USAGE_Handle cpu_usageHandle
 
CPU_USAGE_Obj cpu_usage
 
EST_Handle estHandle
 the handle for the estimator More...
 
FW_Handle fwHandle
 
FW_Obj fw
 
PID_Obj pid [3]
 three handles for PID controllers 0 - Speed, 1 - Id, 2 - Iq More...
 
PID_Handle pidHandle [3]
 three objects for PID controllers 0 - Speed, 1 - Id, 2 - Iq More...
 
uint16_t pidCntSpeed
 count variable to decimate the execution of the speed PID controller More...
 
IPARK_Handle iparkHandle
 the handle for the inverse Park transform More...
 
IPARK_Obj ipark
 the inverse Park transform object More...
 
FILTER_FO_Handle filterHandle [6]
 the handles for the 3-current and 3-voltage filters for offset calculation More...
 
FILTER_FO_Obj filter [6]
 the 3-current and 3-voltage filters for offset calculation More...
 
SVGENCURRENT_Obj svgencurrent
 
SVGENCURRENT_Handle svgencurrentHandle
 
SVGEN_Handle svgenHandle
 the handle for the space vector generator More...
 
SVGEN_Obj svgen
 the space vector generator object More...
 
TRAJ_Handle trajHandle_Id
 the handle for the id reference trajectory More...
 
TRAJ_Obj traj_Id
 the id reference trajectory object More...
 
TRAJ_Handle trajHandle_spd
 the handle for the speed reference trajectory More...
 
TRAJ_Obj traj_spd
 the speed reference trajectory object More...
 
HAL_Handle halHandle
 the handle for the hardware abstraction layer (HAL) More...
 
HAL_PwmData_t gPwmData = {_IQ(0.0), _IQ(0.0), _IQ(0.0)}
 contains the three pwm values -1.0 - 0%, 1.0 - 100% More...
 
HAL_AdcData_t gAdcData
 contains three current values, three voltage values and one DC buss value More...
 
MATH_vec3 gOffsets_I_pu = {_IQ(0.0), _IQ(0.0), _IQ(0.0)}
 contains the offsets for the current feedback More...
 
MATH_vec3 gOffsets_V_pu = {_IQ(0.0), _IQ(0.0), _IQ(0.0)}
 contains the offsets for the voltage feedback More...
 
MATH_vec2 gIdq_ref_pu = {_IQ(0.0), _IQ(0.0)}
 contains the Id and Iq references More...
 
MATH_vec2 gVdq_out_pu = {_IQ(0.0), _IQ(0.0)}
 contains the output Vd and Vq from the current controllers More...
 
MATH_vec2 gIdq_pu = {_IQ(0.0), _IQ(0.0)}
 contains the Id and Iq measured values More...
 
USER_Params gUserParams
 The user parameters. More...
 
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 More...
 
int16_t gCmpOffset = (int16_t)(1.0 * USER_SYSTEM_FREQ_MHz)
 
MATH_vec3 gIavg = {_IQ(0.0), _IQ(0.0), _IQ(0.0)}
 
uint16_t gIavg_shift = 1
 
_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((float_t)USER_MOTOR_NUM_POLE_PAIRS * 1000.0 / (USER_IQ_FULL_SCALE_FREQ_Hz * 60.0))
 
_iq gSpeed_hz_to_krpm_sf = _IQ(60.0 / (float_t)USER_MOTOR_NUM_POLE_PAIRS / 1000.0)
 
_iq gIs_Max_squared_pu = _IQ((USER_MOTOR_MAX_CURRENT * USER_MOTOR_MAX_CURRENT) / (USER_IQ_FULL_SCALE_CURRENT_A * USER_IQ_FULL_SCALE_CURRENT_A))
 
float_t gCpuUsagePercentageMin = 0.0
 
float_t gCpuUsagePercentageAvg = 0.0
 
float_t gCpuUsagePercentageMax = 0.0
 
uint32_t gOffsetCalcCount = 0
 
volatile bool gFlag_enableRsOnLine = false
 
volatile bool gFlag_updateRs = false
 
volatile _iq gRsOnLineFreq_Hz = _IQ(0.2)
 
volatile _iq gRsOnLineId_mag_A = _IQ(0.5)
 
volatile _iq gRsOnLinePole_Hz = _IQ(0.2)
 
VIB_COMP_Handle vib_compHandle
 
_iq vib_comp_reserved [400]
 
_iq gSpeed_fbk_out [360]
 
uint16_t gSpeed_array_index = 0
 
_iq gSpeed_max_pu = _IQ(0.0)
 
_iq gSpeed_min_pu = _IQ(1.0)
 
_iq gSpeed_delta_krpm = _IQ(0.0)
 
volatile bool gFlag_speedStatsReset = false
 
_iq gAbsAngle_elec_pu = _IQ(0.0)
 
_iq gAbsAngle_mech_pu = _IQ(0.0)
 
_iq gAngle_mech_poles = _IQ(0.0)
 
_iq gAngle_z1_pu = _IQ(0.0)
 
volatile _iq gAlpha = _IQ(0.99)
 
volatile int16_t gAdvIndexDelta = 10
 
volatile bool gFlag_enableOutput = false
 
volatile bool gFlag_enableUpdates = true
 
volatile bool gFlag_resetVibComp = false