2021-10-28 12:19 AM
I used motor profiler .Saved the paramters and then while using the examples Imported those paramters.I used following as user code in main.c in while(1):
if( MCI_GetSTMState() == RUN )
{
MCI_ExecSpeedRamp(MCI_EXECSPEEDRAMP,1000,2000);
MCI_StartMotor(MCI_EXECSPEEDRAMP);
}
else;
MCI_StopMotor()
How to start motor with user code in example from MC WB?
Solved! Go to Solution.
2021-10-28 05:39 AM
Ok, So you want to start your motor at power on and stop it after 5 seconds.
Use the API provided in mc_api.h as shown in the exemple below (in your main.c) :
/* USER CODE BEGIN 2 */
MC_ProgramSpeedRampMotor1( (int16_t) (1000/6), 10 ); /* Apply a ramp to reach 1000 RPM in 10 ms - 1000 RPM = 1000/6 0.1 Hz */
MC_StopMotor1(void);
HAL_Delay(5000); /* wait for 5 seconds*/
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
}
/* USER CODE END 3 */
Regards
Cedric
2021-10-28 12:48 AM
Hello @Tejashree
I am not sure I understand what do you want to do.
Could you describe on which events do you want to start and stop your motor.
Regards
Cedric
2021-10-28 12:51 AM
i just imported the example with parameters from motor profiler.Now i just want to run the motor with user code.Example:Run motor at 1000rpm for 5sec
2021-10-28 12:54 AM
I am not able understand the motor_interface.h file properly to use the functions.Can you suggest me how can i run the motor by defining user code?
2021-10-28 05:39 AM
Ok, So you want to start your motor at power on and stop it after 5 seconds.
Use the API provided in mc_api.h as shown in the exemple below (in your main.c) :
/* USER CODE BEGIN 2 */
MC_ProgramSpeedRampMotor1( (int16_t) (1000/6), 10 ); /* Apply a ramp to reach 1000 RPM in 10 ms - 1000 RPM = 1000/6 0.1 Hz */
MC_StopMotor1(void);
HAL_Delay(5000); /* wait for 5 seconds*/
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
}
/* USER CODE END 3 */
Regards
Cedric