Skip to main content
Associate II
October 1, 2026
Solved

Position Control PID Inner Loop Tuning

I am reading through AN5464 and UM1052 looking through the PID tuning sections.
https://www.st.com/resource/en/application_note/an5464-position-control-of-a-threephase-permanent-magnet-motor-using-xcubemcsdk-or-xcubemcsdkful-stmicroelectronics.pdf

https://www.st.com/resource/en/user_manual/um1052-stm32f-pmsm-singledual-foc-sdk-v43-stmicroelectronics.pdf

Typically one would tune the inner loop PI for Torque and Flux then go onto tune the outer loop position PID. The calculated position control PID parameters for the project by default are completely unstable. I am looking for any documentation around the recommended method of tuning the inner loops as in both the Flux and Torque PI parameters. Is there anything along these lines available?

joshuaaustinBest answer
Explorer II
October 15, 2026

I agree with the approach you described. Tune from the inside out, in this order:

  1. Torque and flux current loops first. Use a speed or torque control project. The starting gains come from the motor’s resistance and inductance, so check that the motor parameters in the workbench are accurate. Wrong R and L values are a common reason the default gains come out unstable.
  2. Test with step responses. Command a small step in Iq (torque current) with Id at 0, keeping the current limit low and the motor lightly loaded or free to spin. Watch the response and adjust Kp for rise time and Ki to remove steady-state error. Stop if it oscillates or overshoots badly.
  3. Keep the loops in order of speed. The current loop should be much faster than the speed loop, and the speed loop faster than the position loop. If an outer loop is too fast, the system becomes unstable.
  4. Then tune the position PID. Once the inner loops are stable, follow the AN5464 procedure, starting with low gains and increasing them gradually.

5 replies

GMA
ST Technical Moderator
October 6, 2026

Hello ​@Vasalic,

Refer to the “5.9 PID tuning” chapter of the AN5464 Application note.

If you agree with the answer, please accept it by clicking on 'Best answer'.Best regards.GMA
VasalicAuthor
Associate II
October 6, 2026

I have already read through this note. I am asking for further clarifications as this note does not cover the steps involved in tuning the inner loops. I believe one should most likely create a Speed Control project and tune the Torque and Flux loops first. Then subsequently with the Torque and Flux loops tuned one would then follow AN5464 and tune the Position PID.

GMA
ST Technical Moderator
October 15, 2026

Hello ​@Vasalic,

Inner-loop torque and flux current proportional-integral (PI) tuning is done by first generating a speed/torque control mode project.
MOOC - Motor Control Part 3 : Troubleshooting and fine tuning is available (based on MCDSK5.x version).

If you agree with the answer, please accept it by clicking on 'Best answer'.Best regards.GMA
joshuaaustinBest answer
Explorer II
October 15, 2026

I agree with the approach you described. Tune from the inside out, in this order:

  1. Torque and flux current loops first. Use a speed or torque control project. The starting gains come from the motor’s resistance and inductance, so check that the motor parameters in the workbench are accurate. Wrong R and L values are a common reason the default gains come out unstable.
  2. Test with step responses. Command a small step in Iq (torque current) with Id at 0, keeping the current limit low and the motor lightly loaded or free to spin. Watch the response and adjust Kp for rise time and Ki to remove steady-state error. Stop if it oscillates or overshoots badly.
  3. Keep the loops in order of speed. The current loop should be much faster than the speed loop, and the speed loop faster than the position loop. If an outer loop is too fast, the system becomes unstable.
  4. Then tune the position PID. Once the inner loops are stable, follow the AN5464 procedure, starting with low gains and increasing them gradually.
VasalicAuthor
Associate II
October 15, 2026

Thank you that sounds reasonable. I’m not too sure why this is not documented anywhere by ST themselves.