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.

MCSDK same motor not accelerate SDK40 does same motor

Guru 55913 points
Part Number: TMS320F280049C
Other Parts Discussed in Thread: DRV8323

Hello all,

Build:  CCS12.3 Compiler 22.6.0.LTS

My big motor run to user set trajectory speed SDK 4.0 pu:0.5, 20Khz and only reach 1Hz UMCSDK no matter what the start, torque, delta currents and acceleration start speeds are set below text files. Have tried every possible combination UMCSDK user_mtr1.h settings below and found it strange the CCS show source for both Delta currents have no links in the build to any functions or user parameters. I hope this helps to debug the newer MCSDK code. The small motor Nidec 25H +24v load 0.35A  has very low current but has lot of torque at higher speeds >8Krpm UMCSDK no issues.

Oddly USER_MOTOR1_FORCE_DELTA_ A , USER_MOTOR1_ALIGN_DELTA_A  have no associated function or variable being defined in user_mtr1.h is broken link to fast_full_lib.lib. No compiler warnings ABI or COF issues though this seems to be COF library build for ABI build project settings?

Why both motors work ok in SDK4.0 but not in MCSDK? When the motor current is <1A  small motor starts and runs to reference target trajectory speed but big motor stay in forced angle open loop speed 1Hz.? Please suggest some user_mtr1.h setting to help the kgm^2 rotor mass of the big motor, many EV class range >63lbs inertia. Also tied UMCSDK with several M1.Kp_spd values, e.g. 148.xxx, 48.xxx to 0.48xxxx still no change to accelerate to reference trajectory speed.

MCSDK big motor user_mtr1.h         SDK4.0 big motor user.h settings

   

Settings SDK4.0 that are similar but do not work UMCSDK same motor, more current same issue does not accelerate to reference trajectory speed.

#define USER_MOTOR1_TYPE                   MOTOR_TYPE_PM
#define USER_MOTOR1_NUM_POLE_PAIRS         (18)

#define USER_MOTOR_SPEED_REF_HZ            (265) // Set Trajectory Speed

#define USER_MOTOR1_Rr_Ohm                 (NULL)//ACIM only
//Cust-INV: DCINV 0.16828759, DRV8320RS 0.155892089
#define USER_MOTOR1_Rs_Ohm                 (0.16828759)
//Cust-INV: 0.000986817526, DRV8320RS 0.000890934956
#define USER_MOTOR1_Ls_d_H                 (0.000896817526)
#define USER_MOTOR1_Ls_q_H                 (0.000896817526)
//Cust-INV:0.138790429
#define USER_MOTOR1_RATED_FLUX_VpHz        (0.138790429)

#define USER_MOTOR1_MAGNETIZING_CURRENT_A  (NULL)//ACIM only

#define USER_MOTOR1_RES_EST_CURRENT_A      (5.0f)  // 10-30% of rated current HV36/8.2A, unloaded 5.0/100v
#define USER_MOTOR1_IND_EST_CURRENT_A      (-4.5f) // 10-30% of rated current(LS) HV36:-4.5
#define USER_MOTOR1_MAX_CURRENT_A          (5.65f) // Saturation current(Peak) HV36:5.6
#define USER_MOTOR1_FLUX_EXC_FREQ_Hz       (60.0f) // MotorID 60 Hz for [1 uH < Lphase < 10 uH]
                                                   // MotorID 20 Hz for [10 uH < Lphase < 1000 uH]

// Number of lines on the motor's quadrature encoder
#define USER_MOTOR1_NUM_ENC_SLOTS          (NULL)

#define USER_MOTOR1_INERTIA_Kgm2           (0.352838295721)

#define USER_MOTOR1_FREQ_NEARZEROLIMIT_Hz  (2.0f)       // Hz

#define USER_MOTOR1_RATED_VOLTAGE_V        (250.0f)
#define USER_MOTOR1_RATED_SPEED_KRPM       (3.5f)

#define USER_MOTOR1_FREQ_MIN_HZ            (2.0f)       // Hz
#define USER_MOTOR1_FREQ_MAX_HZ            (1350.0f)    // Hz 720Hz*60/18=2400rpm, Hz-suggested to set to 120% of rated motor frequency

#define USER_MOTOR1_FREQ_LOW_HZ            (65.0f)     // Hz 65Hz - suggested to set to 10% of rated motor frequency
#define USER_MOTOR1_FREQ_HIGH_HZ           (650.0f)    // Hz 650Hz*60/18=2166rpm: suggested to set to 100% of rated motor frequency

#define USER_MOTOR1_VOLT_MIN_V             (85.0f)      // Volt
#define USER_MOTOR1_VOLT_MAX_V             (186.0f)     // Volt

#define USER_MOTOR1_FORCE_DELTA_A          (0.55f)      // A
#define USER_MOTOR1_ALIGN_DELTA_A          (0.25f)      // A
#define USER_MOTOR1_FLUX_CURRENT_A         (5.25f)      // !A
#define USER_MOTOR1_ALIGN_CURRENT_A        (5.0f)       // !A
#define USER_MOTOR1_STARTUP_CURRENT_A      (7.25f)      // !A
#define USER_MOTOR1_TORQUE_CURRENT_A       (2.65f)      // !A
#define USER_MOTOR1_OVER_CURRENT_A         (12.8f)      // !A

#define USER_MOTOR1_BRAKE_CURRENT_A        (1.0f)       // A
#define USER_MOTOR1_BRAKE_TIME_DELAY       (12000U)     // 60s/5ms
#define USER_MOTOR1_SPEED_START_Hz         (5.0f)
#define USER_MOTOR1_SPEED_FORCE_Hz         (15.0f)
#define USER_MOTOR1_ACCEL_START_Hzps       (5.0f)       // !Hz
#define USER_MOTOR1_ACCEL_MAX_Hzps         (25.0f)      // !Hz

Change settings universal MCSDK motor still remains ±1Hz does not accelerate to reference trajectory speed, even when less current motor still starts up spins only 1Hz.

#define USER_MOTOR1_FREQ_NEARZEROLIMIT_Hz  (2.0f)       // Hz

#define USER_MOTOR1_RATED_VOLTAGE_V        (250.0f)
#define USER_MOTOR1_RATED_SPEED_KRPM       (3.5f)

#define USER_MOTOR1_FREQ_MIN_HZ            (2.0f)       // Hz
#define USER_MOTOR1_FREQ_MAX_HZ            (1350.0f)    // Hz 720Hz*60/18=2400rpm, Hz-suggested to set to 120% of rated motor frequency

#define USER_MOTOR1_FREQ_LOW_HZ            (65.0f)     // Hz 65Hz - suggested to set to 10% of rated motor frequency
#define USER_MOTOR1_FREQ_HIGH_HZ           (650.0f)    // Hz 650Hz*60/18=2166rpm: suggested to set to 100% of rated motor frequency

#define USER_MOTOR1_VOLT_MIN_V             (85.0f)      // Volt
#define USER_MOTOR1_VOLT_MAX_V             (186.0f)     // Volt

#define USER_MOTOR1_FORCE_DELTA_A          (0.55f)      // A
#define USER_MOTOR1_ALIGN_DELTA_A          (0.25f)      // A
#define USER_MOTOR1_FLUX_CURRENT_A         (1.75f)      // !A
#define USER_MOTOR1_ALIGN_CURRENT_A        (4.0f)       // !A
#define USER_MOTOR1_STARTUP_CURRENT_A      (3.55f)      // !A
#define USER_MOTOR1_TORQUE_CURRENT_A       (1.65f)      // !A
#define USER_MOTOR1_OVER_CURRENT_A         (12.0f)      // !A

#define USER_MOTOR1_BRAKE_CURRENT_A        (1.0f)       // A
#define USER_MOTOR1_BRAKE_TIME_DELAY       (12000U)     // 60s/5ms
#define USER_MOTOR1_SPEED_START_Hz         (15.0f)
#define USER_MOTOR1_SPEED_FORCE_Hz         (25.0f)
#define USER_MOTOR1_ACCEL_START_Hzps       (35.0f)      // !Hz
#define USER_MOTOR1_ACCEL_MAX_Hzps         (55.0f)      // !Hz

SDK4.0 user settings work ok for bigger motor to startup but why not in MCSDK?

	USER_MOTOR_TYPE				=	  1, // MOTOR_TYPE_PM,

	USER_MOTOR_NUM_POLE_PAIRS   =     18, // HV36:18pp

	USER_MOTOR_Rr_Ohm           =     0, //ACIM only

	USER_MOTOR_Rs_Ohm           =     0.16828759,
	//HV36: DCINV 0.16828759, DRV8320RS 0.155892089

	USER_MOTOR_Ls_d_H           =    0.000896817526,
	//HV36: INV 0.000986817526, DRV8320RS 0.000890934956

	USER_MOTOR_Ls_q_H           =    0.000896817526,
	//HV36: INV 0.000986817526, DRV8320RS 0.000890934956

	USER_MOTOR_RATED_FLUX_VpHz  =      0.138790429,
	//HV36:0.138790429
	USER_MOTOR_MAGNETIZING_CURRENT_A = 0, //ACIM only
	USER_MOTOR_RES_EST_CURRENT_A   =    5.0,  // 10-30% of rated current HV36/8.2A, unloaded 5.0/100v
	USER_MOTOR_IND_EST_CURRENT_A   =   -4.5, // 10-30% of rated current(LS) HV36:-4.5
	USER_MOTOR_MAX_CURRENT_A       =    5.6, // Saturation current(Peak) HV36:5.6
	USER_MOTOR_FLUX_EXC_FREQ_Hz    =   60.0, // MotorID 60 Hz for [1 uH < Lphase < 10 uH]
						 // MotorID 20 Hz for [10 uH < Lphase < 1000 uH]

        USER_MOTOR_INERTIA_EN	    =	(1), //1:true, 0:false

	USER_MOTOR_INERTIA_Kgm2     =   0.325505192710553, 

	USER_MOTOR_NUM_ENC_SLOTS     =      71, // Number of lines on the motor's quadrature encoder

	USER_MOTOR_FREQ_MIN_HZ       =      2.0,  // Hz
	USER_MOTOR_FREQ_MAX_HZ       =      780.0, // 720Hz*60/18=2400rpm, Hz-suggested to set to 120% of rated motor frequency

	USER_MOTOR_FREQ_LOW_HZ       =       65.0, // 65Hz - suggested to set to 10% of rated motor frequency
	USER_MOTOR_FREQ_HIGH_HZ      =      650.0, // 650Hz*60/18=2166rpm: suggested to set to 100% of rated motor frequency

	USER_MOTOR_VOLT_MIN_V        =       60.0,  // Volt - suggested to set to 15% of rated motor voltage
	USER_MOTOR_VOLT_MAX_V        =      160.0,  // Volt - suggested to set to 100% of rated motor voltage

	HAL_PWM_DBRED_CNT			 =	   	20, // PWM Deadband RED register x 10 nanosecond SYSCLK periods
	HAL_PWM_DBFED_CNT			 =	   	20, // PWM Deadband FED register x 10 nanosecond SYSCLK periods
	HAL_PWM_DB_CNT			 	 =	   	20, // DRV 8320RS gate driver deand band SPI register value.

	USER_PWM_FREQ_kHz     		 =     	20.0, // EPWM module PRD clock frequency for DC inverter modulation.

    //! \brief Defines the maximum P2P current at the AD converter   
    USER_ADC_FULL_SCALE_CURRENT_A   =   82.0; //PGA 42.843, INA240A1:78-82.0

  • Why both motors work ok in SDK4.0 but not in MCSDK?

    What do you mean SDK4.0 and MCSDK? Which TI EVM tools are you using? Or your own board?

  • Testing both project builds with x49c launch pad and custom DC inverter. Same motor parameters used in SDK4.0 get into closed loop MCSDK to fast. Only a little motor will accelerate in MCSDK peak current 350mA. What do we set the MCSDK added new parameters, don't seem to make much difference as the big motor will not accelerate >1Hz in MCSDK, only SDK4.0 project does big motor accelerate up to trajectory target speed Hz.

    The MCSDK open loop transitions into closed loop far to rapidly after alignment current and startup currents have very little effect on transition timing. One can hear current crackling last longer via SDK open loop into closed loop. Past saw similar behavior when RS online calibration was enabled SDK4.0 LAB is07, now it has swift startup no back kicking or hunting Nth pole. I see the MCSDK has enabled RS online by default, perhaps the cause? Also noticed FDW was enable true in the downloaded code and expressions tab. Tested eSMO with little 4 pole Nidec H25 motor did not work so great each second startup with eSMO motor did nothing after it sputtered into stall on first run.

  • What do we set the two delta and flux currents? The little 4 pole motor would stall vibrate >75mA deltas, the big motor not much seems to happen no matter what the value put into those deltas. However they don't link to any function when ctrl+click or do a search nothing links to these values on two different computers with CC12.3 compiler v22.6.0.LTS. So the SDK4.0 settings above post spin the big motor well above 1Hz why the MCSDK can't, build level 4 above posted settings.

    #define USER_MOTOR1_FORCE_DELTA_A (0.05f) // A
    #define USER_MOTOR1_ALIGN_DELTA_A (0.03f) // A

    What to set flux & align current in relation to 5%, 10% 15%, 20% peak current?

    #define USER_MOTOR1_FLUX_CURRENT_A (1.025f) // !A
    #define USER_MOTOR1_ALIGN_CURRENT_A (1.575f) // !A

  • Hi Lue,

    There is new code UMCSDK controls open loop with seek position SDK4.0 did not have, seemingly a focal point. Oddly the seek position timing SDK4.0 OL slow speed observer has a much longer duration. I have no idea how different delays need to be set so both project OL observers have the same time cycles. Can you test the two project differences as I'm shutting down my lab moving to another local at present.

    // motor1_drive.c
    
    #elif defined(MOTOR1_FAST) && defined(MOTOR1_ESMO)
        obj->estState = EST_STATE_IDLE;
        obj->trajState = EST_TRAJ_STATE_IDLE;
    
        obj->estimatorMode = ESTIMATOR_MODE_FAST;
    
        obj->flagEnableAlignment = true;
        obj->alignTimeDelay = (uint16_t)(objUser->ctrlFreq_Hz * 0.1f);          // 0.1s
        obj->forceRunTimeDelay = (uint16_t)(objUser->ctrlFreq_Hz * 1.0f);       // 1.0s
        obj->fwcTimeDelay = (uint16_t)(objUser->ctrlFreq_Hz * 2.0f);        // 2.0s
        
    // Suspect fast code has seek position timing issues >4 pole motors
    
       else if(obj->flagMotorIdentified == true)
        {
            if(obj->flagRunIdentAndOnLine == true)
            {
                obj->counterTrajSpeed++;
    
                if(obj->counterTrajSpeed >= objUser->numIsrTicksPerTrajTick)
                {
                    // clear counter
                    obj->counterTrajSpeed = 0;
    
                    // run a trajectory for speed reference,
                    // so the reference changes with a ramp instead of a step
                    TRAJ_run(obj->trajHandle_spd);
                }
    
                obj->enableCurrentCtrl = obj->flagEnableCurrentCtrl;
                obj->enableSpeedCtrl = obj->flagEnableSpeedCtrl;
    
    
                // get Id reference for Rs OnLine
                obj->IdRated_A = EST_getIdRated_A(obj->estHandle);
            }
            else
            {
                obj->enableSpeedCtrl = false;
                obj->enableCurrentCtrl = false;
            }
    
            obj->estInputData.speed_ref_Hz = TRAJ_getIntValue(obj->trajHandle_spd);
            obj->speed_int_Hz = obj->estInputData.speed_ref_Hz;
        }
    
        // store the input data into a buffer
        obj->estInputData.dcBus_V = obj->adcData.VdcBus_V;
    
    
        // run the FAST estimator
        EST_run(obj->estHandle, &obj->estInputData, &obj->estOutputData);
    
        // compute angle with delay compensation
        obj->angleDelta_rad =
                objUser->angleDelayed_sf_sec * obj->estOutputData.fm_lp_rps;
    
        obj->angleEST_rad =
                MATH_incrAngle(obj->estOutputData.angle_rad, obj->angleDelta_rad);
    
        obj->speedEST_Hz = EST_getFm_lp_Hz(obj->estHandle);
    
    
        obj->oneOverDcBus_invV = obj->estOutputData.oneOverDcBus_invV;
    
    
        // run the eSMO
        ESMO_setSpeedRef(obj->esmoHandle, obj->speed_int_Hz);
        ESMO_run(obj->esmoHandle, obj->adcData.VdcBus_V,
                        &(obj->pwmData.Vabc_pu), &(obj->estInputData.Iab_A));
    
        obj->angleComp_rad = obj->speedPLL_Hz * obj->angleDelayed_sf;
        obj->anglePLL_rad = MATH_incrAngle(ESMO_getAnglePLL(obj->esmoHandle), obj->angleComp_rad);
    
        SPDFR_run(obj->spdfrHandle, obj->anglePLL_rad);
        obj->speedPLL_Hz = SPDFR_getSpeedHz(obj->spdfrHandle);
    
    
        obj->speedFilter_Hz = obj->speedFilter_Hz *0.875f + obj->speed_Hz * 0.125f;
        obj->speedAbs_Hz = fabsf(obj->speedFilter_Hz);
    
        // Running state
        if(obj->estimatorMode == ESTIMATOR_MODE_FAST)
        {
            obj->speed_Hz = obj->speedEST_Hz;
    
            if(obj->motorState >= MOTOR_CTRL_RUN)
            {
                obj->angleFOC_rad = obj->angleEST_rad;
    
                ESMO_updateKslide(obj->esmoHandle);
            }
            else if(obj->motorState == MOTOR_CL_RUNNING)
            {
                obj->angleFOC_rad = obj->angleEST_rad;
                ESMO_setAnglePu(obj->esmoHandle, obj->angleFOC_rad);
            }
            else if(obj->motorState == MOTOR_OL_START)
            {
                obj->angleFOC_rad = obj->angleEST_rad;
                obj->motorState = MOTOR_CL_RUNNING;
    
                ESMO_setAnglePu(obj->esmoHandle, obj->angleFOC_rad);
            }
            else if(obj->motorState == MOTOR_ALIGNMENT)
            {
                obj->angleFOC_rad = 0.0f;
                obj->enableSpeedCtrl = false;
    
                obj->stateRunTimeCnt++;
    
                obj->IsRef_A = 0.0f;
                obj->Idq_out_A.value[0] = obj->alignCurrent_A;
                obj->Idq_out_A.value[1] = 0.0f;
    
                TRAJ_setIntValue(obj->trajHandle_spd, 0.0f);
                EST_setAngle_rad(obj->estHandle, obj->angleFOC_rad);
                ESMO_setAnglePu(obj->esmoHandle, obj->angleFOC_rad);
    
                if((obj->stateRunTimeCnt > obj->alignTimeDelay) ||
                         (obj->flagEnableAlignment == false))
                {
                    obj->stateRunTimeCnt = 0;
                    obj->motorState = MOTOR_OL_START;
    
                    obj->Idq_out_A.value[0] = obj->fluxCurrent_A;
                    PI_setUi(obj->piHandle_spd, 0.0);
                }
            }
            else if(obj->motorState == MOTOR_SEEK_POS)
            {
                obj->enableSpeedCtrl = false;
    
                obj->stateRunTimeCnt++;
    
                obj->IsRef_A = 0.0f;
                obj->Idq_out_A.value[0] = 0.0f;
                obj->Idq_out_A.value[1] = 0.0f;
    
                if(obj->stateRunTimeCnt > obj->flyingStartTimeDelay)
                {
                    obj->stateRunTimeCnt = 0;
    
                    if(obj->speedAbs_Hz > obj->speedFlyingStart_Hz)
                    {
                        obj->speed_int_Hz = obj->speedFilter_Hz;
                        TRAJ_setIntValue(obj->trajHandle_spd, obj->speedFilter_Hz);
                        PI_setUi(obj->piHandle_spd, 0.0f);
    
                        obj->motorState = MOTOR_CL_RUNNING;
    
                        ESMO_setAnglePu(obj->esmoHandle, obj->angleFOC_rad);
                    }
                    else
                    {
                        obj->angleFOC_rad = 0.0f;
                        obj->motorState = MOTOR_ALIGNMENT;
                    }
                }
            }

  • The Universal Motor Control Lab in Motor Control SDK doesn't support F28004x. Do you follow the lab user's guide to migrate the lab to F28004x, and run the lab from build level 1 to 4 to verify if the porting is correct? And set the related control parameters according to the motor you used.

  • . Do you follow the lab user's guide to migrate the lab to F28004x, and run the lab from build level 1 to 4 to verify if the porting is correct?

    Had you check PM you would know that x49c launch pad was migrated and porting works fine with small motor currents >390Hz. The rotor mass is large and startup open to closed loop timing is clearly an issue, motor can only rotate 1Hz. This is the same MCSDK code the Boolean state changes are failing in custom user modules.

    And set the related control parameters according to the motor you used.

    The newer variables have no explanation how to set, above could be wrong for a larger rotor mass, who knows. Perhaps check the code PM to you on x49c launch pad with any connected inverter 100VDC. One possible is pole count being greater than 4 cause in issue with trajectory generator timing.

  • Have checked and tested the Universal lab on some PMSM/BLDC including low voltage (24V~100V) and high voltage (220V~380V) on the supporting kit with F28002x/F28003x/F280013x in MCSDK, seems like the universal lab spin these motors well had the similar performance as the InstaSPIN-FOC labs on F28004x. We didn't test the F28004x that should be the same since the same FAST library is used for all of the C2000 device.

    Could you please show some tested waveform or data to enable us understand your questions?

  • Could you please show some tested waveform or data to enable us understand your questions?

    Again my lab is shut down for moving but you can load the project from PM just comment sys_main.c call to initialize nextion. The current clamp was ramping up and down after the initial startup failed to accelerate the motor in the first 60°. Depending on the motor1 current settings it would perpetually spin rotor at 1Hz but never accelerate. Not much to capture as scope being 1 second horizontal sweep to see ramping cycles after 60° of rotor spinning. Esmo results were worse than fast observer even with 4 pole motor it would often stall shortly after entering closed loop.

  • Do you have an chance to use the supporting kits and controllers of the universal lab? And try to run your motor without changing the example code and only set the related parameters according to the motor you used.

    Can you share the motor parameters? I believe we have a similar motor in our lab to test the lab. 

  • Can you share the motor parameters?

    Some of the settings are shown above might spin 360° 1Hz, 36 pole motor is now disassembled.  Below are the last parameters would spin 36 rotor 60° then stop ramp current up and down. It seems like the load was dropped but there are no faults occurring only fast flicker of red LED in x49c Lpad. Haven't yet test the PM code with drv8320rs but it should support drv8323_rev1 (Site1 x25c) and drv8320rs (Site2 x49c) symbols are set. Supports x25 clocking calls and x49 both 100MHz hal.c. Site1 may not have correct ADC channels for x49c but support PGA on site 2 with drv8320rs with added symbols to enable functions. Tried to keep PM code compatible for both launch pads, not the HV kit. I don't know what to set both delta values, they did cause 4 pole rotor to spin few degrees & torque lock the shaft if set below value of USER_MOTOR1_RES_EST_CURRENT_A  = 0.35 or USER_MOTOR1_MAX_CURRENT_A = 0.355 USER_MOTOR1. sys_main.c selects motor parameters to run set (true/false) for motor defines below, comment each to match so you can quickly switch between predefined motor parameters.

    //==============================================================================
    // Motor defines
    
    
    //#define USER_MOTOR1 my_pm_motor_1 // NI25H6P
    #define USER_MOTOR2 my_pm_motor_2 // HV36P
    //#define USER_MOTOR3   my_pm_motor_3 // PT24P
    //#define USER_MOTOR4   my_pm_motor_4 // New ID
    //#define USER_MOTOR5 my_aci_motor_1
    
    //------------------------------------------------------------------
    #if defined(USER_MOTOR1)
    #define USER_MOTOR_SPEED_REF_HZ            (235) // Set Trajectory Speed
    #define USER_MOTOR1_TYPE                   MOTOR_TYPE_PM
    #define USER_MOTOR1_NUM_POLE_PAIRS         (3) //Nidec25:3pp,
    #define USER_MOTOR1_Rr_Ohm                 (NULL)//ACIM only
    
    #define USER_MOTOR1_Rs_Ohm                 (0.45774436)//0.316983044
    #define USER_MOTOR1_Ls_d_H                 (0.000636240817)// 0.000617085374
    #define USER_MOTOR1_Ls_q_H                 (0.000636240817)// 0.000617085374
    #define USER_MOTOR1_RATED_FLUX_VpHz        (0.0331647545)
    
    #define USER_MOTOR1_MAGNETIZING_CURRENT_A  (NULL)//ACIM only
    #define USER_MOTOR1_RES_EST_CURRENT_A      (0.35f)
    #define USER_MOTOR1_IND_EST_CURRENT_A      (-0.315f)
    #define USER_MOTOR1_MAX_CURRENT_A          (0.355f)
    #define USER_MOTOR1_FLUX_EXC_FREQ_Hz       (35.0f)
    
    // Number of lines on the motor's quadrature encoder
    #define USER_MOTOR1_NUM_ENC_SLOTS          (NULL)
    
    #define USER_MOTOR1_INERTIA_Kgm2           (7.06154e-06)
    
    #define USER_MOTOR1_FREQ_NEARZEROLIMIT_Hz  (5.0f)          // Hz
    
    #define USER_MOTOR1_RATED_VOLTAGE_V        (24.0f)
    #define USER_MOTOR1_RATED_SPEED_KRPM       (10.0f)
    
    #define USER_MOTOR1_FREQ_MIN_HZ            (2.0f)           // Hz
    #define USER_MOTOR1_FREQ_MAX_HZ            (350.0f)         // Hz
    
    #define USER_MOTOR1_FREQ_LOW_HZ            (5.0f)           // Hz
    #define USER_MOTOR1_FREQ_HIGH_HZ           (350.0f)         // Hz
    #define USER_MOTOR1_VOLT_MIN_V             (18.0f)          // Volt
    #define USER_MOTOR1_VOLT_MAX_V             (24.0f)          // Volt
    
    #define USER_MOTOR1_FORCE_DELTA_A          (0.03f)          // A  15% ALC (0.05f)
    #define USER_MOTOR1_ALIGN_DELTA_A          (0.01f)          // A   5% ALC (0.01f)
    #define USER_MOTOR1_FLUX_CURRENT_A         (0.225f)           //0.325 !A
    #define USER_MOTOR1_ALIGN_CURRENT_A        (0.150f)           //0.25 !A
    #define USER_MOTOR1_STARTUP_CURRENT_A      (0.3f)           // !A
    #define USER_MOTOR1_TORQUE_CURRENT_A       (0.45f)            // !A
    #define USER_MOTOR1_OVER_CURRENT_A         (1.5f)             // !A
    
    #define USER_MOTOR1_BRAKE_CURRENT_A        (1.0f)           // A
    #define USER_MOTOR1_BRAKE_TIME_DELAY       (12000U)         // 60s/5ms
    
    #define USER_MOTOR1_SPEED_START_Hz         (30.0f)
    #define USER_MOTOR1_SPEED_FORCE_Hz         (25.0f)
    #define USER_MOTOR1_ACCEL_START_Hzps       (15.0f)  // !Hz
    #define USER_MOTOR1_ACCEL_MAX_Hzps         (30.0f)  // !Hz
    
    #define USER_MOTOR1_SPEED_FS_Hz            (3.0f)
    
    // only for encoder
    #define USER_MOTOR1_ENC_POS_MAX            (USER_MOTOR1_NUM_ENC_SLOTS * 4 - 1)
    #define USER_MOTOR1_ENC_POS_OFFSET         (668)
    
    // 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_BEMF_THRESHOLD         (0.5f)
    #define USER_MOTOR1_BEMF_KSLF_FC_Hz        (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)
    #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)
    
    // for Rs online calibration
    #define USER_MOTOR1_RSONLINE_WAIT_TIME      (60000U)    // 5min/300s at 5ms base
    #define USER_MOTOR1_RSONLINE_WORK_TIME      (24000U)     //2min/120s at 5ms base
    
    #ifndef USER_MOTOR1
    #error /"Motor type is not defined in user_mtr1.h"/
    #endif
    #endif
    // End HI25H
    
    //***************************************************************************
    #if defined(USER_MOTOR2)
    #define USER_MOTOR1_TYPE                   MOTOR_TYPE_PM
    #define USER_MOTOR1_NUM_POLE_PAIRS         (18)
    #define USER_MOTOR_SPEED_REF_HZ            (65) // Set Trajectory Speed
    #define USER_MOTOR1_Rr_Ohm                 (NULL)//ACIM only
    //Cust-INV: DCINV 0.16828759, DRV8320RS 0.155892089
    #define USER_MOTOR1_Rs_Ohm                 (0.16828759)
    //Cust-INV: 0.000986817526, DRV8320RS 0.000890934956
    #define USER_MOTOR1_Ls_d_H                 (0.000896817526)
    #define USER_MOTOR1_Ls_q_H                 (0.000896817526)
    //Cust-INV:0.138790429
    #define USER_MOTOR1_RATED_FLUX_VpHz        (0.138790429)
    
    #define USER_MOTOR1_MAGNETIZING_CURRENT_A  (NULL)//ACIM only
    
    #define USER_MOTOR1_RES_EST_CURRENT_A      (5.0f)  // 10-30% of rated current HV36/8.2A, unloaded 5.0/100v
    #define USER_MOTOR1_IND_EST_CURRENT_A      (-4.5f) // 10-30% of rated current(LS) HV36:-4.5
    #define USER_MOTOR1_MAX_CURRENT_A          (5.65f) // Saturation current(Peak) HV36:5.6
    #define USER_MOTOR1_FLUX_EXC_FREQ_Hz       (60.0f) // MotorID 60 Hz for [1 uH < Lphase < 10 uH]
                                                       // MotorID 20 Hz for [10 uH < Lphase < 1000 uH]
    
    // Number of lines on the motor's quadrature encoder
    #define USER_MOTOR1_NUM_ENC_SLOTS          (NULL)
    
    #define USER_MOTOR1_INERTIA_Kgm2           (0.352838295721)
    
    #define USER_MOTOR1_FREQ_NEARZEROLIMIT_Hz  (2.0f)       // Hz
    
    #define USER_MOTOR1_RATED_VOLTAGE_V        (250.0f)
    #define USER_MOTOR1_RATED_SPEED_KRPM       (3.5f)
    
    #define USER_MOTOR1_FREQ_MIN_HZ            (2.0f)       // Hz
    #define USER_MOTOR1_FREQ_MAX_HZ            (1350.0f)    // Hz 720Hz*60/18=2400rpm, Hz-suggested to set to 120% of rated motor frequency
    
    #define USER_MOTOR1_FREQ_LOW_HZ            (65.0f)      // Hz 65Hz - suggested to set to 10% of rated motor frequency
    #define USER_MOTOR1_FREQ_HIGH_HZ           (1350.0f)    // Hz 650Hz*60/18=2166rpm: suggested to set to 100% of rated motor frequency
    
    #define USER_MOTOR1_VOLT_MIN_V             (55.0f)      // Volt
    #define USER_MOTOR1_VOLT_MAX_V             (86.0f)      // Volt
    
    #define USER_MOTOR1_FORCE_DELTA_A          (0.05f)          // A
    #define USER_MOTOR1_ALIGN_DELTA_A          (0.03f)          // A
    #define USER_MOTOR1_FLUX_CURRENT_A         (1.025f)           // !A
    #define USER_MOTOR1_ALIGN_CURRENT_A        (1.575f)           // !A
    #define USER_MOTOR1_STARTUP_CURRENT_A      (3.525f)           // !A
    #define USER_MOTOR1_TORQUE_CURRENT_A       (1.65f)            // !A
    #define USER_MOTOR1_OVER_CURRENT_A         (12.8f)             // !A
    
    #define USER_MOTOR1_BRAKE_CURRENT_A        (1.0f)           // A
    #define USER_MOTOR1_BRAKE_TIME_DELAY       (12000U)         // 60s/5ms
    
    #define USER_MOTOR1_SPEED_START_Hz         (5.0f)
    #define USER_MOTOR1_SPEED_FORCE_Hz         (15.0f)
    #define USER_MOTOR1_ACCEL_START_Hzps       (5.0f)  // !Hz
    #define USER_MOTOR1_ACCEL_MAX_Hzps         (25.0f)  // !Hz
    
    #define USER_MOTOR1_SPEED_FS_Hz            (3.0f)  //!Flying start speed
    
    // only for encoder
    #define USER_MOTOR1_ENC_POS_MAX            (USER_MOTOR1_NUM_ENC_SLOTS * 4 - 1)
    #define USER_MOTOR1_ENC_POS_OFFSET         (668)
    
    // 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_BEMF_THRESHOLD         (0.5f)
    #define USER_MOTOR1_BEMF_KSLF_FC_Hz        (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)
    #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)
    
    // for Rs online calibration
    #define USER_MOTOR1_RSONLINE_WAIT_TIME      (60000U)    // 5min/300s at 5ms base
    #define USER_MOTOR1_RSONLINE_WORK_TIME      (24000U)     //2min/120s at 5ms base
    
    #ifndef USER_MOTOR2
    #error /"Motor type is not defined in user_mtr1.h"/
    #endif
    #endif
    //------------------------------------------------------------------------------
    #if defined(BSXL8320RS_REVA) // LaunchPad-F280049
    //! \brief Defines the nominal DC bus voltage, V
    //!
    #define USER_M1_NOMINAL_DC_BUS_VOLTAGE_V         (103.3f) //DRV8320RS: 48.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         (157.528f) //DRV8320RS: 57.528f
    
    //! \brief Defines the analog voltage filter pole location, Hz
    //! 100nF->56nF/47nF
    #define USER_M1_VOLTAGE_FILTER_POLE_Hz           (416.834f)     //DRV8329RS:338.357f 500~800Hz
    
    #if defined(PGA_GAIN_6S)
    //! \brief Defines the maximum current at the AD converter
    // Gain = 6, Rin=3.3k, Rdac=27.4k
    #define USER_M1_ADC_FULL_SCALE_CURRENT_A         (88.034f)
    //
    #elif defined(PGA_GAIN_12S) && !defined(INA240A1)
    //! \brief Defines the maximum current at the AD converter
    //! BOARD_BSXL8320RS_REVA 15AP2P/30AP Gain=12 84mV/A,
    // Gain = 12, Rin=2.49k, Rdac=27.4k
    #define USER_M1_ADC_FULL_SCALE_CURRENT_A         (42.856f)
    
    #elif defined(INA240A1)
    //! \brief Defines the maximum P2P current at the AD converter
    //!  External INA240 shunts sensor, Gain=20V/V or 3.17v/40mV/A
    #define USER_M1_ADC_FULL_SCALE_CURRENT_A         (82.0f)//INA240A1:78-82.0
    #endif
    
    //! \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 voltage offsets for A, B, and C phases
    #define USER_M1_VA_OFFSET_SF    (0.496752918f)
    #define USER_M1_VB_OFFSET_SF    (0.496881396f)
    #define USER_M1_VC_OFFSET_SF    (0.499790519f)
    
    //! \brief DC bus over voltage threshold
    #define USER_M1_OVER_VOLTAGE_FAULT_V        (135.0f)
    
    //! \brief DC bus over voltage threshold
    #define USER_M1_OVER_VOLTAGE_NORM_V         (125.0f)
    
    //! \brief DC bus under voltage threshold
    #define USER_M1_UNDER_VOLTAGE_FAULT_V       (80.0f) //10.0f
    
    //! \brief DC bus under voltage threshold
    #define USER_M1_UNDER_VOLTAGE_NORM_V        (75.0f)
    
    //! \brief motor lost phase current threshold
    #define USER_M1_LOST_PHASE_CURRENT_A        (0.02f)
    
    //! \brief motor unbalance ratio percent threshold
    #define USER_M1_UNBALANCE_RATIO             (0.3f) //0.2f
    
    //! \brief motor over load power threshold
    #define USER_M1_OVER_LOAD_POWER_W           (560.0f)
    
    //! \brief motor stall current threshold
    #define USER_M1_STALL_CURRENT_A             (18.0f) // 10f Amps
    
    //! \brief motor fault check current threshold
    #define USER_M1_FAULT_CHECK_CURRENT_A       (0.05f) //!0.05f
    
    //! \brief motor failed maximum speed threshold
    #define USER_M1_FAIL_SPEED_MAX_HZ           (750.0f) //1800.0f
    
    //! \brief motor failed minimum speed threshold
    #define USER_M1_FAIL_SPEED_MIN_HZ           (2.0f)
    
    //! \brief Defines the number of failed torque
    //!
    #define USER_M1_TORQUE_FAILED_SET           (0.000001f)
    // end of BSXL8320RS_REVA
    
    //------------------------------------------------------------------------------
    #elif defined(BSXL8323RS_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         (57.52845691f)
    
    //! \brief Defines the analog voltage filter pole location, Hz
    #define USER_M1_VOLTAGE_FILTER_POLE_Hz           (680.4839141f)     // 47nF
    
    //! \brief Defines the maximum current at the AD converter
    #define USER_M1_ADC_FULL_SCALE_CURRENT_A         (47.14285714f)     // gain=10
    
    //! \brief ADC current offsets for dc-link
    // the dc-link offset current for BSXL8323RS_REVA
    #define USER_M1_IDC_OFFSET_A            (USER_M1_ADC_FULL_SCALE_CURRENT_A / 2.0f)
    
    //! \brief ADC current offsets for A, B, and C phases
    #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)
    
    //! \brief ADC current offsets for A, B, and C phases
    #define USER_M1_IA_OFFSET_AD    (2030.99646f)
    #define USER_M1_IB_OFFSET_AD    (2016.76001f)
    #define USER_M1_IC_OFFSET_AD    (2007.99329f)
    
    //! \brief ADC voltage offsets for A, B, and C phases
    #define USER_M1_VA_OFFSET_SF    (0.498977453f)
    #define USER_M1_VB_OFFSET_SF    (0.497419506f)
    #define USER_M1_VC_OFFSET_SF    (0.500700474f)
    
    //! \brief DC bus over voltage threshold
    #define USER_M1_OVER_VOLTAGE_FAULT_V        (54.5f)
    
    //! \brief DC bus over voltage threshold
    #define USER_M1_OVER_VOLTAGE_NORM_V         (52.5f)
    
    //! \brief DC bus under voltage threshold
    #define USER_M1_UNDER_VOLTAGE_FAULT_V       (8.0f)
    
    //! \brief DC bus under voltage threshold
    #define USER_M1_UNDER_VOLTAGE_NORM_V        (10.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           (50.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           (1500.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 BSXL8323RS_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
    #define USER_M1_IA_OFFSET_AD_MAX    (USER_M1_IA_OFFSET_AD + 150.0f)
    #define USER_M1_IB_OFFSET_AD_MAX    (USER_M1_IB_OFFSET_AD + 150.0f)
    #define USER_M1_IC_OFFSET_AD_MAX    (USER_M1_IC_OFFSET_AD + 150.0f)
    
    #define USER_M1_IA_OFFSET_AD_MIN    (USER_M1_IA_OFFSET_AD - 150.0f)
    #define USER_M1_IB_OFFSET_AD_MIN    (USER_M1_IB_OFFSET_AD - 150.0f)
    #define USER_M1_IC_OFFSET_AD_MIN    (USER_M1_IC_OFFSET_AD - 150.0f)
    
    //! \brief ADC voltage offsets for A, B, and C phases
    #define USER_M1_VA_OFFSET_SF_MAX    (USER_M1_VA_OFFSET_SF + 0.05f)
    #define USER_M1_VB_OFFSET_SF_MAX    (USER_M1_VB_OFFSET_SF + 0.05f)
    #define USER_M1_VC_OFFSET_SF_MAX    (USER_M1_VC_OFFSET_SF + 0.05f)
    
    #define USER_M1_VA_OFFSET_SF_MIN    (USER_M1_VA_OFFSET_SF - 0.05f)
    #define USER_M1_VB_OFFSET_SF_MIN    (USER_M1_VB_OFFSET_SF - 0.05f)
    #define USER_M1_VC_OFFSET_SF_MIN    (USER_M1_VC_OFFSET_SF - 0.05f)
    
    //******************************************************************************
    //------------------------------------------------------------------------------
    //! \brief Vbus used to calculate the voltage offsets A, B, and C
    // =0.5*USER_M1_NOMINAL_DC_BUS_VOLTAGE_V
    #define USER_M1_VBUS_OFFSET_V  (0.5*USER_M1_ADC_FULL_SCALE_VOLTAGE_V)
    
    
    //! \brief Defines the maximum negative current to be applied in Id reference
    //!
    #define USER_M1_MAX_NEGATIVE_ID_REF_CURRENT_A       ((float32_t)(-2.0))
    
    
    //! \brief Defines the number of pwm clock ticks per isr clock tick
    //!        Note: Valid values are 1, 2 or 3 only
    #define USER_M1_NUM_PWM_TICKS_PER_ISR_TICK          (2) //1
    
    
    //! \brief Defines the number of ISR clock ticks per current controller clock tick
    //!
    #define USER_M1_NUM_ISR_TICKS_PER_CURRENT_TICK      (2)//1
    
    
    //! \brief Defines the number of ISR clock ticks per speed controller clock tick
    //!
    #define USER_M1_NUM_ISR_TICKS_PER_SPEED_TICK        (8) //10
    
    
    //! \brief Defines the number of current sensors
    //!
    #define USER_M1_NUM_CURRENT_SENSORS                 (3)
    
    
    //! \brief Defines the number of voltage sensors
    //!
    #define USER_M1_NUM_VOLTAGE_SENSORS                 (3)
    
    
    //! \brief Defines the Pulse Width Modulation (PWM) frequency, kHz
    //!
    #define USER_M1_PWM_FREQ_kHz        ((float32_t)(20.0f)) //20KHz
    #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     ((float32_t)1000.0/USER_M1_PWM_FREQ_kHz)
    
    
    //! \brief Defines the Interrupt Service Routine (ISR) frequency, Hz
    //!
    #define USER_M1_ISR_FREQ_Hz         (USER_M1_PWM_FREQ_kHz * (float32_t)1000.0 / (float32_t)USER_M1_NUM_PWM_TICKS_PER_ISR_TICK)
    
    //! \brief Defines the SFRA sampling, Hz
    //!
    #define MOTOR1_SAMPLING_FREQ_HZ     USER_M1_ISR_FREQ_Hz
    
    
    //! \brief Defines the Interrupt Service Routine (ISR) period, usec
    //!
    #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               ((float32_t)(0.95f))
    
    
    //! \brief Defines the voltage scale factor for the system
    //!
    #define USER_M1_VOLTAGE_SF          (USER_M1_ADC_FULL_SCALE_VOLTAGE_V / 4096.0f)
    
    //! \brief Defines the current scale factor for the system
    //!
    #define USER_M1_CURRENT_SF          (USER_M1_ADC_FULL_SCALE_CURRENT_A / 4096.0f)
    
    
    //! \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)
    
    
    //! \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)
    
    //! \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.66)
    //#define USER_M1_MAX_VS_MAG_PU              (0.65)
    //#define USER_M1_MAX_VS_MAG_PU            (0.576)
    //#define USER_M1_MAX_VS_MAG_PU            (0.565)
    #define USER_M1_MAX_VS_MAG_PU            (0.5)
    
    
    //! \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             (float32_t)(0.8) * USER_MAX_VS_MAG_PU)
    
    //! \brief Defines the R/L excitation frequency, Hz
    //!
    #define USER_M1_R_OVER_L_EXC_FREQ_Hz  ((float32_t)(250.0))
    
    
    //! \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        ((float32_t)(0.02))
    
    
    //! \brief Defines maximum acceleration for the estimation speed profiles, Hz/sec
    //!
    #define USER_M1_MAX_ACCEL_Hzps        ((float32_t)(2.0))
    
    
    //! \brief Defines the controller execution period, usec
    //!
    #define USER_M1_CTRL_PERIOD_usec      (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/(float32_t)1000000.0)
    
    
    //! \brief Defines the IdRated delta to use during estimation
    //!
    #define USER_M1_IDRATED_DELTA_A                 ((float32_t)(0.0001))
    
    #if defined(_FULL_FAST_LIB)
    //! \brief Defines the forced angle frequency, Hz
    #define USER_M1_FORCE_ANGLE_FREQ_Hz             ((float32_t)(1.0))
    
    //! \brief Defines the forced angle acceleration, Hz
    #define USER_M1_FORCE_ANGLE_ACCEL_Hzps          ((float32_t)(10.0))
    #else  // !_FULL_FAST_LIB
    //! \brief Defines the forced angle frequency, Hz
    #define USER_M1_FORCE_ANGLE_FREQ_Hz             ((float32_t)(1.0))
    #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      ((float_t)(0.0f))
    
    //! \brief Defines the fraction of IdRated to use during inductance estimation
    //!
    #define USER_M1_IDRATED_FRACTION_FOR_L_IDENT    ((float32_t)(0.5))
    
    
    //! \brief Defines the fraction of SpeedMax to use during inductance estimation
    //!
    #define USER_M1_SPEEDMAX_FRACTION_FOR_L_IDENT  ((float32_t)(1.0))
    
    
    //! \brief Defines the Power Warp gain for computing Id reference
    //! \brief If motor parameters are known, set this gain to:
    //! \brief USER_M1_PW_GAIN = SQRT(1.0 + USER_MOTOR1_Rr_Ohm / USER_MOTOR1_Rs_Ohm)
    //!
    #define USER_M1_PW_GAIN                        ((float32_t)(1.0))
    
    
    //! \brief Defines the pole location for the DC bus filter, rad/sec
    //!
    #define USER_M1_DCBUS_POLE_rps                  ((float32_t)(100.0))
    
    
    //! \brief Defines the pole location for the voltage and current offset estimation, rad/s
    //!
    #define USER_M1_OFFSET_POLE_rps                 ((float32_t)(20.0))
    
    
    //! \brief Defines the pole location for the speed control filter, rad/sec
    //!
    #define USER_M1_SPEED_POLE_rps                  ((float32_t)(100.0))
    
    
    //! \brief Defines the pole location for the direction filter, rad/sec
    //!
    #define USER_M1_DIRECTION_POLE_rps             (MATH_TWO_PI * (float32_t)(10.0))
    
    
    //! \brief Defines the pole location for the second direction filter, rad/sec
    //!
    #define USER_M1_DIRECTION_POLE_2_rps           (MATH_TWO_PI * (float32_t)(100.0))
    
    
    //! \brief Defines the pole location for the flux estimation, rad/sec
    //!
    #define USER_M1_FLUX_POLE_rps                  ((float32_t)(10.0))
    
    //! \brief Defines the pole location for the R/L estimation, rad/sec
    //!
    #define USER_M1_R_OVER_L_POLE_rps              (MATH_TWO_PI * (float32_t)(3.2))
    
    //! \brief Defines the convergence factor for the estimator
    //!
    #define USER_M1_EST_KAPPAQ                          ((float32_t)(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                     ((float32_t)(0.120f))
    #define USER_M1_EST_FLUX_HF_SF                     ((float32_t)(0.250f))
    //#define USER_M1_EST_FLUX_HF_SF                     ((float32_t)(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                     ((float32_t)(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                     ((float32_t)(1.00f))
    
    //------------------------------------------------------------------------------
    //! brief Define the Kp gain for Field Weakening Control
    #define USER_M1_FWC_KP                 0.0225
    
    //! brief Define the Ki gain for Field Weakening Control
    #define USER_M1_FWC_KI                 0.00225
    
    //! brief Define the maximum current vector angle for Field Weakening Control
    #define USER_M1_FWC_MAX_ANGLE          -10.0f                        // degree
    #define USER_M1_FWC_MAX_ANGLE_RAD      USER_M1_FWC_MAX_ANGLE /180.0f * MATH_PI
    
    //! brief Define the minimum current vector angle for Field Weakening Control
    #define USER_M1_FWC_MIN_ANGLE          0.0f                          // degree
    #define USER_M1_FWC_MIN_ANGLE_RAD      USER_M1_FWC_MIN_ANGLE /180.0f * MATH_PI
    
    //! \brief Defines the number of DC bus over/under voltage setting time
    //!  timer base = 5ms
    #define USER_M1_VOLTAGE_FAULT_TIME_SET          (500)
    
    //! \brief Defines the number of motor over load setting time
    //!  timer base = 5ms, 1s
    #define USER_M1_OVER_LOAD_TIME_SET              (200)
    
    //! \brief Defines the number of motor stall setting time
    //!  timer base = 5ms, 1s
    #define USER_M1_STALL_TIME_SET                  (200)
    
    //! \brief Defines the number of phase unbalance setting time
    //!  timer base = 5ms, 5s
    #define USER_M1_UNBALANCE_TIME_SET              (1000)
    
    //! \brief Defines the number of lost phase setting time
    //!  timer base = 5ms, 10s
    #define USER_M1_LOST_PHASE_TIME_SET             (2000)
    
    //! \brief Defines the number of over speed setting time
    //!  timer base = 5ms
    #define USER_M1_OVER_SPEED_TIME_SET             (600)
    
    //! \brief Defines the number of startup failed setting time
    //!  timer base = 5ms, 10s
    #define USER_M1_STARTUP_FAIL_TIME_SET           (2000)
    
    //! \brief Defines the number of over load setting times
    //!
    #define USER_M1_OVER_CURRENT_TIMES_SET          (5) //5
    
    //! \brief Defines the number of stop wait time
    //!  timer base = 5ms, 10s
    #define USER_M1_STOP_WAIT_TIME_SET              (2000)
    
    //! \brief Defines the number of restart wait time
    //!  timer base = 5ms, 10s
    #define USER_M1_RESTART_WAIT_TIME_SET           (2000)
    
    //! \brief Defines the number of restart time
    //!
    #define USER_M1_START_TIMES_SET                 (3)
    
    //! \brief Defines the alignment time
    //!
    #define USER_M1_ALIGN_TIMES_SET                 (2000)     // ctrl period
    
    //!
    //!
    #define USER_M1_QEP_UNIT_TIMER_TICKS            (uint32_t)(USER_SYSTEM_FREQ_MHz/(2.0f * USER_M1_ISR_FREQ_Hz) * 1000000.0f)
    

      

  • Seems like the motor you uses is not a tough one for InstaSPIN-FOC since it's just a generic motor and not a high frequency, low inductance and high current motor.

    You may try to use a supporting kits of the Universal Motor Control lab for a test if possible. Or follow the lab user's guide to run the example lab from build level 1 to make sure that the migration you did is correct. If you just run the motor without load for an initial test in this phase, I don't think you need to change any control parameters beside setting a correct motor electrical parameters (Rs, Ld, Lq and flux)

  • Or follow the lab user's guide to run the example lab from build level 1 to make sure that the migration you did is correct

    All build levels 1-4 with Nidec 4 pole work as expected motor runs high speed startup progresses but eSMO does not work so great.

    I don't think you need to change any control parameters beside setting a correct motor electrical parameters (Rs, Ld, Lq and flux)

    These values shown above for SDK4.0 run 36 pole motor without any issues.  UMCSD has added user motor settings the SDK never had. Perhaps the UMCSDK delta values need to be adjusted or the delay times in code snip above as to handle the larger rotor mass? Again UMCSDK drops the unloaded mass first 60° when it can't accelerate trajectory reference Hz with similar USER_MOTOR1_MAX_CURRENT_A  settings the SDK4.0 has. I can make 36 pole rotate 360 degrees 1-2Hz closed loop but never will accelerate to trajectory reference Hz. Seems like MCSDK enters the trajectory reference window to fast for the Kgm^2 mass. Adjusting KI/KP_spd values have some effect in this issue but not so much as SDK4.0 did.

  • but eSMO does not work so great.

    You need to tune the eSMO parameters according to the motor you used. The default parameters is only for the tested motors in the example lab.

    Perhaps the UMCSDK delta values need to be adjusted or the delay times in code snip above as to handle the larger rotor mass

    Yes. You may need to tune the delay time and current for the startup according to the motor.

  • Yes. You may need to tune the delay time and current for the startup according to the motor.

    Meantime will buy high voltage little motor to see if it works any better with default delays and default startup alignment time. Seems a fair price and checking other page adds we find 220VDC/AC 100,000 RPM little motor for experimenters that crave high speeds. Perhaps print 3D weighted sled for 100KRPM motor, it might act like jet engine velocity of air from fan blades on front end.  

    SHINANO DC105V 25W High Speed 3-Phase 8-Wire Hall DC Brushless Motor High Torque | eBay

    Can you suggest align time for large rotor mass (IM: 0.352838295721kg/m^2 ) and default below defined (2000) = 2 seconds or milliseconds?

    #define USER_M1_ALIGN_TIMES_SET                 (2000)     // ctrl period

  • You need to tune the eSMO parameters according to the motor you used. The default parameters is only for the tested motors in the example lab.

    Ok I see some new settings for eSMO PLL but it did start the Nidec motor though rapidly stalled and would not restart without resetting MCU.

    Also test MCSDK on User_Motor_3 (PT24P) several current levels, 103VDC up to 11.95A User_Max. The rotor mass (0.0622692574922507kg/m^2) had the same symptoms, would not accelerating to trajectory only spin 1-4Hz at best and the high side V phase NFET would rapidly dissipate high heat >5 other NFET. Can you suggest what delay times settings could help to spin this other mass? The motor ID did not spin rotor at any current settings yet the RS_Ohms is very exact.

    #if defined(USER_MOTOR3)
    #define USER_MOTOR1_TYPE                   MOTOR_TYPE_PM
    #define USER_MOTOR1_NUM_POLE_PAIRS         (12) //
    
    #define USER_MOTOR_SPEED_REF_HZ            (120) // Set Trajectory Speed
    
    #define USER_MOTOR1_Rr_Ohm                 (NULL)//ACIM only
    
    #define USER_MOTOR1_Rs_Ohm                 (0.310084999)//0.310084999
    #define USER_MOTOR1_Ls_d_H                 (0.00638059108)//0.00638059108
    #define USER_MOTOR1_Ls_q_H                 (0.00638059108)//0.00638059108
    #define USER_MOTOR1_RATED_FLUX_VpHz        (0.870792627)//0.870792627
    
    #define USER_MOTOR1_MAGNETIZING_CURRENT_A  (NULL)//ACIM only
    
    #define USER_MOTOR1_RES_EST_CURRENT_A      (8.75f)
    #define USER_MOTOR1_IND_EST_CURRENT_A      (-7.4375f) //-15%
    #define USER_MOTOR1_MAX_CURRENT_A          (9.355f)
    #define USER_MOTOR1_FLUX_EXC_FREQ_Hz       (20.0f)
    
    // Number of lines on the motor's quadrature encoder
    #define USER_MOTOR1_NUM_ENC_SLOTS          (NULL)
    
    #define USER_MOTOR1_INERTIA_Kgm2           (0.0622692574922507)
    
    #define USER_MOTOR1_FREQ_NEARZEROLIMIT_Hz  (5.0f)          // Hz
    
    #define USER_MOTOR1_RATED_VOLTAGE_V        (130.0f)
    #define USER_MOTOR1_RATED_SPEED_KRPM       (1.0f)
    
    #define USER_MOTOR1_FREQ_MIN_HZ            (2.0f)           // Hz
    #define USER_MOTOR1_FREQ_MAX_HZ            (90.0f)         // Hz
    
    #define USER_MOTOR1_FREQ_LOW_HZ            (2.0f)           // Hz
    #define USER_MOTOR1_FREQ_HIGH_HZ           (80.0f)         // Hz
    #define USER_MOTOR1_VOLT_MIN_V             (1.0f)           // Volt
    #define USER_MOTOR1_VOLT_MAX_V             (110.0f)          // Volt
    
    #define USER_MOTOR1_FORCE_DELTA_A          (0.05f)          // A
    #define USER_MOTOR1_ALIGN_DELTA_A          (0.01f)          // A
    #define USER_MOTOR1_FLUX_CURRENT_A         (3.325f)           // !A
    #define USER_MOTOR1_ALIGN_CURRENT_A        (5.325f)           // !A
    #define USER_MOTOR1_STARTUP_CURRENT_A      (8.325f)           // !A
    #define USER_MOTOR1_TORQUE_CURRENT_A       (3.65f)            // !A
    #define USER_MOTOR1_OVER_CURRENT_A         (15.5f)            // !A
    
    #define USER_MOTOR1_BRAKE_CURRENT_A        (1.0f)           // A
    #define USER_MOTOR1_BRAKE_TIME_DELAY       (12000U)         // 60s/5ms
    
    #define USER_MOTOR1_SPEED_START_Hz         (1.0f)
    #define USER_MOTOR1_SPEED_FORCE_Hz         (2.0f)
    #define USER_MOTOR1_ACCEL_START_Hzps       (1.5f)  // !Hz
    #define USER_MOTOR1_ACCEL_MAX_Hzps         (2.0f)  // !Hz
    
    #define USER_MOTOR1_SPEED_FS_Hz            (3.0f) // Flying Start

  • Can you suggest what delay times settings could help to spin this other mass?

    #define USER_MOTOR1_RES_EST_CURRENT_A (8.75f)
    #define USER_MOTOR1_IND_EST_CURRENT_A (-7.4375f) //-15%

    What's the rated current of the motor? Do you try to identify the motor without load?

  • What's the rated current of the motor? Do you try to identify the motor without load?

    Probably 30A peak #17 AWG Cu though it starts to spin 10.75A and quickly overheats V high side NFET oddly no others. Yes motor ID via FAST without any shaft loads. Rotor weighs 4.898797596Kg (10.8lbs) via digital scale, AG is wide in this testing and torque peaks 5-8Nm. Motor ID rapidly drops the rotor load same as online runtime have to give rotor some help to get spinning current is ramping to fast. Current is peaking since the AG is wider in this test, needs much longer delay going from open to closed loop.

    Since the unpowered rotor self-aligns with stator teeth, alignment delay time can be NULL or omitted?

  • AG is wide in this testing and torque peaks 5-8Nm

    What do you mean this? What's the rated current of the motor? Seems like the value of the USER_MOTOR1_IND_EST_CURRENT_A  is too high compare to USER_MOTOR1_MAX_CURRENT_A.

  • What do you mean this?

    Air Gap. 

    Seems like the value of the USER_MOTOR1_IND_EST_CURRENT_A  is too high compare to USER_MOTOR1_MAX_CURRENT_A.

    I set the saturation current above user_est to get the rotor to spin and ind_est -15% of user_est as instructed for motor ID process. Oddly setting ind_est -14A and user_est +14A equal values makes no change in the open loop observer startup delay time.  

    Seems this issue effects both SDK and MCSDK low speed observer jumping into closed loop to soon, just above 1Hz. Noticing speed_Hz starts toggling positive and negative integers and current wave form is present 2 seconds before the rotor is even moving. Seemingly need to set the open loop observer to wait for steady state speed_>5Hz prior to enabling closed loop or set a delay time in slow speed observer. The motor with tight AG (0.036") SDK4.0 almost does not start it at times and forge MCSDK is complete failure. Can hear magnetic slip current racing the coils during open loop transition into closed loop. It seems there are non-synchronous slip of electrical degrees during open loop transition in the SPM on both large mass rotors.

    Depending on shaft load, transition delay may need to be longer or open loop hertz setting higher. Is that considered the zero speed user setting = 1Hz?

    That may be why SDK4..0 can start 36 pole motor but MCSDK cannot and immediacy jumps into closed loop before the rotor is moving. Even after increasing alignment delay 2-3 seconds or setting (align = false) the same issue occurs but much sooner.

  • I set the saturation current above user_est to get the rotor to spin and ind_est -15% of user_est as instructed for motor ID process. Oddly setting ind_est -14A and user_est +14A equal values makes no change in the open loop observer startup delay time.  

    What's the rated and maximum current of the motor? What's the  rated voltage and power of the motor?

    Depending on shaft load, transition delay may need to be longer or open loop hertz setting higher. Is that considered the zero speed user setting = 1Hz?

    It's not necessary to be changed. As mentioned above, make sure that the migration is correct. You may check the migration in build level 1~3, or run another motor to verify the porting.

  • It seems some of the trouble is how the SDK4.0 MCSDK sets SVM_MIN_C to run an identified motor with FWC enabled. Even disable FWC the PWM is not evenly distributed as with SVM_COM_C NFETS stay even heat dissipation. Documentation PDF SPRUJ26 – SEPTEMBER 2021 does not explain how motor ID should use either case.

    Why would FWC be enabled for Motor ID process use SVM_MIN_C versus mode SVM_COM_C? Is it required to use FWC enabled for motor ID process?

    What's the rated and maximum current of the motor?

    Answered that question above, 30A 110V at this point. Using trapezoidal FOC timer algorithm, 100v DC inverter motor spins 82 RPM open loop, roughly 0-6.8A slope 101vdc. So it can spin open loop but the AC sine wave (~VS_PU 0.5) has to be set very high for SVM_MIN_C not producing distributed PWM. Hence the high side NFET on V phase is being stressed by SVM_MIN_C. Seemingly SVM_COM_C produces distributed PWM, spreads current load over all 6 bridge NFETS is something to beware of.

    make sure that the migration is correct.

    Mentioned above migration starts a very low current 4 pole motor it identified without issues. However not the 36 pole motor that runs flawlessly SDK4.0 with the same identified motor user parameters. That is the control in the experiment, not so much the migration as UMCSDK seems 75% functional though more complex startup parameters exist that are not well explained what they do.

    So we have to use best guess setting user_motor1_delta, _flux, _align, _startup, _torque currents?

    I discovered questionable code issue [ #if !defined(MOTOR1_PUMODE) ] setup controller parameters two ways but no symbol in project build. This is another post asking about PU mode believed to be enabled when USER_M1_MAX_VS_PU (0.5).

    Why was the UMCSDK SDK 4.0 download set for USER_M1_MAX_VS_MAG_PU  (0.576) without current reconstruction? Perhaps was overlooked or has the ADC window been widened and improved addition of PPB? So we can use 0.576 without current reconstruction?

  • Hi Yanming,

    The problem seems to be project build forces to use MOTOR1_ESMO symbol or else motor1_drive.c has missing handle/s variables defined in motor_common.h. There is a duplicate define MOTOR1_FAST in motor_common.h.  So build must have eSMO enabled and FAST estimator runs eSMO function calls if project build has MOTOR1_ESMO_N symbol. So we are forced to use eSMO when MOTOR1_FAST only project build or the ISR breaks and run LED don't blink halts the MCU. We can't run FAST estimator only build. Was this issue below fixed in later v4.01 universal MCSDK?

    Why would it be ok to run eSMO function calls in FAST estimator only project build? Perhaps adding #if around eSMO calls in motor1_drive.c though it seems odd build allowed eSMO at all when the symbol MOTOR1_ESMO_N exists in the build.

    *** Trouble area motor1_drive.c. ***

    #if defined(MOTOR1_FAST) && defined(MOTOR1_ESMO)    //Maybe add || (OK<->OK)

    // run the eSMO
    ESMO_setSpeedRef(obj->esmoHandle, obj->speed_int_Hz);
    ESMO_run(obj->esmoHandle, obj->adcData.VdcBus_V,
    &(obj->pwmData.Vabc_pu), &(obj->estInputData.Iab_A));

    obj->angleComp_rad = obj->speedPLL_Hz * obj->angleDelayed_sf;
    obj->anglePLL_rad = MATH_incrAngle(ESMO_getAnglePLL(obj->esmoHandle), obj->angleComp_rad);

    SPDFR_run(obj->spdfrHandle, obj->anglePLL_rad);
    obj->speedPLL_Hz = SPDFR_getSpeedHz(obj->spdfrHandle);

    ***** Trouble area motor_common.h ***

    #if defined(MOTOR1_ESMO)
    //!< the handle for the speedfr object
    SPDFR_Handle spdfrHandle;

    //!< the handle for the esmo object
    ESMO_Handle esmoHandle;
    #endif // MOTOR1_ESMO

    #if (DMC_BUILDLEVEL <= DMC_LEVEL_3) || defined(MOTOR1_VOLRECT) || \
    defined(MOTOR1_ESMO) || defined(MOTOR1_ENC)
    //!< the handles for Angle Generate for open loop control
    ANGLE_GEN_Handle angleGenHandle;
    #endif // DMC_BUILDLEVEL <= DMC_LEVEL_3 || MOTOR1_ESMO || MOTOR1_VOLRECT

    #elif defined(MOTOR1_FAST) || defined(MOTOR1_ESMO) // 5/3/23 added motor1_esmo stop index build errors
    typedef enum
    {
    ESTIMATOR_MODE_FAST = 0, //!< FAST estimator
    ESTIMATOR_MODE_ESMO = 1 //!< ESMO estimator
    } ESTIMATOR_Mode_e;

    #elif defined(MOTOR1_FAST)
    typedef enum
    {
    ESTIMATOR_MODE_FAST = 0 //!< FAST estimator
    } ESTIMATOR_Mode_e;
    #elif defined(MOTOR1_ESMO)
    typedef enum
    {
    ESTIMATOR_MODE_ESMO = 1 //!< ESMO estimator
    } ESTIMATOR_Mode_e;

  • Upon further investigation it seems MOTOR1_FAST enabled mandates MOTOR1_ESMO be enabled otherwise the ADC interrupt runs extremely slow and CPUTM0 fails to reload the period. Yet debug indicates ADC reading data, the forever loop seems to stop, making it appear as if the ADC ISR had stopped so the LED does not flash just stays on. Some instruction in fast_full_lib.lib eabi code is running extremely slow when MOTOT1_FAST only mode is enabled, MOTOR1_ESMO_N build.

    Partial resolve: Compiling MOTOR1_FAST only mode somehow defeats CPUTM0 one second period never reloads counter via Register view the counts never reach 100K. Does not matter CPUTM0 emulation mode. Add statement above 1ms relay loop [systemVars.flagEnableSystem = true] to override relay 1sec while loop. CPUTM0 counting was also acting odd with MOTOR1_ESMO enabled though it did not preempt CPUTM0 count as does FAST only mode, count to zero stop or run free emulation modes. Advise do not defeat CPUTM0 on HV kits. We use high current wattage thermistor versus relay inrush current control, also helps smooth DC supply ripple current.

    Oddly motor ID had SVM_MIN_C and FWC enabled as SVM_COM_C is enable for MOTOR1_FAST only mode when flagMotorIdentify = true. And the motor ID process executes eSMO + FAST estimator, though PDF tables show motor ID only works in FAST mode works for very low current motors SVM_MIN_C.

  • The lab can support eSMO or FAST separately, or support eSMO and FAST at the same time. Seems like all of the configurations are tested and validated when we release this lab. I will take a look at the example lab to see if there are any issues as you mentioned above. What PWM and ISR frequency are you using? Thanks! 

  • Hi Luo,

    What PWM and ISR frequency are you using?

    20KHz PWM, 10us 100Mhz clock rate x25 below formula seems to work much better. The hex count value seemed wrong for CPUTM0 1ms with 10ns SYSCLK. Register view counts never reloads defined hex period value, seems to overflow very early, runs very slow LED flash rates no LCD updates.

    #if defined(_F28004x) uint32_t timerPeriod = (uint32_t)((USER_SYSTEM_FREQ_MHz * 1000.0f) / timeBaseFreq_Hz) - 1; //100.0f *1000.0f /100.0f
    #endif

    I try to update SDK4.0 4 files MCSDK 4.02.01 (motor_common.c/h) and (motor1_drive.c/h) and add few newer struct members that did not exist back then. That causes 2 compiler symbol errors even though indexer resolved them. Though not during compile time (hal) and (userParams_M1) refuse to resolve no matter where I put the global externs or add includes to them, use pointers rather than (.) to join the members resolve but not compile CCS12.4 updated few days ago. The odd part is they both resolve during compile with the SDK 4.0 file names show above. I save copy name version number for that very reason to put them back . Its only working with eSMO and FAST together SDK4.0 and there is no phase current being produced FAST only estimator. 

    Later switched to CPUTM1 in forever loop 1ms times. That fixed SDK4.02.01 files very slow ADC ISR times (sys_main.c).  Odder yet have to multiply (BusVoltage * 2.2) to get same value as debug for LCD output, very bizarre. Typical (((float32_t)motorVars_M1.adcData.VdcBus_V * 2.2) * 10) where (*10) moves decimal point in the widget, then shows -101.2 vdc. I see where seemingly code issue was SDK4.02.01 FAST only mode added new current controls, did not exist SDK4.0 version.

  • If you don't set the control ISR frequency to a higher value (>20KHz) and enable the CPU has enough width for background loop. I don't think the lab has any issues as you mentioned above.

    You can use one of the CPU timers as the virtual timer for background loop, or even you don't use any virtual timer for background loop. The lab can still works well, only the ISR frequency is critical for the lab.

    BTW, you can try to run the example without adding any your own code to see what happens, and then add your own code step by step to see where is the issue.

  • Seems it's the CPU timers periods are affected by eSMO with FAST being enabled in the build. Though after seeing symbol errors in main_sys.c build with same 4 files above to update FAST control section SDK4.02.01. There is something 4 new files that affects below symbols main_sys.c from being resolved by #include "motor1_drive.h. (halHandle) and #include "motor_common.c" do not resolve on compile but do with SDK4.0 MCSDK files. I'm generally very good fixing hundreds of symbol errors but after hours trying gave up! The CPU timers somehow change the execution time of the period being loaded by firmware so the LED flash rate at 10µs set for 1ms period is even more puzzling how it reduces reload time, likely checking overflow status register is incorrect read.

    extern volatile MOTOR_Vars_t motorVars_M1; extern USER_Params userParams_M1;

    HAL_MTR_Handle halHandle; //!< the handle for the hardware abstraction layer

    HAL_MTR_Obj hal; //!< the hardware abstraction layer object

    #if defined(_F28004x)
    
        uint32_t timerPeriod = (uint32_t)((USER_SYSTEM_FREQ_MHz * 1000.0f) /
                                                        timeBaseFreq_Hz) - 1; //100*1000/100=1ms
    #endif
    
        // use timer 1 for 1ms timebase
        CPUTimer_setPreScaler(obj->timerHandle[1], 0);
    
        CPUTimer_setEmulationMode(obj->timerHandle[1],
                                  CPUTIMER_EMULATIONMODE_RUNFREE);
    
        CPUTimer_setPeriod(obj->timerHandle[1], timerPeriod);
    
        CPUTimer_enableInterrupt(obj->timerHandle[1]);
    
        CPUTimer_startTimer(obj->timerHandle[1]);
    
        return;
    }  // end of HAL_setupADCTriggerTimer() function

  • Seems like there is something wrong in your project. Please check if the CPU clock, PWM is configured correctly and there is any time overflow in ISR loop.

  • Agree CPUTM0, CPUTM1 appears to be configured correctly. Past checked ISR decimation time 50µs 50% duty cycle, 25µs. Oddly when CPUTM0 didn't divide period count via #define MACRO's it was loading correct period value. Though oscillator MACRO's are mathematically correct by visual inspection USER_SYSTEM_FREQ_MHz.

    Oddly after fixing FWC SVM_MIN_C issue runs motor ID Shinano LA034 (2polepairs) - runs smooth 102vdc >10KRPM. Use same motor settings SDK4.0 the motor won't accelerate >5.5KRPM 185Hz mild field bucking. Yet the Nidec 25H (2polepairs) 24VDC runs >10KRPM 325HZ or so in same SDK 4.0 code.

  • If you didn't change the example lab, the FWC will be disabled and the SVM mode is SVM_COM_C by default for motor ID. Only switch the SVM to SVM_MIN_C  when the motor start to run up to a setting speed.

  • Only switch the SVM to SVM_MIN_C  when the motor start to run up to a setting speed.

    What do you mean by that? FWC mode it startup in SVM_MIN_C then switch to SMV_COM_C? The default code was set to bypass motor ID set FWC enable but the symbol MOTOR1_FWC_N did not stop SMV_MIN_C during motor ID it set FWC flag enable too though code was not present as Kevin pointed out in another thread. If logic was so easy everybody would be programmers in the world Nerd right.

    Below discovered issue CPUTM0 later CPUTM1 complier warning only when decimal values replace cast integers and Macros, period not equal 1ms. For 1ms clock period load of 0x186A0 or 100,000 decimal. So the value was truncated for 100µs tick of 10,000 load count but compiler did not warn when macro and variable are cast by the caller. I have seen the code Boolean logic work for 1ms tick set CPUTM0 but other parts did not seem to like that slow tick rate.

  • What do you mean by that? FWC mode it startup in SVM_MIN_C then switch to SMV_COM_C?

    Motor control will start from SMV_COM_C, and switch to SVM_MIN_C . The SVM mode is not related to FWC mode. The FWC is not related to the motor ID as well, just the motor ID will not use FWC.

  • Motor control will start from SMV_COM_C, and switch to SVM_MIN_C 

    When does it do that - what mode, eSMO into FAST?

    The SVM mode is not related to FWC mode.

    Ok, so that is what was happening snip above, FWC flag was being set but the mode would remain SVM_MIN_C. Very low current motors would spin up in SVM_MIN_C and remain in SVM_MIN_C. Bigger motor load would quickly stall SVM_MIN_C when flag_bypassMotorId = true. The Shinano motor (+103v, 243mA, 25W) would not accelerate >5.5KRPM (SDKv4.0) due to VpHz being very different from MCSDK motor ID would speed >10KRPM. SDK v4.0 manually reduced VpHz until speed passes 7KRPM after several more tweaks >10KRM without field bucking. Oddly inductance was not the determining factor, could vary it greatly not much change. Fairly large spread between the SDK and MCSDK VpHz though just Shanano as Nidec +24v had same VpHz in both versions. 

    UMCSDK v4.0: USER_MOTOR1_RATED_FLUX_VpHz  (0.259595213)

            SDK v4.0: USER_MOTOR_RATED_FLUX_VpHz   (0.101245213)

  • When does it do that - what mode, eSMO into FAST?

    It's the same for ESMO and FAST. The SVM mode is not related to the estimator algorithm, ESMO fo FAST.

    Ok, so that is what was happening snip above, FWC flag was being set but the mode would remain SVM_MIN_C

    If you didn't change the control flow in the example lab, I don't think there is issue as you mentioned above. Please try to use the example lab first.