Skip to main content
Associate
Nov 3, 2026 10:06 PM UTC
Question

STSPIN32G0A2 for application that requires reversing direction

I am experimenting with hall, 6-step sensorless, and FOC. Our application requires periodic spin reversal and fairly quick acceleration. I have been able to tune for smooth acceleration using MCWB but changing direction does not seem to be supported in the Motor Pilot GUI. Can someone point me to sample code or examples that provide this function, GPIO-driven?

3 replies

GMA
ST Technical Moderator
Nov 5, 2026 8:34 AM UTC

Hello ​@cjf,

Field-oriented control (FOC) with Hall sensor mode allows a direction change during operation by using the MC_ProgramSpeedRampMotor1_F() application programming interface (API) with a positive or negative speed value.

It is not the case in 6Step with Hall sensor mode.

If you agree with the answer, please accept it by clicking on 'Best answer'.Best regards.GMA
cjfAuthor
Associate
Nov 10, 2026 10:06 PM UTC

Hello GMA:

Understood. So I tried to play with speed first with a few variations of the code below:

 while (1)
  {
    /* USER CODE END WHILE */
      MC_ProgramSpeedRampMotor1(3000, 5000);
      MC_StartMotor1();
      HAL_Delay(10000);
      MC_StopMotor1();
    /* USER CODE BEGIN 3 */
  }
  /* USER CODE END 3 */
}

 

Start, Stop, and Delay work as expected but so far I cannot change the speed or ramp-up. I looked at MCI_ExecSpeedRamp, drive_parameters.h, revup.h, but none of my changes seem to have any effect on speed or ramp-up time. The motor ramps up, runs at constant speed for the programmed time, and then stops.

Are there any flow charts or docs explaining how the settings get translated from the GUIs, MCWB & Motor Pilot, to code? and where(variables) these values are stored?

Tx.

cjf

GMA
ST Technical Moderator
Nov 12, 2026 8:54 AM UTC

Hello ​@cjf,

Set the required speed.

   MC_ProgramSpeedRampMotor1_F((1500), 1000);
MC_StartMotor1();
HAL_Delay(4000);
MC_ProgramSpeedRampMotor1_F((-1500), 1000);
HAL_Delay(4000);
MC_StopMotor1();

For more details, refer to the Components and Data Structures tabs in the documentation available from Workbench tool > About > Documentations > Documentation.

If you agree with the answer, please accept it by clicking on 'Best answer'.Best regards.GMA