cancel
Showing results for 
Search instead for 
Did you mean: 

MC-SDK position mode follow

MWiel.1
Associate II

Hi,

I want to control a motor in position mode but also want to be able to just move the motor with no given end position.

I have the positioning mode working so far and recently I found out that when calling MC_ProgramPositionCommandMotor1 with a duration of 0 the TC_FollowCommand function call is used. But somehow I can't get it to work. I'M using MC-SDK 6.2.1 on a STM32F746 controller.

Do have to add something to the code to get this working properly?

5 REPLIES 5
GMA
ST Employee

Hello @MWiel.1,

What do you mean by "I can't get it to work"? From my side, it seems to follow trajectory using following code:

 MC_StartMotor1();
 HAL_Delay(3000); //Wait for alignment phase
 MC_ProgramPositionCommandMotor1(-0.5,0);
 HAL_Delay(1000);
 MC_ProgramPositionCommandMotor1(0,0);
 HAL_Delay(1000);
 MC_ProgramPositionCommandMotor1(0.5,0);
 HAL_Delay(1000);
 MC_ProgramPositionCommandMotor1(0,0);
 HAL_Delay(1000);
 MC_StopMotor1();
If you agree with the answer, please accept it by clicking on 'Accept as solution'.
Best regards.
GMA

Maybe I'm also misunderstanding what follow mode is capable of.

What I want to achieve is a continous motion in one direction. I either drive to a certain position in a given time or I drive continously at a maximum speed as long as I keep a button pressed.

 

Below is a sequence I experimented with (MC_StartMotor1() and MC_StopMotor() are handled seperately)

MC_ProgramPositionCommandMotor1(0, 0);
osDelay(0.5 * 1000);
MC_ProgramPositionCommandMotor1(20, 0);
osDelay(0.5 * 1000);
MC_ProgramPositionCommandMotor1(40, 0);
osDelay(0.5 * 1000);
MC_ProgramPositionCommandMotor1(60, 0);
osDelay(0.5 * 1000);

And if I double the values of the target position I hoped for higher RPM which I didn't get.

GMA
ST Employee

Hello @MWiel.1,

You can also use the "Trajectory control mode" is a loop with small duration for a smooth rotation

while(push button == true)
{
MC_ProgramPositionCommandMotor1(0.5*i, 0.1);
HAL_Delay(100);
i++;
}

 

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

I had thought about it and scrapped the idea because using MC_ProgramPositionCommandMotor1() always has to finish before the next function call to it is accepted. That means the motor drives to the position with acceleration, drive with constant speed and deceleration.

I just tested your solution anyway and it was not a smooth rotation but it was choppy because of the continous stop&go and changing the 2nd parameter from 0.1 to 0.2 but keeping the delay at 100ms didn't help either.

You will have the same behavior acceleration/stop with duration equal to zero...
You have to manage the best position steps and duration for your usecase.

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