How do i count the time the pulse is at 0 state for a square wave in Simulink?

1 回表示 (過去 30 日間)
Tejeshwar Anbazhagan
Tejeshwar Anbazhagan 2015 年 12 月 9 日
回答済み: Arnab Sen 2015 年 12 月 30 日
I have a square wave with 1 and 0 states representing engine on and off correspondingly. I want to count the time in seconds the engine was off meaning i have to count the total amount of time the wave was at 0 state in 1000 second drive time.
Please let me know how to count the total time in 0 state in Simulink??

回答 (1 件)

Arnab Sen
Arnab Sen 2015 年 12 月 30 日
I understand that you would like to get the cumulative time when the engine is off. You can achieve this functionality using 'stateflow chart' and two inbuilt MATLAB commands 'tic' and 'toc'. In 'stateflow chart' it is possible to create DFA and switch from one state to another based on the input.
Refer to the attached sample model 'sf1.slx' for demonstration. I am also attaching the screenshots 'stateflow.pdf' for convenience. For more details about 'stateflow' and 'tic toc', refer to the following links:

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by