Stateflow time jumps even with fixed time-step

I am trying to create a State Machine for machinery which uses a PLC and want to simulate the process using Stateflow.
To experiment with Stateflow I added a state called "ON" with the default transition added to it. When starting the simulation, the simulation time (T) rapidly rises to huge numbers, however I expected it to count upwards every 0.1s as in real time. Is it possible to force Simulink from increasing the time so rapidly and have the time increase like in real time?
I have also added an after(30, sec) transition to a state calle "OFF" and the simulation time immediately jumps to this time step and does not increase T every 0.1s until it reaches 30 seconds. I have attached the Example Stateflow Chart to this post.
Following Simulation Settings are set:
Start Time: 0.0
Stop Time: inf (in order to simulate the endless loop of a PLC)
Model Settings -> Solver -> Fixed-Step, Automatic solver selection, 0.1s step size
Chart Properties -> Update method: Inherited

댓글 수: 2

Abhipsa
Abhipsa 2025년 5월 28일
Hello @Andreas,
As mentioned in the Simulink stop time documentation, the simulation time is not the same as the wall clock time. So, the increment of 0.1sec in simulation time is not the same 0.1s in real-time.
You can refer to the documentation here:
To verify that the time increments by 0.1, you can use the Step Forward option available in the Simulation tab. As illustrated in the figure below, the time correctly advances to T = 0.100, confirming the desired increment.
If you want to achieve real-time increment, you can utilize the Simulation Pacing option present in the Simulation tab.
You can refer to the below MATAB documentation for more information regarding Simulation pacing:
Thanks for the explanation and the desired solution!

댓글을 달려면 로그인하십시오.

 채택된 답변

Epsilon
Epsilon 2025년 5월 28일

0 개 추천

Hi Andreas,
The simulation time can be slowed down using ‘Simulation Pacing’ option to match it with real world wall clock duration. To do so please follow these steps:
  1. Locate the Run button in the Simulate Section in the Simulation tab of the toolstrip.
  2. Click on the drop-down icon below the run button. The select ‘Simulation Pacing’ from the drop-down.
  3. In the dialogue box that appears, tick the check box to enable ‘Enable pacing to slow down simulation’ option.
Please also find these attached screenshots for further reference.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Simulink PLC Coder에 대해 자세히 알아보기

제품

릴리스

R2024b

질문:

2025년 5월 16일

댓글:

2025년 6월 2일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by