This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TMS320F280039C: ModuleOverCurrent fault in DMC_LEVEL_2

Part Number: TMS320F280039C
Other Parts Discussed in Thread: BOOSTXL-3PHGANINV

Tool/software:

I am using the F280039C microcontroller with the BOOSTXL-3PHGANINV driver and opened Universal_motorcontrol_lab_f28003x.

1) In DMC_LEVEL_1: the parameters in the live expressions are correct, however (compared to your pdf guide) I notice that the duty cycle is not 50% in one of the 3 phases:

EPwm1Regs.TBPRD.TBPRD = 2000

EPwm1Regs.CMPA.CMPA = 1000

EPwm2Regs.CMPA.CMPA = 1000

EPwm3Regs.CMPA.CMPA = 0

EPwm6Regs.CMPA.CMPA = 1000

Is there anything wrong with this?

2) In DMC_LEVEL_2 there is module_over _current_flag at 1 as soon as I press on flag_RunAndIdentify.

It's strange, because in DMC_LEVEL_4 the FAST sensorless works without any problems.

  • Hi,

    EPwm3Regs.CMPA.CMPA = 0

    ePWM3 is not used for the BoosterPack, only 1,2,6.

    2) In DMC_LEVEL_2 there is module_over _current_flag at 1 as soon as I press on flag_RunAndIdentify.

    What motor are you using? If a custom one you need to update the v/f parameters. You can also try reducing the acceleration parameter.

    Best,

    Kevin

  • My motor:

    user_mtr1.h:

    
    
    //! \file   /solutions/universal_motorcontrol_lab/common/include/user_mtr1.h
    //! \brief  Contains the user related definitions
    //!         This file is used for each device includes F28002x, F28003x, F280013x,
    //!         F280015x, and the other newer C2000 MCUs.
    //!
    
    
    #ifndef USER_MTR1_H
    #define USER_MTR1_H
    
    //*****************************************************************************
    //
    // If building with a C++ compiler, make all of the definitions in this header
    // have a C binding.
    //
    //*****************************************************************************
    #ifdef __cplusplus
    extern "C"
    {
    #endif
    
    //*****************************************************************************
    //
    //! \defgroup USER USER_MTR1
    //! @{
    //
    //*****************************************************************************
    
    //
    // the includes
    // platforms
    #include "hal.h"
    
    // modules
    #include "userParams.h"
    
    #include "user_common.h"
    
    // *****************************************************************************
    // the defines
    
    //------------------------------------------------------------------------------
    #if defined(HVMTRPFC_REV1P1)
    
    // Bypass the 820k resistor for low voltage motor on this kit
    //#define LV_JUMPER_EN            // Bypass the 820k resistor
    
    
    #ifndef LV_JUMPER_EN
    //! \brief Defines the nominal DC bus voltage, V
    //!
    #define USER_M1_NOMINAL_DC_BUS_VOLTAGE_V         (220.0f)
    
    //! \brief Defines the maximum voltage at the AD converter
    //  Full scale voltage of AD converter, not the current voltage
    #define USER_M1_ADC_FULL_SCALE_VOLTAGE_V         (409.90f)
    
    //! \brief Defines the analog voltage filter pole location, Hz
    //!
    #define USER_M1_VOLTAGE_FILTER_POLE_Hz           (375.55f)
    
    #else   // Populate jumpers on J1/J2/J3/J4 for short R20/R23/R26/R37 for low voltage motor
    //! \brief Defines the nominal DC bus voltage, V
    //!
    #define USER_M1_NOMINAL_DC_BUS_VOLTAGE_V         (24.0f)
    
    //! \brief Defines the maximum voltage at the AD converter
    //  Full scale voltage of AD converter, not the current voltage
    #define USER_M1_ADC_FULL_SCALE_VOLTAGE_V         (112.21f)
    
    //! \brief Defines the analog voltage filter pole location, Hz
    //!
    #define USER_M1_VOLTAGE_FILTER_POLE_Hz           (381.15f)
    #endif
    
    // High Voltage motor control kit
    #if defined(MOTOR1_DCLINKSS) || defined(MOTOR1_ISBLDC)
    //! \brief Defines the maximum current at the AD converter
    #define USER_M1_ADC_FULL_SCALE_CURRENT_A         (19.995f)
    
    //! \brief Defines the sign of the current_sf based on
    //!        the polarity of the current feedback circuit
    //!
    //!        the "sign" = -1.0f if the current feedback polarity is positive that
    //!        means the same pin of the shunt resistor is connected to ground and
    //!        is also connected to the noninverting pin of the operational amplifier
    //!
    //!        the "sign" = 1.0f if the current feedback polarity is negative that
    //!        means the same pin of the shunt resistor is connected to ground and
    //!        is also connected to the inverting pin of the operational amplifier
    #define USER_M1_SIGN_CURRENT_SF         (-1.0f)
    
    //! \brief ADC current offsets for dc-link
    #define USER_M1_IDC_OFFSET_A                     (9.997f)
    
    //! \brief ADC current offsets for dc-link
    #define USER_M1_IDC_OFFSET_AD       (2048.0f)
    
    #define USER_M1_IDC_OFFSET_AD_MAX    (USER_M1_IDC_OFFSET_AD + 100.0f)
    #define USER_M1_IDC_OFFSET_AD_MIN    (USER_M1_IDC_OFFSET_AD - 100.0f)
    #else  // !(MOTOR1_ISBLDC || MOTOR1_DCLINKSS)
    //! \brief Defines the maximum current at the AD converter
    #define USER_M1_ADC_FULL_SCALE_CURRENT_A         (19.995f)
    
    //! \brief Defines the sign of the current_sf based on
    //!        the polarity of the current feedback circuit
    //!
    //!        the "sign" = -1.0f if the current feedback polarity is positive that
    //!        means the same pin of the shunt resistor is connected to ground and
    //!        is also connected to the inverting pin of the operational amplifier
    //!
    //!        the "sign" = 1.0f if the current feedback polarity is negative that
    //!        means the same pin of the shunt resistor is connected to ground and
    //!        is also connected to the noninverting pin of the operational amplifier
    #define USER_M1_SIGN_CURRENT_SF         (1.0f)
    #endif   // !(MOTOR1_ISBLDC || MOTOR1_DCLINKSS)
    
    //! \brief ADC current offsets for A, B, and C phases
    #define USER_M1_IA_OFFSET_AD        (2049.367f)
    #define USER_M1_IB_OFFSET_AD        (2042.771f)
    #define USER_M1_IC_OFFSET_AD        (2054.451f)
    
    //! \brief ADC current offset for CMPSS
    #define USER_M1_IS_OFFSET_CMPSS     (uint16_t)((USER_M1_IA_OFFSET_AD + USER_M1_IB_OFFSET_AD + USER_M1_IC_OFFSET_AD) / 3.0f)
    
    //! \brief ADC voltage offsets for A, B, and C phases
    #define USER_M1_VA_OFFSET_SF        (0.503290117f)
    #define USER_M1_VB_OFFSET_SF        (0.500881076f)
    #define USER_M1_VC_OFFSET_SF        (0.497107089f)
    
    //! \brief DC bus over voltage threshold
    #define USER_M1_OVER_VOLTAGE_FAULT_V        (380.0f)
    
    //! \brief DC bus over voltage threshold
    #define USER_M1_OVER_VOLTAGE_NORM_V         (350.0f)
    
    //! \brief DC bus under voltage threshold
    #define USER_M1_UNDER_VOLTAGE_FAULT_V       (12.0f)
    
    //! \brief DC bus under voltage threshold
    #define USER_M1_UNDER_VOLTAGE_NORM_V        (15.0f)
    
    //! \brief motor lost phase current threshold
    #define USER_M1_LOST_PHASE_CURRENT_A        (0.2f)
    
    //! \brief motor unbalance ratio percent threshold
    #define USER_M1_UNBALANCE_RATIO             (0.2f)
    
    //! \brief motor over load power threshold
    #define USER_M1_OVER_LOAD_POWER_W           (250.0f)
    
    //! \brief motor stall current threshold
    #define USER_M1_STALL_CURRENT_A             (10.0f)
    
    //! \brief motor fault check current threshold
    #define USER_M1_FAULT_CHECK_CURRENT_A       (0.2f)
    
    //! \brief motor failed maximum speed threshold
    #define USER_M1_FAIL_SPEED_MAX_HZ           (500.0f)
    
    //! \brief motor failed minimum speed threshold
    #define USER_M1_FAIL_SPEED_MIN_HZ           (5.0f)
    
    //! \brief Defines the number of failed torque
    //!
    #define USER_M1_TORQUE_FAILED_SET           (0.000001f)
    // end of HVMTRPFC_REV1P1
    //------------------------------------------------------------------------------
    #elif defined(BSXL8353RS_REVA)
    // TODO: BSXL8353RS_REVA defines
    //! \brief Defines the nominal DC bus voltage, V
    //!
    #define USER_M1_NOMINAL_DC_BUS_VOLTAGE_V    (48.0f) // MODIFICABILE
    
    //! \brief Defines the maximum voltage at the AD converter
    #define USER_M1_ADC_FULL_SCALE_VOLTAGE_V    (132.7979508f) // MODIFICABILE ..FORSE è 95V? dato che DRV8353 ha max 95V
    
    //! \brief Defines the analog voltage filter pole location, Hz
    #define USER_M1_VOLTAGE_FILTER_POLE_Hz      (338.1100618f)      // 9.76k/47nF // MODIFICABILE
    
    //! Defines the maximum current at the AD converter, modificalo se c'è overcurrent fault (pag. 74/121 di "Motor Control SDK Universal Project and Lab")
    //  If the motor cannot run with current-closed loop control and an over current fault appears, check if the
    //  sign of "motorVars_M1.adcData.current_sf" and the value of "userParams_M1.current_sf" are set correctly
    //  according to the hardware board
    //#define USER_M1_ADC_FULL_SCALE_CURRENT_A         (94.28571429f)     // gain=5
    #define USER_M1_ADC_FULL_SCALE_CURRENT_A         (47.14285714f)     // gain=10 // MODIFICABILE
    
    #if defined(MOTOR1_DCLINKSS) || defined(MOTOR1_ISBLDC)
    //! \brief Defines the sign of the current_sf based on
    //!        the polarity of the current feedback circuit
    //!
    //!        the "sign" = -1.0f if the current feedback polarity is positive that
    //!        means the same pin of the shunt resistor is connected to ground and
    //!        is also connected to the noninverting pin of the operational amplifier
    //!
    //!        the "sign" = 1.0f if the current feedback polarity is negative that
    //!        means the same pin of the shunt resistor is connected to ground and
    //!        is also connected to the inverting pin of the operational amplifier
    #define USER_M1_SIGN_CURRENT_SF         (-1.0f)
    #error "Single shunt is not supported on this kit"
    #else //!MOTOR1_DCLINKSS
    //! \brief Defines the sign of the current_sf based on
    //!        the polarity of the current feedback circuit
    //!
    //!        the "sign" = -1.0f if the current feedback polarity is positive that
    //!        means the same pin of the shunt resistor is connected to ground and
    //!        is also connected to the inverting pin of the operational amplifier
    //!
    //!        the "sign" = 1.0f if the current feedback polarity is negative that
    //!        means the same pin of the shunt resistor is connected to ground and
    //!        is also connected to the noninverting pin of the operational amplifier
    #define USER_M1_SIGN_CURRENT_SF         (1.0f) // MODIFICABILE
    
    //! \brief ADC current offsets for A, B, and C phases // MODIFICABILE
    #define USER_M1_IA_OFFSET_AD    (2048.0f)
    #define USER_M1_IB_OFFSET_AD    (2048.0f)
    #define USER_M1_IC_OFFSET_AD    (2048.0f)
    
    //! \brief ADC current offset for CMPSS
    #define USER_M1_IS_OFFSET_CMPSS     (uint16_t)((USER_M1_IA_OFFSET_AD + USER_M1_IB_OFFSET_AD + USER_M1_IC_OFFSET_AD) / 3.0f)
    
    //! \brief ADC voltage offsets for A, B, and C phases
    #define USER_M1_VA_OFFSET_SF    (0.500514159f) // MODIFICABILE
    #define USER_M1_VB_OFFSET_SF    (0.506255884f) // MODIFICABILE
    #define USER_M1_VC_OFFSET_SF    (0.503381569f) // MODIFICABILE
    #endif  // !MOTOR1_DCLINKSS
    
    //! \brief DC bus over voltage threshold
    #define USER_M1_OVER_VOLTAGE_FAULT_V        (56.0f) // MODIFICABILE
    
    //! \brief DC bus over voltage threshold
    #define USER_M1_OVER_VOLTAGE_NORM_V         (45.0f) // MODIFICABILE
    
    //! \brief DC bus under voltage threshold
    #define USER_M1_UNDER_VOLTAGE_FAULT_V       (10.0f) // MODIFICABILE
    
    //! \brief DC bus under voltage threshold
    #define USER_M1_UNDER_VOLTAGE_NORM_V        (12.0f) // MODIFICABILE
    
    //! \brief motor lost phase current threshold
    #define USER_M1_LOST_PHASE_CURRENT_A        (0.2f) // MODIFICABILE
    
    //! \brief motor unbalance ratio percent threshold
    #define USER_M1_UNBALANCE_RATIO             (0.2f) // MODIFICABILE
    
    //! \brief motor over load power threshold
    #define USER_M1_OVER_LOAD_POWER_W           (500.0f) // MODIFICABILE
    
    //! \brief motor stall current threshold
    #define USER_M1_STALL_CURRENT_A             (10.0f) // MODIFICABILE
    
    //! \brief motor fault check current threshold
    #define USER_M1_FAULT_CHECK_CURRENT_A       (0.8f) // MODIFICABILE
    
    //! \brief motor failed maximum speed threshold
    #define USER_M1_FAIL_SPEED_MAX_HZ           (500.0f) // MODIFICABILE
    
    //! \brief motor failed minimum speed threshold
    #define USER_M1_FAIL_SPEED_MIN_HZ           (5.0f) // MODIFICABILE
    
    //! \brief Defines the number of failed torque
    //!
    #define USER_M1_TORQUE_FAILED_SET           (0.000001f)
    // end of BSXL8353RS_REVA
    
    //------------------------------------------------------------------------------
    #elif defined(BSXL3PHGAN_REVA)
    //! \brief Defines the nominal DC bus voltage, V
    //!
    #define USER_M1_NOMINAL_DC_BUS_VOLTAGE_V         (48.0f)
    
    //! \brief Defines the maximum voltage at the AD converter
    #define USER_M1_ADC_FULL_SCALE_VOLTAGE_V         (81.49905213f) //max Voltage ADC reading, settalo sulla Vmax prevista a all'ingresso dell'ADC (default 81.49905213f)
    
    //! \brief Defines the analog voltage filter pole location, Hz
    //se lo setto per esempio a 1603.026917f va in moduleovercurrent verso i 650Hz
    #define USER_M1_VOLTAGE_FILTER_POLE_Hz           (1103.026917f)     // default 1103.026917f (33nF) .. nello schematico (in "Phase Current/Voltage Sense") fai f_cutoff=1/[2*pi*R56//R59*C51], spiegato anche a pag 243/591 di "1b - InstaSPIN-FOC and InstaSPIN-MOTION"
    
    //! \brief Defines the maximum current at the AD converter
    #define USER_M1_ADC_FULL_SCALE_CURRENT_A         (33.0f)     // gain=20 .. è la corrente più alta che può essere misurata dall'ADC
    
    //! \brief Defines the sign of the current_sf based on
    //!        the polarity of the current feedback circuit
    //!
    //!        the "sign" = -1.0f if the current feedback polarity is positive that
    //!        means the same pin of the inline shunt resistor is connected to the
    //!        output of the three-phase power inverter and is also connected to
    //!        the inverting pin of the operational amplifier
    //!
    //!        the "sign" = 1.0f if the current feedback polarity is positive that
    //!        means the same pin of the inline shunt resistor is connected to the
    //!        output of the three-phase power inverter and is also connected to
    //!        the non-inverting pin of the operational amplifier
    #define USER_M1_SIGN_CURRENT_SF         (-1.0f)
    
    //! \brief ADC current offsets for A, B, and C phases
    #define USER_M1_IA_OFFSET_AD    (2048.0f)
    #define USER_M1_IB_OFFSET_AD    (2048.0f)
    #define USER_M1_IC_OFFSET_AD    (2048.0f)
    
    //! \brief ADC current offset for CMPSS
    #define USER_M1_IS_OFFSET_CMPSS     (uint16_t)((USER_M1_IA_OFFSET_AD + USER_M1_IB_OFFSET_AD + USER_M1_IC_OFFSET_AD) / 3.0f)
    
    //! \brief ADC voltage offsets for A, B, and C phases
    #define USER_M1_VA_OFFSET_SF    (0.500514159f)
    #define USER_M1_VB_OFFSET_SF    (0.506255884f)
    #define USER_M1_VC_OFFSET_SF    (0.503381569f)
    
    //! \brief DC bus over voltage threshold
    #define USER_M1_OVER_VOLTAGE_FAULT_V        (56.0f)
    
    //! \brief DC bus over voltage threshold
    #define USER_M1_OVER_VOLTAGE_NORM_V         (36.0f)
    
    //! \brief DC bus under voltage threshold
    #define USER_M1_UNDER_VOLTAGE_FAULT_V       (10.0f) //soglia di undervoltage per l'hardware del motore e dell'inverter. Una Vdc maggiore di questo valore indica che un errore software o un guasto hardware ha portato la Vdc calcolata al di sotto dell'intervallo sicuro o previsto definito dall'utente. Settalo su un valore in genere alcuni volt al di sopra del valore minimo necessario per far girare il motore                                                                                                                                                                                   k
    
    //! \brief DC bus under voltage threshold
    #define USER_M1_UNDER_VOLTAGE_NORM_V        (12.0f) //upper threshold that indicates that a DC bus under-voltage fault. Settalo > USER_M1_UNDER_VOLTAGE_FAULT_V
    
    //! \brief motor lost phase current threshold
    #define USER_M1_LOST_PHASE_CURRENT_A        (0.2f)
    
    //! \brief motor unbalance ratio percent threshold
    #define USER_M1_UNBALANCE_RATIO             (0.2f)
    
    //! \brief motor over load power threshold
    #define USER_M1_OVER_LOAD_POWER_W           (100.0f) //la soglia di sovrapotenza per l'hardware del motore e dell'inverter. Nello stato di funzionamento del motore, se la potenza calcolata del motore è superiore a questo valore, indica un errore
    
    //! \brief motor stall current threshold
    #define USER_M1_STALL_CURRENT_A             (10.0f) //soglia di corrente per la Istatore RMS del motore quando la velocità del motore calcolata è inferiore alla soglia di velocità (USER_M1_FAIL_SPEED_MIN_HZ)
    
    //! \brief motor fault check current threshold
    #define USER_M1_FAULT_CHECK_CURRENT_A       (0.2f)
    
    //! \brief motor failed maximum speed threshold
    #define USER_M1_FAIL_SPEED_MAX_HZ           (800.0f) //origine 500
    
    //! \brief motor failed minimum speed threshold
    #define USER_M1_FAIL_SPEED_MIN_HZ           (5.0f)
    
    //! \brief Defines the number of failed torque
    //!
    #define USER_M1_TORQUE_FAILED_SET           (0.000001f)
    // end of BSXL3PHGAN_REVA
    
    //------------------------------------------------------------------------------
    
    //------------------------------------------------------------------------------
    #else   // No Board Selection
    #error The board parameters are not defined in user_mtr1.h
    #endif  // No Board Selection
    
    //------------------------------------------------------------------------------
    //! \brief ADC current offsets checking value for A, B, and C phases
    // the error threshold to check if the ADC offset of the phase current sensing circuit is correct.
    #define USER_M1_IS_OFFSET_AD_DELTA      (150.0f)    // The value is 0.0f~1024.0f // MODIFICABILE =150 di default
    
    // the high threshold of the ADC offsets checking value for A/B/C phase current
    #define USER_M1_IA_OFFSET_AD_MAX        (USER_M1_IA_OFFSET_AD + USER_M1_IS_OFFSET_AD_DELTA)
    #define USER_M1_IB_OFFSET_AD_MAX        (USER_M1_IB_OFFSET_AD + USER_M1_IS_OFFSET_AD_DELTA)
    #define USER_M1_IC_OFFSET_AD_MAX        (USER_M1_IC_OFFSET_AD + USER_M1_IS_OFFSET_AD_DELTA)
    
    // the low threshold of the ADC offsets checking value for A phase current
    #define USER_M1_IA_OFFSET_AD_MIN        (USER_M1_IA_OFFSET_AD - USER_M1_IS_OFFSET_AD_DELTA)
    #define USER_M1_IB_OFFSET_AD_MIN        (USER_M1_IB_OFFSET_AD - USER_M1_IS_OFFSET_AD_DELTA)
    #define USER_M1_IC_OFFSET_AD_MIN        (USER_M1_IC_OFFSET_AD - USER_M1_IS_OFFSET_AD_DELTA)
    
    #define USER_M1_IS_OFFSET_AD_MAX        (USER_M1_IA_OFFSET_AD + USER_M1_IB_OFFSET_AD + USER_M1_IC_OFFSET_AD + (USER_M1_IS_OFFSET_AD_DELTA * 3.0f))
    #define USER_M1_IS_OFFSET_AD_MIN        (USER_M1_IA_OFFSET_AD + USER_M1_IB_OFFSET_AD + USER_M1_IC_OFFSET_AD - (USER_M1_IS_OFFSET_AD_DELTA * 3.0f))
    
    //! \brief ADC voltage offsets for A, B, and C phases
    // the error threshold to check if the ADC offset of the phase voltage sensing circuit is correct
    #define USER_M1_VA_OFFSET_SF_DELTA      (0.05f)     // The value is 0.0f ~ 0.5f // MODIFICABILE =0.05 di default
    
    // the high threshold of the ADC offsets checking value for A/B/C phase voltage
    #define USER_M1_VA_OFFSET_SF_MAX        (USER_M1_VA_OFFSET_SF + USER_M1_VA_OFFSET_SF_DELTA)
    #define USER_M1_VB_OFFSET_SF_MAX        (USER_M1_VB_OFFSET_SF + USER_M1_VA_OFFSET_SF_DELTA)
    #define USER_M1_VC_OFFSET_SF_MAX        (USER_M1_VC_OFFSET_SF + USER_M1_VA_OFFSET_SF_DELTA)
    
    // the low threshold of the ADC offsets checking value for A/B/C phase voltage
    #define USER_M1_VA_OFFSET_SF_MIN        (USER_M1_VA_OFFSET_SF - USER_M1_VA_OFFSET_SF_DELTA)
    #define USER_M1_VB_OFFSET_SF_MIN        (USER_M1_VB_OFFSET_SF - USER_M1_VA_OFFSET_SF_DELTA)
    #define USER_M1_VC_OFFSET_SF_MIN        (USER_M1_VC_OFFSET_SF - USER_M1_VA_OFFSET_SF_DELTA)
    
    #define USER_M1_VS_OFFSET_SF_MAX        (USER_M1_VA_OFFSET_SF + USER_M1_VB_OFFSET_SF + USER_M1_VC_OFFSET_SF + (USER_M1_VA_OFFSET_SF_DELTA * 3.0f))
    #define USER_M1_VS_OFFSET_SF_MIN        (USER_M1_VA_OFFSET_SF + USER_M1_VB_OFFSET_SF + USER_M1_VC_OFFSET_SF - (USER_M1_VA_OFFSET_SF_DELTA * 3.0f))
    
    //******************************************************************************
    // TODO: Motor defines
    //! \brief Defines the number of pwm clock ticks per isr clock tick --> è nella formula di USER_M1_ISR_FREQ_Hz e USER_M1_ISR_PERIOD_usec
    //!        Note: Valid values are 1, 2 or 3 only
    #define USER_M1_NUM_PWM_TICKS_PER_ISR_TICK          (3) // MODIFICABILE .. number of PWM periods per interrupt, this value divides the control interrupt frequency (compreso tra 1 e 3)
    
    //! \brief Defines the number of ISR clock ticks per current controller clock tick
    #define USER_M1_NUM_ISR_TICKS_PER_CURRENT_TICK      (1) //              .. number of interrupt ticks per speed controller ticks, this value divides the speed controller trigger rate
    
    
    //! \brief Defines the number of ISR clock ticks per speed controller clock tick
    #define USER_M1_NUM_ISR_TICKS_PER_SPEED_TICK        (10) // MODIFICABILE origine (10) .. number of interrupt ticks per speed controller ticks, this value divides the speed controller trigger rate. This contributes to system response time
    
    
    //! \brief Defines the number of current sensors
    #define USER_M1_NUM_CURRENT_SENSORS                 (3) // MODIFICABILE
    
    //! \brief Defines the number of voltage sensors
    #define USER_M1_NUM_VOLTAGE_SENSORS                 (3) // MODIFICABILE
    
    
    //! \brief Defines the Pulse Width Modulation (PWM) frequency, kHz
    #define USER_M1_PWM_FREQ_kHz        (30.0f) // MODIFICABILE
    #define USER_M1_PWM_TBPRD_NUM       (uint16_t)(USER_SYSTEM_FREQ_MHz * 1000.0f / USER_M1_PWM_FREQ_kHz / 2.0f)
    
    //! \brief Defines the Pulse Width Modulation (PWM) period, usec
    
    #define USER_M1_PWM_PERIOD_usec     (1000.0f / USER_M1_PWM_FREQ_kHz)
    
    
    //! \brief Defines the Interrupt Service Routine (ISR) frequency, Hz                    // MODIFICABILE
    #define USER_M1_ISR_FREQ_Hz         (USER_M1_PWM_FREQ_kHz * 1000.0f / (float32_t)USER_M1_NUM_PWM_TICKS_PER_ISR_TICK)
    
    //! \brief Defines the Interrupt Service Routine (ISR) period, usec
    //!                     // MODIFICABILE
    #define USER_M1_ISR_PERIOD_usec     (USER_M1_PWM_PERIOD_usec * (float32_t)USER_M1_NUM_PWM_TICKS_PER_ISR_TICK)
    
    
    //! \brief Defines the direct voltage (Vd) scale factor
    #define USER_M1_VD_SF               (0.95f) // MODIFICABILE .. valore massimo iniziale di Vd per il regolatore di corrente Id (tra 0.1 and 0.95), default è 0.95
    
    
    //! \brief Defines the voltage scale factor for the system
    #define USER_M1_VOLTAGE_SF          (USER_M1_ADC_FULL_SCALE_VOLTAGE_V / 4096.0f) // MODIFICABILE
    
    //! \brief Defines the current scale factor for the system
    #define USER_M1_CURRENT_SF          (USER_M1_ADC_FULL_SCALE_CURRENT_A / 4096.0f) // MODIFICABILE
    
    
    //! \brief Defines the current scale invert factor for the system
    #define USER_M1_CURRENT_INV_SF      (4096.0f / USER_M1_ADC_FULL_SCALE_CURRENT_A) // MODIFICABILE
    
    
    //! \brief Defines the analog voltage filter pole location, rad/s
    #define USER_M1_VOLTAGE_FILTER_POLE_rps  (MATH_TWO_PI * USER_M1_VOLTAGE_FILTER_POLE_Hz) // MODIFICABILE
    
    //! \brief Defines the maximum Vs magnitude in per units allowed
    //! \brief This value sets the maximum magnitude for the output of the Id and
    //! \brief Iq PI current controllers. The Id and Iq current controller outputs
    //! \brief are Vd and Vq. The relationship between Vs, Vd, and Vq is:
    //! \brief Vs = sqrt(Vd^2 + Vq^2).  In this FOC controller, the Vd value is set
    //! \brief equal to USER_MAX_VS_MAG*USER_VD_MAG_FACTOR.
    //! \brief so the Vq value is set equal to sqrt(USER_MAX_VS_MAG^2 - Vd^2).
    //!
    //! \brief Set USER_MAX_VS_MAG = 0.5 for a pure sinewave with a peak at
    //! \brief SQRT(3)/2 = 86.6% duty cycle.  No current reconstruction
    //! \brief is needed for this scenario.
    //!
    //! \brief Set USER_MAX_VS_MAG = 1/SQRT(3) = 0.5774 for a pure sinewave
    //! \brief with a peak at 100% duty cycle.  Current reconstruction
    //! \brief will be needed for this scenario (Lab08).
    //!
    //! \brief Set USER_MAX_VS_MAG = 2/3 = 0.6666 to create a trapezoidal
    //! \brief voltage waveform.  Current reconstruction will be needed
    //! \brief for this scenario (Lab08).
    //!
    //! \brief For space vector over-modulation, see lab08 for details on
    //! \brief system requirements that will allow the SVM generator to
    //! \brief go all the way to trapezoidal.
    //!
    //#define USER_M1_MAX_VS_MAG_PU             (0.66f)
    //#define USER_M1_MAX_VS_MAG_PU             (0.65f)
    #define USER_M1_MAX_VS_MAG_PU               (0.576f)
    //#define USER_M1_MAX_VS_MAG_PU             (0.565f)
    //#define USER_M1_MAX_VS_MAG_PU             (0.5f)
    
    
    //! \brief Defines the reference Vs magnitude in per units allowed
    //! \      Set the value equal from 0.5 to 0.95 of the maximum Vs magnitude
    #define USER_M1_VS_REF_MAG_PU               (0.8f * USER_MAX_VS_MAG_PU)
    
    //! \brief Defines the R/L excitation frequency, Hz
    #define USER_M1_R_OVER_L_EXC_FREQ_Hz        (300.0f)
    
    
    //! \brief Defines the R/L Kp scale factor, pu
    //! \brief Kp used during R/L is USER_M1_R_OVER_L_KP_SF * USER_M1_NOMINAL_DC_BUS_VOLTAGE_V / USER_MOTOR1_MAX_CURRENT_A;
    //!
    #define USER_M1_R_OVER_L_KP_SF              (0.02f) // MODIFICABILE .. consigliano di non cambiarlo!
    
    
    //! \brief Defines maximum acceleration for the estimation speed profiles, Hz/sec
    #define USER_M1_MAX_ACCEL_Hzps              (2.0f) // MODIFICABILE
    
    
    //! \brief Defines the controller execution period, usec
    #define USER_M1_CTRL_PERIOD_usec            ((float32_t)USER_M1_ISR_PERIOD_usec)
    
    
    //! \brief Defines the controller execution period, sec
    #define USER_M1_CTRL_PERIOD_sec             ((float32_t)USER_M1_CTRL_PERIOD_usec / 1000000.0f)
    
    
    //! \brief Defines the IdRated delta to use during estimation
    #define USER_M1_IDRATED_DELTA_A                 (0.0001f) // MODIFICABILE
    
    #if defined(_FULL_FAST_LIB)
    //! \brief Defines the forced angle frequency, Hz
    #define USER_M1_FORCE_ANGLE_FREQ_Hz             (1.0f) // MODIFICABILE
    
    //! \brief Defines the forced angle acceleration, Hz
    #define USER_M1_FORCE_ANGLE_ACCEL_Hzps          (1.0f)
    #else  // !_FULL_FAST_LIB
    //! \brief Defines the forced angle frequency, Hz
    #define USER_M1_FORCE_ANGLE_FREQ_Hz             (1.0f)
    #endif  // !_FULL_FAST_LIB
    
    //! \brief Defines the near zero speed limit for electrical frequency estimation, Hz
    //!        The flux integrator uses this limit to regulate flux integration
    #define USER_M1_FREQ_NEARZEROSPEEDLIMIT_Hz      (0.5f) // MODIFICABILE .. 0.5 default
    
    //! \brief Defines the fraction of IdRated to use during inductance estimation
    #define USER_M1_IDRATED_FRACTION_FOR_L_IDENT    (0.5f) // MODIFICABILE
    
    
    //! \brief Defines the fraction of SpeedMax to use during inductance estimation
    #define USER_M1_SPEEDMAX_FRACTION_FOR_L_IDENT   (1.0f) // MODIFICABILE
    
    
    //! \brief Defines the Power Warp gain for computing Id reference
    #define USER_M1_PW_GAIN                         (1.0f) // MODIFICABILE
    
    
    //! \brief Defines the pole location for the DC bus filter, rad/sec
    #define USER_M1_DCBUS_POLE_rps                  (100.0f) // MODIFICABILE
    
    
    //! \brief Defines the pole location for the voltage and current offset estimation, rad/s
    //!
    #define USER_M1_OFFSET_POLE_rps                 (20.0f)
    
    
    //! \brief Defines the pole location for the speed control filter, rad/sec
    //!
    #define USER_M1_SPEED_POLE_rps                  (100.0f) // MODIFICABILE
    
    
    //! \brief Defines the pole location for the direction filter, rad/sec
    //!
    #define USER_M1_DIRECTION_POLE_rps              (MATH_TWO_PI * 10.0f)
    
    //! \brief Defines the pole location for the flux estimation, rad/sec
    //!
    #define USER_M1_FLUX_POLE_rps                   (10.0f)
    
    
    //! \brief Defines the pole location for the R/L estimation, rad/sec
    //!
    #define USER_M1_R_OVER_L_POLE_rps               (MATH_TWO_PI * 3.2f)
    
    
    //! \brief Defines the convergence factor for the estimator
    //!
    #define USER_M1_EST_KAPPAQ                      (1.5f)
    
    //! \brief Defines the scale factor for the flux estimation
    //! the default value is 1.0f, change the value between 0.1f and 1.25f
    //!
    //#define USER_M1_EST_FLUX_HF_SF                (0.120f)
    #define USER_M1_EST_FLUX_HF_SF                  (0.250f) // MODIFICABILE .. default 0.250
    //#define USER_M1_EST_FLUX_HF_SF                (1.00f)
    
    //! \brief Defines the scale factor for the frequency estimation
    //! the default value is 1.0f, change the value between 0.5f and 1.5f
    //!
    #define USER_M1_EST_FREQ_HF_SF                  (1.00f) //..default 1.00f
    
    //! \brief Defines the scale factor for the bemf estimation
    //! the default value is 1.0f, change the value between 0.50f and 1.25f
    //!
    #define USER_M1_EST_BEMF_HF_SF                  (1.00f) // MODIFICABILE
    
    //------------------------------------------------------------------------------
    //! brief Define the Kp gain for Field Weakening Control
    #define USER_M1_FWC_KP                          (0.0525f) // MODIFICABILE
    
    //! brief Define the Ki gain for Field Weakening Control
    #define USER_M1_FWC_KI                          (0.00325f) // MODIFICABILE
    
    //! brief Define the maximum current vector angle for Field Weakening Control
    #define USER_M1_FWC_MAX_ANGLE          -15.0f                        // degree // MODIFICABILE
    #define USER_M1_FWC_MAX_ANGLE_RAD      USER_M1_FWC_MAX_ANGLE /180.0f * MATH_PI  // rad
    
    //! brief Define the minimum current vector angle for Field Weakening Control
    #define USER_M1_FWC_MIN_ANGLE          0.0f                          // degree // MODIFICABILE
    #define USER_M1_FWC_MIN_ANGLE_RAD      USER_M1_FWC_MIN_ANGLE /180.0f * MATH_PI  // rad
    
    //! \brief Defines the number of DC bus over/under voltage setting time
    //!  timer base = 5ms
    #define USER_M1_VOLTAGE_FAULT_TIME_SET          (500U)      // in 5ms
    
    //! \brief Defines the number of motor over load setting time
    //!  timer base = 5ms, 1s
    #define USER_M1_OVER_LOAD_TIME_SET              (200U) // MODIFICABILE
    
    //! \brief Defines the number of motor stall setting time
    //!  timer base = 5ms, 1s
    #define USER_M1_STALL_TIME_SET                  (200U) // MODIFICABILE
    
    //! \brief Defines the number of phase unbalanced setting time
    //!  timer base = 5ms, 5s
    #define USER_M1_UNBALANCE_TIME_SET              (1000U) // MODIFICABILE
    
    //! \brief Defines the number of lost phase setting time
    //!  timer base = 5ms, 10s
    #define USER_M1_LOST_PHASE_TIME_SET             (2000U) // MODIFICABILE
    
    //! \brief Defines the number of over speed setting time
    //!  timer base = 5ms
    #define USER_M1_OVER_SPEED_TIME_SET             (600U) // MODIFICABILE
    
    //! \brief Defines the number of startup failed setting time
    //!  timer base = 5ms, 10s
    #define USER_M1_STARTUP_FAIL_TIME_SET           (2000U) // MODIFICABILE
    
    //! \brief Defines the number of over load setting times
    //!
    #define USER_M1_OVER_CURRENT_TIMES_SET          (5U) // MODIFICABILE
    
    //! \brief Defines the number of stop wait time
    //!  timer base = 5ms, 10s
    #define USER_M1_STOP_WAIT_TIME_SET              (2000U)
    
    //! \brief Defines the number of restart wait time
    //!  timer base = 5ms, 10s
    #define USER_M1_RESTART_WAIT_TIME_SET           (2000U) // MODIFICABILE
    
    //! \brief Defines the number of restart times when has a fault
    //!
    #define USER_M1_START_TIMES_SET                 (3U) // MODIFICABILE
    
    //! \brief Defines the alignment time
    //!  timer base = 5ms, 10s
    #define USER_M1_ALIGN_TIME_SET              (2000U)
    
    //! \brief Defines the QEP unit ticks
    #define USER_M1_QEP_UNIT_TIMER_TICKS        (uint32_t)(USER_SYSTEM_FREQ_MHz/(2.0f * USER_M1_ISR_FREQ_Hz) * 1000000.0f)
    
    //! \brief Defines the current filter pole location, Hz
    #define USER_M1_IS_FILTER_POLE_Hz           (7500.0f)      // default 7500.0f (7.5kHz)
    
    //! \brief Defines the current filter pole location, rad/s
    //!
    #define USER_M1_IS_FILTER_POLE_rps          (MATH_TWO_PI * USER_M1_IS_FILTER_POLE_Hz)
    
    
    //! \brief Defines the voltage filter pole location, Hz
    #define USER_M1_VS_FILTER_POLE_Hz           (30000.0f)     // 30.0kHz
    
    //! \brief Defines the voltage filter pole location, rad/s
    //!
    #define USER_M1_VS_FILTER_POLE_rps          (MATH_TWO_PI * USER_M1_VS_FILTER_POLE_Hz)
    
    //==============================================================================
    // Only a few listed motor below are tested with the related algorithm as the comments
    // TODO: Motor defines
    // Motor defines
    // High voltage PMSM Motors
    //#define USER_MOTOR1 Estun_EMJ_04APB22            //* Tested, FAST/eSMO/ENC
    //#define USER_MOTOR1 Anaheim_BLWS235D             //* Tested, FAST
    
    //#define USER_MOTOR1 CHMotor_WM_Test
    //#define USER_MOTOR1 Anaheim_BLZ362S
    //#define USER_MOTOR1 ziehlab_Fan160hv                //* Tested, FAST/eSMO
    //#define USER_MOTOR1 embpast_Fan160hv              //* Tested, FAST/eSMO
    //#define USER_MOTOR1 GMCC_KSK89D53U                //* Tested, FAST/eSMO
    //#define USER_MOTOR1 QXA_A091ZE190A                //* Tested, FAST/eSMO
    //#define USER_MOTOR1 Baldor_BSM90N175              //* Tested, FAST/eSMO
    //#define USER_MOTOR1 Marathon_N56PNRA10102         //* Tested, FAST
    
    // Low Voltage PMSM Motors
    //#define USER_MOTOR1 Anaheim_BLY172S_24V           //* Tested, FAST/eSMO/HALL/ENC(MD)
    //#define USER_MOTOR1 Teknic_M2310PLN04K            //* Tested, FAST/eSMO/ENC/HALL
    //#define USER_MOTOR1 Nedic_EPSMS037_D12V
    //#define USER_MOTOR1 Anaheim_BLY341S_48V
    //#define USER_MOTOR1 Anaheim_BLY341S_Y24V
    //#define USER_MOTOR1 Anaheim_BLY341S_D24V
    //#define USER_MOTOR1 Drone_DJI920KV                //* Tested, FAST
    //#define USER_MOTOR1 Drone_BLK2BLADE               //* Tested, FAST
    //#define USER_MOTOR1 Drone_SENSEFLY                //* Tested, FAST
    //#define USER_MOTOR1 Drone_SF_Black                //* Tested, FAST
    //#define USER_MOTOR1 Drone9616_110KV_48V           //* Tested, FAST
    
    //#define USER_MOTOR1 Tamagawa_TS4606N8302            //* Tested, FAST/Resolver
    //#define USER_MOTOR1 AKM21G_CK9NGE00               //* Tested, FAST/sin&cos encoder
    
    //#define USER_MOTOR1 AirFan_MFA0500_24V            //* Tested, FAST
    //#define USER_MOTOR1 Tool_Makita_GFD01             //* Tested, FAST
    
    // ACI Motor
    //#define USER_MOTOR1 Marathon_5K33GN2A
    //#define USER_MOTOR1 Marathon_56H17T2011A
    //#define USER_MOTOR1 Dayton_3N352C
    //#define USER_MOTOR1 EMSYNERGY_LVACI
    
    #define USER_MOTOR1 my_pm_motor_1
    //#define USER_MOTOR1 my_aci_motor_2
    //#define USER_MOTOR1 RL_simulation
    
    //------------------------------------------------------------------------------
    #if (USER_MOTOR1 == Teknic_M2310PLN04K)
    // the motor type
    #define USER_MOTOR1_TYPE                   MOTOR_TYPE_PM
    
    // the number of pole pairs of the motor
    #define USER_MOTOR1_NUM_POLE_PAIRS         (4)
    
    // the rotor resistance value of the motor, in Ohm
    #define USER_MOTOR1_Rr_Ohm                 (NULL)
    
    // the stator resistance value of the motor, in Ohm
    #define USER_MOTOR1_Rs_Ohm                 (0.393955578f)
    
    // the stator inductance value of the motor in the direct direction, in H
    #define USER_MOTOR1_Ls_d_H                 (0.000190442806f)
    
    // the stator inductance value of the motor in the quadrature direction, in H
    #define USER_MOTOR1_Ls_q_H                 (0.000190442806f)
    
    // the rated flux value of the motor, in V/Hz
    #define USER_MOTOR1_RATED_FLUX_VpHz        (0.0399353318f)
    
    // the Id rated current value of the motor, in A. Induction motors only
    #define USER_MOTOR1_MAGNETIZING_CURRENT_A  (NULL)
    
    // the maximum current value for stator resistance (R_s) identification, in A
    #define USER_MOTOR1_RES_EST_CURRENT_A      (1.5f)
    
    // the maximum current value to use for stator inductance identification, in A
    #define USER_MOTOR1_IND_EST_CURRENT_A      (-1.0f)
    
    // the maximum current value of the motor, in A
    #define USER_MOTOR1_MAX_CURRENT_A          (6.6f)
    
    // the R/L excitation frequency for motor parameters identification, in Hz
    #define USER_MOTOR1_FLUX_EXC_FREQ_Hz       (60.0f)
    
    // the inertia that describes the amount of mass, in Kg.m2
    #define USER_MOTOR1_INERTIA_Kgm2           (7.06154e-06)
    
    // the rated voltage of the motor, V
    #define USER_MOTOR1_RATED_VOLTAGE_V        (24.0f)          // V
    
    // the minimum rotation frequency if the motor (Hz)
    #define USER_MOTOR1_FREQ_MIN_Hz            (9.0f)           // Hz
    
    // the maximum/base rotation frequency of the motor (Hz)
    #define USER_MOTOR1_FREQ_MAX_Hz            (600.0f)         // Hz
    
    // V/f Profile Parameters for open-loop in build level 2
    // the low frequency f_low  of V/f profile, in Hz,
    // set to 10% of rated motor frequency
    #define USER_MOTOR1_FREQ_LOW_Hz            (5.0f)           // Hz
    
    // the high frequency f_high of V/f profile, in Hz,
    // set to 100% of rated motor frequency
    #define USER_MOTOR1_FREQ_HIGH_Hz           (400.0f)         // Hz
    
    // the minimum voltage V_min  of V/f profile,
    // the value is suggested to set to 15% of rated motor voltage, in Volt.
    #define USER_MOTOR1_VOLT_MIN_V             (1.0f)           // Volt
    
    // the maximum voltage,  V_max of V/f profile,
    // the value is suggested to set to 100% of rated motor voltage, in Volt
    #define USER_MOTOR1_VOLT_MAX_V             (24.0f)          // Volt
    
    // the current increasing delta value for running the motor with force open-loop , in A
    #define USER_MOTOR1_FORCE_DELTA_A          (0.05f)          // A
    
    // the current increasing delta value for motor rotor alignment, in A
    #define USER_MOTOR1_ALIGN_DELTA_A          (0.01f)          // A
    
    // the current for running the motor with force open-loop or startup, in A
    #define USER_MOTOR1_FLUX_CURRENT_A         (0.5f)           // A
    
    // the current for motor rotor alignment, in A
    #define USER_MOTOR1_ALIGN_CURRENT_A        (1.5f)           // A
    
    // the current for start to run motor with closed-loop when the speed is
    //  lower than the startup setting speed, in A
    #define USER_MOTOR1_STARTUP_CURRENT_A      (3.5f)           // A
    
    // the current for running the motor with torque control mode when start the motor, in A.
    #define USER_MOTOR1_TORQUE_CURRENT_A       (3.0f)           // A
    
    // the over-current threshold for the motor, in A.
    // The value can be set to 50%~300% of the rated current of the motor
    #define USER_MOTOR1_OVER_CURRENT_A         (7.5f)           // A
    
    // the speed threshold for start the motor, in Hz
    #define USER_MOTOR1_SPEED_START_Hz         (35.0f)          // Hz
    
    // the speed threshold for running the motor with force open-loop, in Hz
    #define USER_MOTOR1_SPEED_FORCE_Hz         (30.0f)          // Hz
    
    // the acceleration for start the motor, in Hz/s.
    #define USER_MOTOR1_ACCEL_START_Hzps       (10.0f)          // Hz/s
    
    // the maximum acceleration for running the motor, in Hz/s
    #define USER_MOTOR1_ACCEL_MAX_Hzps         (20.0f)          // Hz/s
    
    // the speed threshold for running the motor with flying start mode, in Hz
    #define USER_MOTOR1_SPEED_FS_Hz            (3.0f)           // Hz
    
    // the current for motor brake, in A.
    #define USER_MOTOR1_BRAKE_CURRENT_A        (1.0f)           // A
    
    // the duration time for motor brake, in 5ms time base
    #define USER_MOTOR1_BRAKE_TIME_DELAY       (12000U)         // 60s/5ms
    
    #if defined(MOTOR1_ENC)
    // Only for encoder
    #define USER_MOTOR1_NUM_ENC_SLOTS          (1000)           // lines
    #define USER_MOTOR1_ENC_POS_MAX            (USER_MOTOR1_NUM_ENC_SLOTS * 4 - 1)
    #define USER_MOTOR1_ENC_POS_OFFSET         (668)            // lines
    #endif  // MOTOR1_ENC
    
    #if defined(MOTOR1_FAST)
    // the slope coefficient for Ld compensation, (0.0f~0.5f)
    #define USER_MOTOR1_Ls_d_COMP_COEF         (0.15f)          // 0.0f~0.5f
    
    // the slope coefficient for Lq compensation, (0.0f~0.5f)
    #define USER_MOTOR1_Ls_q_COMP_COEF         (0.35f)          // 0.0f~0.5f
    
    // the minimum inductance coefficient for inductance compensation, (0.0f~0.5f)
    #define USER_MOTOR1_Ls_MIN_NUM_COEF        (0.55f)          // 0.5f~1.0f
    
    // the near zero speed limit for electrical frequency estimation, Hz.
    // The flux integrator uses this limit to regulate flux integration
    #define USER_MOTOR1_FREQ_NEARZEROLIMIT_Hz  (5.0f)           // Hz
    
    // the waiting time without enabling the Rs online clibrartion,  in 5ms
    #define USER_MOTOR1_RSONLINE_WAIT_TIME      (60000U)    // 5min/300s at 5ms base
    
    // the the duration time with enabling the Rs online clibrartion,  in 5ms
    #define USER_MOTOR1_RSONLINE_WORK_TIME      (24000U)     //2min/120s at 5ms base
    #endif  // MOTOR1_FAST
    
    #if defined(MOTOR1_ESMO)
    // Only for eSMO
    // PLL (phase-locked loop)
    // PID proportional, integral, derivative
    // the sliding mode control maximum gain that equals to Ke*fmax/vscale/sqrt(2)*factor(max),
    //  tune the factor(0.1~10) based the test status
    #define USER_MOTOR1_KSLIDE_MAX             (0.50f)
    
    // the sliding mode control minimum gain that equals to Ke*fmin/vscale/sqrt(2)*factor(min),
    //  tune the factor(0.1~10) based the test status
    #define USER_MOTOR1_KSLIDE_MIN             (0.10f)
    
    // the PLL control maximum gain that equals to 2*(Damping factor)*(Natural frequency)*factor(max),
    // tune the factor(0.1~10) based the test status
    #define USER_MOTOR1_PLL_KP_MAX             (10.0f)
    
    // the PLL control minimum gain that equals to 2*(Damping factor)*(Natural frequency)*factor(min),
    // tune the factor(0.1~5) based the test status
    #define USER_MOTOR1_PLL_KP_MIN             (1.50f)
    
    // the PLL control gain adjusting coefficient that
    // equals to (Kpll_max-Kpll_min)/fscale/fmax
    #define USER_MOTOR1_PLL_KP_SF              (5.0f)
    
    // the phase-locked loop control integration gain that
    // equals to (Natural frequency)*(Natural frequency)*Ts
    #define USER_MOTOR1_PLL_KI                 (2.8125E-06f)    // Not used, reserve
    
    // the threshold of the estimated current error for sliding mode control that
    // equals to (motor maximum BEMF voltage / rated voltage), (0.3~0.5 )
    #define USER_MOTOR1_BEMF_THRESHOLD         (0.5f)
    
    // the parameters of the low-pass filter for the estimated back EMF,
    // Kslf equal to (fc*2*PI()*Ts), (0.5~2.5)
    #define USER_MOTOR1_BEMF_KSLF_FC_SF        (2.0f)
    
    // the offset coefficient to compensate the error by using
    // the low-pass filter that equals to 1.0, or [0.5~1.5]
    #define USER_MOTOR1_THETA_OFFSET_SF        (1.0f)
    
    // the cut-off frequency of the low-pass filter to calculate the estimated speed, (100~400)
    #define USER_MOTOR1_SPEED_LPF_FC_Hz        (200.0f)
    #endif  // MOTOR1_ESMO
    
    #if defined(MOTOR1_HALL)
    // Only for hall sensor
    #define USER_MOTOR1_HALL_DELTA_rad          (MATH_TWO_PI / 36.0f)   // rad
    #endif  // MOTOR1_HALL
    
    #if defined(MOTOR1_ISBLDC)
    // Only for IS-BLDC
    #define USER_MOTOR1_RAMP_START_Hz           (3.0f)
    #define USER_MOTOR1_RAMP_END_Hz             (30.0f)
    #define USER_MOTOR1_RAMP_DELAY              (5)
    
    #define USER_MOTOR1_ISBLDC_INT_MAX          (0.015f)
    #define USER_MOTOR1_ISBLDC_INT_MIN          (0.010f)
    
    #define USER_MOTOR1_ISBLDC_I_REF_A          (1.0f)      // 1.0(A)
    #define USER_MOTOR1_ISBLDC_I_START_A        (0.5f)      // 0.5(A)
    
    #define USER_MOTOR1_ISBLDC_DUTY_REF         (0.10f)     // 10%
    #define USER_MOTOR1_ISBLDC_DUTY_START       (0.10f)     // 10%
    #endif  // MOTOR1_ISBLDC
    
    // Current and Speed PI Regulators Tuning Coefficient
    // the low speed threshold for adjusting the Kp and Ki of the speed PI regulator
    #define USER_MOTOR1_GAIN_SPEED_LOW_Hz        (60.0f)      // 10%~50% of the rated speed
    
    // the high speed threshold for adjusting the Kp and Ki of the speed PI regulator
    #define USER_MOTOR1_GAIN_SPEED_HIGH_Hz       (150.0f)     // 50%~100% of the rated speed
    
    // the gain coefficient to adjust the Kp of the speed PI regulator for startup
    #define USER_MOTOR1_KP_SPD_START_SF          (1.5f)       // 0.1~100.0
    
    // the gain coefficient to adjust the Ki of the speed PI regulator for startup
    #define USER_MOTOR1_KI_SPD_START_SF          (1.5f)       // 0.1~10.0
    
    // the low gain coefficient  to adjust the Kp of the speed PI regulator
    #define USER_MOTOR1_KP_SPD_LOW_SF            (2.0f)       // 0.1~100.0
    
    // the low gain coefficient  to adjust the Ki of the speed PI regulator
    #define USER_MOTOR1_KI_SPD_LOW_SF            (2.0f)       // 0.1~10.0
    
    // the high gain coefficient  to adjust the Kp of the speed PI regulator
    #define USER_MOTOR1_KP_SPD_HIGH_SF           (1.0f)       // 0.1~100.0
    
    // the high gain coefficient  to adjust the Ki of the speed PI regulator
    #define USER_MOTOR1_KI_SPD_HIGH_SF           (1.0f)       // 0.1~10.0
    
    // the low current threshold to adjust the Kp and Ki of the q-axis current PI regulator
    #define USER_MOTOR1_GAIN_IQ_LOW_A            (2.0f)       // 10%~50% of the rated current
    
    // the high current threshold to adjust the Kp and Ki of the q-axis current PI regulator
    #define USER_MOTOR1_GAIN_IQ_HIGH_A           (6.0f)       // 50%~100% of the rated current
    
    // the gain coefficient to adjust the Kp of the q-axis current PI regulator for startup
    #define USER_MOTOR1_KP_IQ_START_SF           (1.5f)       // 0.1~10.0
    
    // the gain coefficient to adjust the Ki of the q-axis current PI regulator for startup
    #define USER_MOTOR1_KI_IQ_START_SF           (1.5f)       // 0.1~10.0
    
    // the low gain coefficient to adjust the Kp of the q-axis current PI regulator
    #define USER_MOTOR1_KP_IQ_LOW_SF             (2.0f)       // 0.1~10.0
    
    // the low gain coefficient to adjust the Ki of the q-axis current PI regulator
    #define USER_MOTOR1_KI_IQ_LOW_SF             (2.0f)       // 0.1~10.0
    
    // the high gain coefficient to adjust the Kp of the d-axis current PI regulator
    #define USER_MOTOR1_KP_IQ_HIGH_SF            (1.0f)       // 0.1~10.0
    
    // the high gain coefficient to adjust the Ki of the d-axis current PI regulator
    #define USER_MOTOR1_KI_IQ_HIGH_SF            (1.0f)       // 0.1~10.0
    
    // the gain coefficient to adjust the Kp of the q-axis current PI regulator
    #define USER_MOTOR1_KP_ID_SF                 (1.0f)       // 0.1~10.0
    
    // the gain coefficient to adjust the Ki of the q-axis current PI regulator
    #define USER_MOTOR1_KI_ID_SF                 (1.0f)       // 0.1~10.0
    
    //------------------------------------------------------------------
    #elif (USER_MOTOR1 == my_pm_motor_1)
    
    // TODO: Motor defines (motore grande) .. settati per identificazione
    /* Dal sito web (vedi chat whatsapp):
    Imax = 80A
    Vmax = 58V
    Pmax = 4.5kW
    Tmax = 15Nm
    KV = 170
    */
    #if 0
    #define USER_MOTOR1_TYPE                   MOTOR_TYPE_PM
    #define USER_MOTOR1_NUM_POLE_PAIRS         (7)
    #define USER_MOTOR1_Rr_Ohm                 (NULL)
    #define USER_MOTOR1_Rs_Ohm                 (0.00581)
    #define USER_MOTOR1_Ls_d_H                 (0.00001395)
    #define USER_MOTOR1_Ls_q_H                 (0.00001395)
    #define USER_MOTOR1_RATED_FLUX_VpHz        (0.03879)
    #define USER_MOTOR1_MAGNETIZING_CURRENT_A  (NULL)
    #define USER_MOTOR1_RES_EST_CURRENT_A      (10.0f)  //10~30% of rated current of the motor
    #define USER_MOTOR1_IND_EST_CURRENT_A      (-10.0f) //10~30% of rated current of the motor
    #define USER_MOTOR1_MAX_CURRENT_A          (95.0f)  //30~150% of rated current of the motor
    #define USER_MOTOR1_FLUX_EXC_FREQ_Hz       (20.0f)  //10~30% of rated frequency of the motor
    #endif
    
    // (motore medio) .. stimati da Marco con la 069
    #if 0
    #define USER_MOTOR1_TYPE                   MOTOR_TYPE_PM
    #define USER_MOTOR1_NUM_POLE_PAIRS         (7)
    #define USER_MOTOR1_Rr_Ohm                 (NULL)
    #define USER_MOTOR1_Rs_Ohm                 (0.0228128177)
    #define USER_MOTOR1_Ls_d_H                 (0.00004598)
    #define USER_MOTOR1_Ls_q_H                 (0.00004598)
    #define USER_MOTOR1_RATED_FLUX_VpHz        (0.0452475)
    #define USER_MOTOR1_MAGNETIZING_CURRENT_A  (NULL)
    #define USER_MOTOR1_RES_EST_CURRENT_A      (10.0f)
    #define USER_MOTOR1_IND_EST_CURRENT_A      (-10.0f)
    #define USER_MOTOR1_MAX_CURRENT_A          (95.0f)
    #define USER_MOTOR1_FLUX_EXC_FREQ_Hz       (20.0f)
    #endif
    
    // (motore medio) .. stimati da me con il boostxl
    #if 1
    #define USER_MOTOR1_TYPE                   MOTOR_TYPE_PM
    #define USER_MOTOR1_NUM_POLE_PAIRS         (7)
    #define USER_MOTOR1_Rr_Ohm                 (NULL)
    #define USER_MOTOR1_Rs_Ohm                 (0.0298128177)
    #define USER_MOTOR1_Ls_d_H                 (0.00004258)
    #define USER_MOTOR1_Ls_q_H                 (0.00004258)
    #define USER_MOTOR1_RATED_FLUX_VpHz        (0.0402475)
    #define USER_MOTOR1_MAGNETIZING_CURRENT_A  (NULL)
    #define USER_MOTOR1_RES_EST_CURRENT_A      (8.0f)  //10~30% of rated current of the motor
    #define USER_MOTOR1_IND_EST_CURRENT_A      (-8.0f) //10~30% of rated current of the motor, just enough to enable rotation
    #define USER_MOTOR1_MAX_CURRENT_A          (40.0f)  //30~150% of rated current of the motor
    #define USER_MOTOR1_FLUX_EXC_FREQ_Hz       (20.0f)  //30% of rated frequency of the motor
    #endif
    
    
    //DJI2312 (motore piccolino)
    //stimati nella GUI (funzionano!)
    #if 0
    #define USER_MOTOR1_TYPE                   MOTOR_TYPE_PM
    #define USER_MOTOR1_NUM_POLE_PAIRS         (7)
    #define USER_MOTOR1_Rr_Ohm                 (NULL)
    #define USER_MOTOR1_Rs_Ohm                 (0.03577)
    #define USER_MOTOR1_Ls_d_H                 (0.00001395)
    #define USER_MOTOR1_Ls_q_H                 (0.00001395)
    #define USER_MOTOR1_RATED_FLUX_VpHz        (0.00613)
    #define USER_MOTOR1_MAGNETIZING_CURRENT_A  (NULL)
    #define USER_MOTOR1_RES_EST_CURRENT_A      (1.0f)
    #define USER_MOTOR1_IND_EST_CURRENT_A      (-1.0f)
    #define USER_MOTOR1_MAX_CURRENT_A          (1.5f)  //Imax gestibile dal motore
    #define USER_MOTOR1_FLUX_EXC_FREQ_Hz       (20.0f)
    #endif
    
    //DJI2312 (motore piccolino)
    //stimati qui su CCS (funzionano!) .. valori strani! non fidarti!
    #if 0
    #define USER_MOTOR1_TYPE                   MOTOR_TYPE_PM
    #define USER_MOTOR1_NUM_POLE_PAIRS         (7)
    #define USER_MOTOR1_Rr_Ohm                 (0.00101999997)
    #define USER_MOTOR1_Rs_Ohm                 (0.00101999997)
    #define USER_MOTOR1_Ls_d_H                 (0.0000000999997)
    #define USER_MOTOR1_Ls_q_H                 (0.0000000999997)
    #define USER_MOTOR1_RATED_FLUX_VpHz        (0.011187955)
    #define USER_MOTOR1_MAGNETIZING_CURRENT_A  (NULL)
    #define USER_MOTOR1_RES_EST_CURRENT_A      (1.0f)
    #define USER_MOTOR1_IND_EST_CURRENT_A      (-1.0f)
    #define USER_MOTOR1_MAX_CURRENT_A          (1.0f)
    #define USER_MOTOR1_FLUX_EXC_FREQ_Hz       (20.0f)
    #endif
    
    
    // TODO: Motor defines
    // Number of lines on the motor's quadrature encoder
    #define USER_MOTOR1_NUM_ENC_SLOTS          (1000)     // MODIFICABILE
    
    #define USER_MOTOR1_INERTIA_Kgm2           (7.06154e-06) // MODIFICABILE
    
    // Ls compensation coefficient
    #define USER_MOTOR1_Ls_d_COMP_COEF         (0.15f)          // 0.0f~0.5f // MODIFICABILE
    #define USER_MOTOR1_Ls_q_COMP_COEF         (0.35f)          // 0.0f~0.5f // MODIFICABILE
    #define USER_MOTOR1_Ls_MIN_NUM_COEF        (0.55f)          // 0.5f~1.0f // MODIFICABILE
    
    #define USER_MOTOR1_FREQ_NEARZEROLIMIT_Hz  (5.0f)          // Hz
    
    #define USER_MOTOR1_RATED_VOLTAGE_V        (48.0f)         // Volt     // MODIFICABILE
    #define USER_MOTOR1_FREQ_MIN_Hz            (9.0f)          // Hz       // MODIFICABILE
    #define USER_MOTOR1_FREQ_MAX_Hz            (800.0f)         // Hz      // MODIFICABILE .. maximum rotational speed of the motor in Hz, dipende dal sistema e può essere superiore alla velocità nominale del motore. Un valore di 100% - 150% della velocità nominale del motore è tipico.
    
    
    //Open Loop Voltage/Frequency Profile Parameters:
    #define USER_MOTOR1_FREQ_LOW_Hz            (5.0f)            // Hz     // MODIFICABILE .. limiti inferiori della regione lineare del profilo tensione/frequenza del motore. Settalo a circa il 10% della frequenza nominale del motore .. era 5 .. il 10% di USER_MOTOR1_FREQ_HIGH_Hz, quindi 672
    #define USER_MOTOR1_FREQ_HIGH_Hz           (2000.0f)          // Hz     // MODIFICABILE .. limiti superiori della regione lineare del profilo tensione/frequenza del motore. Settalo uguale alla frequenza nominale del motore, motore medio ha KV=140[RPM/V], con 48V (rated voltage) --> 140*48=6720 .. era 400
    #define USER_MOTOR1_VOLT_MIN_V             (1.0f)            // Volt   // MODIFICABILE .. è la tensione that generates a speed of USER_MOTOR1_FREQ_LOW_Hz nel motore. Settalo circa al 15% of the rated motor voltage (default è 1.0f)
    #define USER_MOTOR1_VOLT_MAX_V             (48.0f)           // Volt   // MODIFICABILE .. è la tensione that generates a speed of USER_MOTOR1_FREQ_HIGH_Hz nel motore. Settalo uguale alla tensione nominale del motore (default è 55.0f)
    
    
    #define USER_MOTOR1_FORCE_DELTA_A          (0.05f)          // A
    #define USER_MOTOR1_ALIGN_DELTA_A          (0.01f)          // A
    #define USER_MOTOR1_FLUX_CURRENT_A         (0.5f)           // A // MODIFICABILE .. è la correnet used to run the motor in forced open-loop. Settalo to 5%-50% of the rated current of the motor
    #define USER_MOTOR1_ALIGN_CURRENT_A        (1.5f)           // A // MODIFICABILE 5%-50% of the rated current of the motor
    #define USER_MOTOR1_STARTUP_CURRENT_A      (3.5f)           // A // MODIFICABILE
    #define USER_MOTOR1_TORQUE_CURRENT_A       (2.0f)           // A // MODIFICABILE
    
    //The over current fault will be trigger if the motorVars_M1.overCurrent_A is set to a value less than the motor phase current actual value,
    //the PWM output will be disabled, the motorVars_M1.flagEnableRunAndIdentify is cleared to 0, and the motorVars_M1.faultMtrUse.all will be set to 0x10 (16)
    #define USER_MOTOR1_OVER_CURRENT_A         (40.0f)           // A // MODIFICABILE è la Imax(picco) di fase prima del fault over current .. è settato tra il 50% e il 300% della Inominale del motore .. motore medio = 9.5A ..
    
    #define USER_MOTOR1_BRAKE_CURRENT_A        (1.0f)           // A // MODIFICABILE
    #define USER_MOTOR1_BRAKE_TIME_DELAY       (12000U)        // 60s/5ms  // MODIFICABILE// MODIFICABILE
    
    #define USER_MOTOR1_SPEED_START_Hz         (30.0f) // MODIFICABILE
    #define USER_MOTOR1_SPEED_FORCE_Hz         (25.0f) // MODIFICABILE
    #define USER_MOTOR1_ACCEL_START_Hzps       (10.0f) // MODIFICABILE .. era 10
    #define USER_MOTOR1_ACCEL_MAX_Hzps         (80.0f) // MODIFICABILE .. era 80
    
    #define USER_MOTOR1_SPEED_FS_Hz            (3.0f) // MODIFICABILE
    
    // only for encoder
    #define USER_MOTOR1_ENC_POS_MAX            (USER_MOTOR1_NUM_ENC_SLOTS * 4 - 1) // MODIFICABILE
    #define USER_MOTOR1_ENC_POS_OFFSET         (668) // MODIFICABILE
    
    // Only for eSMO
    #define USER_MOTOR1_KSLIDE_MAX             (0.75f)      //
    #define USER_MOTOR1_KSLIDE_MIN             (0.15f)
    
    #define USER_MOTOR1_PLL_KP_MAX             (6.75f)      //
    #define USER_MOTOR1_PLL_KP_MIN             (0.75f)
    #define USER_MOTOR1_PLL_KP_SF              (5.0f)
    #define USER_MOTOR1_PLL_KI                 (2.8125E-06f)    // Not used, reserve
    
    #define USER_MOTOR1_BEMF_THRESHOLD         (0.5f)
    #define USER_MOTOR1_BEMF_KSLF_FC_SF        (1.0f)
    #define USER_MOTOR1_THETA_OFFSET_SF        (1.0f)
    #define USER_MOTOR1_SPEED_LPF_FC_Hz        (200.0f)
    
    // for IS-BLDC
    #define USER_MOTOR1_RAMP_START_Hz           (3.0f) // MODIFICABILE
    #define USER_MOTOR1_RAMP_END_Hz             (30.0f) // MODIFICABILE
    #define USER_MOTOR1_RAMP_DELAY              (5) // MODIFICABILE
    
    #define USER_MOTOR1_ISBLDC_INT_MAX          (0.015f) // MODIFICABILE
    #define USER_MOTOR1_ISBLDC_INT_MIN          (0.010f) // MODIFICABILE
    
    // for Rs online calibration
    #define USER_MOTOR1_RSONLINE_WAIT_TIME      (60000U)    // 5min/300s at 5ms base // MODIFICABILE
    #define USER_MOTOR1_RSONLINE_WORK_TIME      (24000U)     //2min/120s at 5ms base // MODIFICABILE
    
    // Current and Speed PI Regulators Tuning Coefficient
    #define USER_MOTOR1_GAIN_SPEED_LOW_Hz        (60.0f)  // MODIFICABILE
    #define USER_MOTOR1_GAIN_SPEED_HIGH_Hz       (150.0f) // MODIFICABILE
    
    #define USER_MOTOR1_KP_SPD_START_SF          (1.5f)       // 0.1~100.0 // MODIFICABILE
    #define USER_MOTOR1_KI_SPD_START_SF          (1.5f)       // 0.1~10.0  // MODIFICABILE
    
    #define USER_MOTOR1_KP_SPD_LOW_SF            (2.0f)       // 0.1~100.0 // MODIFICABILE// MODIFICABILE
    #define USER_MOTOR1_KI_SPD_LOW_SF            (2.0f)       // 0.1~10.0  // MODIFICABILE
    
    #define USER_MOTOR1_KP_SPD_HIGH_SF           (1.0f)       // 0.1~100.0 // MODIFICABILE
    #define USER_MOTOR1_KI_SPD_HIGH_SF           (1.0f)       // 0.1~10.0  // MODIFICABILE
    
    #define USER_MOTOR1_GAIN_IQ_LOW_A            (2.0f) // MODIFICABILE
    #define USER_MOTOR1_GAIN_IQ_HIGH_A           (6.0f) // MODIFICABILE
    
    #define USER_MOTOR1_KP_IQ_START_SF           (1.5f)       // 0.1~10.0 // MODIFICABILE
    #define USER_MOTOR1_KI_IQ_START_SF           (1.5f)       // 0.1~10.0 // MODIFICABILE
    
    #define USER_MOTOR1_KP_IQ_LOW_SF             (2.0f)       // 0.1~10.0 // MODIFICABILE
    #define USER_MOTOR1_KI_IQ_LOW_SF             (2.0f)       // 0.1~10.0 // MODIFICABILE
    
    #define USER_MOTOR1_KP_IQ_HIGH_SF            (1.0f)       // 0.1~10.0 // MODIFICABILE
    #define USER_MOTOR1_KI_IQ_HIGH_SF            (1.0f)       // 0.1~10.0 // MODIFICABILE
    
    #define USER_MOTOR1_KP_ID_SF                 (1.0f)       // 0.1~10.0 // MODIFICABILE
    #define USER_MOTOR1_KI_ID_SF                 (1.0f)       // 0.1~10.0 // MODIFICABILE
    
    #elif (USER_MOTOR1 == my_aci_motor_2)
    // Refer to the description of the following parameters for Teknic_M2310PLN04K
    #define USER_MOTOR1_TYPE                   MOTOR_TYPE_INDUCTION
    #define USER_MOTOR1_NUM_POLE_PAIRS         (2)
    #define USER_MOTOR1_Rr_Ohm                 (NULL)
    #define USER_MOTOR1_Rs_Ohm                 (NULL)
    #define USER_MOTOR1_Ls_d_H                 (NULL)
    #define USER_MOTOR1_Ls_q_H                 (NULL)
    #define USER_MOTOR1_RATED_FLUX_VpHz        (0.8165f * 230.0f / 60.0f)
    #define USER_MOTOR1_MAGNETIZING_CURRENT_A  (NULL)
    #define USER_MOTOR1_RES_EST_CURRENT_A      (0.5f)
    #define USER_MOTOR1_IND_EST_CURRENT_A      (NULL)
    #define USER_MOTOR1_MAX_CURRENT_A          (5.0f)
    #define USER_MOTOR1_FLUX_EXC_FREQ_Hz       (5.0f)
    
    // Number of lines on the motor's quadrature encoder
    #define USER_MOTOR1_NUM_ENC_SLOTS          (1000)
    
    #define USER_MOTOR1_FREQ_MIN_Hz            (5.0f)           // Hz
    #define USER_MOTOR1_FREQ_MAX_Hz            (300.0f)         // Hz
    
    #define USER_MOTOR1_FREQ_LOW_Hz            (10.0f)          // Hz
    #define USER_MOTOR1_FREQ_HIGH_Hz           (400.0f)         // Hz
    #define USER_MOTOR1_VOLT_MIN_V             (4.0f)           // Volt
    #define USER_MOTOR1_VOLT_MAX_V             (24.0f)          // Volt
    
    // Current and Speed PI Regulators Tuning Coefficient
    #define USER_MOTOR1_GAIN_SPEED_LOW_Hz        (60.0f)
    #define USER_MOTOR1_GAIN_SPEED_HIGH_Hz       (150.0f)
    
    #define USER_MOTOR1_KP_SPD_START_SF          (1.5f)       // 0.1~100.0
    #define USER_MOTOR1_KI_SPD_START_SF          (1.5f)       // 0.1~10.0
    
    #define USER_MOTOR1_KP_SPD_LOW_SF            (2.0f)       // 0.1~100.0
    #define USER_MOTOR1_KI_SPD_LOW_SF            (2.0f)       // 0.1~10.0
    
    #define USER_MOTOR1_KP_SPD_HIGH_SF           (1.0f)       // 0.1~100.0
    #define USER_MOTOR1_KI_SPD_HIGH_SF           (1.0f)       // 0.1~10.0
    
    #define USER_MOTOR1_GAIN_IQ_LOW_A            (2.0f)
    #define USER_MOTOR1_GAIN_IQ_HIGH_A           (6.0f)
    
    #define USER_MOTOR1_KP_IQ_START_SF           (1.5f)       // 0.1~10.0
    #define USER_MOTOR1_KI_IQ_START_SF           (1.5f)       // 0.1~10.0
    
    #define USER_MOTOR1_KP_IQ_LOW_SF             (2.0f)       // 0.1~10.0
    #define USER_MOTOR1_KI_IQ_LOW_SF             (2.0f)       // 0.1~10.0
    
    #define USER_MOTOR1_KP_IQ_HIGH_SF            (1.0f)       // 0.1~10.0
    #define USER_MOTOR1_KI_IQ_HIGH_SF            (1.0f)       // 0.1~10.0
    
    #define USER_MOTOR1_KP_ID_SF                 (1.0f)       // 0.1~10.0
    #define USER_MOTOR1_KI_ID_SF                 (1.0f)       // 0.1~10.0
    
    //------------------------------------------------------------------------------
    #else
    #error No motor type specified
    #endif
    
    // TODO: Motor defines
    //! \brief Defines the maximum current slope for Id trajectory
    //!
    #define USER_M1_MAX_CURRENT_DELTA_A        (USER_MOTOR1_RES_EST_CURRENT_A / USER_M1_ISR_FREQ_Hz)
    
    
    //! \brief Defines the maximum current slope for Id trajectory during power warp mode
    //!
    #define USER_M1_MAX_CURRENT_DELTA_PW_A    (0.3 * USER_MOTOR1_RES_EST_CURRENT_A / USER_M1_ISR_FREQ_Hz)
    
    
    #ifndef USER_MOTOR1
    #error Motor type is not defined in user_mtr1.h
    #endif
    
    #ifndef USER_MOTOR1_TYPE
    #error The motor type is not defined in user_mtr1.h
    #endif
    
    #ifndef USER_MOTOR1_NUM_POLE_PAIRS
    #error Number of motor pole pairs is not defined in user_mtr1.h
    #endif
    
    #ifndef USER_MOTOR1_Rr_Ohm
    #error The rotor resistance is not defined in user_mtr1.h
    #endif
    
    #ifndef USER_MOTOR1_Rs_Ohm
    #error The stator resistance is not defined in user_mtr1.h
    #endif
    
    #ifndef USER_MOTOR1_Ls_d_H
    #error The direct stator inductance is not defined in user_mtr1.h
    #endif
    
    #ifndef USER_MOTOR1_Ls_q_H
    #error The quadrature stator inductance is not defined in user_mtr1.h
    #endif
    
    #ifndef USER_MOTOR1_RATED_FLUX_VpHz
    #error The rated flux of motor is not defined in user_mtr1.h
    #endif
    
    #ifndef USER_MOTOR1_MAGNETIZING_CURRENT_A
    #error The magnetizing current is not defined in user_mtr1.h
    #endif
    
    #ifndef USER_MOTOR1_RES_EST_CURRENT_A
    #error The resistance estimation current is not defined in user_mtr1.h
    #endif
    
    #ifndef USER_MOTOR1_IND_EST_CURRENT_A
    #error The inductance estimation current is not defined in user_mtr1.h
    #endif
    
    #ifndef USER_MOTOR1_MAX_CURRENT_A
    #error The maximum current is not defined in user_mtr1.h
    #endif
    
    #ifndef USER_MOTOR1_FLUX_EXC_FREQ_Hz
    #error The flux excitation frequency is not defined in user_mtr1.h
    #endif
    
    #if ((USER_M1_NUM_CURRENT_SENSORS < 2) || (USER_M1_NUM_CURRENT_SENSORS > 3))
    #error The number of current sensors must be 2 or 3
    #endif
    
    #if (USER_M1_NUM_VOLTAGE_SENSORS != 3)
    #error The number of voltage sensors must be 3
    #endif
    
    // **************************************************************************
    // the Defines
    // TODO: Motor defines
    //! \brief Defines the minimum ADC value for pot
    #define USER_M1_POT_ADC_MIN         (200U)          // 0 < the value < 4096
    
    //! \brief Defines the maximum ADC value for pot
    #define USER_M1_POT_ADC_MAX         (4096U - 200U)  // 0 < the value < 4096
    
    //! \brief Defines the speed conversion coefficient for pot
    #define USER_M1_POT_SPEED_SF        USER_MOTOR1_FREQ_MAX_Hz / ((float32_t)(USER_M1_POT_ADC_MAX - USER_M1_POT_ADC_MIN))
    
    //! \brief Defines the minimum frequency for pot
    #define USER_M1_POT_SPEED_MIN_Hz    (USER_MOTOR1_FREQ_MAX_Hz * 0.1f)
    
    //! \brief Defines the maximum frequency for pot
    #define USER_M1_POT_SPEED_MAX_Hz    (USER_MOTOR1_FREQ_MAX_Hz * 0.5f)
    
    //! \brief Defines the pot signal wait delay time
    #define USER_M1_WAIT_TIME_SET       (500U)         // 0.5s/1ms // MODIFICABILE
    
    //! \brief Defines the minimum frequency for pulse input
    #define USER_M1_SPEED_CAP_MIN_Hz        (15.0f) // MODIFICABILE
    
    //! \brief Defines the maximum frequency for pulse input
    #define USER_M1_SPEED_CAP_MAX_Hz        (600.0f) // MODIFICABILE
    
    //! \brief Defines the pulse capture wait delay time
    #define USER_M1_CAP_WAIT_TIME_SET       (125U)     // 0.125s/1ms (8Hz) // MODIFICABILE
    
    //! \brief Defines the switch signal wait delay time
    #define USER_M1_SWITCH_WAIT_TIME_SET    (50U)      // 0.05s/1ms // MODIFICABILE
    
    // **************************************************************************
    // the typedefs
    
    
    // **************************************************************************
    // the globals
    extern USER_Params userParams_M1;
    
    #if defined(BSXL8323RS_REVA) || defined(BSXL8353RS_REVA) || \
        defined(BSXL8316RT_REVA)
    // Watch window interface to the drv8323/drv8353/DRV8316 SPI
    extern DRVIC_VARS_t drvicVars_M1;
    #endif  // BSXL8323RS_REVA | BSXL8353RS_REVA | BSXL8316RT_REVA
    
    // **************************************************************************
    // the functions
    //! \param[in]  pUserParams  The pointer to the user param structure
    extern void USER_setMotor1Params(userParams_Handle handle);
    
    //*****************************************************************************
    //
    // Close the Doxygen group.
    //! @}
    //
    //*****************************************************************************
    
    //*****************************************************************************
    //
    // Mark the end of the C bindings section for C++ compilers.
    //
    //*****************************************************************************
    #ifdef __cplusplus
    }
    #endif
    
    #endif // end of USER_MTR1_H definition
    
    
    
    

  • Increasing USER_MOTOR1_FREQ_HIGH_Hz to 2000 the motor rotates well until amotorVars_M1.speedRef_Hz = 22.0f ... then overcurrent appears.

    The situation gets worse if I increase FREQ_HIGH_Hz above 2000

  • Hi,

    The BOOSTXL-3PHGANINV is only rated for 48-V/10-A, your motor is much higher power than this. Maybe this is the issue.

    Increasing USER_MOTOR1_FREQ_HIGH_Hz to 2000 the motor rotates well until amotorVars_M1.speedRef_Hz = 22.0f ... then overcurrent appears.

    The situation gets worse if I increase FREQ_HIGH_Hz above 2000

    Can you use a current probe to measure current waveforms when testing? Could also plot using CCS graphing tool as described in the Motor Lab User's Guide.

    Best,

    Kevin