"From Workspace" time delay

Hello community, I have a tricky problem with the "From workspace" block.
I want the output of my Block A to be written to workspace (which works fine) and then be red by a "from workspace" block for beeing processed by block B.
My problem is now to make sure, that the "from workspace" block reads the variable AFTER block A has written down the information to the workspace.
In my case I have a 2-block demo for getting along with this issue. My aim is to build up a simulation with about a hundered of timedepending blocks, connected through to-and-from-workspace blocks.
The reason for using the workspace is that I can't say which output belongs to which input. This will be assigned by a m-File at the beginning of the simulation.
Edit: here is an screenshot, which shows the use of priority: http://img825.imageshack.us/i/screenshotbs.jpg/ As you see, the display on the right should show "0" instead of "1" (which was my former test value). This shows, that the "From workspace" block is beeing handled before the "to workspace" block. In this case there's another problem: When I start my simulation the first time, I get an exception, that the variable "simin" does not yet exist. If the order of priority would have been handled correctly, this problem may have not been occure...
It would be nice, if someone can give me a hint onto this topic.
Greets, Tobias

 採用された回答

Martijn
Martijn 2011 年 2 月 2 日

0 投票

If you right-click a block and select "Block Properties..." you can enter a Priority which influences the order in which blocks are executed. More about block priorities can be found in the documentation:
http://www.mathworks.com/help/releases/R2010b/toolbox/simulink/ug/f13-91940.html#f13-91958

3 件のコメント

Tobias
Tobias 2011 年 2 月 2 日
hi, I tried your suggestion, it seems to work, but not on my issue with the to/from workspace blocks :( could you please have a look on my edit note in my topic? Thanks a lot!
Kaustubha Govind
Kaustubha Govind 2011 年 2 月 2 日
Tobias: Again, even though the From/To Workspace blocks may be executing in the correct priority, it only means that their "Output" methods have executed in the given order. For example, it could mean the To Workspace block maintains an internal buffer to write the data, that it dumps to the workspace much later. There is no guarantee that it is written to the workspace in time for the To Workspace block to read it.
Tobias
Tobias 2011 年 2 月 8 日
damn, I clicked at "accepted" by accident, sorry for that. The problem of getting an order to my blocks has been solved by the "Enabled Subsystem" blocks

サインインしてコメントする。

その他の回答 (1 件)

Kaustubha Govind
Kaustubha Govind 2011 年 2 月 2 日

0 投票

I am not sure if the From/To Workspace blocks lock down the workspace variable at any point during the simulation, but passing data through the model using these blocks may not be the best idea since they are meant solely for reading static data and data-logging, respectively. Is there a reason you wouldn't consider using the From / Goto blocks instead?
Note that assigning block priorities will be non-trivial if you plan to connect hundreds of blocks in this fashion. Also, Simulink will honor your setting only if there are no data-dependency violations.

4 件のコメント

Tobias
Tobias 2011 年 2 月 2 日
Hi, I think that the last point can be solved by grouping several blocks to one block, so I have a better overview. My concerns about From/Goto is, that is might be incompatible to the priority: http://www.mathworks.com/help/toolbox/simulink/ug/f13-88939.html#f13-82250
Kaustubha Govind
Kaustubha Govind 2011 年 2 月 2 日
I'm not sure what you mean by "incompatible to priority". From/Goto blocks are merely connection points and are therefore virtual. Think of them as two ends of a signal - they do not need to be executed like other (non-virtual) blocks. Consequently, they do not have a priority that you can set. However, priority is inconsequential for these blocks - it is the priority of their source/destination blocks that is useful.
Tobias
Tobias 2011 年 2 月 8 日
hey, I just tried using from/goto but how can I parametrize the tags that they can be assigned by a m-file (by the preLoadFcn callback)? I need to use a dynamic way to assign the output ports of one block to one or more input ports of another block...
This whole procedure shall simulate several signals which are processed and written back to it's source to be written from the next block (which does the same and so on...)
Kaustubha Govind
Kaustubha Govind 2011 年 2 月 8 日
Try something like:
set_param('mymodel/From', 'GotoTag', 'A')
set_param('mymodel/Goto', 'GotoTag', 'A')

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeSimulink Functions についてさらに検索

製品

タグ

質問済み:

2011 年 2 月 2 日

Community Treasure Hunt

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

Start Hunting!

Translated by