2 Example: Exporting a Model as an FMU File - MapleSim Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : MapleSim Toolboxes : MapleSim FMI Connector : Getting Started Guide : 2 Example: Exporting a Model as an FMU File

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 app.

 

To open the slider-crank mechanism example:

1. 

In MapleSim, click the Help menu item.

2. 

Select Examples > User's Guide Examples > Chapter 6, and then select Planar Slider-Crank Mechanism.

 

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 you want to export. Since the FMI connector supports data signals and properties on acausal connectors such as mechanical flanges and electrical pin, in this example, you will group all of the components into a subsystem and use an acausal input into the subsystem.

To create a subsystem:

1. 

Draw a box around all of the components in the model by dragging your mouse over them.

2. 

From the Edit menu, select Create Subsystem.

3. 

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

4. 

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. In this example, since FMI supports causal and acausal ports, a torque driver is used as an input to the subsystem in MapleSim and for the FMU file.

You will convert the displacements of the slider and the joint between the crank and connecting rod to output signals. The input will be a torque driver that is applied to the revolute joint that represents the crank shaft.

To create a subsystem output port:

1. 

Double-click the subsystem block to view its contents. In this view, the broken line indicates the subsystem boundary. You can edit the connection lines and components within the boundary, and add subsystem ports to connect the subsystem to other components.

2. 

Delete the probes that are attached to the model.

3. 

In the Library Components tab ( ) on the left side of the MapleSim window, expand the Multibody palette and then expand the Sensors submenu.

4. 

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

5. 

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

6. 

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.

7. 

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.

8. 

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

9. 

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.

 

10. 

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

 

 

11. 

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

 

12. 

Add another Absolute Translation component above the Connecting Rod subsystem.

13. 

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

14. 

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.

 

 

15. 

Click on the white flange of the leftmost Revolute Joint and drag the pointer to the left boundary. This will act as the acausal input connection to the subsystem.

 

 

The complete subsystem appears below.

 

16. 

Click Main ( ) in the Model Workspace toolbar to browse to the top level of the model.

17. 

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

18. 

From the Signal blocks>Common menu, add a Constant signal component to the Model Workspace and next to the Torque component and connect it to the Torque component.

 

19. 

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

20. 

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

21. 

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

1. 

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

2. 

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

3. 

Change the Type to Length from the drop-down menu.

4. 

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

5. 

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

6. 

Change the Type to Length from the drop-down menu.

7. 

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

8. 

Click Diagram View ( ) to switch to the diagram view, and then click Main ( ).

9. 

Select the SliderCrank subsystem. The parameters are defined in the Properties tab ( ).

 

10. 

Double-click the SliderCrank subsystem, and then select the Crank subsystem.

11. 

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

12. 

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

13. 

Click Main ( ) in the Model Workspace toolbar 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 App

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

To generate an FMU file

1. 

In the main toolbar in MapleSim, click Show Apps Manager ( ).  The Analysis window opens with Apps tab selected.

2. 

Double-click on the FMU Generation entry under FMI Connector in the Apps palette.  The Analysis window opens with the FMU Component Code Generation app loaded in the Apps tab.

3. 

In the Subsystem Selection section, select the SliderCrank subsystem from the drop-down list, and then click Load Selected Subsystem. All of the app fields are populated with information specific to the subsystem.

4. 

Since this example uses an acausal 1D - mechanical rotational flange, on selecting the input option, you have the option to either choose a torque or an angle input that can be fed into the subsystem.

5. 

In the Export section, specify the location for the Target Directory and provide a name for the generated FMU Archive.

6. 

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

 

Contents     Previous     Next     Index