Setting priority to data store read/write blocks
조회 수: 13 (최근 30일)
이전 댓글 표시
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
댓글 수: 0
채택된 답변
Jarrod Rivituso
2011년 5월 26일
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
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Stateflow Charts에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!