Stateflow time jumps even with fixed time-step
Mostrar comentarios más antiguos
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 comentarios
Abhipsa
el 28 de Mayo de 2025
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
el 2 de Jun. de 2025
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Decision Logic en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

