Hello Mr. Schwartz,

thanks for replying on my problem.

I kinda understand what you are trying to tell me. But in my case, a C-Script for modelling the SHE-modulator would be kinda advantageous. The goal is to implement a SHE-modulator which can operate with a different number of switching angles (e.g. 3, 5, 7, 9, 11, 13, 15, 17, … 33) as a function of the fundamental frequency.

As I understood right, there are different ideas to get this working with a C-Script to avoid sampling-related issues. Either I can add Zero Crossing Signals to tell the Script when to execute or using macros like “IsMajorStep”. I’ve already tried some ideas, but I don’t really know how to get this working with it.

The reason why we decide to use a C-Script for this is, having one Script for all possible switching angle number cases. I’ve wanted to give the switching angles as a variable (dependent on the fundamental) vectorized input into the Script, which creates the switching signals for all cases the same way.

Without using the Script it’s also kinda elaborate or even in German a “barrel without a bottom”. In my mind there is only one way to implement it using vectors/arrays for the switching angles and compare the vectorized signal (multiplexed signal) with the reference signal. And at the end, demultiplex it and create the switching signal by adding all enclosed parts.

Anyway, I upload my .m-file for calculating the switching angles in the case of 3 switching angles and the simulink/plecs-file.

I hope you can understand what I want to achieve, it’s kinda hard to describe. And I hope we can find a solution for it. I would be also up for talking on the telephone.

PS: The sampling problem is pretty random. For the first few tries it worked like we wanted. But for example, after adding death-time correction, it showed the problem with the script. The uploaded file just shows it in T3 at the first edge. Adding more correction in the angles means more problems with sampling. And please don’t wonder, just phase R is implemented with the Script, Phase S and T is implemented with simple PLECS-blocks (sum, compare, …).