Skip to main content
Associate
October 11, 2023
Solved

problem in STM32Cubeide

  • October 11, 2023
  • 1 reply
  • 2292 views

Hello,

Im new to this and im stuck on 2 things i generated a code from the motorcontrol workbench and im using a Nucleo 64 f030R8 with a IHM07M1A BLDC Motor controller. i can start the motor and control speed. 

1st question : where can i change direction because the motor is rotating always the same direction CCW and i also want the motor to turn CW.

2nd question : i needed to insert the motor parameters in the workbench but cant find these back in the IDE software maybe someone knows where to find this.

Thank you in advance for your assistance. I look forward to receiving your response.

This topic has been closed for replies.
Best answer by SRedd.5

One mistake i found is uint16_t speed = -1000; this is unsigned value and you are assigning negative value. 

You can modify the code as below 

if (MC_GetImposedDirectionMotor1 == 1)

{

MC_StopMotor1();

HAL_Delay(500);

output_speed = RPM_2_SPEED_UNIT(1000);

}

else if (MC_GetImposedDirectionMotor1 == -1){

MC_StopMotor1();

HAL_Delay(500);

output_speed = RPM_2_SPEED_UNIT(-1000);

}

MC_ProgramSpeedRampMotor1(output_speed, 100);

you have to ensure the value of output_speed will be positive in one direction and negative in other direction.

 

 

 

1 reply

Gael A
ST Employee
October 27, 2023

Hello StanPeeters,

You can change motor direction by using the MC_ProgramSpeedRampMotor1(int16_t hFinalSpeed, uint16_t hDurationms) function located in mc_api.c. You just need to enter a negative speed. However be aware that changing motor direction in sensorless cannot be done while running : you need to stop your motor first.
Moreover, have you checked the MotorPilot tool provided with the MCSDK package ? It allows you to manually set speed through its GUI as well as many other parameters.

Concerning the motor parameters, they are located in the pmsm_motor_parameters.h file. As it is a header file, it may be the reason you have trouble finding it. In CubeIDE, when looking at your Project Explorer, go to Includes -> C:/PROJECT_PATH/Inc to find it.

If you agree with my answer, please consider accepting it by clicking on 'Accept as solution'.Hope this will help,Gaël A.
SRedd.5
Senior III
October 27, 2023

However be aware that changing motor direction in sensorless cannot be done while running : you need to stop your motor first.

Just a small clarification if this is mandatory, can it be handled as part of the API itself without the user taking care of it?