Wireless communication between 2 Simulink blocks without Goto/From

4 vues (au cours des 30 derniers jours)
langrg
langrg le 21 Jan 2021
Modifié(e) : langrg le 8 Fév 2021
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

Réponse acceptée

Jonas
Jonas le 21 Jan 2021
  • Global Goto/From blocks
  • Data Store Memory block with Data Store Read and Data Store Write blocks
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 commentaires
Jonas
Jonas le 22 Jan 2021
Modifié(e) : Jonas le 22 Jan 2021
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.
langrg
langrg le 8 Fév 2021
Modifié(e) : langrg le 8 Fév 2021
Thanks for all your ideas!
I'm going to look at the Data Store Memory solution.
I do not like the bus solution too, because my models are very deep and contain a lot of subsystems, I don't want to increase the number of lines.

Connectez-vous pour commenter.

Plus de réponses (0)

Produits


Version

R2016b

Community Treasure Hunt

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

Start Hunting!

Translated by