cancel
Showing results for 
Search instead for 
Did you mean: 

How to set the value of hFinaltorque?

Vincent7
Associate III

Hello Everybody,

MCSDK:6.3.0

CubeMX: 6.3.0

Workbench : 6.3.0

Motor Pilot : 1.2.9

Power Board : IHM08M1(Rshunt=0.01Ω)

Control Board : NUCLEO-G431RB

Motor : BLDC 26w 24v/8 pole pairs / rpm=4k / rated current=1.8A/hall sensor

I am currently testing torque control, and I am a bit confused about the hFinalTorque setting in the MC_ProgramTorqueRampMotor1 API.

I would like to set the Target Torque to 0.02.

According to the formula provided in the API:
current(digit) = (0.02 * 65536 * 0.01Ω * 5.18) / 3.3 = 20.57 (rounded to 21)

Should hFinalTorque be set to 21 or 210?

Additionally, do I need to manually enable the timer and PWM? (I have already used the Workbench to generate code and CubeMX to generate the project.)

 

9 REPLIES 9
Vincent7
Associate III

Hello Everybody,

When I execute MC_ProgramTorqueRampMotor1(Set_FinalTor, Set_Duration), the motor runs for a few seconds and then shows fault code 32. According to online resources, it is said to be a software issue. However, I only executed the following commands:

MC_ProgramTorqueRampMotor1(Set_FinalTor,Set_Duration);
MC_StopMotor1();

The rest of the code is generated from the project. May I know which direction I should take to debug this issue?

GMA
ST Employee

Hello @Vincent7,

You can use MC_ProgramTorqueRampMotor1_F() that uses a float Ampere format as input parameter.

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

Hello @Vincent7,

I assume that you used MC_StartMotor1() api previously at MC_StopMotor1() call.
Fault code 32 (0x20) means Speed feedback (MC_SPEED_FDBK). Using HALL sensor feature, check that HALL sensor is correctly connected.

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

Hello GMA,

Thank you for your reply.

When I used the API to test torque mode, I first used Motor Pilot to tune the parameters. During the tuning process, I noticed that if the Torque Reference remained at 0 or around < 0.2, the "speed feedback" fault would indeed occur when starting, unless I increased the Torque Reference slightly higher.

Now that I am testing with the API, should I still consider the Torque Reference value set in Motor Pilot?

Hello @Vincent7,

FinalTorque of MC_ProgramTorqueRampMotor1_F() api or Motor Pilot "Torque Ramp/Target Torque" are aligned.

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

Hello GMA,

Thank you for your reply.

I will try increasing the current to test again.

Additionally, do I need to manually enable the timer and PWM? (I have already used the Workbench to generate code and CubeMX to generate the project.)I did not manually enable the timer and PWM, but the motor still rotates.(ven though fault code 32 occurred.)

Vincent7
Associate III

Hello Everybody,

 

The issue with Fault 32 has been resolved.
 
However, another problem remains. When I issue the following commands:
MC_ProgramTorqueRampMotor1_F(0.02,2000);
MC_StartMotor1();
 
The motor runs for only 2 seconds and then stops. There are no fault codes.
 
In the attached image, the Temp_State shows that the motor is still in the "Run" state, but it is not rotating.
Even when I set the duration to 0, the result is the same.
 
With the same settings, when I execute them via Motor Pilot, the motor keeps running as expected.
Could you provide guidance on what could cause the motor to stop after just a brief rotation?motor state.png

Hello @Vincent7,

As mentioned in MC_ProgramTorqueRampMotor1_F() function header: " A torque ramp is a linear change from the current torque reference to the FinalTorque target torque reference".
From boot, "Current Torque" is null. On other cases, the latest Trorque value command will be used. 
Did you previously used another command before "MC_ProgramTorqueRampMotor1_F(0.02,2000);"?

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

Hello GMA,

Thank you for your reply.

 

I issued the following two commands before entering the while loop:
  /* USER CODE BEGIN 2 */
MC_ProgramTorqueRampMotor1_F(0.02,2000);  
HAL_Delay(500); 
  /* USER CODE END 2 */
 
Then, inside the while loop, I modified the value of OL_StartFlag.
When no fault code occurred, I first changed the flag value to 1,
which is why the motor only ran for 2 seconds and then stopped