Enable block vs atomic block

2 visualizzazioni (ultimi 30 giorni)
alessandro mutasci
alessandro mutasci il 20 Ott 2022
Modificato: Fangjun Jiang il 21 Ott 2022
Good evening,I have a doubt regarding how the enable block and atomic block interact with each other. I'm attaching a small project to let you understand better my problem. I have a clock that enable a subsystem after 9 seconds, image: systemLevel0.png. When the block is enabled, an atomic subsystem with a period of 4 seconds, starts a recursive sum, image: systemLevel1.png, image: systemLevel2.png.
My problem, is that the first sum is at 12 seconds and not as I thought at 13 seconds; it doesn't start when the block is enabled. Could you give me an insight regarding how to solve this problem without using a trigger. In order to have a easier code generation?

Risposte (1)

Fangjun Jiang
Fangjun Jiang il 21 Ott 2022
Modificato: Fangjun Jiang il 21 Ott 2022
The atomic subsystem is executed at 4s, 8s, 12s, etc. if enabled.
It is not "after it is enabled (regard this as time 0), then execut at time after 4s, 8s, 12s, etc" as you probably imagined.
Change the threshold value for enable flag to be 1,2,3 and see the effect.
To get what you want, you need to have some time related blocks inside the enabled subsystem. For example, a Pulse generator with period of 4 and pulse width 25%, to enable the atomic subsystem. You will get the desired output, once you set the threshold value to be 13 seconds.

Categorie

Scopri di più su Schedule Model Components in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by