2 Further Examples - MapleSim Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Online Help

All Products    Maple    MapleSim


Contents     Previous     Next     Index

2 Further Examples

This chapter describes how to prepare a model for export by grouping the necessary components in a subsystem, shows how to use the B&R MapleSim Connector to export a spreadsheet of operational data for use by the B&R SERVOsoft drive train tool, and demonstrates the 1-D motion generation app.

2.1 Preparing the 2-D Rigid Slider Crank Model for Export Using Subsystems

Preparing a Model

This example starts with a slider crank model and prepares it for export by grouping the necessary components in a subsystem.  At the end of the process, the example will look like the example model used in the FMU Generation Example: Slider Crank Model section of the Chapter 1.  This step is necessary before exporting your model to an FMU.

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

2. Define subsystem inputs and outputs.

3. Define and assign subsystem parameters.

 

To open the slider-crank mechanism example:

1. 

In MapleSim, under the Help menu, browse to the Examples > User's Guide Examples > Chapter 6 menu.

2. 

Open the Planar Slider-Crank Mechanism example. The example appears in the Model Workspace.

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 generate C code for. In this example, you will group all of the components into a subsystem.

To create a subsystem:

1. 

Using the selection tool ( ) located in the Model Workspace Toolbar, draw a box around all of the components in the model.

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.  Since the B&R MapleSim Connector 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 generated C code.

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.  A spherical geometry component is also added for visualization purposes.

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. 

Under the Libraries tab on the left side of the MapleSim window, expand the 1-D Mechanical palette and then expand the Rotational > Sensors subpalette.

4. 

Drag the Angle Sensor component to the Model Workspace and place it above the Revolute2 component.

5. 

To connect the Angle Sensor component to the model, click the triangular y connector. The frame is highlighted in green when you hover your pointer over it.

6. 

Drag your pointer to the subsystem boundary.

7. 

Click the boundary once. A real output port is added to your subsystem.

8. 

Connect the other end of the Angle Sensor to the white flange of revolute joint Revolute1.

Since the B&R connector supports causal and acausal ports, an acausal input is added outside of the subsystem to control the torque on the crank shaft.

9. 

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

 

10. 

From the Multibody > Visualization palette, select the Spherical Geometry component and add it above the Rigid Body component. Use Edit > Flip Horizontal to flip the component and then connect it to both Revolute3 and the Rigid Body component.

11. 

Add a probe: Click Attach Probe( ) above the Model Workspace toolbar and then click the connection line from Revolute1 to Angle Sensor.  Click the probe once to position it.

12. 

In the Properties tab, name the probe crank, and select Angle, Angular velocity, and Torque to measure these quantities.

The complete subsystem appears below.

13. 

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

14. 

From the 1-D Mechanical > Rotational > Torque Drivers menu, add a Torque component to the Model Workspace and place it next to the subsystem.  Connect its output port to the input port of the SliderCrank subsystem.

15. 

From the Signal Blocks > Controllers palette, drag a PID component into the model workspace and connect its output port to the input signal port of the Torque component.  The result is shown below.

 

16. 

Click on the PID and in the Properties tab set k to 400, Ti to 0.5 s, and Td to 0.1 s.

17. 

From the Signal Blocks > Math > Operators palette, drag a Feedback component into the model workspace and connect its output port to the input port of the PID component.

18. 

Click the Feedback component, and from the Edit menu, select Flip Vertical.

19. 

Connect the Feedback component to the PID component and the SlidingCrank subsystem to the Feedback component.

20. 

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

21. 

The model is prepared and ready to use with the apps in the B&R MapleSim Connector.

 

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 in the B&R Connector App.

2.3 Exporting Your Model Using the B&R Automation Studio FMU Generation App

After preparing the model, you can use the B&R Automation Studio FMU Generation app to set export options and convert the model to an FMU file. In this example, the Slider Crank Subsystem is exported as an FMU block for which the controller can be designed in the Automation Studio.

1. 

From the main toolbar, click Show Apps Manager ( ).

2. 

Double-click on the B&R Automation Studio FMU Generation entry under B&R connector in the Apps palette.  The B&R FMU Component Code Generation app opens.

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

2.4 Generating Operational Data Model

In this example, you will use the B&R SERVOsoft Data Generation app to create a spreadsheet of the velocity/torque characteristics needed to drive the slider crank model.

1. 

Open the Slider Crank example created in the above section,

2. 

Load the B&R SERVOsoft Data Generation app.

3. 

Define app settings.

4. 

Simulate and display the graph.

5. 

Export data to a spreadsheet.

To open the Slider Crank example and load the app:

1. 

Open the Slider Crank example created in the previous session.

2. 

From the main toolbar, click Show Apps Manager ( ).

3. 

Double-click the B&R SERVOsoft Data Generation entry from the B&R connector in the Apps palette. The B&R SERVOsoft Data Generation app opens.

4. 

In the app, click Load System.  All of the app fields are populated with information specific to your model.  You can now specify the app settings.

 

To define the app settings:

1. 

In the Actuator and Export section, select ** Probes ** from the Device drop-down menu, click the Rotational radio button, and set the Probe, Velocity, and Thrust to be crank.phi, crank.w, and crank.tau, respectively.  Note the default units, which are appropriate for this example.

2. 

In the Export Options section, ensure the time is from 0 to 2.

To simulate and display the graph:

1. 

Click Preview Export(Simulate). The simulation runs and the graph is displayed.

2. 

Click the Thrust vs Velocity radio button to view this graph.

 

To export the data to a spreadsheet:

1. 

Specify the locations for the Target Directory.

2. 

Provide a name for the generated XLS file in Filename.

3. 

Click Export.  The XLS files are created and saved in the target directory.

Note: Generating a block may require a few minutes.

2.5 Using the 1-D Motion Generation App

The example shows how to create a motion profile using the 1-D Motion Generation app in MapleSim.

1. 

From the main toolbar, click Show Apps Manager ( ).

2. 

Double-click the 1-D Motion Generation entry in the Apps palette.

3. 

Change the class to Rotational Angle from the Configure section.  Note the default units, which are appropriate for this example.

4. 

select Add Right from the Waveform Creation.

5. 

Change the Height from Segment Properties to 1 and choose Sinusoid from the drop down menu and click Apply.

6. 

Click on Add Right again and change the Height to -1 from the Segment Properties.

7. 

Change the Model Name to Motion under Model Generation.

8. 

And click Generate.

9. 

The new motion profile created will be seen in the Local Components tab ( ) in MapleSim.

 

Contents     Previous     Next     Index