Chart Execution by Using Temporal Logic
2 views (last 30 days)
Show older comments
Paul Anderson on 19 May 2021
Answered: Pavan Guntha on 3 Sep 2021
I have a stateflow chart that needs a timer in one of it's transitions. We typically use the after(n,tick) but a new designer has started using after(n,msec). My main question is if this model is running on target hardware how does the code know when after(n,msec) is complete? Is processor time defined anywhere?
Pavan Guntha on 3 Sep 2021
The generated code for a stateflow chart which has one of the conditions for state transitions as either 'after(n,tick)' or 'after(n,sec)' indicates that in both the cases a counter is implemented to keep track of time. The only thing changes is the condition which depends on how 'sec' and 'tick' are interpretted. The following example illustrates this idea:
Consider the following stateflow chart:
The generated code for this looks as follows:
If the condition in stateflow chart is changed to 'after(n,tick)' format, the generated code looks as follows:
In both the cases, the stepsize is considered to be 0.2 sec. The conditions in the first case considers how many steps of size 0.2 sec are required to complete 1 sec and 2 sec respectively to make a state transition whereas in second case it considers just the number of steps mentioned in the condition itself (that's how 'ticks' are interpretted).
For more information on 'after' command you can have a look at this documentation page.
Hope this helps!
Find more on Syntax for States and Transitions in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!