Contents Previous Next Index
1 Getting Started
1.1 Working with Apps
The B&R MapleSim Connector includes the following apps:
B&R Automation Studio FMU Generation app — Generate a custom B&R FMU archive that can be used in B&R Automation Studio.
B&R SERVOsoft Data Generation app — Generate a Microsoft® Excel spreadsheet that contains the operational data (time, velocity, thrust) for a motion driver in the model. The spreadsheet can be used by the SERVOsoft® drive design tool that's in B&R Automation Studio.
Other apps are included in MapleSim itself, such as the 1-D Motion Generation app.
This chapter describes how to use the B&R MapleSim Connector to generate an FMU archive for use in B&R Automation Studio.
The next chapter describes how to use the B&R SERVOsoft Data Generation app.
1.2 B&R FMU Generation Steps
In the FMU Generation Example: Slider Crank Model section of this chapter, a step by step example shows you how to generate the FMU archive. The MapleSim Connector for B&R FMU Generation app consists of the following steps in generating FMU archive and is described in the sections below:
Subsystem selection
Inputs/Outputs and parameter management
Export Options
Info Options
Generate and export FMU archive
The BRConnector Package
The BRConnector package is a collection of procedures for generating a custom B&R FMU archive from MapleSim models, based on the model's algebraic equations and DynamicSystems objects.
For information about the BRConnector package, in Maple, refer to the BRConnector help page.
1.3 Opening the B&R FMU Generation App
To open the B&R FMU Generation app:
From the main toolbar, click Show Apps Manager ( ).
Double-click the B&R Automation Studio FMU Generation entry in the Apps palette. The B&R FMU Generation app opens.
1.4 Using the B&R FMU Generation App
The B&R FMU Generation app can be used to manipulate and export MapleSim subsystems.
With this app, you can define inputs and outputs for the subsystem, set the level of code optimization, generate the source code, and choose the format of the resulting FMU component and library code. You can use any Maple commands to perform task analysis, assign model equations to a variable, group inputs and outputs and define additional input and output ports for variables.
Note: FMU component generation now handles all systems modeled in MapleSim, including hybrid systems with defined signal input (RealInput) and signal output (RealOutput) ports.
Example models are available in MapleSim. To access these, from the Help menu, select Examples > BR Connector Examples.
Step 1: Subsystem Selection
This part of the app identifies the subsystem modeling components that you want to export as a block component.
To connect a subsystem to modeling components outside of its boundary, you add subsystem ports to your model. A subsystem port is an extension of a component port in your subsystem. The resulting signals can then be directed as inputs and outputs for the FMU archive file. By creating a subsystem you improve the visual layout of a system in the model workspace and also prepare the model for export. The Preparing the 2-D Rigid Slider Crank Model for Export Using Subsystems section in Chapter 2 shows you how to group all of the components into a subsystem.
You can select which subsystems from your model you want to export to an FMU archive file. To begin, select a subsystem.
After selecting a subsystem, click Load Selected Subsystem. All defined input and output ports are loaded.
Step 2: Inputs, Outputs, and Parameters
The Inputs, Outputs, and Parameters sections let you customize, define, and assign parameter values to specific ports. Subsystem components to which you assign the parameter inherit a parameter value defined at the subsystem level.
After the subsystem is loaded you can group individual input and output variable elements into a vector array, and add additional input and output ports for customized parameter values. Input ports can include variable derivatives, and output ports can include subsystem state variables. You can specify prefixes for both input and output port variables. The prefix for the input (output) port variables will be applied to all the variables in the input ports (outputs) table.
Note: If the parameters are not marked for export they will be numerically substituted. Parameters marked as tunable will also be marked for export by default. However, tunable parameters will be ignored if FMI Version and Environment (see Step 3: Export Options) are anything other than FMI 2.0 and Co-Simulation. To use fully qualified parameter names for the generated FMU, check the corresponding check box; otherwise, short parameter names will be used by default.
The Port and Parameter Management interface lets you customize, define and assign parameter values to specific ports. Subsystem components to which you assign the parameter inherit a parameter value defined at the subsystem level.
Step 3: Export Options
The export options include solver specifications and visualization options (for models with multibody components).
Solver Options
Specify the solver and step size.
For solver, select one of the following options:
Euler: forward Euler method
Implicit Euler: implicit Euler method
RK2: second-order Runge-Kutta method
RK3: third-order Runge-Kutta method
RK4: fourth-order Runge-Kutta method
CK45: Variable Step CK45 solver (Semi - stiff)
Rosenbrock : Variable step stiff Rosenbrock solver
For the Implicit Euler (stiff) solver, you can select between a symbolic or numeric approximation to the system Jacobian.
Visualization Options
For models with multibody components, the B&R Generation app creates an FMU that includes a B&R specific scene file, which can be used to create an animation in B&R Automation Studio.
Select Export geometric shapes/primitives to control whether geometric shapes or primitives are exported.
Constraint Handling Options
The Constraint Handling Options specifies whether the constraints are satisfied in a DAE system by using constraint projection in the generated C code. Use this option to improve the accuracy of a DAE system that has constraints. If the constraint is not satisfied, the system result may deviate from the actual solution and could lead to an increase in error at an exponential rate.
Set the Max projection iterations to specify the maximum number of times that a projection is permitted to iterate to obtain a more accurate solution.
Set the Error tolerance to specify the desirable error tolerance to achieve after the projection.
Select Apply projection during event iterations to interpolate iterations to obtain a more accurate solution.
Constraint projection is performed using the constraint projection routine in the External Model Interface as described on The MathWorks™ website to control the drift in the result of the DAE system.
Event Handling Options
The Event Handling Options specifies whether the events are satisfied in a DAE system by using event projection in the generated C code. Use this option to improve the accuracy of a DAE system with events. If the constraint is not satisfied, the system result may deviate from the actual solution and could lead to an increase in error at an exponential rate.
Set the Max event iterations to specify the maximum number of times that a projection is permitted to iterate to obtain a more accurate solution.
Set the Width of event hysteresis band to specify the desirable error tolerance to achieve after the projection.
Event projection is performed using the event projection routine in the External Model Interface as described on The MathWorks website to control the drift in the result of the DAE system.
Note: Currently, if the model has events, they are handled using the event handling functions in the generated MsimModel.c file, and not the FMI provided Event Handling routines.
Run-time Error Reporting
Select the check box to report run-time errors in detail.
Step 4: Info Options
In the generated FMU archive file, model information (for example, variable names, units and initial values) are stored in a text file in XML format. Additional information about the model, such as the model author, description, and version, can also be included in this file.
Author: Name and organization of the model author (for example, J. Smith, Maplesoft http://www.maplesoft.com).
Description: Brief description of the model (for example, Model of a lithium-ion battery).
Version: Model version or FMU version.
Copyright: Intellectual property copyright (for example, (C) Maplesoft 2024).
License: Intellectual property licensing (for example, Proprietary, Public Domain, or BSD License).
Step 5: Export
Generating the FMU archive creates temporary files for viewing purposes.
Specify the locations for the Target Directory.
Provide a name for the generated FMU archive in FMU Archive Name.
Select Remove temporary `fmiTMPXXXXXX`directory to remove temporary files after code generation.
Select Overwrite FMU to overwrite the file if it already exists.
To generate an FMU archive click Generate FMU Archive. The file is saved to the target directory.
1.5 Viewing Examples
Within MapleSim there are many examples for you to view.
To view an example:
From the Help menu, select the Examples > BR Connector Examples submenu.
Click the entry for the model that you want to view.
Note: Some models may include additional documents, such as templates that display model equations or define custom components. These are found in the Attached Files tab.
1.6 FMU Generation Example: Slider Crank Model
In this example, you will generate an FMU archive for a Slider Crank model created in MapleSim.
To generate the FMU archive:
From the Help menu, select the Examples > BR Connector Examples submenu, and select the Slider Crank example.
In the Subsystem Selection section, select the SlidingCrank1 subsystem from the drop-down menu in the toolbar above the model diagram. This menu displays all of the subsystems and components in your MapleSim model.
Click Load Selected Subsystem. All of the app fields are populated with information specific to the subsystem displayed in the model diagram. You can now specify which subsystem parameters will be kept as configurable parameters in the generated block.
Under the Export Options section, select all the Visualization options:
In the Export section of the app, specify the target directory and name.
Click Generate FMU Archive. The FMU file is created and saved in the target directory.
Note: Generating a block may require a few minutes.
Download Help Document