I am using a script to perform a parameter sweep. However, when I set a very small phase delay for the pulse generator, such as -2.775557576e-22, the pulse generator stops after outputting a single pulse, as shown in the figure. When I increase the absolute value of phase delay slightly, for example to -2.775557576e-21, the pulses are output normally. This phenomenon also occurs when manually setting the simulation parameters. I think this might be a hidden bug.
Normally, it should look like this:
These are my simulation settings:
Can you share what version of PLECS you are using? Are you using Blockset or Standalone? When recreating the problematic issue I receive an error message.
Relating to simulation you may want to review the concept of Machine Epsilon. Floating point representation places a hard limit on numerical precision. For a 64-bit double (as used by PLECS), the smallest representable difference depends on the magnitude of the number in question. For a switching period of 1e-4 seconds (10 kHz), this limit is eps(1e-4) = 2^-66 ≈ 1.355e-20 seconds — already 2 orders of magnitude larger than your requested phase shift of 2e-22. This value is indistinguishable from zero in double-precision arithmetic, so the pulse would behave identically to one with no phase shift at all. (or generate the error I observed in my simulation).
I’ll also note that this extremely small phase shift is likely impractical to realize with a real controller without specialized hardware. Let’s imagine you have a 1 Terahertz PWM clock for your 10 kHz PWM. The smallest achieivable phase shift is still 1e-12, which is a more “reasonable” minimum value.
I am using Blockset, version 5.0.2.
The occurrence of these very small floating-point numbers is primarily due to calculations performed by scripts based on formulas, resulting from floating-point computation errors. Although these errors are negligible for circuit analysis, they seem to have caused unexpected issues. Therefore, I have to handle them through additional steps in the script.