Skip to main content
Associate
October 17, 2023
Solved

How to reverse motor direction

  • October 17, 2023
  • 6 replies
  • 4823 views

Hi All,

I have an STM32f302R8 with IHM07M1 with a Bull Runner 2804 motor. This may seem like a simple question but I cannot find any information as to reversing the direction of the motor. In my final project I will need to reverse the direction of the motor on occasion. Does anyone have any information that may help me?

DonCorr

    Best answer by Fred V.

    Hello @DonCorr,
    Are you using the ST Motor Control SDK firmware to spin the motor? If yes, you can use its

    MC_ProgramSpeedRampMotor1() API to set a negative speed reference and the motor will spin in the opposite direction.

    Note however, that you cannot reverse the speed of the motor this way. The sensorless FOC code will lose the control of the motor at low speed. If you want to go from a positive to a negative speed (or vice versa), you'll need to stop the motor when reaching low speed (around 10% of the max speed, but that depends on the load; for this setup, with no or a very light load, one can go down to around 1200 RPM), set a negative (or positive...) speed ramp and then start the motor again (with MC_StartMotor1()). You may also need to tune with the rev-up  parameters to your needs. If you use the ST Motor Control Workbench that comes with the SDK, go to the Sensorless start-up parameters page or the Speed Sensing  Config. panel to configure them.

    Another option would be to play with the open loop mode, switching between closed and open loop when spinning the motor at low speeds. Using the ST Motor Control Workbench that comes with the SDK, you can do that by ticking the Open Loop check box in the Debug Settings section of the Stage Configuration panel (Don't forget to regenerate, rebuild and reload you application in the STM32). But that option may be tricky to use.

    In the hope it'll help.

    6 replies

    SRedd.5
    Senior III
    October 18, 2023

    If you are using FOC then if you give negative IQ the motor will run in reverse direction.

    DonCorrAuthor
    Associate
    October 18, 2023

    I am  using FOC (nice catch) but I have no experience in BLDC motors. Exactly how do I give negative IQ?

    DonCorr

    SRedd.5
    Senior III
    October 18, 2023

    How are you running the motor in the forward direction?

    Fred V.
    Fred V.Best answer
    ST Employee
    October 18, 2023

    Hello @DonCorr,
    Are you using the ST Motor Control SDK firmware to spin the motor? If yes, you can use its

    MC_ProgramSpeedRampMotor1() API to set a negative speed reference and the motor will spin in the opposite direction.

    Note however, that you cannot reverse the speed of the motor this way. The sensorless FOC code will lose the control of the motor at low speed. If you want to go from a positive to a negative speed (or vice versa), you'll need to stop the motor when reaching low speed (around 10% of the max speed, but that depends on the load; for this setup, with no or a very light load, one can go down to around 1200 RPM), set a negative (or positive...) speed ramp and then start the motor again (with MC_StartMotor1()). You may also need to tune with the rev-up  parameters to your needs. If you use the ST Motor Control Workbench that comes with the SDK, go to the Sensorless start-up parameters page or the Speed Sensing  Config. panel to configure them.

    Another option would be to play with the open loop mode, switching between closed and open loop when spinning the motor at low speeds. Using the ST Motor Control Workbench that comes with the SDK, you can do that by ticking the Open Loop check box in the Debug Settings section of the Stage Configuration panel (Don't forget to regenerate, rebuild and reload you application in the STM32). But that option may be tricky to use.

    In the hope it'll help.

    DonCorrAuthor
    Associate
    October 18, 2023

    I am using WorkBench 6.2.0. This information will take me a while to test while I get familiar with the SDK.  It sounds like a promising start. Thanks you.

    DonCorr

    Fred V.
    ST Employee
    October 19, 2023

    You're welcome. Note that the ST Motor Control SDK comes with a set of documentations that will help you get familiar with it.

    Best Regards,

    FredV

    DonCorrAuthor
    Associate
    October 21, 2023

    Thanks for the start Fred. I have the Faulhaber motor merrily rotating along with the Hall effect sensors both clockwise and counter-clockwise.  Thanks again,

    Don,Corr

    MMoha.10
    Associate III
    July 31, 2024

    HI Don, How did you go about reversing the direction.

    It looks like it needs to stop and then reverse the direction. I was hoping to do it instantaneously. I'm using FOC with hall sensors.

    DMeie.2
    Associate III
    July 15, 2025

    @Fred V. 

    What would be the ST recommended algorithm for a directional change when running FOC on hall sensors?
    At the moment, when a direction change request occurrs, I'm stopping the motor with MC_StopMotor1(), then checking if the motor is standing still with MC_GetMecSpeedAverageMotor1() and if that's the case, restarting it in the opposite direction.
    This method yields unsatisfactory results, however. Direction change is slow as this method depends on the motor load/inertia, and the function to determine the average speed seems to be not very accurate at slow speeds, yielding to harsh transitions.

     

    If I'm completely honest, it was quite surprising to see that direction change is not part of the basic API functionality...