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.

The simulation always stops with the compare unit

+2 votes
2,548 views
I run the simulation model and it always remind me as Fig.I. When I change the setting according to the reminder as Fig.II the simulation still stuck there but no reminder shows anymore.
asked Dec 18, 2018 by YuJin (22 points)
edited Dec 18, 2018 by Wolfgang Hammer

1 Answer

+3 votes

The attached simple model demonstrates your problem: Whenever the input signal of the Compare to Constant block crosses zero, the change of the output signal immediately causes the input signal to change its direction and cross the zero line again. And again. And again.

This behavior will bring the simulation to a virtual standstill (notice the small time steps in the scope above). This is why PLECS by default flags an error after 1000 repetitions. You can disable the error message itself (by setting the corresponding parameter to "0"), but this will not solve the actual problem. (As a side note, it is almost never a good idea to simply silence error or warning messages.)

To solve the problem, you must limit the switching frequency of the Compare to Constant block in one way or another. Here are two possibilities:

  1. Add some hysteresis by replacing the Compare to Constant block with a Relay block with suitable upper and lower thresholds (e.g. "1e-6" and "-1e-6").
  2. Set the switching frequency explicitly by inserting a Zero Order Hold with a suitable sample time in front of the Compare to Constant block.
answered Dec 18, 2018 by Wolfgang Hammer (401 points)
...