instaspin_foc
Macros | Functions
user.h File Reference
#include "sw/modules/types/src/types.h"
#include "sw/modules/motor/src/32b/motor.h"
#include "sw/modules/est/src/32b/est.h"
#include "sw/modules/est/src/est_states.h"
#include "sw/modules/est/src/est_Flux_states.h"
#include "sw/modules/est/src/est_Ls_states.h"
#include "sw/modules/est/src/est_Rs_states.h"
#include "sw/modules/ctrl/src/32b/ctrl_obj.h"
#include "sw/modules/fast/src/32b/userParams.h"

Go to the source code of this file.

Macros

#define USER_IQ_FULL_SCALE_FREQ_Hz   (800.0)
 CURRENTS AND VOLTAGES. More...
 
#define USER_IQ_FULL_SCALE_VOLTAGE_V   (24.0)
 Defines full scale value for the IQ30 variable of Voltage inside the system. More...
 
#define USER_ADC_FULL_SCALE_VOLTAGE_V   (44.30)
 Defines the maximum voltage at the input to the AD converter. More...
 
#define USER_VOLTAGE_SF   ((float_t)((USER_ADC_FULL_SCALE_VOLTAGE_V)/(USER_IQ_FULL_SCALE_VOLTAGE_V)))
 Defines the voltage scale factor for the system. More...
 
#define USER_IQ_FULL_SCALE_CURRENT_A   (20.0)
 Defines the full scale current for the IQ variables, A. More...
 
#define USER_ADC_FULL_SCALE_CURRENT_A   (47.14)
 Defines the maximum current at the AD converter. More...
 
#define USER_CURRENT_SF   ((float_t)((USER_ADC_FULL_SCALE_CURRENT_A)/(USER_IQ_FULL_SCALE_CURRENT_A)))
 Defines the current scale factor for the system. More...
 
#define USER_NUM_CURRENT_SENSORS   (3)
 Defines the number of current sensors used. More...
 
#define USER_NUM_VOLTAGE_SENSORS   (3)
 Defines the number of voltage (phase) sensors. More...
 
#define I_A_offset   (1.210729778)
 ADC current offsets for A, B, and C phases. More...
 
#define I_B_offset   (1.209441483)
 
#define I_C_offset   (1.209092796)
 
#define V_A_offset   (0.5084558129)
 ADC voltage offsets for A, B, and C phases. More...
 
#define V_B_offset   (0.5074239969)
 
#define V_C_offset   (0.5065535307)
 
#define USER_SYSTEM_FREQ_MHz   (60.0)
 CLOCKS & TIMERS. More...
 
#define USER_PWM_FREQ_kHz   (45.0)
 Defines the Pulse Width Modulation (PWM) frequency, kHz. More...
 
#define USER_MAX_VS_MAG_PU   (2.0/3.0)
 Defines the maximum Voltage vector (Vs) magnitude allowed. This value sets the maximum magnitude for the output of the. More...
 
#define USER_EST_HANDLE_ADDRESS   (0x600)
 Defines the address of estimator handle. More...
 
#define USER_VD_SF   (0.95)
 Defines the direct voltage (Vd) scale factor. More...
 
#define USER_PWM_PERIOD_usec   (1000.0/USER_PWM_FREQ_kHz)
 Defines the Pulse Width Modulation (PWM) period, usec. More...
 
#define USER_ISR_FREQ_Hz   ((float_t)USER_PWM_FREQ_kHz * 1000.0 / (float_t)USER_NUM_PWM_TICKS_PER_ISR_TICK)
 Defines the Interrupt Service Routine (ISR) frequency, Hz. More...
 
#define USER_ISR_PERIOD_usec   (USER_PWM_PERIOD_usec * (float_t)USER_NUM_PWM_TICKS_PER_ISR_TICK)
 Defines the Interrupt Service Routine (ISR) period, usec. More...
 
#define USER_NUM_PWM_TICKS_PER_ISR_TICK   (3)
 DECIMATION. More...
 
#define USER_NUM_ISR_TICKS_PER_CTRL_TICK   (1)
 Defines the number of isr ticks (hardware) per controller clock tick (software) More...
 
#define USER_NUM_CTRL_TICKS_PER_CURRENT_TICK   (1)
 Defines the number of controller clock ticks per current controller clock tick. More...
 
#define USER_NUM_CTRL_TICKS_PER_EST_TICK   (1)
 Defines the number of controller clock ticks per estimator clock tick. More...
 
#define USER_NUM_CTRL_TICKS_PER_SPEED_TICK   (15)
 Defines the number of controller clock ticks per speed controller clock tick. More...
 
#define USER_NUM_CTRL_TICKS_PER_TRAJ_TICK   (15)
 Defines the number of controller clock ticks per trajectory clock tick. More...
 
#define USER_CTRL_FREQ_Hz   (uint_least32_t)(USER_ISR_FREQ_Hz/USER_NUM_ISR_TICKS_PER_CTRL_TICK)
 Defines the controller frequency, Hz. More...
 
#define USER_EST_FREQ_Hz   (uint_least32_t)(USER_CTRL_FREQ_Hz/USER_NUM_CTRL_TICKS_PER_EST_TICK)
 Defines the estimator frequency, Hz. More...
 
#define USER_TRAJ_FREQ_Hz   (uint_least32_t)(USER_CTRL_FREQ_Hz/USER_NUM_CTRL_TICKS_PER_TRAJ_TICK)
 Defines the trajectory frequency, Hz. More...
 
#define USER_CTRL_PERIOD_usec   (USER_ISR_PERIOD_usec * USER_NUM_ISR_TICKS_PER_CTRL_TICK)
 Defines the controller execution period, usec. More...
 
#define USER_CTRL_PERIOD_sec   ((float_t)USER_CTRL_PERIOD_usec/(float_t)1000000.0)
 Defines the controller execution period, sec. More...
 
#define USER_MAX_NEGATIVE_ID_REF_CURRENT_A   (-0.5 * USER_MOTOR_MAX_CURRENT)
 LIMITS. More...
 
#define USER_ZEROSPEEDLIMIT   (0.5 / USER_IQ_FULL_SCALE_FREQ_Hz)
 Defines the low speed limit for the flux integrator, pu. More...
 
#define USER_FORCE_ANGLE_FREQ_Hz   (2.0 * USER_ZEROSPEEDLIMIT * USER_IQ_FULL_SCALE_FREQ_Hz)
 Defines the force angle frequency, Hz. More...
 
#define USER_MAX_CURRENT_SLOPE_POWERWARP   (0.3*USER_MOTOR_RES_EST_CURRENT/USER_IQ_FULL_SCALE_CURRENT_A/USER_TRAJ_FREQ_Hz)
 Defines the maximum current slope for Id trajectory during PowerWarp. More...
 
#define USER_MAX_ACCEL_Hzps   (20.0)
 Defines the starting maximum acceleration AND deceleration for the speed profiles, Hz/s. More...
 
#define USER_MAX_ACCEL_EST_Hzps   (5.0)
 Defines maximum acceleration for the estimation speed profiles, Hz/s. More...
 
#define USER_MAX_CURRENT_SLOPE   (USER_MOTOR_RES_EST_CURRENT/USER_IQ_FULL_SCALE_CURRENT_A/USER_TRAJ_FREQ_Hz)
 Defines the maximum current slope for Id trajectory during estimation. More...
 
#define USER_IDRATED_FRACTION_FOR_RATED_FLUX   (1.0)
 Defines the fraction of IdRated to use during rated flux estimation. More...
 
#define USER_IDRATED_FRACTION_FOR_L_IDENT   (1.0)
 Defines the fraction of IdRated to use during inductance estimation. More...
 
#define USER_IDRATED_DELTA   (0.00002)
 Defines the IdRated delta to use during estimation. More...
 
#define USER_SPEEDMAX_FRACTION_FOR_L_IDENT   (1.0)
 Defines the fraction of SpeedMax to use during inductance estimation. More...
 
#define USER_FLUX_FRACTION   (1.0)
 Defines flux fraction to use during inductance identification. More...
 
#define USER_POWERWARP_GAIN   (1.0)
 Defines the PowerWarp gain for computing Id reference. More...
 
#define USER_R_OVER_L_EST_FREQ_Hz   (300)
 Defines the R/L estimation frequency, Hz. More...
 
#define USER_VOLTAGE_FILTER_POLE_Hz   (344.62)
 POLES. More...
 
#define USER_VOLTAGE_FILTER_POLE_rps   (2.0 * MATH_PI * USER_VOLTAGE_FILTER_POLE_Hz)
 Defines the analog voltage filter pole location, rad/s. More...
 
#define USER_OFFSET_POLE_rps   (20.0)
 Defines the software pole location for the voltage and current offset estimation, rad/s. More...
 
#define USER_FLUX_POLE_rps   (100.0)
 Defines the software pole location for the flux estimation, rad/s. More...
 
#define USER_DIRECTION_POLE_rps   (6.0)
 Defines the software pole location for the direction filter, rad/s. More...
 
#define USER_SPEED_POLE_rps   (100.0)
 Defines the software pole location for the speed control filter, rad/s. More...
 
#define USER_DCBUS_POLE_rps   (100.0)
 Defines the software pole location for the DC bus filter, rad/s. More...
 
#define USER_EST_KAPPAQ   (1.5)
 Defines the convergence factor for the estimator. More...
 
#define Estun_EMJ_04APB22   101
 USER MOTOR & ID SETTINGS. More...
 
#define Anaheim_BLY172S   102
 
#define My_Motor   104
 
#define hobby_3p5T   105
 
#define hobby_4p5T   106
 
#define small_hobby   107
 
#define teknic_2310P   108
 
#define hobbywing_ezrun_8p5T   109
 
#define eflite_helicopter_420   110
 
#define Bodine_34B3FEBL   114
 
#define Pittman_elcom_5233B599   115
 
#define medical_instrument   117
 
#define Test_Motor   118
 
#define Belt_Drive_Washer_IPM   201
 
#define Marathon_5K33GN2A   301
 
#define Kinetek_YDQ1p3_4   302
 
#define LPKF_CAD_CAM   303
 
#define USER_MOTOR   Anaheim_BLY172S
 Uncomment the motor which should be included at compile. More...
 
#define USER_MOTOR_TYPE   MOTOR_Type_Pm
 
#define USER_MOTOR_NUM_POLE_PAIRS   (4)
 
#define USER_MOTOR_Rr   (NULL)
 
#define USER_MOTOR_Rs   (0.3968007)
 
#define USER_MOTOR_Ls_d   (0.0006708066)
 
#define USER_MOTOR_Ls_q   (0.0006708066)
 
#define USER_MOTOR_RATED_FLUX   (0.03433958)
 
#define USER_MOTOR_MAGNETIZING_CURRENT   (NULL)
 
#define USER_MOTOR_RES_EST_CURRENT   (1.0)
 
#define USER_MOTOR_IND_EST_CURRENT   (-1.0)
 
#define USER_MOTOR_MAX_CURRENT   (5.0)
 
#define USER_MOTOR_FLUX_EST_FREQ_Hz   (20.0)
 

Functions

void USER_setParams (USER_Params *pUserParams)
 Sets the user parameter values. More...
 
void USER_checkForErrors (USER_Params *pUserParams)
 Checks for errors in the user parameter values. More...
 
USER_ErrorCode_e USER_getErrorCode (USER_Params *pUserParams)
 Gets the error code in the user parameters. More...
 
void USER_setErrorCode (USER_Params *pUserParams, const USER_ErrorCode_e errorCode)
 Sets the error code in the user parameters. More...
 
void USER_softwareUpdate1p6 (CTRL_Handle handle)
 Recalculates Inductances with the correct Q Format. More...
 
void USER_calcPIgains (CTRL_Handle handle)
 Updates Id and Iq PI gains. More...
 
_iq USER_computeTorque_Ls_Id_Iq_pu_to_Nm_sf (void)
 Computes the scale factor needed to convert from torque created by Ld, Lq, Id and Iq, from per unit to Nm. More...
 
_iq USER_computeTorque_Flux_Iq_pu_to_Nm_sf (void)
 Computes the scale factor needed to convert from torque created by flux and Iq, from per unit to Nm. More...
 
_iq USER_computeFlux_pu_to_Wb_sf (void)
 Computes the scale factor needed to convert from per unit to Wb. More...
 
_iq USER_computeFlux_pu_to_VpHz_sf (void)
 Computes the scale factor needed to convert from per unit to V/Hz. More...
 
_iq USER_computeFlux (CTRL_Handle handle, const _iq sf)
 Computes Flux in Wb or V/Hz depending on the scale factor sent as parameter. More...
 
_iq USER_computeTorque_Nm (CTRL_Handle handle, const _iq torque_Flux_sf, const _iq torque_Ls_sf)
 Computes Torque in Nm. More...
 
_iq USER_computeTorque_lbin (CTRL_Handle handle, const _iq torque_Flux_sf, const _iq torque_Ls_sf)
 Computes Torque in lbin. More...