PID tuning PMSM motor

13 visualizzazioni (ultimi 30 giorni)
LUCA DE BARTOLO
LUCA DE BARTOLO il 28 Gen 2025
Commentato: Shivam Gothi il 30 Gen 2025
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.

Risposta accettata

Shivam Gothi
Shivam Gothi il 29 Gen 2025
I analysed both the models as attached by you in the comments. I found the following differences:
  • Model1 uses gain scheduling mechanism to change the gains of PI controller, as the speed varies from zero to its rated vaue. Model2 uses constant gain PI controllers
  • Model1 is meant only for simulation purposes. You cannot deploy it on embedded targets. Whereas, model2 has simulink/codegen variant blocks that are capable of generating code to be deployed on embedded targets.
  • In Model2, a sensorless observer is employed to estimate the rotor's position, eliminating the need for an encoder. Conversely, Model1 takes a different approach: the "motor position" output from the "Surface Mount PMSM" block is initially converted into Quadrature Encoder Pulse (QEP) signals, which are then used to estimate both speed and position.
From what I understand, you've developed your own controllers and are looking to evaluate their performance using a Simulink model. You plan to adjust the controller parameters to observe how these changes affect the output. Your goal is to fine-tune the parameters until the desired response is achieved.
Please correct me if I understood it incorrectly.
Based on the above understanding, I can suggest the following:
For you purpose, It is better to go with Model1, as you want only the simulation model. But, you can remove the gain scheduling algorithm and replace them with constant gains (which you have calculated for your controller). This will help you to test the performance of the PI controller designed by you.
I hope it helps !
  6 Commenti
Shivam Gothi
Shivam Gothi il 30 Gen 2025
Yes ! You interpreted the below statement correctly.
"remove the gain scheduling algorithm and replace them with constant gains":
Shivam Gothi
Shivam Gothi il 30 Gen 2025
The procedure followed by you is correct. Actually, I will recommend you to copy the entire folder "slcontrol" at the below given location instead of placing it at desktop.
C:\Users\lucad\Documents\MATLAB\Examples
Note one important point:
Change the current working directory of MATLAB to the path: C:\Users\lucad\Documents\MATLAB\Examples\slcontrol\TuneGainScheduledControllerForPMSMUsingPIDAutotunerExample
In this way, your original model will be at :
C:\Users\lucad\Documents\MATLAB\Examples\R2023b\slcontrol
and the modified model will be at:
C:\Users\lucad\Documents\MATLAB\Examples
IMPORTANT: Make sure to set the current working directory in MATLAB to the folder containing the project you wish to work on.
For an example, if you want to run the original model, change the current working directory of MATLAB to:
C:\Users\lucad\Documents\MATLAB\Examples\R2023b\slcontrol\TuneGainScheduledControllerForPMSMUsingPIDAutotunerExample
if you want to work at your own model, change the current working directory of MATLAB to:
C:\Users\lucad\Documents\MATLAB\Examples\slcontrol\TuneGainScheduledControllerForPMSMUsingPIDAutotunerExample
Feel free to reply back if you face any difficulty in following this approach !

Accedi per commentare.

Più risposte (1)

Shivam Gothi
Shivam Gothi il 29 Gen 2025
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:
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 Commenti
LUCA DE BARTOLO
LUCA DE BARTOLO il 29 Gen 2025
Another thing, I don't want the simulink to generate embeeded code, I just want a PID simulation depending on the engine etc..
In the examples you sent me it is always required to microrpocessor TI etc.
Shivam Gothi
Shivam Gothi il 29 Gen 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

Accedi per commentare.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by