Info

この質問は閉じられています。 編集または回答するには再度開いてください。

Custom sensor library: Execute setup block before others

1 回表示 (過去 30 日間)
offroad
offroad 2017 年 11 月 14 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
Hello,
I am implementing a Simulink library for communication with an external sensor. I split the configuration of the sensor and the reading of sensor values in separate blocks. When running a model with a "configuration" and a "read value" block the second one must only be executed after the first one has finished. How is this best implemented?
Currently I ensure this with a function-call generator and splitter that is connected in the right order to function-call subsystems containing the "configuration" and "read value" blocks. But this setup is rather clumsy and does not correspond to many existing libraries. The option by sorted execution order seems to be model-dependent and thus does not apply to a library.
Thank you for helping!
  1 件のコメント
offroad
offroad 2017 年 11 月 28 日
I would like to push this one as it only got 2 views.

回答 (1 件)

Mark McBroom
Mark McBroom 2017 年 11 月 29 日
do you need to execute the configuration block each time "read value" block executes? If so, I use function -call trigger and then combine blocks into a single block in your library.
However, if the configure block runs only one time at startup, you might want to consider the new Initialize Function block in Simulink. The contents of the Initialize Function block get executed only one time at start up.
  1 件のコメント
offroad
offroad 2017 年 11 月 30 日
Thanks for your answer. No the configuration block needs to be executed once at startup. I tried using the Initialize Function block. However it can only contain blocks that do not need an initialization themselves. The I2C driver blocks I use do not work with that method.
Basically I just need a way to execute the configuration block in the first time step and in the following time steps always execute the read block. Is there some way we could use a global variable in the model workspace to contain the "configuration state"? Then we could set this state as "true" once the configuration block has finished and depending on its state execute the read block.

この質問は閉じられています。

製品

Community Treasure Hunt

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

Start Hunting!

Translated by