Using model reference with different system target files

4 views (last 30 days)
I have multiple hardware targets and want to be able to build the same model to these targets.
Each hardware target has its own top level model where I use hardware target specific blocks for input and output to other hardware. By using model reference block I include a non hardware specific model that holds my logic. When using model reference each model has its own Configuration set and these need to match the top model.
I would like to be able to build for my different targest without making changes to the referenced models.
What I have tried is to add my configurations to each model via "Add Configuration Reference" in Model Explorer and then use setActiveConfigSet() function in each init script for my different target hardware. However when I try to build I get error due to unsaved changes in the models I have referenced.
Is there a way to switch configuration sets in the referenced models with out saving the setting to each model?

Accepted Answer

Jonas
Jonas on 16 Oct 2020
Edited: Jonas on 16 Oct 2020
You need to create Data Dictionaries and use the Model Explorer. I will explain step by step.
  1. Create a Data Dictionary for each top model and the model reference, and Link the data dictionary to each model (e.g. create 'model_A.sldd' and in 'model_A.slx' link to 'model_A.sldd', do the same for 'model_B' and 'model_C', and finally create 'model_reference.sldd' and link it to 'model_reference.slx'.)
  2. Create another Data Dictionary, called for example 'global.sldd'.
  3. Add this 'global.sldd' data dictionary as a reference to each of the data dictionaries created in step 1. (in 'model_A.sldd' add 'global.sldd' as a reference, in 'model_B.sldd' add 'global.sldd' as a reference, ...)
  4. Create one Configuration Reference object in 'global.sldd', and one regular Configuration object for each and every topmodel in 'global.sldd' (so we have 'Configuration Reference', 'Configuration model A', 'Configuration model B', ...)
  5. In each top model, go to Configurations and create a new Configuration Reference object. In the drop-down menu to the right, you can now select the Configurations which are inside 'global.sldd', because this data dictionary is referred to by the model data dictionary, and this model data dictionary is linked to the simulink model file. Select the 'Configuration Reference' which you created inside 'global.sldd'.
  6. For the model reference submodel, also refer to the same 'Configuration Reference' object which resides in 'global.sldd'
Now the Configuration Parameters for your model reference submodel is the same as the top model, being the Configuration Reference object. When you go inside the 'global.sldd' data dictionary, you can select the Configuration Reference object, and refer to one of the other Configuration Parameters objects inside 'global.sldd'. This is the location where you can switch between Configuration Parameters, using the drop-down menu. This changes the Configuration Parameters for both the top model and the model reference. E.g., when you open your top model for Simulation, select the Simulation Configuration Parameters. If you switch to the top model for embedded code generation, switch to the Embedded Configuration Parameters.
  2 Comments
Johan Eklöv
Johan Eklöv on 16 Oct 2020
Does this force you to use data dictionaries instead of workspace variables as well? Or can you use data dictionaries only for configuration sets?
The problem is that one of the target hardware I use is a dSPACE autobox. That enviroment does not support data dictionaries for some reason.
What I am trying to accomplish is to be able to build my models to a autobox but also do code generation only with embedded coder.
Jonas
Jonas on 16 Oct 2020
Pretty sure you can continue to use Model Workspace variables with a Data Dictionary.

Sign in to comment.

More Answers (0)

Products


Release

R2017b

Community Treasure Hunt

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

Start Hunting!