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.

About step size

0 votes
i build a model and run it in Plecs (discrete state with 1e-7 step size) it works quite well.

the RT box hat a minimal sample time of 1 micro sec (1e-6),  so i change the plecs parameter to 1e-6, but when i build the model to generate c code, an error occurs (red light on rt box).

then i change the step size to 1e-5, it can be built.

how to build the model in the step size of 1e-6 ?

does anyone meet the same problem?
asked Jan 16, 2019 by yanshaofei333 (56 points)

1 Answer

+2 votes
Best answer

Hi Yanshao,

It is possible that your real-time model needs longer than 1e-6 seconds to execute. Open the "RT Box Web Interface" by clicking on the blue monitor icon button in the “Target” tab of Coder Options dialog (it's next to the “Browse Available RT Boxes”binoculars button). 

You can verify the execution time of your model here under "Processor load" > "current cycle time". Make sure that your "sample time" is larger than the "current cycle time" in the following image.

To see what the RT Box error is, click on the "Diagnostics" tab of the "RT Box Web Interface". The error info should be displayed under "Application Log".

Additionally, you can verify if your "sample step size" is good enough for your model or not by using“Codegen” mode, even before running your model on the RT Box. This means that instead of running the model on PLECS normally, you would run the model using the code generated by the PLECS coder within PLECS. For more details on "Code Generation" please go through pages 251-268 of the PLECS User Manual.

For example, consider the  “Boost_codegen.plecs” example attached. To enable codegen mode, create a subsystem of the model you want to generate the code for, right click and go to Subsystem > Execution settings > check “enable code generation”. Then change the "simulation mode" to "CodeGen". Next, go to Coder > Coder Options and enter the desired sample step size value under "Discretization step size" of your subsystem. Then choose the "Target" as "Generic" and click "Build". This generates ANSI-C code of your model. Now run the simulation and verify if you are satisfied with the "sample step size”. 

For more help, please send an email to


answered Jan 17, 2019 by Manu Parimi (363 points)
edited Jan 24, 2019 by Manu Parimi