Stateflow different timesteps for an embedded application
1 view (last 30 days)
Show older comments
I am new to Stateflow and need more information on timesteps.
My system wakes up every second to run the state chart ( rt_OneStep() ) yet some state chart transitions rely on waiting a number of milliseconds before taking a transition. This all occurs before going back to sleep. The exectution time of the state machine, most of the time, would be less than a millisecond....not that this matters.
So basically, rt_OneStep() is called every second yet I have transitions that use after(10, milliseconds)...how do I implement the millisecond part since my timestep is 1 second?
Thanks
0 Comments
Answers (1)
Jeevan Thomas
on 7 Nov 2013
It appears that you already have a model from which you generated code and trying to run it on a platform by attaching rt_OneStep() to give the base tick (similar to sample time configured in Simulink configuration parameters. All functions that map to your implementation in Simulink model is called from rt_OneStep() [including the one from Stateflow]. So it is not possible to call your rt_OneStep() every second and do switching of transitions in Statechart (since this is part of the same model) unless you make the statechart as an standalone function and call it individually from your ISR scheduler. But in this case, be ready to compromise on functionality between MiL and PiL.
Else the only option is to bring down the sampling time to milliseconds as in your requirement.
See Also
Categories
Find more on Simulink Functions in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!