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!

Thank you for the clarification. I have checked my installed versions:

  • PLECS: 4.9.8
  • RT Box Target Support Package: 3.0.6
  • Hardware: RT Box 1

In my current installation, the standard RT Box Analog In block does not contain a Trigger section, a Trigger source parameter, or the Use PWM trigger port option. I also cannot find the Multiphase Buck Converter model among my locally installed RT Box demos.





Before upgrading anything, could you please confirm whether upgrading the RT Box TSP is strictly required to obtain PWM-triggered Analog In sampling?

All RT Box 1 systems in our laboratory currently use RT Box TSP 3.0.6. The RT Boxes are shared by multiple users, so changing the TSP or the corresponding RT Box firmware may require a coordinated update for everyone and could affect our existing models and experimental setup.

Could you please clarify the following?

  • Is PWM-triggered Analog In sampling available in TSP 3.0.6 through another configuration or implementation?
  • If not, what is the minimum TSP version required?
  • Does upgrading the TSP also require updating the firmware of the RT Box 1?
  • Can TSP 3.0.6 and a newer TSP version coexist on the same computer or be selected separately for different projects?
  • Will models developed with TSP 3.0.6 remain compatible after the upgrade?

This information would help us evaluate the impact before changing the software environment used by the entire laboratory.

Thank you for your help.

Hi pimagine,

Great questions.

The RT Box TSP introduced PWM-triggered Analog In sampling in TSP v3.1. Unfortunately, I am not aware of an alternative approach to perform synchronized sampling in versions prior to this feature being added.

Support for the dynamic ADC triggering scheme was introduced in RT Box TSP v3.1.

You can find the release history for all RT Box TSP versions here:

Yes. The version of the RT Box TSP used to generate the model must match the firmware version running on the RT Box.

Yes, this is possible, although I would not generally recommend it. I highly encourage upgrading to the latest version supported by your license, as newer releases include feature enhancements, bug fixes, and performance improvements.

If you do need to maintain multiple TSP versions for different projects, you can extract each TSP into its own directory and then update the search path in:

PLECS Preferences → Coder Configuration

to point to the desired Target Support Package.

Yes. In general, we strive to maintain backward compatibility so that models created with older TSP versions continue to work with newer releases without requiring significant modifications.

I recommend upgrading both PLECS and the RT Box TSP to the latest versions supported by your license.

Note: RT Box TSP v4.0.7 requires PLECS 5.0 or later. If you prefer to remain on the PLECS 4.9 release, I would at least recommend upgrading to PLECS 4.9.10, which contains the latest bug fixes for that major release. Fortunately, RT Box TSP v3.1 is compatible with PLECS 4.9.

Previous RT Box TSP releases can be downloaded here:

Hope this helps!

Hi ,
Thank you for the detailed reply. We discussed the upgrade internally and have decided to update both PLECS and the RT Box TSP to the latest versions supported by our license. We will update the RT Box firmware at the same time and coordinate the change with the other users in our lab.
We will also test our existing models after the upgrade to confirm that everything still works as expected.
Thanks again for clearing this up.
Best regards.

Let us know if you run into any issues. Best of luck with your work!