I am building a simulation of Field Oriented Control of a PMSM in Simulink. The goal is to approximate the behaviour of a uController sampling the position of the rotor and the stator currents at 10kHz, and generating SVPWM signals at 10kHz to control a DC/AC converter connected to the motor. The motor parameters are from the PMSM Emrax 228 Medium Voltage (datasheet here). The controller's goal is to control the electromagnetic torque produced by the PMSM.
There is no speed control loop since the input of the controller is directly the torque generated by the motor. Also, the reference current Id is set to zero so that the torque may be directly controlled by Iq (given by
T = 3/2 * #pair_poles * Phi_m * Iq). This is essentially equivalent to MTPA control given that Ld is practcaly equal to Lq for this PMSM.
The problem: The simulation results are complete garbage. The PI loops are unable to control the electromagnetic torque without ridiculous oscillation. As far as I know the FOC algorithm is implemented correctly, and so is the model of the motor. The PI gains may be incorrect, but the controller doesn't even seem to work with a simple P gain. I have tried various times to tune de PI gains with no success. I have also dabbled in changing the Simulink simulation settings (such as decreasing the maximum simulation step time), to no avail.
For the life of me, I can't figure out what is wrong. Why am I seeing these results?
Simulink file here.