cancel
Showing results for 
Search instead for 
Did you mean: 

STM32MotorControl project with RTOS (RTX5)

Klemen63
Associate

Are there any examples on how to integrate the project exported from ST MC Workbench, which runs in systick for medium priority tasks and in DMA callback for FOC algorithm, into a custom RTX5 (or any other RTOS - CMSIS RTOS) project?

I have tried moving the MC tasks from systick into a custom timer (tim7 in the example below) and using systick for RTX5 OS. This works to a degree (motor spins, no faults), but it is clear something is interfering with the FOC/HSO algorithm as the motor emits oscillatory noises, indicating regulation is not working as it should.

priorities.png

No MC-related stuff happens in RTX, outside of calling API methods to change, e.g., target motor current.

I am testing right now using https://www.st.com/en/evaluation-tools/steval-lvlp01.html and with https://www.st.com/en/evaluation-tools/b-g473e-zest1s.html, and it operates correctly when the project is exported from ST MC workbench; the problems only arise when integrated with RTOS.

I am looking for guidance on how to troubleshoot this and whether there are any reference designs with RTX5/RTOS for motor control?

1 REPLY 1
faisu887
Visitor

It sounds like a timing/priority issue rather than a functional failure, especially since the motor still spins without faults. FOC control loops are extremely sensitive to interrupt latency and jitter, so moving MC tasks away from SysTick can easily introduce instability if RTX5 scheduling or interrupt priorities interfere with DMA/ADC timing.

You may want to verify that all motor-control interrupts remain at higher priority than the RTOS kernel interrupts and avoid any blocking RTOS calls near the control loop. Unfortunately, ST doesn’t provide many official RTOS + MCSDK reference projects, but several users report better results by keeping the fast FOC path entirely outside the RTOS and only using RTX tasks for UI/communication logic.