Simevent messages receive when new message arrived

3 次查看(过去 30 天)
Hi,
I build a comminucation channel in Simulink, that can simulate bandwitdth, latency and package loss. To create messages I can transmit through the channel, I am working with a stateflow channel, that creates a message every 10 sec and the "message receive" block that receives the messages.
The received messages are necessary input to a controler, updating its parameters every time there is a new data available, but also has the restrictions, that data being older than 10s are not relevant anymore. Due to the stateflow block, the receive block and the sample time of my simulation(10s) all my message are older than 10s and therefore not relevant anymore, when passed to the controler.
(create message --> transmit through communication channel --> receive message --> pass to controler)
Is it possible to decouple execution of blocks from the sample time? More precise, is it possible for the "message receive" block to receive, when there is a new message available and not in intervalls defined from the inherited sample time of the simulations configurations?
Thanks :)

回答(1 个)

Altaïr
Altaïr 2025-6-4
To ensure the Message Receive block executes only when a message is available, an Enabled or Triggered Subsystem can be used. For general details on conditional subsystems, check out:
web(fullfile(docroot, 'simulink/conditional-subsystems-1.html?s_tid=CRUX_lftnav'))
Here’s a step-by-step approach using an Enabled Subsystem:
  1. Adjust the sample time (e.g., to 0.1 seconds) using the Sample Time parameter in relevant blocks.
  2. Place the Message Receive block inside an Enabled Subsystem.
  3. Connect a control signal (indicating message availability) to the subsystem’s Enable port.
Below is an example model where a Message Send block with an enable port generates incoming messages.
The Scope output demonstrates how the Enabled Subsystem receives the messages at each time step and holds the message when it remains disabled.
For more details on Enabled Subsystems, use the folllowing command:
web(fullfile(docroot, 'simulink/slref/enabledsubsystem.html'))

类别

Help CenterFile Exchange 中查找有关 Discrete-Event Simulation 的更多信息

产品


版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by