I created this state machine chart in Simulink using the StateFlow :
There are two states (S1,S2), one of which (S1) has 3 nested parallel FSM , each one has 4 states (SS1, SS2, SS2, SS4) , I put a default state in all of the 3 FSMs (SS1), and in the main two states (default S2).
To test the main FSM (S1,S2) , I used signal builder for all my inputs/events. One of the inputs is a square wave which is a clock event for my main FSM (1 Hz) and the duration of the simulation is 50 sec.
The problem i have is that i can see in the signal builder that i have a square wave, however when i put scope to that clock i see one square wave (extending from 0 to 49.5 second then drops to 0) .
Where is my clock ? what isn't it feeding my FSM properly ?
Here is the FSM:
The orthogonal sub-states are :
in details:
in in between S1 and S2
One of the signal builder , which has the Clock signal is:
The other has the following signals:
The problem is that you are using the default step size with ode3. When using a fixed-step solver the auto
step size is calculated as (StopTime-StartTime)/50
. In your case this gives a step size of 1.
Since at t = 0,1,2,3,...49 the Clock
has a value of 2, that's what you see in the scope.
At t =50 the Clock
has a value of 0, and that's what you're seeing in the scope.
You need to go to the Solver Panel
of the Simulaton->Model Configuration Parameters
pull-down menu.
Then open up the Additional Options
option and change the step size to something smaller, such as 0.01.
Alternatively (depending on your other requirements) you could use a variable step solver.