Stateflow time jumps even with fixed time-step

7 Ansichten (letzte 30 Tage)
Andreas
Andreas am 16 Mai 2025
Kommentiert: Andreas am 2 Jun. 2025
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 Kommentare
Abhipsa
Abhipsa am 28 Mai 2025
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:
Andreas
Andreas am 2 Jun. 2025
Thanks for the explanation and the desired solution!

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Epsilon
Epsilon am 28 Mai 2025
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.

Weitere Antworten (0)

Kategorien

Mehr zu Decision Logic finden Sie in Help Center und File Exchange

Produkte


Version

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by