1
votes

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) .

enter image description here

Where is my clock ? what isn't it feeding my FSM properly ?

Here is the FSM:

enter image description here

The orthogonal sub-states are :

enter image description here

in details:

enter image description here

in in between S1 and S2

enter image description here

One of the signal builder , which has the Clock signal is:

enter image description here

The other has the following signals:

enter image description here

1
What Solver are you using, and what step size is being used? Also, why do you define your Clock as going from 0->2 then convert it to boolean (which inherently is 0->1)?Phil Goddard
solver is ode3. Regarding the clock, I suppose you have to use the converter so that they are boolean since I defined the three events clock and two other "rising edge" inputs. I am not sure if they have to be boolean. The 0-2 that's something created by simulink , im not sure why either...i put the amplitude of 1 of a 50Hz square waveSam Gomari

1 Answers

2
votes

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.