How to create a component reference in the system composer from a simscape component

5 次查看(过去 30 天)
Hello,
I have a Simscape Isothermal Fluid component that is an isolated component (it have its own test harness, test cases and requirements. You can see it is composed with simscape signals and simulink signals.
I would like to build a system composer, were this component is part of. But when I add a "reference component" on the system composer ad link to the compoenent, the physical lines does not come.
The only way I made it works is creating the sismcape compoenent inside the system composer, but this way I need to manage changes and so on inside the composer.
Any solution to create a simscape component that can be referenced inside the system composer and have the physical connections available?

采纳的回答

Josh Kahn
Josh Kahn 2024-8-20
编辑:Josh Kahn 2024-8-27
When you right-click to create your Simulink behavior from System Composer, make sure you choose "Subsystem Reference". Simscape models do not support physical ports crossing the model reference boundaries but they can cross subsystem reference boundaries.
Simulink has two kinds of files - Model Reference and Subsystem Reference. These are treated slightly differently during simulation and code gen. The models are atomic units whereas the subsystems are meant to be pieces of a larger model. Root-level Simscape ports will only work in a referenced subsystem.
The HydraulicPump_Model you shared is a model reference with physical ports at the root level, this is not supported by the Simscape library. The good news is that you can convert the subsystem in that model to a subsystem reference and link your System Composer component directly to it.
Here are some screenshots I made using the model you shared:
1. Right-click your existing subsystem and convert it to a Referenced Subsystem:
2. Give it a name
3. In your architecture model, right click a component and choose Link to Model... then link it to your new subsystem reference.
4. All done!

更多回答(3 个)

Akshat Dalal
Akshat Dalal 2024-8-19
Hello Flavio,
It is possible to create a simscape component that can be referencedn inside a System Composer application and have the physical connections available. One way to achieve this is to use the Simulink Subsystem Reference approach. This allows you to author Simulink or Simscape behaviors with physical ports and connections.
You can refer the following documentation for a more detailed explanation and other approaches: https://www.mathworks.com/help/releases/R2024a/systemcomposer/ug/implement-components-in-simulink.html

Flávio Luiz
Flávio Luiz 2024-8-27
编辑:Flávio Luiz 2024-8-27
@Josh Kahn, thanks for your answer. Sorry to say that I'm having no luck with it. When I select "Link to Model", the component still referenced without the simscape interface.
I am attaching here my component, maybe could be helpfull. The component have some simulink inputs to externally set the parameters ans the simscape interface that will be interfaced with other components on the system composer level. I need to see like this (both simulink and simscape interfaces:
PS: Maybe you wonder why the last picture does not work for me. I cannot create test harness for that subsystem, the optio is not available. So I cannot validate the stand alone component.

Flávio Luiz
Flávio Luiz 2024-8-27
Hi @Josh Kahn thanks a lot for the step-by-step. Now the solution works!
Thanks again :)

类别

Help CenterFile Exchange 中查找有关 System Composer 的更多信息

产品


版本

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by