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.

mainISR

Guru 56218 points

Part Number: TMS320F280049C
Other Parts Discussed in Thread: BOOSTXL-DRV8320RS

Hello,

Context x49c launch, BoostXL-drv8320rs motor SDK and (is_05_motor_id.c)  __Interrupt mainISR(void) interrupt handler and tick monitor via GPIO-30.

During idle state the PWM high side drives never turned off and GPIO30 never turns off once it has been turned on at the top of the mainISR(). The PWM drives issue is not so bad but the decimation pulse time scope capture is cause to ring alarm bells.

The call to turn off GPIO30 never occurs unless the motor ID is enabled but LED5 is toggling in the same function, so it exits but where? The only time GPI030 (J2 pin13) toggles is during motor ID Exactly to PWM frequency (20Khz). Oddly several calls within mainISR have a forced (return) statement above the last ( } ). So the mainISR is not exiting at the bottom as expected and GPIO30 remains high. Seemingly not giving a correct time span of InstaSpin ROM calls following mostly the PWM period. A 30Mhz digital scope can not detect GPIO30 pulses as LED5 is toggling within mainISR. GPIO30 pulse peaks only inflect slightly downward from 3v3 typical of very rapid GPIO exit from function. One would expect a well defined pulse with thin periods extending downward to ground, that does not occur.    

I have noticed similar practice several functions motor SDK where a (return) statement POPs address off the stack prior to the last return ( } ) bottom of function. This case being a false GPIO30 time decimation seems to occur at only the PWM period (50µs 20Khz). Other calls in the mainISR() never seem to add to 50µs decimation time. It would also seem mainISR motor ID loop is re-entrant every time it (returns) from any one of several sub calls in the motor ID stack calls to ROM. If GPIO30 is always toggling with LED5 my 30Mhz scope can not trigger on the ghost pulse that hides from view. 

The odder part being if we move the bottom GPIO30 Low call into call LED5 slower rate, it never pulses GPIO30 placed just before or after. It could be some kind of configuration issue GPIO30 but we can not see any conflicting code. Otherwise the way LED5 GPIO port is being asserted On/Off is baffling how it is even working via what appears to be a hook driven into a handle asserting another triggered call!  LED5 toggling method seems to be part of the problem with mainISR()...

If mainISR() was working correctly the last call to GPIO30 would always pulse even after motor ID is enabled. How is GPIO30 producing a correct decimation time  mainISR() if or when it often exits above the last ( } ) bottom of function?

How can we expect Motor ID to correctly identify motor parameters as mainISR() is thought to be repeatedly entering the call stack far above the last return? Oddly mainISR() does toggle GPIO30 but only when motor ID is enabled can any kind of pulse be captured by 10KSPS deep scope trigger. Again the GPIO30 pulse has V shape leading to apprehension mainISR() decimation time is incorrect. Perhaps this too leads to 100% trapezoidal modulation causing rotor vibration at the SVPWM rotation angle drifts off the vector frame. We feel random rotor oscillations occurring after motor ID flag=1 thus after ID motor (700Hz) only reach 115Hz speed 1.1Krpm, if not held down to large mass rotor starts to vibrate. 

__interrupt void mainISR(void)
{
    //
    // check ISR executing time by toggling the GPIO
    //
    HAL_setGPIOHigh(halHandle, HAL_GPIO_ISR);

    motorVars.pwmISRCount++;

    //
    // toggle status LED
    //
    counterLED++;

    if(counterLED > (uint32_t)(USER_ISR_FREQ_Hz / LED_BLINK_FREQ_Hz))
    {
        HAL_toggleLED(halHandle, HAL_GPIO_LED2);//LED5
        counterLED = 0;
    }


// Motor ID and enable code checks //


    //
    // write the PWM compare values
    //
    HAL_writePWMData(halHandle, &pwmData);


    //
    // Force trig DMA channel to save the data
    //
    HAL_trigDlogWithDMA(halHandle, 0);
    HAL_trigDlogWithDMA(halHandle, 1);
    HAL_trigDlogWithDMA(halHandle, 2);
    HAL_trigDlogWithDMA(halHandle, 3);
#endif  //  _DATALOG_EN_

    //
    // check ISR executing time
    //
    HAL_setGPIOLow(halHandle, HAL_GPIO_ISR);

    return;
} // end of mainISR() function

    

  • I missed GPIO 30 was configured as input (hal.c), how did it even work at all from mainISR calls? I configure it as output and not much difference for decimation pulse period or shape (J2 pin13) though it seem to pulse bit faster than 50µs. Since the PWM triggers SOC->EOC plus time from mainISR ROM calls so GPIO-30 pulse should be slightly slower than the PWM period, it ain't.

    One major point of SVPWM is to reduce rotor vibration versus other modulation techniques, not increase rotor vibration as it is doing. Albeit this small PM motor has only 1 shaft bearing and rotor is sleeved by Teflon, if it should ever contact stator poles in near 0.040" air gap. Oddly 6 code modulation produces none of the noted vibration thus programming issue/s seem the most likely suspect! 

    Also reducing the IRatedDelta made no difference to reduce rotor vibration during ramp up estimation >100Hz. 

    //! \brief Defines the IdRated delta to use during estimation
    //!
    #define USER_IDRATED_DELTA_A       ((float32_t)(0.00002))//0.0001
    
        // GPIO30->Reserve (N/A), mainISR START/STOP
        #ifdef CLA
        GPIO_setMasterCore(30, GPIO_CORE_CPU1_CLA1);
        #else
        GPIO_setMasterCore(30, GPIO_CORE_CPU1_CLA1);
        #endif
        GPIO_setMasterCore(30, GPIO_CORE_CPU1);
        GPIO_setPinConfig(GPIO_30_GPIO30);
        GPIO_setDirectionMode(30, GPIO_DIR_MODE_OUT);// default was IN
        GPIO_setPadConfig(30, GPIO_PIN_TYPE_PULLUP);

  • This PWM period logic is in milliseconds and not 20Khz microsecond period 1/frequency. So to make 50us PWM mainISR then LED5 No longer pulses and motor ID flag jump to 1 prior to enable flag being set. Please do not write PWM period is microseconds if you mean it to be milliseconds as the later InstaSpin control period. Anyone will immediately think it a bug in timing if PWM period is indeed microseconds as the variable below shows.  Something in mainISR vibrates this motor during ID and it ain't the user.h preset motor settings. 

    The same formula derives user control period in seconds and the angle delay user.c.

    //! \brief Defines the Pulse Width Modulation (PWM) period, usec
    //!
    #define USER_PWM_PERIOD_usec    ((float32_t)1/USER_PWM_FREQ_kHz) //1000.0
    
    //! \brief Defines the controller execution period, sec
    //!
    #define USER_CTRL_PERIOD_sec    ((float32_t)USER_CTRL_PERIOD_usec/(float32_t)1000000.0)
    
    //user.c
        pUserParams->angleDelayed_sf_sec = (float32_t)0.5 * USER_CTRL_PERIOD_sec;
    
    

       

  • The GPIO30 toggles in ISR that's for the test in development, so the related configuration has been removed, but the test code was not removed accordingly. Sorry, confusing you, we will remove the test code also.

    I can't find the code in the example project you mentioned above, it should usec with the formula "#define USER_PWM_PERIOD_usec    ((float32_t)1000.0/USER_PWM_FREQ_kHz)".

  • Yanming Luo said:
    The GPIO30 toggles in ISR that's for the test in development, so the related configuration has been removed

    There is a timing problem in mainISR GPIO30 not behaving as it should to show decimation timing. There is no missing code in mainISR, how else could we see decimation periods of mainISR? Based on x49c launch pad schematic J2 pin being GPIO 30 pin 39. BoosterPack quick card changed to reflect schematic J2/J4 since user guide suggest silk was wrong J6/J8 on card PCB but not J2/J4, was very confusing.

    Again the scope capture of GPIO-30 is very odd shaped check it out your self. We do the same for other interrupts in TM4C1294 MCU and never see GPIO output signal with no period sustain. The GPIO-30 period is being chopped by the interrupt handler, otherwise should have full pulse period going to ground. Otherwise GPIO-30 V pulse (2 tips) seem to indicates extremely short execution time inside mainISR.

    Yanming Luo said:
    I can't find the code in the example project you mentioned above, it should usec with the form

    1000/20.0=50 but not (0 .000050µs) that was why to try P=1/F thinking user parameter PWM frequency 20000Hz not simply 20.0 as it was defined. Point again being 50 is not 50µs unless perhaps a periodic triggered timer. InstaSpins EOC interrupt to maintain rotation angle seems to drift in and out of phase causing periods of negative torque cycles during and after ramp down. 

    The motor flux is only stable by very low user phase current <0.5mA and fails to produce speed >155Hz in ramp up. In ramp down with >0.5mA user flux is highly unstable motor ID flag=1. No wonder others are having problems with motor ID is05 as the timing in mainISR is not keeping consistent. There is no way this motor should be vibrating like this even from very low user current. SPRUHJ1H–January 2013–Revised June 2019 never states the ramp up frequency 20Hz goes above USER_MOTOR_FLUX_EXC_FREQ_Hz states (LS,CL1,CL2,CL) makes it odd 20Hz rose up to 155Hz ramp up in watch window. How it do that when it was forced to 20Hz in Lab is05_motor_id.c?

  • Perhaps timing mainISR ends up causing truncated ramp up period <20 seconds as defined below. Motor can not reach peak Hz for flux detection via CL1 no matter IND/RES current setting. In this case MotorFreqHighHz (600Hz) rotor only reach 155Hz for values input IND/RES. Ramp down (CL1) seems to start <20 seconds rotor vibration results.

    Perhaps over modulation causes speed issues or some other PWM triggered timing reduces the ramp up period HighHz cycle? The user is forced to set very low IND/RES current (<0.5A) to counter CL1 vibration and motor never (safely) reach MotorFreqHighHz (600Hz).  Otherwise user input IND/EST current (>1.0A) and ramp down has violent vibrations negative flux cycles. Square wave inverter output results phase voltages sharp rising edges small roll off during is05 motor ID. Find it odd the 3 PGA gain are set level 12 but you guys are the experts we are only reporters of issues when it don't work so well. 

    6.5.5.2 Ramp-Up Time and Acceleration
    The next parameter during the ramp-up state is the period of time while the motor is ramped up (Figure 6-17). This is set by default to 20 seconds as shown in the next code example from user.c file:

    [EST_State_RampUp]
    pUserParams->estWaitTime = (uint_least32_t)(20.0*USER_EST_FREQ_Hz);
    //! \brief Defines the timer frequency for estimator, kHz
    #define USER_EST_FREQ_Hz (USER_ISR_FREQ_Hz)
    #elif (USER_MOTOR == NidecMotor_1)
    #define USER_MOTOR_TYPE                   MOTOR_TYPE_PM
    #define USER_MOTOR_NUM_POLE_PAIRS         (6)
    #define USER_MOTOR_Rr_Ohm                 (NULL)//ACIM only
    #define USER_MOTOR_Rs_Ohm                 (1.46257722)//1.45991349
    #define USER_MOTOR_Ls_d_H                 (0.00211925316)//0.00223078486
    #define USER_MOTOR_Ls_q_H                 (0.00211925316)//0.00223078486
    #define USER_MOTOR_RATED_FLUX_VpHz        (0.0239039753)//0.0243388247
    #define USER_MOTOR_MAGNETIZING_CURRENT_A  (NULL)//ACIM only
    #define USER_MOTOR_RES_EST_CURRENT_A      (1.6) //++ to spin motor under load
    #define USER_MOTOR_IND_EST_CURRENT_A      (-1.6)//-- to spin motor under load
    #define USER_MOTOR_MAX_CURRENT_A          (2.0) // After ID never used again
    #define USER_MOTOR_FLUX_EXC_FREQ_Hz       (20.0)
    //#define USER_MOTOR_INERTIA_Kgm2           (7.06154e-06)
    
    // Number of lines on the motor's quadrature encoder
    #define USER_MOTOR_NUM_ENC_SLOTS          (NULL)
    
    #define USER_MOTOR_FREQ_MIN_HZ             (5.0)           // Hz
    #define USER_MOTOR_FREQ_MAX_HZ            (775.0)         // Hz
    
    #define USER_MOTOR_FREQ_LOW_HZ            (10.0)          // Hz
    #define USER_MOTOR_FREQ_HIGH_HZ           (600.0)         // Hz
    
    #define USER_MOTOR_VOLT_MIN_V             (12.0)          // Volt
    #define USER_MOTOR_VOLT_MAX_V             (24.0)          // Volt

  • Note (iso5_motor_id.c) statement over rules (user.h)  #define USER_MOTOR_FLUX_EXC_FREQ_Hz . The WA requires the patch below. Seemingly LC state detection is not meant to run at such low rotor speeds (Hz) according to SPRUHJ1H–January 2013–Revised June 2019. There are new states CL2, RR not discussed.

    CL2 seems to ramp motor upto 1.3krpm after state OL flux. Patch allows (300Hz - 500Hz) state OL, PM not stall lock rotor in this state via higher frequency. Yet LC state still vibrates rotor but less noticed at higher Hz speed. It seems LC is not being correctly identified since cogging seems to be an integral part of _IND_EST_CURRENT_A and LAB guide instructing we match it with _RES_  makes it worse. It seems IND (-) current needs to be less not equal to reduce negative torque via LS state.

        //
        // Set some global variables
        //
        motorVars.pwmISRCount = 0;          // clear the counter
        motorVars.speedRef_Hz = USER_MOTOR_FLUX_EXC_FREQ_Hz;  // set reference frequency to 300.0Hz
        motorVars.accelerationMax_Hzps = 10.0; //defines starting maximum acceleration and deceleration for the speed profiles,

  • 1. Problem was GPIO 30 x49c launch pad user guide schematic has J2 / J4 marked over the wrong headers. So GPIO 30 is on J4 pin 33. The InstaSpin mainISR is 32µs long inside each 50µs PWM period.  

    2. Ramp up was being skipped and the same SVPWM motor current used in six step commutation was excessively high. So 1.6A need to be more like 0.3A to keep the motor from cogging undocumented CL2 mode @20Hz for (30 * User_Est_Freq_Hz). That finally smoked center phase windings Rs_Ohm=1.5. It seems odd that the same motor runs great via 6 step commutation 1.6A steady state peak but got smoking hot under InstaSpin SVPWM modulation.

    3. No reduced amount of Res_Est_Current seems to mitigate low frequency rotor vibration <200Hz. Sputtering PWM drive signals remains consistent (0Hz >500Hz) entering the inverter finally the motor. The sputtering PWM noise entering the system seems to be coming from PGA's in my best off hand analysis. I have tweaked ePWM ADC, SOC, PIE interrupts priority and still fail to get clean PWM from mainISR ROM calls to Clarke/Park transforms.  

  • Did you have any captured waveforms to show the problems you mentioned above if possible? That should help us to fully understand your questions. Thanks!