- Global Goto/From blocks
- Data Store Memory block with Data Store Read and Data Store Write blocks
Wireless communication between 2 Simulink blocks without Goto/From
4 次查看(过去 30 天)
显示 更早的评论
Hi,
Would there be a way to create 2 Simulink blocks (Matlab Function? S-Function ?) that would be in a same model, at different levels and which could communicate together wirelessly?
I'm looking for a solution that do not use Goto/From blocks. I'm pretty sure there is a code solution, surely complicated, but the outlines of this solution are not clear in my mind.
GL
0 个评论
采纳的回答
Jonas
2021-1-21
The advantage of the first solution is that the signal at the 'From' block is calculated after it is put on the 'Goto' block. In other words, order of execution is managed automatically. Using Data Store Memories you are not sure that the data is written before it is read.
The advantage of the second solution is that you can write to the Data Store in multiple locations.
When sending the signal accross subsystems which run at different sample rates, a Rate Transition is automatically inserted at Goto/From blocks. This is not the case for the Data Store blocks.
3 个评论
Jonas
2021-1-22
编辑:Jonas
2021-1-22
I do would suggest looking into Data Store Memories. You can even omit using the Data Store Memory blocks, and create Simulink.Signal objects inside a Data Dictionary, and then you can refer to those Signal objects in your Data Store Read and Data Store Write blocks directly, without having to create Data Store Memory blocks.
I use Data Store Write and Data Store Read blocks, and I make sure the order of execution is correct because of my model structure. I have Function Call Subsystems, which I call in a fixed order by using a Stateflow. This way, I know one subsystem is executed before the other subsystem and correspondingly also the Data Store Read/Write order is then fixed.
Another alternative I see some people use - but I personally do not like it - is that people put all signals on a bus object and then they provide this bus object as an input to all functions. Then inside the function, they extract the signal they need with a Bus Selector. This way, the bus object acts as your 'global workspace' kind of and you only have one signal line going to each subsystem. Then you need to manage what is inside the bus object and clearly define all the signals.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Inputs 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!