PMSM FOC works in offline simulation but not on RT Box

SSZ.plecs (211.1 KB)

Hello,

I am using the Plexim “Sensorless Vector Control of a PMSM” demo model as a reference to implement the FOC of my own PMSM. I have modified the demo model with my motor parameters, switching frequency, controller parameters, and operating conditions.

I have successfully implemented and tested the modified FOC model in PLECS offline simulation, and it is working as expected.

However, when I try to run the same model on the RT Box, it does not work as expected.

I am not sure what I am missing when moving from the offline simulation to the RT Box implementation. The motor and controller parameters have been calculated/tuned for my PMSM, and the required controller blocks have been discretized for real-time implementation. Since I started from the working Plexim demo model and the modified model is also working correctly offline, I expected similar behavior after deploying it to the RT Box.

My main configuration is:

  • PMSM FOC
  • DC-link voltage: 600 V
  • Switching frequency: 6 kHz
  • Pole pairs: 2
  • Rated power: 10 kW
  • Rated mechanical speed: 1500 rpm
  • Current and speed PI controllers adapted for my motor
  • Discrete controller implementation for RT Box

I would like to understand whether there are any additional changes required when moving from the offline model to RT Box, particularly regarding:

  • Plant and controller sample times
  • Fixed-step/discrete implementation
  • PWM configuration and timing
  • RT Box task configuration
  • I/O scaling or delays
  • Any other RT Box-specific settings that may cause the offline and real-time results to differ

I am attaching my modified PLECS model so that the configuration can be checked directly.

I would really appreciate any suggestions about what I may have missed or what I should check to identify why the model works correctly offline but not on the RT Box.

Thank you in advance for your help.

  • Your “En sw” logic is inverted, so your Plant model does not receive any PWM signals (and you didn’t connect the “En sw” signal for offline simulation, so the effect doesn’t show there)
  • The modulation index of your controller saturates, leading to huge stator currents in the plant that finally end up being infinity. The model cannot recover from this condition.