Carrier-peak synchronized sampling using the PWM Out block on RT Box

Hello,

I am implementing a PWM control system on an RT Box using the PWM Out block. In my control algorithm, I need to perform a sampling operation exactly at the positive peak of the triangular carrier used by the PWM Out block, once per PWM period.

Is it possible to obtain a trigger or synchronization signal corresponding to the positive peak of the internal PWM carrier?

If the internal carrier signal is not accessible, I could generate a separate triangular waveform in the model and use its peak to generate the sampling trigger. However, how can I ensure that this additional carrier is strictly synchronized with the carrier used internally by the PWM Out block?
In particular, I would like to ensure that:
Both carriers use the same time base and switching period.
Their phases and initial counter states are aligned.
No phase offset or accumulated drift occurs during real-time operation.

Does the PWM Out block provide access to its carrier counter, a synchronization event, or another signal that can be used for carrier-peak sampling? If not, what is the recommended way to implement this on an RT Box?

Thank you!

Hi pimagine,

The PWM Out block provides an ADC Trigger output that can be enabled from the Advanced tab. Here, you can configure the PWM block to trigger the ADC at the minimum, maximum, or both points of the carrier waveform.

See the documentation for details:

The Analog In block can then be configured to accept this trigger signal and perform the ADC Start of Conversion (SOC) on the specified trigger.

See:

By connecting these two ports, you can implement the trigger scheme you described.

I also recommend taking a look at the Multiphase Buck Converter demo model included with the RT Box TSP, which demonstrates this configuration:

Hope this helps!