My simple simulink model runs too fast

2.4k views Asked by At

I have designed a simple simulink and stateflow diagrams on Matlab. It works perfectly! But I have two issues:

1) The model runs too fast. The transition time between two states are amazingly fast that I can not see. I tried to change some parameters, but I was not succeed. What should I change (maybe on Model Configuration Parameters?) to make it slower so we can see the transitions?

2) Currently I just have a constant input. How can I set a series of constants, probably periodic? I assume there should be a special component. I need, like an input of say 0 at time 0, then 1 after 1 minute, 2 at time 3, etc ?

enter image description here

enter image description here

3

There are 3 answers

2
Manex On BEST ANSWER

1) I had the same issues with some interactive simulations where the CPU would make them run too fast for the user to interact. Using a Simulink Real Time Execution Block brought the solution, despite it gives heavy CPU load due to the solution it uses. With this, if you define a 10sec simulation, that's what it will last. If you don't want to pass through this burden, just lengthen your simulation, or inspect thoroughly the scopes throughout the whole simulation (disabling point limit in the Scope, clicking the Parameters button and then unchecking Data History/Limit data points to last...)

2) Simulink/Sources/Repeating Sequence. You define vectors of times and the value to output in that time. Keep in mind that the block interpolates the values between two points, therefore, if you want to change from 2 to 3 in T=1s, you have to define two points, one U=2 in T=1s and another U=3 in T=1s. For example, 0 in (0..1), 5 in (1..2), 10 in (2..3) and 15 in (3..4):

Time values:   [0 1 1 2 2  3  3  4]
Output values: [0 0 5 5 10 10 15 15]
2
oro777 On

If you just want to check the transitions, you don't need to make it slower. You can try to use the Debug mode available in Stateflow and you can see how your model works step by step.

0
grungetta On

The option to slow down Stateflow animation (so that, for example, you can better see the transitions between states during simulation) is under the Display menu in the Simulink menu bar.

In the latest release (R2014b), the option is under Display->Stateflow Animation (as well as under Simulation->Stateflow Animation). (See here for more details.)

In older releases, it's under Display->Data Display in Simulation->Chart Animation Delay (sec) (although, I'm not 100% sure when this option was moved in the menus).

Note that you have to be inside of the chart for these options to be enabled in the menu.