instaspin_foc
Macros | Functions
USER

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

Detailed Description

Macro Definition Documentation

#define Anaheim_BLY172S   102

Definition at line 338 of file user.h.

#define Belt_Drive_Washer_IPM   201

Definition at line 353 of file user.h.

#define Bodine_34B3FEBL   114

Definition at line 346 of file user.h.

#define eflite_helicopter_420   110

Definition at line 345 of file user.h.

#define Estun_EMJ_04APB22   101

USER MOTOR & ID SETTINGS.

Define each motor with a unique name and ID number

Definition at line 337 of file user.h.

#define hobby_3p5T   105

Definition at line 340 of file user.h.

#define hobby_4p5T   106

Definition at line 341 of file user.h.

#define hobbywing_ezrun_8p5T   109

Definition at line 344 of file user.h.

#define I_A_offset   (1.210729778)

ADC current offsets for A, B, and C phases.

One-time hardware dependent, though the calibration can be done at run-time as well After initial board calibration these values should be updated for your specific hardware so they are available after compile in the binary to be loaded to the controller

Definition at line 125 of file user.h.

Referenced by main().

#define I_B_offset   (1.209441483)

Definition at line 126 of file user.h.

Referenced by main().

#define I_C_offset   (1.209092796)

Definition at line 127 of file user.h.

Referenced by main().

#define Kinetek_YDQ1p3_4   302

Definition at line 357 of file user.h.

#define LPKF_CAD_CAM   303

Definition at line 358 of file user.h.

#define Marathon_5K33GN2A   301

Definition at line 356 of file user.h.

#define medical_instrument   117

Definition at line 348 of file user.h.

#define My_Motor   104

Definition at line 339 of file user.h.

#define Pittman_elcom_5233B599   115

Definition at line 347 of file user.h.

#define small_hobby   107

Definition at line 342 of file user.h.

#define teknic_2310P   108

Definition at line 343 of file user.h.

#define Test_Motor   118

Definition at line 349 of file user.h.

#define USER_ADC_FULL_SCALE_CURRENT_A   (47.14)

Defines the maximum current at the AD converter.

The value that will be represented by the maximum ADC input (3.3V) and conversion (0FFFh) Hardware dependent, this should be based on the current sensing and scaling to the ADC input

Definition at line 107 of file user.h.

#define USER_ADC_FULL_SCALE_VOLTAGE_V   (44.30)

Defines the maximum voltage at the input to the AD converter.

The value that will be represented by the maximum ADC input (3.3V) and conversion (0FFFh) Hardware dependent, this should be based on the voltage sensing and scaling to the ADC input

Definition at line 93 of file user.h.

#define USER_CTRL_FREQ_Hz   (uint_least32_t)(USER_ISR_FREQ_Hz/USER_NUM_ISR_TICKS_PER_CTRL_TICK)

Defines the controller frequency, Hz.

Compile time calculation

Definition at line 215 of file user.h.

Referenced by main().

#define USER_CTRL_PERIOD_sec   ((float_t)USER_CTRL_PERIOD_usec/(float_t)1000000.0)

Defines the controller execution period, sec.

Compile time calculation

Definition at line 231 of file user.h.

Referenced by recalcKpKi(), and recalcKpKiPmsm().

#define USER_CTRL_PERIOD_usec   (USER_ISR_PERIOD_usec * USER_NUM_ISR_TICKS_PER_CTRL_TICK)

Defines the controller execution period, usec.

Compile time calculation

Definition at line 227 of file user.h.

Defines the current scale factor for the system.

Compile time calculation for scale factor (ratio) used throughout the system

Definition at line 111 of file user.h.

#define USER_DCBUS_POLE_rps   (100.0)

Defines the software pole location for the DC bus filter, rad/s.

Definition at line 322 of file user.h.

#define USER_DIRECTION_POLE_rps   (6.0)

Defines the software pole location for the direction filter, rad/s.

Definition at line 316 of file user.h.

#define USER_EST_FREQ_Hz   (uint_least32_t)(USER_CTRL_FREQ_Hz/USER_NUM_CTRL_TICKS_PER_EST_TICK)

Defines the estimator frequency, Hz.

Compile time calculation

Definition at line 219 of file user.h.

Referenced by main().

#define USER_EST_HANDLE_ADDRESS   (0x600)

Defines the address of estimator handle.

Definition at line 161 of file user.h.

Referenced by main().

#define USER_EST_KAPPAQ   (1.5)

Defines the convergence factor for the estimator.

Do not change from default for FAST

Definition at line 326 of file user.h.

#define USER_FLUX_FRACTION   (1.0)

Defines flux fraction to use during inductance identification.

Definition at line 285 of file user.h.

#define USER_FLUX_POLE_rps   (100.0)

Defines the software pole location for the flux estimation, rad/s.

Should not be changed from default of (100.0)

Definition at line 313 of file user.h.

#define USER_FORCE_ANGLE_FREQ_Hz   (2.0 * USER_ZEROSPEEDLIMIT * USER_IQ_FULL_SCALE_FREQ_Hz)

Defines the force angle frequency, Hz.

Frequency of stator vector rotation used by the ForceAngle object Can be positive or negative

Definition at line 249 of file user.h.

#define USER_IDRATED_DELTA   (0.00002)

Defines the IdRated delta to use during estimation.

Definition at line 277 of file user.h.

#define USER_IDRATED_FRACTION_FOR_L_IDENT   (1.0)

Defines the fraction of IdRated to use during inductance estimation.

Definition at line 273 of file user.h.

#define USER_IDRATED_FRACTION_FOR_RATED_FLUX   (1.0)

Defines the fraction of IdRated to use during rated flux estimation.

Definition at line 269 of file user.h.

#define USER_IQ_FULL_SCALE_CURRENT_A   (20.0)

Defines the full scale current for the IQ variables, A.

All currents are converted into (pu) based on the ratio to this value WARNING: this value MUST be larger than the maximum current readings that you are expecting from the motor or the reading will roll over to 0, creating a control issue

Definition at line 102 of file user.h.

Referenced by CTRL_calcMax_Ls_qFmt(), main(), mainISR(), recalcKpKi(), recalcKpKiPmsm(), runFieldWeakening(), runRsOnLine(), softwareUpdate1p6(), updateGlobalVariables(), updateGlobalVariables_motor(), and updateIqRef().

#define USER_IQ_FULL_SCALE_FREQ_Hz   (800.0)

CURRENTS AND VOLTAGES.

Defines the full scale frequency for IQ variable, Hz All frequencies are converted into (pu) based on the ratio to this value this value MUST be larger than the maximum speed that you are expecting from the motor

Definition at line 78 of file user.h.

Referenced by angleDelayComp(), main(), recalcKpKiPmsm(), and updateGlobalVariables().

#define USER_IQ_FULL_SCALE_VOLTAGE_V   (24.0)

Defines full scale value for the IQ30 variable of Voltage inside the system.

All voltages are converted into (pu) based on the ratio to this value WARNING: this value MUST meet the following condition: USER_IQ_FULL_SCALE_VOLTAGE_V > 0.5 * USER_MOTOR_MAX_CURRENT * USER_MOTOR_Ls_d * USER_VOLTAGE_FILTER_POLE_rps, WARNING: otherwise the value can saturate and roll-over, causing an inaccurate value WARNING: this value is OFTEN greater than the maximum measured ADC value, especially with high Bemf motors operating at higher than rated speeds WARNING: if you know the value of your Bemf constant, and you know you are operating at a multiple speed due to field weakening, be sure to set this value higher than the expected Bemf voltage It is recommended to start with a value ~3x greater than the USER_ADC_FULL_SCALE_VOLTAGE_V and increase to 4-5x if scenarios where a Bemf calculation may exceed these limits This value is also used to calculate the minimum flux value: USER_IQ_FULL_SCALE_VOLTAGE_V/USER_EST_FREQ_Hz/0.7

Definition at line 88 of file user.h.

Referenced by CTRL_calcMax_Ls_qFmt(), main(), recalcKpKi(), recalcKpKiPmsm(), softwareUpdate1p6(), updateGlobalVariables(), and updateGlobalVariables_motor().

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

Definition at line 173 of file user.h.

Referenced by main(), and mainISR().

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

Definition at line 177 of file user.h.

#define USER_MAX_ACCEL_EST_Hzps   (5.0)

Defines maximum acceleration for the estimation speed profiles, Hz/s.

Only used during Motor ID (commission)

Definition at line 262 of file user.h.

#define USER_MAX_ACCEL_Hzps   (20.0)

Defines the starting maximum acceleration AND deceleration for the speed profiles, Hz/s.

Updated in run-time through user functions Inverter, motor, inertia, and load will limit actual acceleration capability

Definition at line 258 of file user.h.

Referenced by main().

Defines the maximum current slope for Id trajectory during estimation.

Definition at line 265 of file user.h.

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

For Induction motors only, controls how fast Id input can change under PowerWarp control

Definition at line 253 of file user.h.

#define USER_MAX_NEGATIVE_ID_REF_CURRENT_A   (-0.5 * USER_MOTOR_MAX_CURRENT)

LIMITS.

Defines the maximum negative current to be applied in Id reference Used in field weakening only, this is a safety setting (e.g. to protect against demagnetization) User must also be aware that overall current magnitude [sqrt(Id^2 + Iq^2)] should be kept below any machine design specifications

Definition at line 239 of file user.h.

Referenced by main().

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

Id and Iq PI current controllers. The Id and Iq current controller outputs are Vd and Vq. The relationship between Vs, Vd, and Vq is: Vs = sqrt(Vd^2 + Vq^2). In this FOC controller, the Vd value is set equal to USER_MAX_VS_MAG*USER_VD_MAG_FACTOR. Vq = sqrt(USER_MAX_VS_MAG^2 - Vd^2). Set USER_MAX_VS_MAG = 0.5 for a pure sinewave with a peak at SQRT(3)/2 = 86.6% duty cycle. No current reconstruction is needed for this scenario. Set USER_MAX_VS_MAG = 1/SQRT(3) = 0.5774 for a pure sinewave with a peak at 100% duty cycle. Current reconstruction will be needed for this scenario (Lab10a-x). Set USER_MAX_VS_MAG = 2/3 = 0.6666 to create a trapezoidal voltage waveform. Current reconstruction will be needed for this scenario (Lab10a-x). For space vector over-modulation, see lab 10 for details on system requirements that will allow the SVM generator to go all the way to trapezoidal.

Definition at line 157 of file user.h.

Referenced by main(), and mainISR().

#define USER_MOTOR   Anaheim_BLY172S

Uncomment the motor which should be included at compile.

These motor ID settings and motor parameters are then available to be used by the control system Once your ideal settings and parameters are identified update the motor section here so it is available in the binary code

Definition at line 364 of file user.h.

#define USER_MOTOR_FLUX_EST_FREQ_Hz   (20.0)

Definition at line 408 of file user.h.

#define USER_MOTOR_IND_EST_CURRENT   (-1.0)

Definition at line 406 of file user.h.

#define USER_MOTOR_Ls_d   (0.0006708066)

Definition at line 401 of file user.h.

Referenced by main(), and softwareUpdate1p6().

#define USER_MOTOR_Ls_q   (0.0006708066)

Definition at line 402 of file user.h.

Referenced by main(), and softwareUpdate1p6().

#define USER_MOTOR_MAGNETIZING_CURRENT   (NULL)

Definition at line 404 of file user.h.

Referenced by main().

#define USER_MOTOR_MAX_CURRENT   (5.0)

Definition at line 407 of file user.h.

Referenced by main(), and recalcKpKiPmsm().

#define USER_MOTOR_NUM_POLE_PAIRS   (4)

Definition at line 398 of file user.h.

Referenced by getAbsMechAngle(), mainISR(), and updateGlobalVariables().

#define USER_MOTOR_RATED_FLUX   (0.03433958)

Definition at line 403 of file user.h.

#define USER_MOTOR_RES_EST_CURRENT   (1.0)

Definition at line 405 of file user.h.

Referenced by main(), and recalcKpKiPmsm().

#define USER_MOTOR_Rr   (NULL)

Definition at line 399 of file user.h.

#define USER_MOTOR_Rs   (0.3968007)

Definition at line 400 of file user.h.

Referenced by main().

#define USER_MOTOR_TYPE   MOTOR_Type_Pm

Definition at line 397 of file user.h.

Referenced by main(), and mainISR().

#define USER_NUM_CTRL_TICKS_PER_CURRENT_TICK   (1)

Defines the number of controller clock ticks per current controller clock tick.

Relationship of controller clock rate to current controller (FOC) rate

Definition at line 197 of file user.h.

#define USER_NUM_CTRL_TICKS_PER_EST_TICK   (1)

Defines the number of controller clock ticks per estimator clock tick.

Relationship of controller clock rate to estimator (FAST) rate Depends on needed dynamic performance, FAST provides very good results as low as 1 KHz while more dynamic or high speed applications may require up to 15 KHz

Definition at line 202 of file user.h.

#define USER_NUM_CTRL_TICKS_PER_SPEED_TICK   (15)

Defines the number of controller clock ticks per speed controller clock tick.

Relationship of controller clock rate to speed loop rate

Definition at line 206 of file user.h.

Referenced by mainISR().

#define USER_NUM_CTRL_TICKS_PER_TRAJ_TICK   (15)

Defines the number of controller clock ticks per trajectory clock tick.

Relationship of controller clock rate to trajectory loop rate Typically the same as the speed rate

Definition at line 211 of file user.h.

#define USER_NUM_CURRENT_SENSORS   (3)

Defines the number of current sensors used.

Defined by the hardware capability present May be (2) or (3)

Definition at line 116 of file user.h.

Referenced by main().

#define USER_NUM_ISR_TICKS_PER_CTRL_TICK   (1)

Defines the number of isr ticks (hardware) per controller clock tick (software)

Controller clock tick (CTRL) is the main clock used for all timing in the software Typically the PWM Frequency triggers (can be decimated by the ePWM hardware for less overhead) an ADC SOC ADC SOC triggers an ADC Conversion Done ADC Conversion Done triggers ISR This relates the hardware ISR rate to the software controller rate Typcially want to consider some form of decimation (ePWM hardware, CURRENT or EST) over 16KHz ISR to insure interrupt completes and leaves time for background tasks

Definition at line 193 of file user.h.

#define USER_NUM_PWM_TICKS_PER_ISR_TICK   (3)

DECIMATION.

Defines the number of pwm clock ticks per isr clock tick Note: Valid values are 1, 2 or 3 only

Definition at line 184 of file user.h.

Referenced by angleDelayComp(), and updateCPUusage().

#define USER_NUM_VOLTAGE_SENSORS   (3)

Defines the number of voltage (phase) sensors.

Must be (3)

Definition at line 120 of file user.h.

Referenced by main().

#define USER_OFFSET_POLE_rps   (20.0)

Defines the software pole location for the voltage and current offset estimation, rad/s.

Should not be changed from default of (20.0)

Definition at line 309 of file user.h.

#define USER_POWERWARP_GAIN   (1.0)

Defines the PowerWarp gain for computing Id reference.

Induction motors only

Definition at line 289 of file user.h.

#define USER_PWM_FREQ_kHz   (45.0)

Defines the Pulse Width Modulation (PWM) frequency, kHz.

PWM frequency can be set directly here up to 30 KHz safely (60 KHz MAX in some cases) For higher PWM frequencies (60 KHz+ typical for low inductance, high current ripple motors) it is recommended to use the ePWM hardware and adjustable ADC SOC to decimate the ADC conversion done interrupt to the control system, or to use the software Que example. Otherwise you risk missing interrupts and disrupting the timing of the control state machine

Definition at line 147 of file user.h.

Referenced by angleDelayComp().

#define USER_PWM_PERIOD_usec   (1000.0/USER_PWM_FREQ_kHz)

Defines the Pulse Width Modulation (PWM) period, usec.

Compile time calculation

Definition at line 169 of file user.h.

#define USER_R_OVER_L_EST_FREQ_Hz   (300)

Defines the R/L estimation frequency, Hz.

User higher values for low inductance motors and lower values for higher inductance motors. The values can range from 100 to 300 Hz.

Definition at line 294 of file user.h.

#define USER_SPEED_POLE_rps   (100.0)

Defines the software pole location for the speed control filter, rad/s.

Definition at line 319 of file user.h.

#define USER_SPEEDMAX_FRACTION_FOR_L_IDENT   (1.0)

Defines the fraction of SpeedMax to use during inductance estimation.

Definition at line 281 of file user.h.

#define USER_SYSTEM_FREQ_MHz   (60.0)

CLOCKS & TIMERS.

Defines the system clock frequency, MHz

Definition at line 140 of file user.h.

Referenced by main().

#define USER_TRAJ_FREQ_Hz   (uint_least32_t)(USER_CTRL_FREQ_Hz/USER_NUM_CTRL_TICKS_PER_TRAJ_TICK)

Defines the trajectory frequency, Hz.

Compile time calculation

Definition at line 223 of file user.h.

Referenced by main().

#define USER_VD_SF   (0.95)

Defines the direct voltage (Vd) scale factor.

Definition at line 165 of file user.h.

Referenced by main().

#define USER_VOLTAGE_FILTER_POLE_Hz   (344.62)

POLES.

Defines the analog voltage filter pole location, Hz Must match the hardware filter for Vph

Definition at line 301 of file user.h.

#define USER_VOLTAGE_FILTER_POLE_rps   (2.0 * MATH_PI * USER_VOLTAGE_FILTER_POLE_Hz)

Defines the analog voltage filter pole location, rad/s.

Compile time calculation from Hz to rad/s

Definition at line 305 of file user.h.

Referenced by CTRL_calcMax_Ls_qFmt(), and softwareUpdate1p6().

Defines the voltage scale factor for the system.

Compile time calculation for scale factor (ratio) used throughout the system

Definition at line 97 of file user.h.

#define USER_ZEROSPEEDLIMIT   (0.5 / USER_IQ_FULL_SCALE_FREQ_Hz)

Defines the low speed limit for the flux integrator, pu.

This is the speed range (CW/CCW) at which the ForceAngle object is active, but only if Enabled Outside of this speed - or if Disabled - the ForcAngle will NEVER be active and the angle is provided by FAST only

Definition at line 244 of file user.h.

Referenced by setFeLimitZero().

#define V_A_offset   (0.5084558129)

ADC voltage offsets for A, B, and C phases.

One-time hardware dependent, though the calibration can be done at run-time as well After initial board calibration these values should be updated for your specific hardware so they are available after compile in the binary to be loaded to the controller

Definition at line 132 of file user.h.

Referenced by main().

#define V_B_offset   (0.5074239969)

Definition at line 133 of file user.h.

Referenced by main().

#define V_C_offset   (0.5065535307)

Definition at line 134 of file user.h.

Referenced by main().

Function Documentation

void USER_calcPIgains ( CTRL_Handle  handle)

Updates Id and Iq PI gains.

Parameters
[in]handleThe controller (CTRL) handle

Referenced by main().

void USER_checkForErrors ( USER_Params pUserParams)

Checks for errors in the user parameter values.

Parameters
[in]pUserParamsThe pointer to the user param structure

Referenced by main().

_iq USER_computeFlux ( CTRL_Handle  handle,
const _iq  sf 
)

Computes Flux in Wb or V/Hz depending on the scale factor sent as parameter.

Parameters
[in]handleThe controller (CTRL) handle
[in]sfThe scale factor to convert flux from per unit to Wb or V/Hz
Returns
The flux in Wb or V/Hz depending on the scale factor sent as parameter, in IQ24 format

Referenced by updateGlobalVariables_motor().

_iq USER_computeFlux_pu_to_VpHz_sf ( void  )

Computes the scale factor needed to convert from per unit to V/Hz.

Returns
The scale factor to convert from flux per unit to flux in V/Hz, in IQ24 format

Referenced by main().

_iq USER_computeFlux_pu_to_Wb_sf ( void  )

Computes the scale factor needed to convert from per unit to Wb.

Returns
The scale factor to convert from flux per unit to flux in Wb, in IQ24 format

Referenced by main().

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

Returns
The scale factor to convert torque from Flux * Iq from per unit to Nm, in IQ24 format

Referenced by main().

_iq USER_computeTorque_lbin ( CTRL_Handle  handle,
const _iq  torque_Flux_sf,
const _iq  torque_Ls_sf 
)

Computes Torque in lbin.

Parameters
[in]handleThe controller (CTRL) handle
[in]torque_Flux_sfThe scale factor to convert torque from (Ld - Lq) * Id * Iq from per unit to lbin
[in]torque_Ls_sfThe scale factor to convert torque from Flux * Iq from per unit to lbin
Returns
The torque in lbin, in IQ24 format
_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.

Returns
The scale factor to convert torque from (Ld - Lq) * Id * Iq from per unit to Nm, in IQ24 format

Referenced by main().

_iq USER_computeTorque_Nm ( CTRL_Handle  handle,
const _iq  torque_Flux_sf,
const _iq  torque_Ls_sf 
)

Computes Torque in Nm.

Parameters
[in]handleThe controller (CTRL) handle
[in]torque_Flux_sfThe scale factor to convert torque from (Ld - Lq) * Id * Iq from per unit to Nm
[in]torque_Ls_sfThe scale factor to convert torque from Flux * Iq from per unit to Nm
Returns
The torque in Nm, in IQ24 format

Referenced by updateGlobalVariables_motor().

USER_ErrorCode_e USER_getErrorCode ( USER_Params pUserParams)

Gets the error code in the user parameters.

Parameters
[in]pUserParamsThe pointer to the user param structure
Returns
The error code

Referenced by main().

void USER_setErrorCode ( USER_Params pUserParams,
const USER_ErrorCode_e  errorCode 
)

Sets the error code in the user parameters.

Parameters
[in]pUserParamsThe pointer to the user param structure
[in]errorCodeThe error code
void USER_setParams ( USER_Params pUserParams)

Sets the user parameter values.

Parameters
[in]pUserParamsThe pointer to the user param structure

Referenced by main().

void USER_softwareUpdate1p6 ( CTRL_Handle  handle)

Recalculates Inductances with the correct Q Format.

Parameters
[in]handleThe controller (CTRL) handle

Referenced by main().