cancel
Showing results for 
Search instead for 
Did you mean: 

MCSDK 6.4.0 Bug: Motor Profiler fails with negative Gain

Sergey2Ryb
Visitor

Hello STM32 Motor Control Team,

I have been actively using the MCSDK for about six months, developing custom boards based on STM32F030, STM32F303, and STM32G431 MCUs, always with DRV831x drivers. Despite multiple attempts, I have never been able to successfully run the Motor Profiler until now.

The root cause of the problem is that my hardware setup requires a negative current gain value (due to the use of the DRV8316C driver). While the main MCSDK 6.4.0 FOC library correctly handles this negative gain, the code generated specifically for the Motor Profiler tool does not.

Problem Description

When the Motor Profiler starts (this applies to both the standard profiling process and the Pole Pairs Detection), it ignores the negative gain setting. As a result, the current readings are not inverted, leading to completely incorrect current loop calculations.

The dangerous consequence: The controller consistently applies maximum power to the motor in an attempt to reach the target current, which it never correctly measures. This caused my motor to overheat severely. I have damaged several boards (or triggered my lab power supply's over-current protection) during these attempts. The profiling process always stalled at around 7%.

Root Cause and Workaround

After investigation, I found the exact line of code responsible for this issue.

In the standard FOC code (which works correctly), the current inversion is handled properly:

/* As the Gain is negative, we invert the current read */
Iab.a = -Iab.a;
Iab.b = -Iab.b;

However, in the code generated for the Motor Profiler, the same correction is missing. The profiler code simply assigns the values:

// In the Profiler code:
FOCVars[M1].Iab = Iab; // This is incorrect for negative gain!

Workaround:
I manually modified the profiler code to invert the currents, mimicking the correct FOC behavior:

// Corrected code for the Profiler:
FOCVars[M1].Iab.a = -Iab.a;
FOCVars[M1].Iab.b = -Iab.b;


After this change, the Motor Profiler started working flawlessly for the first time.

Request for Fix

This is a clear bug in the code generation logic for the Motor Profiler when a negative current gain is configured. The tool should automatically apply the same sign correction as the main FOC library.

Could you please forward this issue to the development team for a fix in a future release of MCSDK? This would prevent other users with similar hardware configurations from experiencing motor and hardware damage.

Thank you for your attention and for this otherwise powerful SDK.

0 REPLIES 0