Hello together,

I've implemented a Selective-Harmonic-Elimination PWM-Pulsgeneration within a C-Script Block in PLECS.

A piece of the source code is listed below:

The switching times (angles) are precalculated and compared with a running variable which is synchronized with the electrical angle (theta). Is theta greater or equal than the switching angle, the Transistor T3 (in this example) needs to be turned off (0).

With continuous sampling (Sample time: 0), I get this switching signal for T3:

The red line is what it should look like... The sampling points are at both edges of the green line and is obviously linearly interpolated between both sampling points.

If I change the sampling from continuous to discrete times, the problem gets smaller (and the compute time gets bigger) but is not really satisfactory. This just feels like a problem with the sampling settings.

If you need more information regarding this, please let me know.

Your help would be greatly appreciated.

Thomas