Effacer les filtres
Effacer les filtres

Sharing block (mask) parameters between custom blocks

5 vues (au cours des 30 derniers jours)
Matej
Matej le 15 Août 2012
Hello, I am developping an extension for ECRobot NXT library. Shortly said, it enables NXT robots to communicate in wireless mesh networks. For this I have written hardware driver, number of S-Functions in C and created appropriate masks.
My problem is that I need to share some information between all my simulink blocks. For instance, there is block for setting up configuration. Also, there are blocks for receiving/transmitting data. Now the trouble is that they need to know the configuration in order to send or receive. Whence, Rx/Tx blocks need to read parameters written in "configuration" block (mask).
Is it possible to "share" mask parameters of my blocks if they are within the same system? What is the standard approach to solve such situations?
Thanks in advance, Matej.

Réponse acceptée

Ryan G
Ryan G le 15 Août 2012
You can use a workspace parameter instead of a value inside of the masks or use a function in the initialization of the mask of your configuration block:
assignin('base','newVar',MaskParaminConfigBlk);
This should put the parameter in the workspace and you can have that parameter inside all the other masks to be shared.

Plus de réponses (1)

Matej
Matej le 15 Août 2012
Thank you for your answer.
From a quick test it looks like this approach works nicely. I have used assignin/evalin in initialization of a mask. It works both in simulation and in generated code - values are propagated correctly.

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by