2024-09-23 03:02 AM
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?
2024-10-07 05:15 AM
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();
2024-10-07 06:04 AM
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.
2024-10-07 09:11 AM
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++;
}
2024-10-08 03:33 AM
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.
2024-10-15 08:32 AM
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.