1

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

  • Probably expand scale on `Scope` and visualize the graph, also you can decrease the Simulation Stop Time from 1000.0 to say 1 or 2 or even less – P0W Nov 17 '14 at 05:42

3 Answers3

1

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]
Manex
  • 528
  • 4
  • 15
  • 1
    The Stateflow debugger also allows to put a delay in the animation. – am304 Nov 17 '14 at 09:24
  • @Manex Error! Time values should be monolithic; two consequent numbers can not be similar apparently. –  Nov 21 '14 at 17:25
1

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.

oro777
  • 1,110
  • 1
  • 14
  • 29
  • Thanks. Do you happen to know if we can also validate the generated C code aside from the model itself? I need to check reachability; that a specific state (or piece of code) is never reachable. –  Nov 22 '14 at 17:19
  • @ArianaJasmine The way to do this is with [Simulink Design Verifier](http://uk.mathworks.com/products/sldesignverifier/), which will validate the design in Simulink (not the code), and [Polyspace Code Prover](http://uk.mathworks.com/products/polyspace-code-prover/) for the code. Both of these are (expensive) add-on products to Simulink. – am304 Dec 03 '14 at 10:35
0

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.

grungetta
  • 1,089
  • 1
  • 7
  • 8