PID tuning PMSM motor
Show older comments
I am looking for a tool or Simulink project that is already complete where I can enter my motor parameters (and possibly inverter) and do some testing with PID tuning in the case of Field Oriented Control.
I found this: https://it.mathworks.com/help/mcb/gs/tune-pi-controllers-using-foc-autotuner.html?s_eid=PSM_15028 but I don't understand if I can use it only via software without having to buy that motor and inveter.
Again, I am interested in doing PID tuning tests for my motor in the case of FOC, nothing more.
There is a lot of Simulink material online, so I ask for your help since I have little experience with Matlab
Thank you.
Accepted Answer
More Answers (1)
Shivam Gothi
on 29 Jan 2025
0 votes
The model referred by you is for online tuning of motor control parameters. It requires actual motor and inverter setup. As per my understanding, you want a Simulation model for field oriented control of PMSM motor, so that you can simulate the performance of the controllers designed by you, by changing motor or inverter parameters.
In this case, I will recommend the below given shipped examples from motor control blockset:
- Field-Oriented Control of PMSM Using Hall Sensor: https://www.mathworks.com/help/mcb/gs/foc-pmsm-using-hall-sensor-example.html
- Field-Oriented Control of PMSM Using SI Units: https://www.mathworks.com/help/mcb/gs/foc-pmsm-using-si-units.html
- Sensorless Field-Oriented Control of PMSM: https://www.mathworks.com/help/mcb/gs/sensorless-foc-pmsm-smo-fo.html
These model are build using the simulation and codegen variants blocks. That is, the same model can be used to generate the code and deploy on hardware and it can also be used for simulating the plant without involving any hardware.
To run the model in simulation (without the hardware), just press "Run button" as shown below:

You can change the motor and inverter parameters from the MATLAB script, located in the same folder where the simulink model is found. Using that script, you can also replace the default controller parameters with your own designed parameters and simulate its performance.
I hope this answers the question !
3 Comments
LUCA DE BARTOLO
on 29 Jan 2025
LUCA DE BARTOLO
on 29 Jan 2025
Shivam Gothi
on 29 Jan 2025
The examples I suggested do not require microprocessor to run. You can run them as a normal simulation, without any microcontroller/launchpad.
That's why I noted that the Simulink model is using Codegen/simulink variant blocks. It allows you to run standard simulations while also providing the option to generate code if needed.
The microcontroller is not mandatory to run the simulation
Categories
Find more on Real-Time PID Autotuning in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


