Showing results for 
Search instead for 
Did you mean: 

STM32F0 speed PID tuning and low speed operation


We are working on parameter tuning for a BLDC motor on a custom board, by using demo board STEVAL-SPIN3201 and Motor Control Workbench (FOC mode). The motor is used to drive a peristaltic pump.

The motor has been measured and measurements have been verified (number of poles, back emf, inductance in both axis [this measurement is hard to perform with tight tolerance], hall sequence, etc...). However, we found that the suggested P and I values for speed regulator are generating high instability (the motor keeps vibrating for more than half the speed range), and we had to change them completely to get consistent results. Still, we are unable to run the motor at low speeds (i.e. below 100 mechanical RPMs). The torque ramp is always smooth (and no load speeds are smooth in torque mode, it looks like the current regulator is working correctly).

We identified the following motor parameters:

  • Rs 0.2 Ohm
  • Ld 0.36mH, Lq 0.18mH
  • Bemf 7.0 V/krpm
  • 5 pole pairs
  • Nominal power 50W
  • Nominal current 6.5A peak
  • Mechanical model computed with Motor Profiler and another supported demo board at no load (instability happens irrespective of load): friction 39uNms, intertia 7uNms2
  • Max speed 2500 rpm

Some additional details:

  • The motor starts spinning at lower speeds when MC_SetIdrefMotor1() is added when the speed is set.
  • We are using Kp of about 200/4 and Ki 80/4, from a default calculated value of 2553/32 and 3550/8192.

Since tuning has proven to be so difficult, we are asking for suggestions here.

  1. Is it possible that computed values for speed regulator might be completely wrong? Or, do you have hints about the reason why the values of P and I coefficients automatically calculated may cause instability?
  2. Even after P and I coefficients has been reduced by hand and the motor is working correctly at higher speeds (i.e. > 200-300RPM), could you help to explain why the motor is vibrating or not moving at all at low speed?
  3. Do you have suggesitons about the cause of the issue and possible steps to verify?

Laurent Ca...
Lead II

Dear @LF.1​ 

Many thanks for your detailed question.

I forward it internally.

Best regards


Laurent Ca...

Associate III

What are the suggestions for this issue? Was it solved and if yes, could the solution be provided to the community?

Best regards

Chris K.


Hello Chris,

unfortunately I got no word from ST. I suppose the parameter computation may be somehow broken in the software version I used and with the operating conditions of motors I had on hand. They seem to be aware of the limitations of their tools (and maybe they are working on that), but information is spread across a number of sources (videos, whitepapers, tool documentation, release notes...). In any case, closed loop stability with motors and FOC algorithms is not trivial.

The values we tweaked do not give fully satisfying results at low speed and high torque (instability, noise and slow torque reaction even on demo board). In addition, the resources of the microcontroller (program memory, RAM, speed and core) are very limited (not building without optimization, sometimes measurements are not fast enough) and there is very limited room to make changes. That's why we are planning to test both MCSDK 6 (to be due in the next months) and maybe STSPIN32G4, or a combination of a standard microcontroller and an external motor driver.

The day where ST will finally understand that software quality, support and documentation has the same importance of (their very good) hardware products perhaps their will outsell their competitors...

Best regards,