Simscape export FMU - expose component internal variables

3 vues (au cours des 30 derniers jours)
Ranjit Roshan
Ranjit Roshan le 16 Avr 2023
Commenté : Ranjit Roshan le 25 Mai 2023
I have the task of modelling and exporting from Simscape as FMU. For example, I can say I am modelling a spring mass damper
system and exporting it as FMU. I have a software at the other end, which loads the FMU and simulates it. I need to expose the
position and other information of the mass element, but don't want to add a sensor and create a FMU outport for it. Is there someway
I can expose the mass element internal information as variables in an FMU, so that they can be accessed during simulation after
export?

Réponses (1)

Vijeta
Vijeta le 5 Mai 2023
Yes, you can expose the internal state of a Simscape component as outputs in an FMU. To do this, you can use the Simscape Connector block, which is available in the Simscape Utilities library. The Simscape Connector block allows you to define custom outputs for a Simscape component that can be exported as FMU variables.
Here are the general steps to follow:
  1. Add a Simscape Connector block to your model and connect it to the Simscape component whose internal state you want to expose.
  2. In the Simscape Connector block, define custom output ports that correspond to the internal state you want to expose. You can do this by right-clicking on the Simscape Connector block and selecting Simscape > Define Custom Output Ports.
  3. In the Custom Output Ports dialog box, specify the name, unit, and expression for each output port. The expression should be a Simscape expression that evaluates to the internal state of the component.
  4. In the Simscape Connector block, set the Output FMU flag to 'on' and specify the name of the FMU output file.
  5. Export the model as an FMU.
  6. Load the FMU in your software and access the output variables that correspond to the internal state of the Simscape component.
Also, keep in mind that exposing the internal state of a Simscape component as outputs can increase the size of the FMU and the computational cost of simulating it. So, make sure to only expose the state variables that are necessary for your application.
  2 commentaires
Christian Behr
Christian Behr le 16 Mai 2023
I don't have a "Simscape Connector block" in my library and can't find any documentation on it. Is a special toolbox required? Do you have some documentation on this block?
Ranjit Roshan
Ranjit Roshan le 25 Mai 2023
@Vijeta, I am facing the same thing mentioned by @Christian Behr. I don't see a simscape connector block in the Utilities seciton. Can you send a photo of that block?

Connectez-vous pour commenter.

Catégories

En savoir plus sur Creating Custom Components and Libraries dans Help Center et File Exchange

Produits


Version

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by