Difference between a Simulink library and a model reference
Asked Answered
G

4

18

What are (If there are) the differences between a Simulink library and a model reference. There's advantadges in using either of them in different situations?

Glomeration answered 16/8, 2011 at 16:54 Comment(0)
S
11

The main purpose of libraries and model reference are the same: facilitate the reuse of simulink models. When you work with libraries, simulink "imports" the content of the referenced models in to the main model. Sometimes, this leads to the developer dealing with gigantic models (more than 50k blocks), which can be time consuming. When you are designing a library, the lib file cannot be run. You have to "instantiate" it in the main model. On the other side, model reference deals with separated models. They are put together when you press the simulate button, but during the design time, you deal with completely separated models. With model reference, you can also select acceleration methods (it basically compiles the model) and this can't be done with libraries.

Sluff answered 16/8, 2011 at 17:8 Comment(0)
T
9

Adding some more to danielmsd's answer:

  • Configuration Management: Model references can be put easily into version control and developers can work independently from each other. A library is one file, so the blocks cannot be versioned individually and developers cannot work in parallel.
  • You can protect model references.
  • Code Generation: Incremental build is only possible with model referencing.

BUT: Model referencing has quite a few limitations, so check them out carefully before picking this option. See Model Referencing Limitations.

Tyika answered 13/12, 2012 at 17:39 Comment(0)
C
5

From a system design perspective model references should be used for components of your system. That is the different parts your system is made from. Libraries should be used as utilities. That is reuable blocks that are used through out your design.

For example a robot control system includes components: navigation, control, path_plannen etc. These are components and should be implemented with model references. In that case they are developed as independent models and can be tested independently.

Inside the components you could need utility blocks such as low_pass_fileter, error_state_handler and check_input_range, they are libraries.

Crosstree answered 8/6, 2013 at 21:3 Comment(0)
N
4

Advantages of mdl ref: - Code generation: Model references allow partial builds when using the coder product. Assuming you have a really large model with 100k blocks and it takes 20 minutes to build, splitting it up in model references will reduce the build time since only the changed model will need to rebuild.

  • Model update: only changed model references are updated "CTRL+D" therefore this helps when having really large models.

  • Simulation: In simulations mdl refs are generated as dlls which makes your simulations much faster (the effect is much bigger than the difference between normal and accellerator mode)

Disadvantages pains: - In general Mdl referencing is somehow a pain to use due to limitations

  • There is no possibility to pass a Simulink.parameter.object which has a tree structure. (When using type:BusObject only the value property has a structure, the other properties don't)

  • When a subsystem has a bus signal as input, a mdl ref needs a bus object to specify the input interface, and the library block doesen't. (Even if its quite ugly to use unspecified bus inputs in a lib block). (Note that busobject are always global in the base workspace... risk of naming collisions)

Nehru answered 7/11, 2014 at 15:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.