PMSM controller doesn't work

34 vues (au cours des 30 derniers jours)
frank
frank le 14 Juil 2021
Commenté : Joel Van Sickel le 17 Fév 2026 à 14:56
Hi everyone,
I'm trying to implement my own PMSM model after reviewing the numerous examples inlcuded in Simulink and the simulink community. I think I have all the right components and settings, but the motor erratically oscillates for a constant commanded torque and speed.
Below is a plot of the commanded and measured torque. The speed response is just a negative divergence from zero (commanded speed is 1000 rpm or about 100 rad/s).
Can anybody point me in the right direction for debugging?
I've attached two files. Run the .m file first to load all the variables needed for the simulink .slx file. I'm using Simscape electrical components in MATLAB/Simulink 2021a. Note, I use 'M' to symbolize torque to avoid confusion with 'T' for sample periods.
I got my motor parameters from the Emrax 228 (datasheet link).
Thanks!

Réponse acceptée

Joel Van Sickel
Joel Van Sickel le 3 Août 2021
Hello frank,
you don't have your pole pair parameter entered correctly in your machine. Go to where your mechanical parameters are and you will see that you have friction in the spot where pole pairs should be. Your parameters for that entry should read as follows "[J F n_pole M_fric]"
Regards,
Joel
  2 commentaires
frank
frank le 3 Août 2021
Wow! I can't believe it was something that trivial. Thanks Joel!
Any suggestions for my time-related variables, like Ts, T_spdCtrl, and T_vectCtrl? Or my controller gains?
By decreasing the simulation's discrete timestep to 2e-7 s, I greatly reduced the noise in my torque signal. However, I'm curious if I can get away with a shorter timestep or higher gains.
I know this is an open-ended question, so I would appreciate any rules of thumb that Mathworks recommends for discrete simulation of motors.
Thanks,
Farid
frank
frank le 3 Août 2021
Never mind. I got comparable results with Ts = 2e-6 s, T_vectCtrl = 5*Ts s (10e-6 s). Thanks again!

Connectez-vous pour commenter.

Plus de réponses (1)

Juan Antonie
Juan Antonie le 16 Fév 2026 à 16:10
Hi Joel and community,
I'm building on Frank's PMSM model from this thread (A_model.slx / A_config.m) with the EMRAX 228 motor. The original model works perfectly in **Velocity Control mode** — Te tracks the reference, RPM follows the commanded speed, everything is consistent.
I'm now trying to convert it to **Torque Control mode** for a Formula SAE electric vehicle application, and I'm hitting a fundamental issue:
**Symptom:**
- Te (electromagnetic torque) tracks T_ref ≈ 190 Nm **perfectly** (see attached scope)
- RPM ≈ 0 (oscillates between -5 and +0.2 RPM — essentially locked)
- The FOC current loop works flawlessly, but the shaft doesn't rotate
**What I changed from the original model:**
1. FOC CtrlMode: 'Velocity control' → 'Torque control'
2. FOC Input 1: now receives torque_signal (from driving cycle) instead of omega_ref
3. Motor parameters corrected to EMRAX 228 MV: Ld=76µH, Lq=79µH, Rs=7mΩ, ψ_PM=0.0355 Wb, p=10
4. PI gains recalculated using Modulus Optimum: Kp_d=0.2027, Ki_d=18.67, Kp_q=0.2107, Ki_q=18.67
5. Added SHAFT Connection Port (PMIOPort) for future drivetrain connection
6. PMSM.J set to 0 (using external Inertia block J=0.0383 kg·m²)
**What I did NOT change (and I suspect is the problem):**
The original PMSM subsystem has a **Load block** (connected to the mechanical rotational network via Inport Tm). In velocity control mode, this block works fine as part of the control architecture. But in torque control mode, I believe this block may be imposing ω=0 as an algebraic constraint, absorbing all 190 Nm while keeping the shaft locked.
**The dilemma:**
- If I **keep** the Load block → Te=190 Nm perfect tracking, RPM=0 (shaft locked)
- If I **remove** the Load block → RPM becomes chaotic, Te loses tracking entirely
**My questions:**
1. In the original model's PMSM subsystem, is the Load block an Ideal Angular Velocity Source or an Ideal Torque Source? If it's a velocity source with input=0, that would explain ω=0 perfectly.
2. When converting from velocity to torque control, what should replace the Load block to provide proper mechanical loading without constraining velocity? Should I use an Ideal Torque Source with T_load = f(ω) instead?
3. Is there a recommended Simscape architecture for torque-controlled PMSM driving a mechanical load (gear + tire + vehicle body) where the FOC only controls torque and the mechanical dynamics determine speed naturally?
**System details:**
- EMRAX 228 MV CC (surface-mount PMSM, 10 pole pairs)
- Bamocar D3 inverter, Vdc=420V, fsw=8kHz
- FSAE vehicle: 300kg, gear ratio 8:1, wheel radius 0.23m
- Simscape Solver: BackwardEuler local solver @ 2µs, DoFixedCost=on
- MATLAB R2025b
I've attached screenshots of the PMSM subsystem, the Te tracking scope, and the RPM scope.
Thanks for any guidance!
Juan Antonio
  1 commentaire
Joel Van Sickel
Joel Van Sickel le 17 Fév 2026 à 14:56
Can't really comment, this model is not the same model from A_model and is using a different load block. I recommend utilizing a working torque controle example as another starting point:

Connectez-vous pour commenter.

Produits


Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by