cancel
Showing results for 
Search instead for 
Did you mean: 

Does the mc_api actually do anything?

gazzatav
Associate III

I'm a complete beginner following the motor control tutorial here:

https://wiki.st.com/stm32mcu/wiki/STM32StepByStep:Getting_started_with_Motor_Control#Managing_the_programming_code_part

It tells me that this code will get my motor running.

 while (1)
  {
	  MC_StartMotor1();
	  HAL_Delay(2000); 
      MC_StopMotor1();
 }

Well I've followed the whole tutorial, creating a project from scratch and I think I can safely say that it doesn't do what it's supposed to do.

I know the program is running as I have an LED flashing under my control each time it goes round the loop but the motor does not move. The motor is known to work. Looking at the api, this function just returns another function in mc_interface:

MCI_StartMotor(MCI_Handle_t *pHandle)

I do not know where this second function is supposed to get the pointer from - the wrapping function doesn't supply it. Perhaps it is initialised somewhere else - to me it looks suspect. Is it worth bothering with this tutorial or should I just get on with using mc_interface and initialise the pointer myself?

For completeness my loop is like this:

  while (1)
  {
	  blink(400, 1, 4);
	  blink(400, 2, 3);
	  blink(400, 3, 2);
	  blink(400, 4, 1);
	  HAL_Delay(1000);
	  MC_StartMotor1();
	  HAL_Delay(2000);
	  MC_StopMotor1();

1 REPLY 1
gazzatav
Associate III

In short, the mci_api yes, this tutorial code, NO!

Don't know why the tutorial claims that this will get the motor running. At the very least one would have to program a speed ramp. Have now watched many MOOC tutorials and understand that there is a lot more to getting a motor running than that trivial code. When I came to this tutorial I had already tried programming a ramp. That had also failed and now I know why. There are many parameters to get right in drive settings. Even then a motor might stall and fault 10 or 20 times and then run fine. In fact you're better of not writing any code until you have an idea of how a particular motor will behave.

So instead of trying to program it, check the data sheet, procure an appropriate serial to USB connector, get the soldering iron out, and connect the usart header on the board (STEVAL-ESC001V1) to the PC. Then build a project with an empty while loop. Now at last you can experiment with the monitor in the motor control workbench and get the motor running in minutes!