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
2025년 5월 28일
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:
Andreas
2025년 6월 2일
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Simulink PLC Coder에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

