Skip to main content
Associate
Jun 30, 2025 4:33 AM UTC
Solved

Motor control SDK - manual control API implementation

Hi all,

I am using the STSPIN32G0252Q chip on a custom board (implements 3-shunt current sensing and back-EMF measurement, alongside the required drive features). I have designed the board in the MC Workbench, and have manually profiled the motor I am using, as the motor pilot tool doesn't support the Cortex-M0+ range.

However I am finding it difficult to know where to start with actually implementing the code generated by the workbench/CubeMX; I can see that all of the control functionality is present, but there doesn't seem to be any documentation on how to actually run a motor using just API/HAL calls, instead of using the motor pilot. I have read the SDK documentation, but while this lists all of the functions and control algorithms it doesn't seem to show what a simple implementation loop would look like. Worse still, there seems to be some conflicting information about what each function does (e.g., whether the MC_StartMotor function needs a speed/torque ramp pre-programmed or not).

Does anyone have any tips to point me in the right direction?

Thanks in advance!

This topic has been closed for replies.
Gael A
Gael ABest answer
ST Employee
Jun 30, 2025 9:07 AM UTC

Hello DMorris42,

Could you please tell me which version of the MCSDK you are using ?

Also, I would like to know where the conflicting information is located in the documentation, as I can't seem to find the one you are referring to : 

bool MC_StartMotor1 (void)
 Initiates the start-up procedure for Motor 1.

Extract from MCSDK documentation.

The start-up ramp is already computed by the WB given your system's characteristics, but you can change it in WB or after generation in drive_parameters.h or directly in the RevUpControlM1 handler in mc_config.c.

If you agree with my answer, please consider accepting it by clicking on 'Accept as solution'.

3 replies

Senior III
Jun 30, 2025 6:12 AM UTC

mc_api.c contains all the functions to run the motor in different modes and stop motor, this file is sufficient to drive the motor.

Gael A
Gael ABest answer
ST Employee
Jun 30, 2025 9:07 AM UTC

Hello DMorris42,

Could you please tell me which version of the MCSDK you are using ?

Also, I would like to know where the conflicting information is located in the documentation, as I can't seem to find the one you are referring to : 

bool MC_StartMotor1 (void)
 Initiates the start-up procedure for Motor 1.

Extract from MCSDK documentation.

The start-up ramp is already computed by the WB given your system's characteristics, but you can change it in WB or after generation in drive_parameters.h or directly in the RevUpControlM1 handler in mc_config.c.

If you agree with my answer, please consider accepting it by clicking on 'Accept as solution'.
DMorris42Author
Associate
Jun 30, 2025 11:17 PM UTC

Hi Gael,

I'm using SDK version 6.4.0.

Ah right, it wasn't clear to me that the startup ramp from the WB was pre-programmed for the motor - from reading the documentation it seemed that this needed to be programmed every time, which I found conflicted with the wiki:

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

as this doesn't discuss control profile generation.

Thanks for the input!