2 Example: Exporting a Model as an FMU File - MapleSim Help

Online Help

All Products    Maple    MapleSim

Home : Support : Online Help : MapleSim Toolboxes : MapleSim FMI Connector : Getting Started Guide : MapleSimFMIConnectorGSG/Chapter02

Contents     Previous     Next     Index

2 Example: Exporting a Model as an FMU File

2.1 Preparing a Model for Export

In this example, you will perform the steps required to prepare a slider-crank mechanism model and export it as an FMI file.

1. Convert the slider-crank mechanism model to a subsystem.

2. Define subsystem inputs and outputs.

3. Define and assign subsystem parameters.

4. Export the model using the FMI file Generation template.


To open the slider-crank mechanism example

1. In MapleSim, under the Libraries tab, expand the Examples palette and then expand the User's Guide Examples submenu.

2. Open the Planar Slider-Crank Mechanism example in Chapter 6.


Converting the Model to a Subsystem

By converting your entire model or part of your model into a subsystem, you identify which parts of the model that you want to export. In this example, you will group all of the components into a subsystem.

To create a subsystem


Using the selection tool ( ) located above the model workspace, draw a box around all of the components in the model.


From the Edit menu, select Create Subsystem.


In the Create Subsystem dialog box, enter SliderCrank as the subsystem name.


Click OK. A SliderCrank subsystem block appears in the model workspace.

Defining Subsystem Inputs and Outputs

MapleSim uses a topological representation to connect interrelated components without having to consider how signals flow between them, whereas traditional signal-flow modeling tools require explicitly defined system inputs and outputs.  Since FMI only supports data signals, properties on acausal ports, such as mechanical flanges and electrical pins, must be converted to signals using the appropriate components. The resulting signals are directed as inputs and outputs for the subsystem in MapleSim and for the FMU file.

In this example, you will convert the displacements of the slider and the joint between the crank and connecting rod to output signals. The input signal needs to be converted to a torque that is applied to the revolute joint that represents the crank shaft.

To create a subsystem output port


Double-click the subsystem block to view its contents. The broken line surrounding the components indicates the subsystem boundary, which can be resized by clicking and dragging its sizing handles.


Delete the probes that are attached to the model.


In the Libraries tab on the left side of the MapleSim window, expand the Multibody palette and then expand the Sensors submenu.


Drag the Absolute Translation component to the Model Workspace and place it below the Prismatic Joint component.


Right-click (Control-click for Macintosh®) the Absolute Translation component and select Rotate Counterclockwise.


From the Signal Blocks > Routing > Demultiplexers menu, drag a Real Demultiplexer component to the Model Workspace and place it to the right of the Absolute Translation component.


To connect the Absolute Translation component to the model, click the frame_b connector. The frame is highlighted in green when you hover your pointer over it.


Draw a vertical line and click the connection line directly above the component. The sensor is connected to the rest of the diagram.


In the same way, connect the r output port (TMOutputP) of the Absolute Translation component to the input port of the demultiplexer. This is the displacement signal from the sensor in x, y, and z coordinates. Since the slider only moves along the x axis, the first coordinate must be an output signal.



Hover your pointer over the first demultiplexer port and click your mouse button once.



Drag your pointer to the subsystem boundary and then click the boundary once. A real output port is added to your subsystem.



Add another Absolute Translation component above the Connecting Rod subsystem.


Right-click (Control-click for Macintosh) the Absolute Translation component and select Flip Vertical.  Right-click the Absolute Translation component again and select Rotate Clockwise.


Add a Real Demultiplexer component to the right of the sensor and connect the components as shown below. Since the crank is moving in the x, y plane, you only need to output the first two signals. You are now ready to add a real input port to your subsystem to control the torque on the crank shaft.




From the 1-D Mechanical > Rotational > Torque Drivers menu, add a Torque component to the Model Workspace and place it above the Fixed Frame component.


Connect the white flange of the Torque component to the white flange of the leftmost Revolute Joint.




Click the input port of the Torque component, then drag your pointer to the subsystem boundary and click the boundary once. A real input port is added to your subsystem.


The complete subsystem appears below.



Click Main above the Model Workspace to browse to the top level of the model.


From the Signal Blocks > Sources > Real menu, drag a Constant source into the Model Workspace and connect its output port to the input port of the SliderCrank subsystem as shown below.



Click Probe ( ) above the Model Workspace and then click the top output port of the SliderCrank subsystem.


In the Model Workspace, click the probe once to position it.


In the same way, add probes to the other SliderCrank output ports as shown below.

2.2 Defining and Assigning Subsystem Parameters

You can define custom parameters that can be used in expressions in your model to edit values more easily. To do so, you define a parameter with a numeric value in the parameter editor. You can then assign that parameter as a variable to the parameters of other components; those individual components will then inherit the numeric value of the parameter defined in the parameter editor. By using this approach, you only need to change the value in the parameter editor to change the parameter values for multiple components.

To edit parameters


Double-click the SliderCrank component on the Model Workspace to see the detailed view of the SliderCrank subsystem, and then click Parameters ( ) above the Model Workspace. The parameter editor appears.


In the first Name field, type CrankL and press Enter.


Specify a default value of 1 and enter Crank length as the description.


In the second row of the table, define a parameter called ConRodL and press Enter.


Specify a default value of 2 and enter Connecting Rod Length as the description.


Click Diagram ( ) to switch to the diagram view. The parameters are defined in the Parameters pane.


In the Model Workspace, select the Crank subsystem.


In the Parameters pane, change the length value (L) to CrankL. The Crank subsystem now inherits the numeric value of CrankL that you defined.


Select the ConnectingRod subsystem and change its length value to ConRodL.


Click Main above the Model Workspace to navigate to the top level of the model. You will include these parameter values in the model that you export. You are now ready to convert your model to an FMI block.

2.3 Exporting Your Model Using the FMU file Generation Template

After preparing the model, you can use the FMU Generation template to set export options and convert the model to an FMU file.

To generate an FMU file


Click Templates ( ) in the Main Toolbar.


From the list, select FMU Generation.  The Create Attachment window appears.


In the Attachment field, enter Slider Crank FMI as the worksheet name and click Create Attachment. The slider-crank model opens in the Subsystem Selection window in the FMI Connector Template.


From the Subsystem Selection toolbar select the SliderCrank subsystem and click Load Selected Subsystem. All of the template fields are populated with information specific to the subsystem.


Specify the location for the Target Directory, Visual C++ Directory and provide a name for the generated FMU Archive.


Click Generate FMU Archive to generate the .FMU zip file.


Contents     Previous     Next     Index

Download Help Document

Was this information helpful?

Please add your Comment (Optional)
E-mail Address (Optional)
What is ? This question helps us to combat spam