反復サブシステム実行中の割り込みについて

8 views (last 30 days)
Makoto Nakagawa
Makoto Nakagawa on 10 Jun 2019
Answered: Toshinobu Shintai on 22 Jun 2019
simulink上で
For,Whileを使用し、無限ループ状態とし、
割り込み関数での状態変化を待つ設計は可能でしょうか。
while前後に処理があるため、
whileを時間周期で実行するのは避けたいと考えてます。
int cnt;
/* MAIN*/
int main(void)
{
while(true)
{
if(cnt > 2)
{
break;
}
}
}
/* interrupt */
void interrupt()
{
cnt++;
}

Accepted Answer

Toshinobu Shintai
Toshinobu Shintai on 22 Jun 2019
Simulinkは周期処理を基本とするため、
割り込みなどの非周期処理を設計するのには向いていません。
ただし、出来ないわけではありません。
例えばS-Functionを用いて、clock()によってOSの時間を測定し、
一定時間経過するまで待つ処理をwhileと組み合わせて作成することができます。
もしリアルタイム制御で用いることを想定されていましたら、
無限ループなどの確定的計算時間にならない処理は
可能な限り実装しないようにしてください。

More Answers (0)

Categories

Find more on Simulink in Help Center and File Exchange

Products


Release

R2019a

Community Treasure Hunt

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

Start Hunting!