2025-10-06 1:52 AM - edited 2025-10-07 1:04 AM
I am working on a project to drive a door using a PMSM motor in position control mode.
I've encountered a problem I can't solve. When the motor is positioned at some specific rotor positions, it fails to start properly and tends to spin out of control during the startup sequence.
There are very similar 2 posts titled “Loss of control whenever the motor starts at some specific points” (https://community.st.com/t5/stm32-mcus-motor-control/loss-of-control-whenever-the-motor-starts-at-some-specific/td-p/143892) and “Motor sometimes starts in wrong direction, because of wrong sign of Iq measured” (https://community.st.com/t5/stm32-mcus-motor-control/motor-sometimes-starts-in-wrong-direction-because-of-wrong-sign/td-p/64553).
Has anyone found a solution? If so, could you please share it with us?
Thanks in advance for your help.
Details:
ST MCW Ver : 6.4.0
STM32CubeIDE Ver : 1.19.0
Driving algorithm : FOC
Control board : Nucleo-G474RE
Power board : STEVAL-IHM023V3
Bridge : X-NUCLEO-IHM09M2
PMSM : 10 pairs
Encoder : Incremental, 1024, without index pin (Ch Z)
Solved! Go to Solution.
2025-10-09 3:40 AM
I have solved the problem. I have added current and RPM limits to the first function involving MC_ProgramPositionCommandMotor1(). In case the current or RPM exceeds their limit values, I call the functions PWMC_SwitchOffPWM(), PWMC_TurnOnLowSides(), and HAL_NVIC_SystemReset(). Code snippet is given below. Note: I have added this code to the TSK_MediumFrequencyTaskM1() function in the mc_tasks_foc.c file (under switch (Mci[M1].State), case RUN).
if ((measuredCurrent >= 5.0f) && (fabs(measuredRPM) > 30.0)) // Project specific variables
{
encAligErrCounter++;
}
if (encAligErrCounter >= 10) // Project specific variable
{
encAlignOk = false; // Project specific variable
PWMC_SwitchOffPWM(pwmcHandle[M1]); /* Required before PWMC_TurnOnLowSides */
PWMC_TurnOnLowSides(pwmcHandle[M1], 0UL); /* Turn on Low side switches */
HAL_Delay(300);
HAL_NVIC_SystemReset();
}
2025-10-09 3:40 AM
I have solved the problem. I have added current and RPM limits to the first function involving MC_ProgramPositionCommandMotor1(). In case the current or RPM exceeds their limit values, I call the functions PWMC_SwitchOffPWM(), PWMC_TurnOnLowSides(), and HAL_NVIC_SystemReset(). Code snippet is given below. Note: I have added this code to the TSK_MediumFrequencyTaskM1() function in the mc_tasks_foc.c file (under switch (Mci[M1].State), case RUN).
if ((measuredCurrent >= 5.0f) && (fabs(measuredRPM) > 30.0)) // Project specific variables
{
encAligErrCounter++;
}
if (encAligErrCounter >= 10) // Project specific variable
{
encAlignOk = false; // Project specific variable
PWMC_SwitchOffPWM(pwmcHandle[M1]); /* Required before PWMC_TurnOnLowSides */
PWMC_TurnOnLowSides(pwmcHandle[M1], 0UL); /* Turn on Low side switches */
HAL_Delay(300);
HAL_NVIC_SystemReset();
}
2025-10-09 6:05 AM
Hello @EDokm,
Thank you for your feedback.