How to use Arduino built in millis() function inside statechart? or other timer function...

4 ビュー (過去 30 日間)
Tim Darrah
Tim Darrah 2018 年 4 月 13 日
回答済み: Madhu Govindarajan 2018 年 4 月 17 日
How can this be accomplished? I have tried by declaring t1 in the state chart as a double initialized to 0, then in the custom code section i write "arduinoTest_DW.t1 = millis();" (arduinoTest is the name of my project) and this compiles and deploys, but in my statechart my transitions are based on elapsed time, and i cannot use millis() - t1 = elapsedTime inside the statechart.
If there is another way to accomplish this please help!! Project is due next week and this is my only hang up!

回答 (1 件)

Madhu Govindarajan
Madhu Govindarajan 2018 年 4 月 17 日
According to this page - https://www.mathworks.com/help/stateflow/ug/using-temporal-logic-in-state-actions-and-transitions.html
temporalCount(msec) gives you the elapsed time in milli seconds in each state. This looks like the equivalent to millis.
If this does not resolve your issue, could you share the big picture of what you are trying to achieve and this way stateflow experts here can give you a better alternative.

カテゴリ

Help Center および File ExchangeStateflow についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by