Plecs Ti PWM Block Limitation

Hello, I am a graduate student working on a CSI simulation for my thesis. I’m trying to implement space-vector PWM for a three-phase current-source inverter using PLECS Coder with a TI C2000 target, and I have run into a limitation with the current C2000 PWM block. The switching sequence (I0->I1->I2->I2->I1->I0) I’m trying to implement requires some individual switch waveforms to have two distinct switching boundaries during the up-count portion of the center-aligned PWM period.

Using SW6 as an example, the desired timing is: CMPA = T0/2 and CMPB = (T0 + T1)/2. The required AQ behavior for the same physical PWM output is essentially:

CAU @ CMPA → SET

CBU @ CMPB → CLEAR

CBD @ CMPB → SET

CAD @ CMPA → CLEAR

The C2000 ePWM peripheral itself appears capable of allowing both CMPA- and CMPB-based Action Qualifier events to act on the same ePWM output. The difficulty is with the current PLECS PWM block interface. In single-output mode, the block exposes only one modulation/compare input, so I cannot specify both required compare locations. In dual-output mode, I can provide separate A and B inputs corresponding to CMPA and CMPB, which initially seemed like the correct solution. However, the block separates the corresponding Action Qualifier behavior between PWM A and PWM B. What I need instead is for both CMPA and CMPB events to control the same PWM A output.

Would it be possible to provide a modified C2000 PWM block that supports:

  • separate CMPA and CMPB inputs for each ePWM module;
  • CAU/CAD and CBU/CBD events all acting on the same AQCTLA/PWM A output;
  • variable AQ configuration, similar to the current Variable AQ mode;
  • center-aligned/up-down counting; and
  • one physical PWM output per inverter switch?

If there is already another PLECS block, target-support feature, custom block, Native Code approach, or recommended implementation method that can accomplish this without manually modifying the generated project in CCS, I would also be very interested in that solution.

You have correctly diagnosed the issue - the blocks as configured do not allow for independent action qualifier configuration for CMPA and CMPB for a single PWM channel. See this similar topic for more information. A native resolution to this would require an update to the TSP.

The issue with the other approaches you identified is that they break the convention of the offline simulation matching the behavior of the code on the target. If that’s important to you perhaps you could add some external logic with the generated PWM signals to get the desired behavior in the offline model.

With that said I can send you something via direct message.