Setting priority to data store read/write blocks

6 Ansichten (letzte 30 Tage)
Iban
Iban am 26 Mai 2011
Hi everybody,
I have a model in simulink with a lot of data store read/write blocks. I use the data store read/write blocks just not to draw thousands of wires from one port to another.
Some data store writes depend on data store reads, for example it could be something like this:
DataStoreWrite_A = Input1
DataStoreWrite_B = Constant1
DataStoreWrite_C = DataStoreRead_A + DataStoreRead_B
Thats why, I need to set the priority to each DataStoreRead/Write block, in the block properties. In this example, it could be something like:
Priority of DataStoreWrite_A = 1
Priority of DataStoreWrite_B = 1
Priority of DataStoreRead_A = 2
Priority of DataStoreRead_B = 2
Priority of DataStoreWrite_C = 2
assuring that way that blocks DataStoreRead_A and DataStoreRead_B are going to be executed after the memories have been written.
But this way of modeling is giving me some problems when I work with stateflow charts. I have a stateflow chart (priority = 4) with four states and four output function calls (each state outputs a function call (during)). Each function call output activates a function call subsystem, where a DataStoreMemory (called v) is written (DataStoreWrite priority = 4). The function call subsystem itself has no priority assigned, because Matlab ignores it, taking only into account the priority of the stateflow chart.
Outside the function call subsystem, there is a DataStoreRead block (it reads the DataStoreMemory of v), which has priority = 5.
And I don´t understand why, DataStoreRead (which on the same diagram as the stateflow chart, with a priority of 5) is executed before the DataStoreWrite (inside the function call subsystem, with a priority of 4 in the stateflow chart and in the DataStoreWritte block)!!!!!
And, what is more, I have noticed that if I create a subsystem which groups the stateflow chart and the function call subsystems, and I set the priority of that subsystem to 4, the same problem appears on the first step (time 0.0), but in the following steps the program behaves correctly.
Does anybody know the reason of this strange behavior? And furthermore, does anybody know how to solve the problem?
As I said before, I just use the DataStoreRead/Write blocks not to draw thousands of wires, so if there is a simpler way to do that, I would love to hear your suggestions.
Thanks in advance,
Iban

Akzeptierte Antwort

Jarrod Rivituso
Jarrod Rivituso am 26 Mai 2011
A couple general comments for you
- If you really are just using Data Stores to avoid drawing signal lines, you'd probably be better off using Goto and From blocks. That way, Simulink will still take the topography into account when determining the block sorted order.
- When you use function call subsystems where the function call is emitted from a Stateflow chart, Simulink treats the subsystem as part of the Stateflow chart. So, it should update as part of the Stateflow chart
- "Priority", as set in the Block Properties of a block, is a suggestion to Simulink. Simulink can always trump it if it believes the topography of the system requires that one block execute before another
  1 Kommentar
Iban
Iban am 26 Mai 2011
Thank you Jarrod,
I tried with Gotos and Froms and it works perfect for me.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Syntax for States and Transitions finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by