How do I write to a variable multiple times in the same time step in simulink?

15 views (last 30 days)
I have a control loop in Simulink which writes to a variable multiple times using the DATA STORE WRITE block. I then read the most recent data value using the DATA STORE READ block. Finally, I use this value (signal) elsewhere in my program. How can I do this?
I am getting the following error:
The block 'Data Store Write2' is writing to the data store 'Data Store Memory' but the block(s) 'Data Store Read' have already read from a portion or the entire region of this memory at time 0.0. For performance reasons, occurrences of this diagnostic for this memory at other simulation time steps will be suppressed.
A simple block diagram of what I am trying to do is as follows:

Accepted Answer

Fangjun Jiang
Fangjun Jiang on 1 Aug 2016
This is a good case for using the Merge block. Connect all three outputs to a Merge block and then connect to a single "Data Store Write" block with the tag "rpm_cmd". Double click the Merge block, click the "Help" button to see the detailed explanation of the Merge block.
  3 Comments
Fangjun Jiang
Fangjun Jiang on 2 Aug 2016
Yes. it will. The output of two "If Action Subsystem" can be merged. The output of the "Add" block should not be connected to the Merge block. It doesn't make sense even if the Merge block doesn't give error. The whole subsystem is executed once every sample time. The execution order follows the data flow. The "Add" block is executed, then either the "If" action or the "Else" action. The Merge block always takes the latest update. So connecting the "Add" block to the "Merge" block has no effect even there is no error.

Sign in to comment.

More Answers (0)

Categories

Find more on Event Functions in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!