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

18 visualizaciones (últimos 30 días)
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:

Respuesta aceptada

Fangjun Jiang
Fangjun Jiang el 1 de Ag. de 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 comentarios
Fangjun Jiang
Fangjun Jiang el 2 de Ag. de 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.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Event Functions en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by