Switched PWM model



I’m trying to simulate a Switched PWM model that drives a electric motor Fig1. At 0.1s there is a step position demand and after 1s a force disturbance to the motor. 





The pwm generates currents spikes on the DC bus, but in my results (Fig2 using fixed step integrator) the peaks are really high what is not expected (Fig3). What are the possible problems ?fixedstep.PNG

                                                                                                   Figure 2expected.PNG

                                                                                                   Figure 3

 Another question that I would like to better understand why I get different results when I use fixed step integrator and standard, fig 4 (without peaks after 1s)                                                                                


                                                                                                    Figure 4

Thank you in advance


Re: Switched PWM model

Siemens Valued Contributor Siemens Valued Contributor
Siemens Valued Contributor

Hello RodsMart,



The reason why fixed step and variable step solvers produce different result is often the integration step size. Setting the fixed step solver with a too big integration step will make it unstable, so that it will diverge when the position command changes, or when an external perturbation occurs.


You can have a look at the integration step size used by the variable step solver with the "RSTAT" submodel from "Simulation" library. Place it on the Amesim model and plot the "log 10 current integration step" and "log 10 minimum integration step since last print" variables.







Re: Switched PWM model


Hello OliverS,

thank you for your help!

For the preview result (Fig2)  I set the fixed step in 1e-6. When I set variable step and then plot the log10 I get the following figures. Wich I belive  the steps are in the same order of magnitude but the results are diffents.


Re: Switched PWM model

Siemens Experimenter Siemens Experimenter
Siemens Experimenter

Hello RodsMart,


The unexpected currents spikes on the DC bus might be due to the switching losses modeling:




In the inverter arms parameters, switching loss energies are defined.

Each time a diode or a transistor switches, the switching energy is released at the corresponding thermal port. In the meantime, the same energy is consumed at the DC electrical ports.

With this level of model, the switches are assumed instantaneous. But the switching losses cannot be applied instantaneously (the power would be infinite), so it is spread over a very short period of time, defined by a parameter in the inverter arms:




In the end of the switching energy dissipation spikes, the total amount of energy taken from the DC source is correct but the peak value and the shape of the current is not realistic. You should always filter the current to observe anything meaningful.


Or, if you don't need an accurate estimation of the total energy consumed on DC current and of the heat release by the inverter, you can simply disable the switching energy computation to remove the spikes. With this level of modeling, the switching losses have no impact to the motor voltages and currents.


Concerning the use of the fix step solver:

This kind of high frequency switching model is hard to use with fix step.

Have you consider using the average modeling? See the demo "3-phase PWM inverter with losses estimation" for more details.


If you absolutely need to simulate the high-frequency switching dynamics and to solve it in fix step, I would give the following advices:

  • The integration step must be much shorter than the switching period (1000 or 10000 times shorter).
  • The switching energy dissipation duration must be an exact multiple of integration step.
  • The dead time must be an exact multiple of integration step.


If you still have doubt about your simulation result, feel free to contact your local support.

It would be easier to give you a relevant help if you can share your model and explain your objectives.


Best regards,


Re: Switched PWM model

Thank you for the explanation and the advice!