Please take a minute to review and accept our Terms of Use.
Welcome to the PLECS User Forum, where you can ask questions and receive answers from other members of the community.

Many technical questions regarding PLECS are answered on the Technical Solutions page of our website. Tutorial videos, specific application examples, and pre-recorded webinars are available on our YouTube page. Please follow us on LinkedIn for the latest Plexim news.

How to get data from PWM out to model

0 votes
Hello !


It is possible to get data from the output from the output of the "PWM output block" to use in the simulation?

For example, my task to test different control algorithms for the converter, and this technics need different control (duty cycle control, phase shift control, duty cycle with variable frequency). As I understand to achieve these technics I must build different modulators and only after that I can get the signal for the switching gates. What you can recommend in this situation (yes, I know about 1 and 3 phase PWM and others block, but this blocks did not provide a possibility to get needed parameters in case of changing phase and frequency on the "fly" )?

Thanks and hope to get an answer
asked Jan 8 by shurikspk (16 points)
Can you clarify your question a bit?

Do you want to do a realtime simulation on an RT Box or an offline simulation in PLECS on a PC?

The "PWM out" block from your screenshot should only be used for realtime simulation on an RT Box. In this case the PWM signals are generated as digital output signals that cannot be fed back into the model directly.

Kind regards,

Oliver Schwartz

1 Answer

0 votes
As I understand it is not possible to use the same block for offline simulation and in simulation on RT box.

How in this case I can check the gates signal without rt box? It can limit the functionality of the system in this case.

For example, in the case of different control methods, I must make the signal for offline simulation based on comparators. After that for the same control, I must build the same control for real-time simulation. Right?
answered Jan 9 by shurikspk (16 points)
No, you can build a model that is suitable for realtime simulation and offline simulation using the same block.

To do this, place the part of the model that should be running in realtime later in a subcircuit. The subcircuit must also include the IO blocks like the PWM out block. When you add the PWM out block to the subcircuit, you can access the resulting PWM signals at the outside of the subcircuit in an offline simulation.

If you want to run the subcircuit on the RT Box you need to enable code generation for it. Right-click on the subcircuit and open the "Execution settings" dialog. After selecting "Enable code generation" the subcircuit will appear in the list of coder systems in the "Coder options" dialog.
Sorry, can you explain in more detail how I can get access to the PWM out signal from the subcircuit ?
Once you add the PWM out block to the subcircuit, a new terminal named "PWM Out" will appear on the subcircuit.
Thanks for helping, now with simulation offline and online all good.

But I have one additional question about PWM out block. How I can set the output to the 1 of out of this block(I mean switch must be continuously on). I am trying to set the duty input to the 1 and expected that the out must be 1(in simulation all good, but on a real output of the RT box this out is equal 0  ).

How to fix this issue?
Please send your model to so I can take a look.