poeschlorn
poeschlorn

Reputation: 12440

Simulink: Synchronizing and timing

in order to simulate some processes I have a problem with getting a predefined working order of my self modeled blocks.

How can I be sure, that for example Block A must be finished before Block B and C start working?

The problem is, that some Blocks shall work after some others and some shall not. I must admit I have not much experience with Simulink in order of doing time-depending things (althought basic knowledge of simulink is available).

For instance this scenario shall be realised:

A -> B, C -> D, E, F

The main thing is, that all blocks A-F have no logic correlation to each other, they all do several things. My aim is to make B and C start working, after A has finished. And D/E/F after B AND C have finished. In this case, the word "parallel" was the wrong word, this does not have to be calculated really parallely. Just making sure, that this complies with a predifined steady order.

Edit: My new idea is to use the matlab workspace als buffer, so my block A can push its results to workspace (by the "to workspace" block). But now I have to make sure, that block B and C may read the results (with "From workspace") of A AFTER A pushed its information to workspace...how to do this?

Edit2: Here's a screenshot which should make some thinks clearer: As the documentation of "Sorted order" refers, the set up seems to be ok (including the subsystems timing). But unfortunately problem still exists. The variable "simin" is loaded from workspace, before it was written :( As you see, the display shows "1", which it shouldn't do. In the very first run of the simulation I get an exception, that the variable "simin" does not exist.

It would be nice, if you can help me with my issue.

Greets, poeschlorn

Upvotes: 3

Views: 3511

Answers (3)

akd
akd

Reputation: 179

So in your example, if you have Block A connected with the same wire to both B and C, when Block A is finished, Block B and C will work in parallel.

EDIT: I am using the same blocks as you are, but it works for me. I think you are over complicating things. The way you are setting block priorities is no different than how Simulink runs the blocks without them. Below you can see my setup and the output on both binary displays.

enter image description here

The error you see on the first run is due to Simulink not creating the variable until the first time step is being executed. When Simulink builds the simulation it sees that the variable used as input from the workspace is not created.

Upvotes: 1

Clement J.
Clement J.

Reputation: 3032

If the connection between the block are not enough to set the order, you can use block priorities.

A tip to test the execution order is to add an "embedded Matlab block" with a disp command displaying the name of the block.

Upvotes: 1

MikeT
MikeT

Reputation: 1644

It's not really clear what you're asking. When you say that Block A must be finished, do you mean the Output function? The way simulation works in Simulink is that the blocks are run serially, so Block B and C would never run until Block A finished it's Output function.

I don't know of any obvious way of running blocks B and C in parallel currently in Simulink.

Upvotes: 0

Related Questions