Please take a minute to review and accept our Terms of Use.
Welcome to the PLECS User Forum, where you can ask questions and receive answers from other members of the community.

Many technical questions regarding PLECS are answered on the Technical Solutions page of our website. Tutorial videos, specific application examples, and pre-recorded webinars are available on our YouTube page. Please follow us on LinkedIn for the latest Plexim news.

Differences between simulation on PLECS and RTBox

0 votes


I am using the RT-Box to run a Voltage Source Converter and I am noticing some differences between the simulation from PLECS and the RT-Box.

I am running the same model (Converter + controller) in both, PLECS and RT-Box. I am using the same time step for both cases. However, I see some differences in the obtained waveforms:

Grid Currents from PLECS simulation:

Phase currents from PLECS simulation

Grid Currents from RT-Box simulation:

Grid currents from RT-Box simulation

When implementing the model in the RT-Box, the currents seem to be distorted. Moreover, if I use an external microcontroller to implement the controller and the PWM generation, the currents look okay.  I believe there is some kind of issue with the controller implementation or PWM generation when using the RT-Box.

Do you have any suggestions to improve this?




asked Feb 24, 2022 by fdegioanni (30 points)

Can you please post a model showing how the RT Box based controller is implemented?  If you would not like to share your model publicly, then please reach out to

I'm also interpreting your situation as a) offline simulations in PLECS show the expected response b) behavior is correct for external MCU based controller connected to the RT Box and c) when modeling both the controller and plant in the RT Box, the result is distorted.  Is that accurate?



Hi Bryan,

Thanks for getting back. 

Yes, what you mentioned (a,b and c) are correct. 

This is the way I was implementing the controller (for both PLECS and RT-Box):

I have tried with different configurations for the PI (including discretization methods); but all of them show similar results as shown above. 







1 Answer

0 votes
Best answer

Hi Franco,

Based on the screenshot you shared above, the issue is the PWM generator with the carrier-compare logic in the model. In this case the PWM carrier signal is limited by the model step size of the of the RT Box.  The result is low PWM resolution and the current waveforms you're observing.

This scenario is described in a tutorial on the Plexim website: "RT Box: From Offline to Real-Time".  I copied (and slightly modified) the relevant text below:

The reason is that the “Modulator” subsystem has the carrier-compare logic inside the model and is resolved within the window of the model step size (e.g. 5 µs), which is too little time considering the switching frequency.

To resolve the PWM gating signal with adequate accuracy, the solution is to use the PWM Out block to physically generate the PWM signal on the digital out port of the RT Box, connect the digital out and digital in ports together using a D-Sub 37 pin cable, then capture the physical PWM signals back into the box using the PWM Capture block. With this approach, the gating signal is generated and sampled with a resolution of 7.5 ns, and sub-cycle averaged over the model step size.

Please let me know if this helps.



answered Mar 1, 2022 by Bryan Lieblick (1,995 points)
selected Mar 1, 2022 by fdegioanni
Oh, I see. Yes, that's the right problem.

I didn't find that tutorial before. Thanks for sharing!