+ All Categories
Home > Documents > MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim,...

MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim,...

Date post: 15-Dec-2020
Category:
Upload: others
View: 8 times
Download: 0 times
Share this document with a friend
140
MapleSim User's Guide Copyright © Maplesoft, a division of Waterloo Maple Inc. 2001-2009
Transcript
Page 1: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

MapleSim User's Guide

Copyright © Maplesoft, a division of Waterloo Maple Inc.2001-2009

Page 2: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

MapleSim User's GuideCopyrightMaplesoft, MapleSim, and Maple are all trademarks of Waterloo Maple Inc.

© Maplesoft, a division of Waterloo Maple Inc. 2001-2009. All rights reserved.

No part of this book may be reproduced, stored in a retrieval system, or transcribed, in any form or by any means— electronic, mechanical, photocopying, recording, or otherwise. Information in this document is subject to changewithout notice and does not represent a commitment on the part of the vendor. The software described in thisdocument is furnished under a license agreement and may be used or copied only in accordance with the agreement.It is against the law to copy the software on any medium except as specifically allowed in the agreement.

Java and all Java based marks are trademarks or registered trademarks of Sun Microsystems, Inc. in the UnitedStates and other countries. Maplesoft is independent of Sun Microsystems, Inc.

Macintosh is a trademark of Apple Inc., registered in the U.S. and other countries.

Microsoft, Excel, and Windows are registered trademarks of Microsoft Corporation.

Modelica is a registered trademark of the Modelica Association.

All other trademarks are the property of their respective owners.

This document was produced using a special version of Maple and DocBook.

Printed in Canada

ISBN 978-1-897310-77-9

Page 3: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

ContentsIntroduction .............................................................................................. vii1 Getting Started with MapleSim .............................................................. 1

1.1 Physical Modeling in MapleSim ...................................................... 1Acausal and Causal Modeling ........................................................... 2

1.2 The MapleSim Screen ...................................................................... 71.3 Basic Tutorial: Modeling an RLC Circuit and DC Motor ............... 8

Building an RLC Circuit Model ........................................................ 8Specifying Simulation Conditions .................................................. 13Adding Probes ................................................................................. 13Simulating the RLC Circuit Model .................................................. 14Building a Simple DC Motor Model ............................................... 15Simulating the DC Motor Model ..................................................... 17

2 Building a Model .................................................................................. 192.1 The MapleSim Component Library ............................................... 192.2 Navigating a Model ....................................................................... 202.3 Defining How Components Interact in a System .......................... 212.4 Specifying Simulation Conditions ................................................. 22

Specifying Parameter Units ............................................................. 22Specifying Initial Conditions ........................................................... 23

2.5 Creating and Managing Subsystems .............................................. 24Example: Creating a Subsystem ...................................................... 25Navigating a Subsystem ................................................................... 26Managing Subsystems .................................................................... 27Adding Multiple Subsystem Instances to a Model ......................... 28Editing Subsystem Instances ............................................................ 29

2.6 Global and Subsystem Parameters ................................................. 33Global Parameters ............................................................................ 33Subsystem Parameters ..................................................................... 34

2.7 Creating and Managing Custom Libraries ..................................... 39Example: Adding Subsystems and Attachments to a Custom Lib-rary ................................................................................................... 40Example: Editing a Subsystem in a Custom Library ....................... 42

2.8 Annotating a Model ....................................................................... 44Example: Adding a Text Annotation to a Model ............................. 45

iii

Page 4: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

2.9 Entering Text in 2-D Math Notation .............................................. 462.10 The MapleSim Document Folder ................................................. 482.11 Creating a Data Set for an Interpolation Table Component ......... 48

Example: Creating a Data Set in Maple ........................................... 493 Creating Custom Modeling Components .............................................. 51

3.1 Overview ....................................................................................... 513.2 Opening Custom Component Examples ....................................... 523.3 Example: Non-Linear Spring-Damper Component ....................... 52

Opening the Custom Component Template ..................................... 54Defining the Component Name and Equations ............................... 55Defining Component Ports .............................................................. 56Generating the Custom Component ................................................. 58

3.4 Working with Custom Components in MapleSim ......................... 593.5 Editing a Custom Component ........................................................ 59

4 Simulating and Visualizing a Model ..................................................... 614.1 How MapleSim Simulates a Model ............................................... 614.2 Simulating a Model ....................................................................... 65

Simulation Parameters ..................................................................... 65Parameter Sets .................................................................................. 68

4.3 Managing Simulation Results ........................................................ 694.4 Configuring Display Options for Simulation Graphs .................... 70

Example: Creating a Plot Window Layout ...................................... 71The Plot Window Toolbar ................................................................ 74

4.5 Visualizing a Model ....................................................................... 74The 3-D Visualization Window ....................................................... 75Viewing and Navigating 3-D Models .............................................. 76Adding Shapes to a 3-D Model ........................................................ 77Example: Adding Attached Shapes to a Double Pendulum Mod-el ....................................................................................................... 78

5 Analyzing and Manipulating a Model ................................................. 815.1 Overview ........................................................................................ 815.2 Retrieving Equations and Properties from a Model ...................... 835.3 Analyzing Linear Systems ............................................................ 845.4 Optimizing Parameters ................................................................... 855.5 Generating C Code from a Model .................................................. 885.6 Working with Maple Embedded Components .............................. 89

iv • Contents

Page 5: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

5.7 Example: Working With a Model in Maple ................................... 89Opening a MapleSim Model in an Embedded Component ............. 90Library Routines .............................................................................. 91Extracting Equations From the Model ............................................. 91Simulating the Model ....................................................................... 93

6 Advanced Tutorials ............................................................................... 956.1 Tutorial 1: Modeling a DC Motor with a Gearbox ........................ 95

Adding a Gearbox to the DC Motor Model ..................................... 95Simulating the DC Motor with Gearbox Model .............................. 97Grouping the DC Motor Components into a Subsystem ................. 98Assigning Global Parameters to a Model ........................................ 99Changing Input and Output Values ............................................... 101

6.2 Tutorial 2: Modeling a Cable Tension Controller ........................ 103Building a Cable Tension Controller Model .................................. 104Specifying Simulation Conditions ................................................ 106Simulating the Cable Tension Controller ....................................... 106

6.3 Tutorial 3: Modeling a Non-linear Damper ................................. 108Generating a Custom Spring Damper ............................................ 108Providing Damping Coefficient Values ......................................... 109Building the Non-linear Damper Model ....................................... 110Assigning a Parameter to a Subsystem ......................................... 113Simulating the Non-linear Damper with Linear Spring Model ..... 114

6.4 Tutorial 4: Modeling a Planar Slider-Crank Mechanism ............. 116Creating a Planar Link Subsystem ................................................. 117Defining and Assigning Parameters ............................................... 121Creating the Crank and Connecting Rod Elements ....................... 121Adding the Fixed Frame, Sliding Mass, and Joint Elements ......... 122Specifying Initial Conditions ......................................................... 124Simulating the Planar Slider-Crank Mechanism ............................ 124

7 Reference: MapleSim Keyboard Shortcuts ......................................... 127Index ...................................................................................................... 129

Contents • v

Page 6: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

vi • Contents

Page 7: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

IntroductionMapleSim OverviewMapleSimTM is a modeling environment for creating and simulating complexmulti-domain physical systems. It allows you to build component diagramsthat represent physical systems in a graphical form. Using both symbolicand numeric approaches, MapleSim automatically generates model equationsfrom a component diagram and runs high-fidelity simulations.

Build Complex Multi-domain Models

You can use MapleSim to build models that integrate components fromvarious engineering fields into a complete system. MapleSim features a libraryof over 300 modeling components, including electrical, mechanical, andthermal devices; sensors and sources; and signal blocks. You can also createcustom components to suit your modeling and simulation needs.

Advanced Symbolic and Numeric Capabilities

MapleSim uses the advanced symbolic and numeric capabilities of MapleTM

to generate the mathematical models that simulate the behavior of a physicalsystem. You can, therefore, apply simplification techniques to equations tocreate concise and numerically efficient models.

Pre-built Analysis Tools and Templates

MapleSim provides various pre-built templates in the form of Maple work-sheets for viewing model equations and performing advanced analysis tasks,such as parameter optimization. To analyze your model and present yoursimulation results in an interactive format, you can use Maple features suchas embedded components, plotting tools, and document creation tools. Youcan also translate your models into C code and work with them in other ap-plications and tools, including real-time simulation.

vii

Page 8: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

Interactive 3-D Visualization Tools

The MapleSim 3-D visualization environment allows you to view animated3-D graphical representations of your multibody mechanical system models.You can use this environment to validate the 3-D configuration of yourmodel and visually analyze the system behavior under different conditions.

Related ProductsMapleSim requires the latest version of Maple 13.

MaplesoftTM also offers a suite of toolboxes, packages, and other applicationsthat extend the capabilities of Maple and enhance MapleSim functionality.For a complete list of products, visit the Maplesoft web site atwww.maplesoft.com/products.

Related ResourcesFor additional resources, visit www.maplesoft.com/site_resources.

DescriptionResource

Provides system requirements and installation instructionsfor MapleSim. The MapleSim Installation Guide isavailable in the Install.html file on your MapleSim install-ation DVD.

MapleSim Installation Guide

Provides the following information:• MapleSim User's Guide: contains conceptual inform-

ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using thesoftware.

• Using MapleSim: contains instructions for modelbuilding, simulation, and analysis tasks.

• MapleSim Library Reference Guide: contains descrip-tions of the modeling components available inMapleSim.

MapleSim Help System

viii • Introduction

Page 9: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

DescriptionResource

Provides sample models from various engineering domains.These models are available in the Examples palette on theleft side of the MapleSim window.

MapleSim Examples

Getting HelpTo request customer support or technical support, visitwww.maplesoft.com/support.

Customer FeedbackMaplesoft welcomes your feedback. For comments related to the MapleSimproduct documentation, contact [email protected].

Introduction • ix

Page 10: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

x • Introduction

Page 11: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

1 Getting Started withMapleSimIn this chapter:

• Physical Modeling in MapleSim (page 1)

• The MapleSim Screen (page 7)

• Basic Tutorial: Modeling an RLC Circuit and DC Motor (page 8)

1.1 Physical Modeling in MapleSimPhysical modeling, or physics-based modeling, incorporates mathematicsand physical laws to describe the behavior of an engineering component ora system of interconnected components. Since most engineering systemshave associated dynamics, the behavior is typically defined with ordinarydifferential equations (ODEs).

To help you develop models quickly and easily, MapleSim provides thefollowing features:

Topological or “Acausal” System Representation

The signal-flow approach used by traditional modeling tools requires systeminputs and outputs to be defined explicitly. In contrast, MapleSim allowsyou to use a topological representation to connect interrelated componentswithout having to consider how signals flow between them.

Mathematical Model Formulation and Simplification

A topological representation maps readily to its mathematical representationand the symbolic capability of MapleSim automates the generation of systemequations.

When MapleSim formulates the system equations, several mathematicalsimplification tools are applied to remove any redundant equations and

1

Page 12: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

multiplication by zero or one. The simplification tools then combine andreduce the expressions to get a minimal set of equations required to representa system without losing fidelity.

Advanced Differential Algebraic Equation Solvers

Algebraic constraints are introduced in the topological approach to modeldefinition. Problems that combine ODEs with these algebraic constraints arecalled Differential Algebraic Equations (DAEs). Depending on the natureof these constraints, the complexity of the DAE problem can vary. An indexof the DAEs provides a measure of the complexity of the problem. Complex-ity increases with the index of the DAEs.

The development of generalized solvers for complex DAEs is the subject ofmuch research in the symbolic computation field. With Maple as its compu-tation engine, MapleSim uses advanced DAE solvers that incorporate leading-edge symbolic and numeric techniques for solving high-index DAEs.

Acausal and Causal ModelingReal engineered assemblies, such as motors and powertrains, consist of anetwork of interacting physical components. They are commonly modeledin software by block diagrams. The lines connecting two blocks indicate thatthey are coupled by physical laws.

When simulated by software, block diagrams can either be causal or acausal.Many simulation tools are restricted to causal (or signal-flow) modeling. Inthese tools, a unidirectional signal, which is essentially a time-varyingnumber, flows into a block. The block then performs a well-defined mathem-atical operation on the signal and the result flows out of the other side. Thisapproach is useful for modeling systems that are defined purely by signalsthat flow in a single direction, such as control systems and digital filters.

2 • 1 Getting Started with MapleSim

Page 13: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

This approach is analogous to an assignment, where a calculation is performedon a known variable or set of variables on the right hand side and the resultis assigned to another variable on the left:

Modeling how real physical components interact requires a different ap-proach. In acausal modeling, a signal from two connected blocks travels inboth directions. The programming analogy would be a simple equalitystatement:

The signal includes information about which physical quantities (for example,energy, current, torque, heat and mass flows) must be conserved. The blockscontain information about which physical laws (represented by equations)they must obey and, hence, which physical quantities must be conserved.

MapleSim allows you to use both approaches. This means you can simulatea physical system (with acausal modeling) together with the associated logicor control loop (with causal modeling) in a manner that suits either task best.

Through and Across Variables

When using the acausal modeling approach, it is useful to identify the throughand across variables of the component you are modeling. In general terms,an across variable represents the driving force in a system and a throughvariable represents the flow of a conserved quantity:

Through and Across Variables • 3

Page 14: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

For example, in an electrical circuit, the through variable, i, is the currentand the across variable, V, is the voltage drop:

The following table lists some examples of through and across variables forother domains:

AcrossThroughDomain

Voltage (V)Current (A)Electrical

Velocity (m/s)Force (N)Mechanical (translational)

Angular Velocity (rad/s)Torque (N.m)Mechanical (rotational)

Pressure (N/ )Flow ( /s)Hydraulic

Temperature (K)Heat flow (W)Heat flow

As a simple example, the form of the governing equation for a resistor is

This equation, in conjunction with Kirchhoff’s conservation of current law,allows a complete representation of a circuit.

and

4 • 1 Getting Started with MapleSim

Page 15: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

To extend this example, the following schematic diagram describes an RLCcircuit, an electrical circuit consisting of a resistor, inductor, and a capacitorconnected in series:

If you wanted to model this circuit manually, it can be represented with thefollowing characteristic equations for the resistor, inductor, and capacitorrespectively:

By applying Kirchhoff's current law, the following conservation equationsare at points a, b, and c:

Through and Across Variables • 5

Page 16: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

These equations, along with a definition of the input voltage (defined as atransient going from 0 to 1 volt, 1 second after the simulation starts)

provide enough information to define the model and solve for the voltagesand currents through the circuit.

In MapleSim, all of these calculations are performed automatically; you onlyneed to draw the circuit and provide the component parameters. These prin-ciples can be applied equally to all engineering domains in MapleSim andallow you to connect components in one domain with components in otherseasily.

In the Basic Tutorial: Modeling an RLC Circuit and DC Motor (page 8)section of this chapter, you will model the RLC circuit described above. Thefollowing image shows how the RLC circuit diagram appears when it is builtin MapleSim.

6 • 1 Getting Started with MapleSim

Page 17: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

1.2 The MapleSim ScreenThe MapleSim screen contains the following panes and components:

DescriptionComponent

Contains tools for running a simulation, viewing documentsattached to your model, and performing other common tasks.1. Main toolbar

The area in which you build and edit a model.2. Model workspace

Contains tools for laying out objects in the model workspaceand adding annotations to a model.

3. Drawing and layout tool-bar

Expandable menus containing sample models and domain-specific components that you can add to a model.4. Palettes

1.2 The MapleSim Screen • 7

Page 18: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

DescriptionComponent

Allows you to manage subsystems and navigate your modelhierarchically after components are added to the model work-space.

5. Components pane

Allows you to view and edit component properties, such asnames and parameter values; specify simulation values; andconfigure display options for simulation graphs. The contentsof this pane change depending on your selection in the modelworkspace.

6. Parameters pane

1.3 Basic Tutorial: Modeling an RLCCircuit and DC MotorThis tutorial is intended to familiarize you with the MapleSim componentlibrary and basic model development tools. It illustrates the ability to mixcausal models with acausal models.

In this tutorial, you will perform the following tasks:

1. Build an RLC circuit model.

2. Set component parameters to specify simulation conditions.

3. Add probes to specify the values to include in the simulation.

4. Simulate the RLC circuit model.

5. Modify the RLC circuit diagram to create a simple DC motor model.

6. Simulate the DC motor model under different conditions.

Building an RLC Circuit ModelTo build a model, you add components to the model workspace and connectthem in a system. In this example, the RLC circuit model contains ground,resistor, inductor, capacitor, and signal voltage source components from the

8 • 1 Getting Started with MapleSim

Page 19: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

Electrical library. It also contains a step input source, which is a signal gen-erator that drives the input voltage level in the circuit.

1. From the palettes area of the screen, click the triangle beside Electrical.In the same way, expand the Analog menu and then expand the Passivesubmenu.

2. From the Electrical → Analog → Passive menu, click and drag theGround icon to the model workspace.

1.3 Basic Tutorial: Modeling an RLC Circuit and DC Motor • 9

Page 20: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

Tip: To view the help topic associated with a modeling component, right-click (Control-click for Macintosh®) a component icon in a palette and selectHelp. You can also select a component in the model workspace and pressF2.

3. Add the remaining electrical components to the model workspace:

• From the Electrical → Analog → Passive→ Resistors menu, add theResistor component.

• From the Electrical → Analog → Passive → Inductors menu, add theInductor component.

• From the Electrical → Analog → Passive → Capacitors menu, addthe Capacitor component.

• From the Electrical → Analog → Sources → Voltage menu, add theSignal Voltage component.

4. Click and drag the components in the arrangement shown below.

5. To rotate the Signal Voltage component clockwise, right-click (Con-trol-click for Macintosh) the Signal Voltage icon in the model workspaceand select Rotate Clockwise

6. To flip the component horizontally, right-click (Control-click forMacintosh) the icon again and select Flip Horizontal. Make sure that thepositive (blue) port is at the top.

10 • 1 Getting Started with MapleSim

Page 21: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

7. To rotate the Capacitor component clockwise, right-click (Control-clickfor Macintosh) the Capacitor icon in the model workspace and select RotateClockwise.

You can now connect the modeling components in your model to define in-teractions in your system.

8. Hover your mouse pointer over the Ground component port. The port ishighlighted in green.

9. Click the Ground input port once to start the connection line.

10. Hover your mouse pointer over the negative port of the Signal Voltagecomponent.

11. Click the negative port of the Signal Voltage. The Ground componentis connected to the Signal Voltage component.

1.3 Basic Tutorial: Modeling an RLC Circuit and DC Motor • 11

Page 22: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

12. Connect the remaining components in the arrangement shown below.

You can now add a source to your model.

13. Expand the Signal Blocks palette. Expand the Sources menu and thenexpand the Real submenu.

14. Click the Step source, drag it from the palette, and place it to the left ofthe Signal Voltage component in the model workspace.

The step source has a specific signal flow, which is represented by the arrowson the connections. This flow causes the circuit to respond to the input signal.

15. Connect the Step source to the Signal Voltage component. The completeRLC circuit model is displayed below.

12 • 1 Getting Started with MapleSim

Page 23: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

Specifying Simulation ConditionsTo specify simulation conditions, you set parameter values for componentsin your model.

1. In the model workspace, click the Resistor component. The Parameterspane on the right side of the screen displays the name and parameter valuesof the resistor.

2. In the R field, enter 24, and press Enter. The resistance is changed to 24

3. Specify the following parameter values for the other components. Tospecify units for a parameter, select a value from the drop-down menu foundbeside the parameter value field.

• For the Inductor, specify an inductance of .

• For the Capacitor, specify a capacitance of

• For the Step source, specify a value of 0.1 s.

Adding ProbesTo specify the quantities to include in a simulation graph, you attach probesto lines or ports in your model. In this example, you will measure the voltageof the RLC circuit.

1.3 Basic Tutorial: Modeling an RLC Circuit and DC Motor • 13

Page 24: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

1. From the drawing and layout toolbar, click the probe icon ( ).

2. Hover your mouse pointer over the line that connects the Inductor andCapacitor components. The line is highlighted.

3. Left-click the line once. The Select probe properties dialog box is dis-played.

4. To include the voltage quantity in the simulation graph, select the Voltagecheck box.

5. To display a customized name for this quantity in the model workspace,in the Voltage field, enter Voltage.

6. Click OK. The probe is added to the connection line.

7. Drag the probe to position it on the line.

8. Click the probe once to place it on the line.

Simulating the RLC Circuit ModelTo simulate a model, you specify the duration for which to run the simulation.

14 • 1 Getting Started with MapleSim

Page 25: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

1. Click a blank area in the model workspace.

2. In the Parameters pane, set the simulation end time ( ) to 0.5 seconds

and press Enter.

3. Click the Run Simulation button located in the top-left corner of thewindow. MapleSim generates the system equations and simulates the responseto the step input.

When the simulation is complete, the voltage response is plotted in a graph.

4. Save the model as RLC_Circuit1.msim. The probes and modified para-meter values are saved as part of the model.

Building a Simple DC Motor ModelYou will now add an electromotive force (EMF) and a mechanical inertiacomponent to the RLC circuit model to create a DC motor model. In thisexample, you will add components to the RLC circuit model using the searchfeature.

1.3 Basic Tutorial: Modeling an RLC Circuit and DC Motor • 15

Page 26: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

1. In the search pane located above the palettes, in the Search field, typeEMF. A drop-down menu displays your search results.

2. Select EMF from the drop-down menu. The EMF component is displayedin the square beside the search field.

3. From the square in the search pane, click and drag the EMF icon to themodeling workspace and place it to the right of the Capacitor component.

4. In the search pane, search for Inertia.

5. Add the Inertia component to the model workspace and place it to theright of the EMF component.

6. Connect the components as shown below.

To connect the positive blue port of the EMF component, click the port once,drag your mouse pointer to the line connecting the capacitor and inductor,and click the line.

16 • 1 Getting Started with MapleSim

Page 27: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

7. In the model workspace, click the EMF component and change the value

of the transformation coefficient (k) to 10 .

8. Click the Step component and change the value of the parameter, , to

1.

Simulating the DC Motor Model1. In the model workspace, delete Probe1.

2. From the drawing and layout toolbar, click the probe icon ( ).

3. Hover your mouse pointer over the line that connects the EMF and Inertiacomponents.

4. Left-click the line once.

5. In the Select probe properties dialog box, select the Speed and Torquecheck boxes.

6. Click OK. The probe, with an arrow indicating the direction of the con-served quantity flow, is added to the model.

7. Click a blank area in the model workspace.

8. In the Parameters pane, set the simulation end time ( ) to 5 seconds

and click Run Simulation.

1.3 Basic Tutorial: Modeling an RLC Circuit and DC Motor • 17

Page 28: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

The following graphs are displayed.

9. Save the model as DC_Motor1.msim.

18 • 1 Getting Started with MapleSim

Page 29: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

2 Building a ModelIn this chapter:

• The MapleSim Component Library (page 19)

• Navigating a Model (page 20)

• Defining How Components Interact in a System (page 21)

• Specifying Simulation Conditions (page 22)

• Creating and Managing Subsystems (page 24)

• Global and Subsystem Parameters (page 33)

• Creating and Managing Custom Libraries (page 39)

• Annotating a Model (page 44)

• The MapleSim Document Folder (page 48)

• Creating a Data Set for an Interpolation Table Component (page 48)

2.1 The MapleSim ComponentLibraryThe MapleSim component library contains over 300 components for buildingmodels. Most of these components are based on the Modelica® StandardLibrary and organized in palettes according to their respective domains:electrical, 1-D and multibody mechanical, thermal, and signal blocks.

DescriptionLibrary

Components to model electrical analog circuits, single-phase and multiphase systems, and machines.Electrical

Components to model 1-D translational and rotationalsystems.1-D Mechanical

Components to model multibody mechanical systems, in-cluding force, motion, and joint components.Multibody Mechanical

19

Page 30: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

DescriptionLibrary

Components to manipulate or generate input and outputsignals.Signal Blocks

Components to model heat flow and heat transfer.Thermal

The library also contains sample models that you can view and simulate, forexample, complete electrical circuits and filters. For more information aboutthe MapleSim library structure and modeling components, see the MapleSimLibrary Reference Guide in the MapleSim help system.

To extend the default library, you can also create a custom modeling com-ponent from a mathematical model and add it to a custom library. For moreinformation, see Creating Custom Modeling Components (page 51).

2.2 Navigating a ModelWhen you add a component to the model workspace or group componentsinto a subsystem, a node is added to the model tree in the Components panebelow the model workspace. For example, the model tree of a DC motormodel is shown below.

Each node in the model tree represents a modeling component, subsystem,or connection port in your model. To browse your model, click the nodes inthe model tree. You can click the [Top] node to view the top level of yourmodel or the child nodes to view individual modeling components or subsys-tems in detail. The model tree can help you to create hierarchical levels ofmodeling components. For example, you can navigate to a subsystem nodeand then add and connect modeling components at that sublevel.

20 • 2 Building a Model

Page 31: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

2.3 Defining How ComponentsInteract in a SystemTo define how modeling components interact, you connect them in a system.You can draw a connection line between two connection ports

or between a port and another connection line.

MapleSim permits connections between compatible domains only. By default,each line type is displayed in a specific color.

Line ColorDomain

BlackMechanical 1-D rotational

GreenMechanical 1-D translational

BlackMechanical multibody

BlueElectrical analog

BlueElectrical multiphase

PurpleDigital logic

PinkBoolean signal

Navy blueCausal signal

OrangeInteger signal

RedThermal

2.3 Defining How Components Interact in a System • 21

Page 32: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

The connection ports for each domain are also displayed in specific colors.For more information, see the MapleSim Library Reference → ConnectorsOverview topic in the MapleSim help system.

2.4 Specifying Simulation ConditionsTo specify simulation conditions for a model, you set the parameter valuesfor individual modeling components. When you select a component in themodel workspace, the configurable parameter values for that component aredisplayed in the Parameters pane. Not all components provide parametervalues that you can edit.

You can enter parameter values in 2-D math notation, which is a formattingoption for adding mathematical elements such as superscripts, subscripts,and Greek characters. For more information, see Entering Text in 2-D MathNotation (page 46).

Specifying Parameter UnitsYou can use the drop-down menus beside parameter fields with dimensionsto specify units for parameter values. For example, the image below displaysthe configurable parameter fields for a Sliding Mass component. You canoptionally specify the mass in kg, lb , , or slug, and the length in m,

cm, mm, ft, or in.

22 • 2 Building a Model

Page 33: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

During a simulation, MapleSim automatically converts all parameter unitsto the International System of Units (SI). You can, therefore, select morethan one system of units for parameter values throughout a model.

If you want to convert the units of a signal, use the Unit Conversion Blockcomponent from the Signal Blocks → Signal Converters menu. This com-ponent allows you to perform conversions in dimensions such as time, tem-perature, velocity, pressure, and volume. In the following example, a UnitConversion Block component is connected between a translational PositionSensor and Feedback component to convert the units of an output signal.

If you include an electrical, 1-D mechanical, or thermal sensor in yourmodel, you can also select the units in which to generate an output signal.

Specifying Initial ConditionsTo specify initial conditions for components, you can set parameter values.When you select a component that contains state variables in the modelworkspace, the available initial condition fields are displayed in the Para-meters pane, along with the other configurable parameter values for thatcomponent.

2.4 Specifying Simulation Conditions • 23

Page 34: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

For example, the image below displays the initial velocity and position fieldsthat you can set for a sliding mass component.

You can set initial condition values for several components in the Electricaland 1-D Mechanical libraries, including capacitors, springs, and dampers.

2.5 Creating and ManagingSubsystemsA subsystem (or compound component) is a set of modeling componentsthat are grouped in a single block component. You can group componentsthat form a complete system, such as a tire or DC motor, or common com-ponents according to their domains and you can create a subsystem withinanother subsystem. For example, you can create a subsystem to perform ad-vanced analysis tasks on a group of components, improve the layout of aphysical system in the model workspace, or add multiple instances of a par-ticular system to a model.

24 • 2 Building a Model

Page 35: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

A sample DC motor subsystem is shown below.

When you create or add a subsystem, unique subscript numbers are appendedto subsystem names in the model workspace automatically. For example,the name of the first instance of a subsystem called "DC motor" would be

These numbers can help you to differentiate multiple sub-

system instances in your model.

Example: Creating a SubsystemIn the following example, you will group the electrical components of a DCmotor model into a subsystem block.

1. From the Examples → Tutorial menu, open the Simple DC Motor ex-ample.

2. Using the selection tool ( ), draw a box around the electrical components.

2.5 Creating and Managing Subsystems • 25

Page 36: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

3. From the Edit menu, select Create Subsystem.

4. In the Create Subsystem dialog box, enter DC motor.

5. Click OK. A white box, which represents the DC motor, is displayed inthe model workspace.

Navigating a SubsystemTo view the contents of a subsystem, double-click the subsystem icon in themodel workspace. The detailed view of a subsystem is displayed.

26 • 2 Building a Model

Page 37: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

In this view, a broken line indicates the subsystem boundary. You can editthe connection lines and components within the boundary, add and connectcomponents outside of the boundary, and add subsystem ports to connectthe subsystem to other components. If you want to resize the boundary, clickthe broken line and drag one of the sizing handles displayed around the box.

In addition to the model tree in the Components pane, you can use the nav-igation buttons at the top of the window ( ) to browse betweensubsystems and to parent subsystems.

Managing SubsystemsWhen you create a subsystem, an entry is added to the Subsystems panelocated below the model workspace. This pane can be displayed by clickingthe Subsystems button below the model workspace.

2.5 Creating and Managing Subsystems • 27

Page 38: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

The Subsystems pane consists of two menus:

• User menu: displays a history of subsystems created in the currentMapleSim model

• Library menu: displays a history of individual components added to thecurrent model, including components in subsystems.

You can use this pane to keep track of the subsystems that you create andedit. If you add and then delete subsystems in the model workspace, theentries remain in the Subsystems pane until you close the file or remove theentries by right-clicking them (Control-click for Macintosh) and selectingRemove from the context menu.

Adding Multiple Subsystem Instances to a ModelYou can add multiple subsystem instances to a model by dragging an entryfrom the Subsystems pane to the model workspace.

28 • 2 Building a Model

Page 39: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

As shown in the image above, a unique subscript number is appended to thename of each instance added to the model workspace. You can also copyand paste subsystems from one file to another.

Editing Subsystem InstancesWhen you edit subsystem instances in the model workspace (for example,edit a parameter value or add a shape to the subsystem icon), note the follow-ing:

• If you edit a subsystem instance in the model workspace, your changesare reflected immediately in the corresponding entry displayed in theSubsystems pane. When you drag a new instance from the Subsystemspane after editing that subsystem in the model workspace, the new in-stance and all subsequent instances that you add will contain the changes.

• If you edit a subsystem when corresponding subsystem instances arealready in the model workspace, all of the corresponding subsystem in-stances in the model workspace inherit the change.

• If you edit a subsystem instance that you pasted into another file, yourchanges are reflected only in subsystem instances in the file that youedit; corresponding subsystem instances in other files are unaffected.

Example: Editing Multiple Subsystem Instances

In this example, you will modify the resistance values and subsystem iconsin a model that contains multiple DC motor subsystems called RobotMotor.When you change the resistance value in one RobotMotor subsystem, theother RobotMotor subsystem and any new subsystem instances that youadd will inherit that change.

To start, both RobotMotor subsystems in this model have a resistance valueof 30 .

1. From the Examples → Multidomain menu, open the Sumobot example.

2.5 Creating and Managing Subsystems • 29

Page 40: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

2. In the model workspace, double-click one of the subsys-tems. The detailed view of the subsystem is displayed.

3. Select the Resistor component ( ) and, in the Parameters pane, change

the resistance value to 50 .

4. Click the Icon button above the drawing and layout toolbar.

5. Using the tool located above the model workspace, click and dragyour mouse pointer to draw a shape in the box.

6. Click Diagram above the toolbar to return to the diagram view.

30 • 2 Building a Model

Page 41: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

7. In the model tree, click [Top] to browse to the top level of the model.Both instances of the RobotMotor subsystem now display the square thatyou drew.

This change is also reflected in the entry displayed in the Subsystems pane.

If you double-click the RobotMotor subsystem instances in the modelworkspace and select their Resistor components, you will also see that bothof the instances now have a resistance value of 50

8. From the Subsystems pane, drag a new instance of the RobotMotorsubsystem and place it anywhere in the model workspace. The new instancedisplays the square that you drew and its resistance value is also 50 .

Example: Editing a Particular Subsystem Instance

If your model contains multiple subsystem instances and you want to editone of the instances only, you can copy the subsystem entry in the Subsys-tems pane and then add the copied subsystem to your model. You can thenedit the copied subsystem in the model workspace and replace existing in-stances with the copied subsystem.

1. From the Examples → Multidomain menu, open the Sumobot example.

2.5 Creating and Managing Subsystems • 31

Page 42: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

2. In the Subsystems pane, right-click (Control-click for Macintosh) theRobotMotor subsystem.

3. Select Duplicate.

4. In the Rename Subsystem dialog box, enter RobotMotor2 and click OK.A copy of the subsystem is displayed in the pane.

5. From the Subsystems pane, drag a RobotMotor2 subsystem instance inthe model workspace.

6. Click the Icon button above the drawing and layout toolbar.

7. Using the tool located above the model workspace, click and dragyour mouse pointer to draw a shape in the box.

8. In the model tree, click [Top] to browse to the top level of the model.Note that the change is not reflected in the RobotMotor subsystem instancesin your model.

You can replace a RobotMotor subsystem that is already in the modelworkspace with a RobotMotor2 subsystem to include a modified versionof the subsystem in your model.

32 • 2 Building a Model

Page 43: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

2.6 Global and SubsystemParametersGlobal ParametersA global parameter is a common parameter value that you can define andassign to multiple components in your model. This feature allows you to editparameter values that are shared by multiple components in a central table.First, at the top level of your model, you define a global parameter with anumeric value in the parameter editor. In the following example, a parameterfor a global resistance value is defined.

You can then assign that parameter as a variable or function of a variable tothe component parameters in your model; the individual components willthen inherit the numeric value of the global parameter that you defined. Inthe following example, the variable GlobalResistance is assigned as theresistance value for a resistor component called .

The component therefore inherits the numeric value of the variable

GlobalResistance (in this example, 1).

If you change the numeric value of GlobalResistance in the parameter editor,the change would also apply to any components that have been assigned theparameter as a variable.

2.6 Global and Subsystem Parameters • 33

Page 44: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

To view an example, see Tutorial 1: Modeling a DC Motor with a Gear-box (page 95) in Chapter 6 of this guide.

Subsystem ParametersA subsystem parameter is a custom parameter that you define and then assignto modeling components in a subsystem.

Subsystem parameters are similar to global parameters in that they also allowyou to edit parameter values that are shared by multiple components. Subsys-tem parameters, however, are only accessible to components in the subsystemin which they are defined and all nested subsystems. In this case, you definethe parameter value in the parameter editor at the subsystem level (that is,after double-clicking a subsystem block in the model workspace) and assignthe parameter as a variable or as a function of a variable to components inthat particular subsystem.

To view an example, see Tutorial 3: Modeling a Non-linearDamper (page 108) in Chapter 6 of this guide.

Creating Parameter Blocks

You can create a parameter block to define a set of subsystem parametersand map them to symbolic names. This method of defining parameter valuesallows you to edit parameter values that are shared by multiple instances ofa component and reuse sets of parameter values in other models.

The following image shows a parameter block that has been added to themodel workspace.

When you double-click this block, the Parameter Editor is displayed. Thisview allows you to define parameter values for the block.

34 • 2 Building a Model

Page 45: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

After defining parameter values, you can then assign them as a variable orfunction of a variable to the component parameters in your model.

To use parameter values in another model, you can add a parameter blockto a custom library. For more information about custom libraries, see Creatingand Managing Custom Libraries (page 39).

Example: Creating and Using a Parameter Block

In this example, you will create a set of parameters that can be shared bymultiple components in your model. By creating a parameter block, you onlyneed to edit parameter values in one location to compare results when yourun multiple simulations.

1. From the Examples → Mechanical menu, open the PreLoad example.

2. From the toolbar, click the button.

3. Click anywhere in the model workspace. The Create Parameter Blockdialog box is displayed.

4. Specify a parameter block name SlidingMassParams and click OK.

5. Double-click the SlidingMassParams parameter block in the modelworkspace. The Parameter Editor view is displayed.

2.6 Global and Subsystem Parameters • 35

Page 46: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

6. Click the New Parameter field and define a parameter called MASS.

7. Press Enter.

8. Specify a default value of 5 and enter the description Mass of the slidingmass.

9. In the same way, define the following parameters and values.DescriptionDefault

ValueName

Length of the sliding mass.2LENGTH

Initial velocity of the sliding mass.1

Initial position of the sliding mass.1

Tip: To enter a subscript, press the underscore character ( _ ) and type thevalue to include in the subscript. To move the cursor out of the subscriptposition, press the right arrow key on your keyboard.

The parameter editor appears as follows when the values are defined:

10. To switch back to the diagram view, click [Top] in the model tree. Whenyou click the parameter block in the model workspace, the parameters thatyou defined are displayed in the Parameters pane.

36 • 2 Building a Model

Page 47: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

11. In the model workspace, select one of the Sliding Mass components inthe diagram.

12. In the Parameters pane, specify the following values.

The parameters of this Sliding Mass component now inherits the numericvalues that you defined in the parameter block.

13. In the same way, assign the same values to the parameters of the otherSliding Mass components in the model.

14. In the model workspace, delete Probe1.

2.6 Global and Subsystem Parameters • 37

Page 48: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

15. Right-click (Control-click for Macintosh) Probe2 and select Edit Probe.

16. Clear the check box beside Speed.

17. To simulate the model, click Run Simulation. The following simulationgraph is displayed.

18. In the model workspace, click the parameter block.

19. In the Parameters pane, change the mass to 25, the length to 10, and theinitial velocity to 5. These changes apply to all of the Sliding Mass compon-ents to which you assigned the symbolic parameter values.

20. Simulate the model again. Another simulation graph, which you cancompare to your first first graph, is displayed. In this example, the curveshifts vertically after running a simulation with the new parameter values.

38 • 2 Building a Model

Page 49: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

2.7 Creating and Managing CustomLibrariesYou can create a custom library to save a collection of subsystems, custommodeling components, or attachments that you plan to reuse in multiple files.Custom libraries are displayed in custom palettes below the Examples paletteand saved as .msimlib files on your computer.

A sample custom palette with a subsystem is shown below.

2.7 Creating and Managing Custom Libraries • 39

Page 50: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

Example: Adding Subsystems and Attachmentsto a Custom Library1. From the Examples → Multidomain menu, open the Sliding Table ex-ample.

2. Click the Subsystems button below the model workspace to display theSubsystems pane.

3. From the File menu, select Create Library...

4. Specify the path and name of the .msimlib file that will store the customlibrary.

Note: The file name that you specify will appear as the custom palette namein the MapleSim interface.

5. Click Save. The Add to User Library dialog box is displayed.

6. Select the check box beside Motor to add the subsystem to the customlibrary.

7. Select the check box beside AdvancedAnalysis.mw to add the attachmentto the custom library.

40 • 2 Building a Model

Page 51: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

8. Click OK. A new custom library is added at the left of the MapleSimwindow.

This palette will be displayed in the window the next time you startMapleSim.

9. In the Linear Table palette, click Attachments. The Library Attach-ments dialog box is displayed. This dialog box lists all of the attachmentsthat you have added to the custom library.

It also contains buttons that allow you to add attachments to the documentfolder of another model and open attachments in their associated applications.

10. Close the dialog box.

2.7 Creating and Managing Custom Libraries • 41

Page 52: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

Example: Editing a Subsystem in a Custom LibraryUsing the Linear Table custom library that you created in the previoussection, you will edit the [Linear Table] Motor subsystem instance addedto the library.

1. Open a new MapleSim document.

2. From the Linear Table custom palette, drag an instance of the [LinearTable] Motor subsystem to the model workspace.

3. Double-click the subsystem block to view its contents.

4. Click the Icon button above the drawing and layout toolbar.

5. Using the tool located above the model workspace, click and dragyour mouse pointer to draw a shape in the box.

42 • 2 Building a Model

Page 53: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

6. Click Diagram above the toolbar to return to the diagram view.

7. In the model tree, click [Top] to browse to the top level of the model. Thesquare that you drew appears in the subsystem instances in the modelworkspace and Subsystems pane. Note that the subsystem instance in theLinear Table palette does not inherit the change.

8. To update the instance in the Linear Table custom library, drag the sub-system icon from the Subsystems pane and place it in the Linear Tablepalette.

The following dialog box is displayed.

2.7 Creating and Managing Custom Libraries • 43

Page 54: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

This dialog box allows you to keep the existing version of the subsystem,update the subsystem in the custom palette, or add an instance of the updatedsubsystem to the custom palette.

9. To replace the library entry with a subsystem entry that contains thechanges you just made in the model workspace, click Replace. The libraryentry is updated.

The Linear Table palette will contain the updated subsystem the next timeyou start MapleSim. If you want to rename the library entry, right-click(Control-click for Macintosh) the icon in the Linear Table palette, selectRename, and enter a new subsystem name.

2.8 Annotating a ModelYou can use the tools in the drawing and layout toolbar to draw lines, arrows,and shapes in the model workspace. MapleSim also provides many tools for

44 • 2 Building a Model

Page 55: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

customizing the color, line style, and fill of lines and shapes, and laying outobjects in the model workspace.

You can use the tool in the drawing and layout toolbar to add text annota-tions to your model. In text annotations, you can format enter mathematicaltext in 2-D math notation and modify the style, color, and font of the text.For more information about 2-D math notation, see Entering Text in 2-DMath Notation (page 46).

Example: Adding a Text Annotation to a Model1. From the Examples → Tutorial palette, open the Simple DC Motor ex-ample.

2. From the drawing and layout toolbar, click the text tool icon ( ).

3. In the model workspace, draw a text box for an annotation below the Stepcomponent. When you release your left mouse button, the toolbar above themodel workspace switches to the text formatting toolbar.

4. Enter "This block generates a step signal with a height of 1."

5. Select the text that you entered and change the font to Arial.

6. Click anywhere outside of the text box.

2.8 Annotating a Model • 45

Page 56: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

7. Draw another text box below the Inertia component.

8. Enter the following text "Inertia with a value of 0 rad."

Tip: To enter the omega character ( ), press F5 to switch to the 2-D math

mode, type "omega", and then press Ctrl + Space (Windows), Ctrl + Shift+ Space (Linux), or Command + Shift + Space (Macintosh). To enter thesubscript value, enter an underscore character ( _ ) followed by 0. Press theright arrow key to move the cursor from the subscript position.

9. Click anywhere outside of the text box.

10. Select the text that you entered and change the font to Arial.

2.9 Entering Text in 2-D MathNotationIn parameter values and annotations, you can enter text in 2-D math notation,which is a formatting option for adding mathematical elements such as sub-scripts, superscripts, and Greek characters. This option also provides acommand and symbol completion feature, which automatically suggestsMaple commands or mathematical symbols to insert as you enter a phrasein 2-D math notation.

46 • 2 Building a Model

Page 57: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

The following table lists common key combinations for 2-D math notation:ExampleKey CombinationTask

-F5Switch between text and 2-Dmath mode (annotations only)

-

1. Enter the first few characters of asymbol name, Greek character, or Maplecommand.2. Enter one of the following key combin-ations:Ctrl + Space (Windows)Ctrl + Shift + Space (Linux)Command + Shift + Space (Macintosh)3. From the pop-up menu, select thesymbol or command that you want toinsert.

Command and symbol comple-tion (parameter values and an-notations only)

underscore ( _ )Enter a subscript

caret (^)Enter a superscript

Enter sqrt and press Ctrl (or Commandfor Macintosh) + Space.Enter a square root

Enter nthroot and press Ctrl (or Com-mand) + Space.Enter a root

forward slash (/)Enter a fraction

Ctrl (or Command) + Shift + REnter a piecewise, matrix, orvector row

Ctrl (or Command) + Shift + CEnter a table column

For more information, see Using MapleSim → Building a Model → An-notating a Model → Key Combinations for 2-D Math Notation in theMapleSim help system.

2.9 Entering Text in 2-D Math Notation • 47

Page 58: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

2.10 The MapleSim Document FolderThe MapleSim document folder provides pre-built worksheets that you canuse to perform analysis tasks in Maple, create custom modeling components,and generate a data set for a model. You can also use the document folderto attach files in any format to a model, for example, spreadsheets or designdocuments created in external applications. When you attach files in theMapleSim document folder, those files are associated with the model currentlyopen in MapleSim.

The following is an image of a document folder that contains a customcomponent template called NonLinearMSD and an attachment calledDamperCurve.csv.

To open the document folder, click the View Document Folder... button atthe top of the window. For more information about performing analysis tasks,see Analyzing and Manipulating a Model (page 81) in this guide.

2.11 Creating a Data Set for anInterpolation Table ComponentYou can create a data set to provide values for an interpolation table compon-ent in your model. For example, you can provide custom values for inputsignals, and electrical Current Table and Voltage Table sources. To create

48 • 2 Building a Model

Page 59: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

a data set, you can either attach a Microsoft® Excel® spreadsheet or comma-separated values (.csv) file that contains the custom values, or you can createa data set in Maple using the Data Generation Template provided in theMapleSim document folder.

Example: Creating a Data Set in MapleIn this example, you will use the Data Generation template to create a dataset for a MapleSim interpolation table component. To create a data set, youcould use any Maple commands. For demonstration purposes, you will createa data set using a computation that has already been defined.

1. In MapleSim, from the Signal Blocks → Interpolation Tables menu,add a 1D Lookup Table component to the model workspace.

2. Click View Document Folder... above the drawing and layout toolbar.

3. From the drop-down menu, select Data Generation.

4. Click New.

5. Enter My First Data Set and click OK.

6. In the document list, select My First Data Set and click Open Selected.The Data Generation Template is opened in Maple.

7. To execute the entire worksheet, click at the top of the window.

8. At the bottom of the template, in the Data set name field, enterTestDataSet.

9. To make the data set available in MapleSim, click the Attach Data inMapleSim button.

10. In MapleSim, click View Document Folder... The data set file(TestDataSet.mpld) is displayed in the list.

You can now assign this data set to the interpolation table component in themodel workspace.

2.11 Creating a Data Set for an Interpolation Table Component • 49

Page 60: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

11. Select the 1D Lookup Table component.

12. In the Parameters pane, from the data drop-down menu, select theTestDataSet.mpld file.

13. Save the Data Generation Template in Maple and then save your modelin MapleSim.

50 • 2 Building a Model

Page 61: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

3 Creating Custom ModelingComponentsIn this chapter:

• Overview (page 51)

• Opening Custom Component Examples (page 52)

• Example: Non-Linear Spring-Damper Component (page 52)

• Working with Custom Components in MapleSim (page 59)

• Editing a Custom Component (page 59)

3.1 OverviewTo extend the MapleSim library, you can create custom modeling componentsthat are based on mathematical models that you define. For example, youcan create a custom component to contain a particular subsystem and toprovide specialized functionality.

By using the Custom Component Template, which is a Maple worksheetincluded in the MapleSim document folder, you perform the following tasksin Maple to create a custom component:

• Define the component equations and properties that determine the beha-vior of the component (for example, parameters and port variables)

• Test and analyze your mathematical model

• Define and add ports to the component

• Generate the component and make it available in MapleSim

The Custom Component Template contains pre-built embedded componentsthat allow you to perform these tasks. Each generated custom component isassociated with a particular template and each template can be associatedwith one .msim file at a time.

51

Page 62: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

3.2 Opening Custom ComponentExamplesThe following Custom Component Template examples are available withyour MapleSim installation:

• Custom component defined with an algebraic equation

• A sample DC motor component defined with a differential equation

• A sample non-linear spring-damper component

• Custom component defined with a transfer function

To open an example:

1. In MapleSim, click View Document Folder... at the top of the window.

2. Click More Templates...

3. In the Browse Templates dialog box, open the Component Templatesfolder.

4. Select the example that you want to open, and click Attach Template...

5. In the Enter Document Name dialog box, enter a name for the template.

6. Click OK.

7. In the document list, select the template entry and click Open Selected.The sample Custom Component Template is opened in Maple.

3.3 Example: Non-LinearSpring-Damper ComponentIn this example, you will use the Custom Component Template to create anon-linear spring-damper custom component. The equations defined in thisexample are based on the Translational Spring Damper component in

52 • 3 Creating Custom Modeling Components

Page 63: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

MapleSim. In this case, the stiffness and damping coefficients are replacedwith functions that are added as inputs to the component.

To obtain the governing relationships, you can start with a free-body diagram.The diagram for the spring-damper system is shown below:

The end points, a and b, can be defined as the ports for the component; theequations are derived relative to these ports. Therefore, the general equationof motion,

where is the damping coefficient, is the stiffness of the spring, and

is the relative displacement between the two ports and , can be

written as

3.3 Example: Non-Linear Spring-Damper Component • 53

Page 64: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

Also, an examination of the net force on the system shows that ,

where

All of the above relationships are required to define the behavior of the sys-tem.

Opening the Custom Component TemplateTo start, open the Custom Component Template from the MapleSim docu-ment folder.

1. In MapleSim, open the model to which you want to add the custom com-ponent.

2. Click View Document Folder... above the drawing and layout toolbar.

3. From the drop-down menu, select Custom Component.

4. Click New.

5. Enter Non-linear Spring-Damper as the name for the template and clickOK.

54 • 3 Creating Custom Modeling Components

Page 65: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

6. In the document list, select the template entry and click Open Selected.The Custom Component Template is opened in Maple.

Defining the Component Name and EquationsYou can now specify the name that will be displayed for the component inthe MapleSim interface, a variable to store the equations, and the equationsthemselves.

To define the component equations, you create a system model by usingcommands from the DynamicSystems package. For more information, seethe ?DynamicSystems help topic in the Maple help system.

1. In the Component Description section of the template, specify a compon-ent name called NonLinearSpringDamper.

2. Delete the default equations below the table that defines the variables.

3. To define the non-linear system, enter the following equations.

3.3 Example: Non-Linear Spring-Damper Component • 55

Page 66: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

Note that the equations are entered as a Maple list. The constants,

(damping) and (stiffness) are replaced by the functions and to define them as input states to the system.

4. To assign the equations and the input and output definitions to a systemobject variable called sys, enter the following:

You can now assign these input and output variables to ports that you willinclude in your generated custom component.

Defining Component PortsIn the Component Ports section of the template, you assign input and outputvariables to ports that will appear in the generated component and specifythe layout of the ports.

1. To remove the sample ports from the diagram, click Clear All Ports.

2. Click the Add Port button four times. Four squares, which represent theports that you will define and lay out, are displayed in the diagram.

3. Select the port on the left side of the diagram.

56 • 3 Creating Custom Modeling Components

Page 67: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

4. From the Port Type drop-down menu below the diagram, select Transla-tional Flange.

5. In the Port Components table, in the Position row, select sb(t) from thedrop-down menu and, in the Force row, select Fb(t) from the drop-downmenu.

6. Select the port on the right side of the diagram.

7. From the Port Type drop-down menu, select Translational Flange.

8. In the Position row, select sa(t) from the drop-down menu and, in theForce row, select Fa(t) from the drop-down menu.

9. Select the port at the top of the diagram.

10. From the Port Type drop-down menu, select Real Signal Input.

11. In the Value row, select c(t) from the drop-down menu.

12. Select the port at the bottom of the diagram.

13. From the Port Type drop-down menu, select Real Signal Input.

14. In the Value row, select d(t) from the drop-down menu.

15. In the toolbar above the worksheet, make sure that the tool is selected.

16. Drag the port that you just defined and place it at the top of the diagram.You can also drag the other port to position it.

3.3 Example: Non-Linear Spring-Damper Component • 57

Page 68: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

The left port a is a standard translational flange, which is associated withthe position sa(t) and force Fa(t). The left port is another translational flange,which is associated with the position sb(t) and force Fb(t). The two ports atthe top are signal inputs. The port at the top-left has been added for thestiffness c(t) and the port at the top-right has been added for the dampingd(t).

The ports will be displayed in this arrangement in the generated the customcomponent.

Generating the Custom ComponentTo generate the custom component, click the Generate MapleSim Compon-ent button at the bottom of the template. When it is generated, the customcomponent is displayed in the Subsystems pane in MapleSim.

58 • 3 Creating Custom Modeling Components

Page 69: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

3.4 Working with CustomComponents in MapleSimIn MapleSim, you can manipulate a custom component in the followingways:

Add Text and Illustrations to a Custom Component

To customize the appearance of a custom component, you can change thedefault images that are displayed in the component icon. Select the customcomponent in the model workspace, click Icon above the toolbar, and usethe drawing and annotation tools to add text and illustrations.

Save a Custom Component as Part of the Current Model

To save a custom component as a part of the current model, add the compon-ent by dragging it into the model workspace and then save the model. Thenext time you open the file, the custom component will be displayed in themodel workspace and in the Subsystems pane.

Add a Custom Component to a Custom Library

If you want to use a custom component in a file other than the current model,add that component to a custom library. For more information, see Creatingand Managing Custom Libraries (page 39).

3.5 Editing a Custom ComponentIf you want to edit a custom component that you have generated, make yourchanges in the corresponding Maple worksheet and regenerate the component.

1. In the model workspace, double-click the custom component that youwant to edit. The corresponding Custom Component Template is opened inMaple.

2. In the Maple worksheet, edit the equations, properties, or port values.

3.4 Working with Custom Components in MapleSim • 59

Page 70: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

3. At the bottom of the worksheet, click Generate MapleSim Component.Your changes are generated in the custom component displayed in MapleSim.

4. Save your changes in the .mw file and the .msim file to which you addedthe custom component.

60 • 3 Creating Custom Modeling Components

Page 71: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

4 Simulating and Visualizing aModelIn this chapter:

• How MapleSim Simulates a Model (page 61)

• Simulating a Model (page 65)

• Managing Simulation Results (page 69)

• Configuring Display Options for Simulation Graphs (page 70)

• Visualizing a Model (page 74)

4.1 How MapleSim Simulates a ModelModel DescriptionEach component in your model contains a system of equations that describesits behavior: these systems of equations can consist of purely algebraicequations or differential equations. Also, a component may define anynumber of events, which can change the component behavior during a simu-lation by enabling or disabling part of the equations in the system or changingstate values. Connections between two or more components generate addi-tional equations that describe how these components interact.

Modelica DescriptionThe equations for many of the components from the MapleSim componentlibrary are described using the Modelica physical modeling language. Theequations for multibody components, on the other hand, are generated by aspecial-purpose engine, which takes advantage of advanced mathematicaltechniques to ensure the equations are as concise and efficient as possible.These equations are also converted to Modelica.

For more information about Modelica, visit www.modelica.org.

61

Page 72: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

System EquationsThe next step in the simulation process is to collect all of these equationsinto one large system. Parameter values are also substituted in during thisphase. Now, the MapleSim simulation engine has a potentially large systemof hybrid differential algebraic equations. Essentially, this means that thesystem has differential equations with algebraic constraints, as well as discreteevents.

Simplified EquationsA process called "index reduction" reduces the algebraic constraints as muchas possible. Other symbolic simplification techniques also reduce the numberof equations and variables. Note that algebraic constraints may still be presentin the equations after this step. No information is lost during simplificationand the full accuracy is preserved. At this point, initial values for all of thevariables remaining in the system of equations must be computed. This is anon-trivial step because, typically, only a small number of the initial equationsis fixed in the system model. The remainder of the initial conditions mustbe computed in such a way that the resulting set is consistent. You can fixinitial values for some of the variables by specifying parameter values forcertain components in the Parameters pane. If the supplied initial conditionsare not consistent, an error will be detected during the simulation.

InitializationAfter all of these pre-processing steps are complete, the numeric solvingprocess can begin. A sophisticated differential algebraic equation (DAE)solver based on the Rosenbrock integrator (for stiff systems) or rkf45 integ-rator (for non-stiff systems) is used to numerically integrate the system ofequations. Algebraic constraints are constantly monitored to avoid constraintdrift, which would otherwise affect the solution accuracy. The stiff solveris used by default; it is a good choice for typical systems. In some cases, thenon-stiff solver will offer better performance; it is a good option for modelswhere all quantities vary at approximately the same rate.

62 • 4 Simulating and Visualizing a Model

Page 73: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

Numeric Integration and Event HandlingDuring the numeric solving (or "integration"), inequality conditions that arepart of the model are monitored and event is detected when one or more ofthese conditions change. Whenever such an event is encountered, the numericsolver is stopped and the simulation engine computes a new configurationof the system of equations based on the event conditions. This step also in-volves recomputing initial conditions for the new system configuration. Thesolver is then restarted and continues to numerically solve the system untilanother event is triggered or the simulation end time is reached.

Simulation ResultsIn the last step of the simulation process, the results are generated and dis-played using graphs showing the quantities of interest and, optionally formultibody mechanical systems, a 3-D visualization window.

Numeric Integration and Event Handling • 63

Page 74: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

The simulation process is summarized in the following chart:

Note that the information in this section is a simplified description of thesimulation process. For more information on the DAE solvers used by thesimulation engine, see the ?dsolve,numeric help topic in the Maple helpsystem.

64 • 4 Simulating and Visualizing a Model

Page 75: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

4.2 Simulating a ModelTo include certain quantities in simulation graphs, you add probes to connec-tion lines, ports, or components in your model. In MapleSim, probes allowyou to run simulations with the variables associated with connection ports.

If you add a probe to measure a through variable, an arrow is displayed toindicate the direction of the positive flow in the model workspace.

You can specify the duration for which to run a simulation, the solver touse, and other parameter values for the solver and simulation engine. Afterrunning a simulation, a separate graph is displayed for each specifiedquantity. You can then change the original probe or parameter values andrun another simulation to compare the results.

Simulation ParametersIn the Parameters pane, you can specify the duration of the simulation and,optionally, parameter values for the solver and simulation engine.

DescriptionDefaultParameter

End time of the simulation. You can specify any positivevalue, including floating-point values.

Note: For all simulations, the initial start time is 0.10

4.2 Simulating a Model • 65

Page 76: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

DescriptionDefaultParameter

DAE solver used during the simulation.• true: use a stiff DAE solver (Rosenbrock method).

• false: use a non-stiff DAE solver (rkf45 method).If your physical model is complex, you may want to usea stiff DAE solver to reduce the time required to simulatea model.

falsestiff solver

Specifies whether an adaptive solver or a fixed-stepsolver is used to determine sampling periods for the sim-ulation.• true: use an adaptive solver. The sampling periods,

as determined by the solver, vary throughout thesimulation.

• false: use a fixed-step solver. The sampling periodsare a uniform step size throughout the simulation. Youcan specify the size in the step size field.

If the state of your model changes rapidly, you may wantto use a fixed-step solver to reduce the time required torun the simulation.

Note: When a fixed-step solver is used, fewer samplingperiods may be represented in the simulation results. Forthe most accurate results, use an adaptive solver to runthe simulation.

trueadaptive

Uniform size of the sampling periods if you are using afixed-step solver to run the simulation. You can specifya floating-point value for this option when the adaptivefield is set to false.

0.0010step size

The limit on the absolute error tolerance for a successfulintegration step if you are using an adaptive solver to runthe simulation. You can specify a floating-point value forthis option when the adaptive field is set to true.

The limit on the relative error tolerance for a successfulintegration step if you are using an adaptive solver to runthe simulation. You can specify a floating-point value forthis option when the adaptive field is set to true.

66 • 4 Simulating and Visualizing a Model

Page 77: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

DescriptionDefaultParameter

Minimum number of points to be plotted in the simulationgraph. The data points are distributed evenly in the graphaccording to the simulation duration value. You can spe-cify a positive integer.

Note: This option allows you to specify the number ofpoints for display purposes only. The actual number ofpoints used during the simulation may differ from thenumber of points displayed in the simulation graph.

200plot points

Specifies whether a native C compiler is used during thesimulation. When this option is set to true, Maple proced-ures generated by the simulation engine are translated toC code, which is compiled by an external C compiler.

If your physical model is complex, you may want to setthis option to true to reduce the time required to run asimulation.

falsecompiler

Maximum number of integration steps that occur beforethe simulation stops automatically. You can specify apositive value, or a value of zero or infinity.

If your physical model is complex, you may want to in-crease this value to prevent the simulation from stoppingbefore it is complete.

400000max. steps

You can specify the following parameter values for models containingmultibody mechanical components:

DescriptionDefaultParameter

Direction of gravity.

The acceleration due to gravity of Earth at the

surface. The default units are in .9.81

Specifies whether the 3-D visualization window is dis-played after running a simulation. When this option is setto false, the window is not displayed.

true3-D animation

4.2 Simulating a Model • 67

Page 78: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

DescriptionDefaultParameter

Specifies the duration of the 3-D animation. Thisvalue can differ from the value, which, in

comparison, specifies the simulation durationrepresented in your simulation graphs. You canspecify a floating-point value for this optionwhen the 3-D animation field is set to true.

You can use this option to decrease or increasethe speed at which an animation is played. Forexample, if the value is set to 0.5 seconds and

the 3-D playback time value is set to 10seconds, the 0.5 second simulation will beplayed back over 10 seconds and will thereforebe animated at a slower speed. If you specify a3-D playback time value of 20 seconds whenthe value is set to 0.5 seconds, the 0.5 second

simulation will be played back over 20 secondsand will be animated at a faster speed.

-3-D playbacktime

Number of data points to include per second in the anim-ation. You can specify a positive integer for this optionwhen the 3-D animation field is set to true.

303-D samplingrate

Parameter SetsYou can store a group of parameter values assigned to a model in a parameterset. You can run a simulation using one parameter set, replace those parametervalues with another parameter set, and run another simulation to comparethe results.

For more information, see the Using MapleSim → Building a Model →Saving and Managing Parameter Sets section in the MapleSim help system.

68 • 4 Simulating and Visualizing a Model

Page 79: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

4.3 Managing Simulation ResultsDuring a simulation, progress messages are displayed in the Results Managerwindow. These messages inform you of the status of the MapleSim engineas it generates a mathematical model and can help you to troubleshoot poten-tial simulation errors.

The Manage Results panel at the top of the window allows you to view,manage, and export results for multiple simulations. When you run a simu-lation, an entry is added to the panel and the details associated with thatsimulation are stored. You can click an entry to view the graphs and progressinformation for a previous simulation. This feature allows you to compareand refer to multiple simulation graphs easily. It also allows you to export

4.3 Managing Simulation Results • 69

Page 80: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

your simulation data to a Microsoft Excel (.xls) or comma-separated value(.csv) file.

Optionally, before running a simulation, you can specify the amount of detaildisplayed in progress messages by selecting a level from the Messages drop-down menu at the top of the window.

4.4 Configuring Display Options forSimulation GraphsBefore running a simulation, you can use the Plots tab on the right side ofthe MapleSim screen to configure various options for simulation graphs inthe plot window.

For example, you can specify which expressions are plotted along certainaxes, a plot title, and the layout of graphs in the plot window. After you run

70 • 4 Simulating and Visualizing a Model

Page 81: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

a simulation, a custom plot window with the layout attributes that you spe-cified in the Plots tab is displayed in addition to the default plot window.You can store multiple plot window layouts and select the one you want touse when you run a simulation.

Example: Creating a Plot Window LayoutIn this example, you will create a plot window layout to display multiplecurves in the generated simulation graphs.

1. From the Examples → Multidomain menu, open the Controlled 2 LinkRobot example.

2. In the Parameters pane, click the Plots tab. The following table, whichdisplays all of the selected probe quantities, is displayed.

This table displays the default layout of the graphs in the plot window. Forexample, this table indicates that the graph for the Joint1:Angle value willbe displayed in the top-left corner of the plot window, the graph for theJoint1:Torque value will be displayed in the top-right corner of the plotwindow, and so on after you run a simulation.

You will now create a custom plot window that displays both of the anglevalues in one graph and both of the torque values in another graph.

4.4 Configuring Display Options for Simulation Graphs • 71

Page 82: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

3. From the drop-down list at the top of the pane, select Add Window.

4. In the Create Plot Window dialog box, specify a plot window layoutname Angle and Torque Comparison.

5. In the Columns field, type 2 and press Enter. The table in the pane nowcontains two cells; each cell represents a plot window area that you canconfigure.

6. Click Empty in the left cell.

7. In the Title field, enter Angle.

8. From the Primary Y-axis drop-down menu, select Joint1: Angle.

9. Click [Add Variable] below the drop-down menu.

10. From the second Primary Y-axis drop-down menu, select Joint2: Angle.

11. In the table at the top of the pane, click Empty in the top-right cell.

12. In the Title field, enter Torque.

13. From the Primary Y-axis drop-down menu, select Joint1: Torque.

14. Click [Add Variable] below the drop-down menu.

15. From the second Primary Y-axis drop-down menu, select Joint2:Torque. You can now simulate the model using the new plot window layout.

72 • 4 Simulating and Visualizing a Model

Page 83: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

16 Make sure that the Show Window check box below the table at the topof the Parameters pane is selected.

17. Click Run Simulation at the top-left of the MapleSim window. Thefollowing custom plot window, which compares the angle values in onegraph and the torque values in another, is displayed in addition to the defaultplot window.

If you want to display the default plot window only, clear the Show Windowcheck box on the Plots tab in the Parameters pane and simulate your modelagain.

4.4 Configuring Display Options for Simulation Graphs • 73

Page 84: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

The Plot Window ToolbarAfter running a simulation, you can use the tools and menus in the plotwindow toolbar to specify display options for curves, axes, and gridlines;navigate simulation graphs; and export simulation graphs to several imageformats.

For more information about these tools, see the Using MapleSim → Simu-lating a Model → Working with Simulation Graphs section of theMapleSim help system.

4.5 Visualizing a ModelIn MapleSim, the 3-D visualization environment allows you to view animated3-D graphical representations of multibody mechanical systems. You canview the components in your model as 3-D graphic objects and visualizeyour simulation results by playing an animation that depicts the projectedmovement of these components. As you build a model and change its para-meters, you can validate its 3-D configuration and visually analyze the systembehavior under different conditions.

74 • 4 Simulating and Visualizing a Model

Page 85: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

In the 3-D visualization environment, you can view your model from allangles in 3-D space and control animation playback options to focus oncertain components and animation frames. You can also add shapes andlines, including geometry imported from an external CAD file, to create amore realistic representation of your model.

For more information about adding geometry and using the 3-D visualizationenvironment, see the Using MapleSim → Visualizing a Model section ofthe MapleSim help system.

The 3-D Visualization WindowAfter simulating a multibody mechanical system, the simulation graphs aregenerated and then the 3-D visualization window is displayed. This windowcontains the following components:

4.5 Visualizing a Model • 75

Page 86: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

DescriptionComponent

Contains tools for hiding and displaying components in the window,changing the 3-D model view, and specifying camera tracking op-tions.

1. Toolbar

The area in which you view and animate a 3-D model. The arrowsindicate the directions of the world axes, which are displayed inthe following colors:

• X - blue

• Y - red

• Z - green

2. Viewport

Controls for animating a 3-D model.3. Playback controls

You can hover your mouse pointer over any of the buttons to view their de-scriptions.

Viewing and Navigating 3-D ModelsIn the viewport, you can view and navigate a 3-D model from the perspectiveview or one of the orthographic views. The perspective view allows you toexamine and navigate a model from all angles in 3-D space. It allows youto see 3-D spatial relationships between elements in your model because theperspective effect displays objects closer to you and larger than those thatare further away from the camera.

The orthographic view allows you to examine a model from a particulardirection (top, front, or side) that is perpendicular to the plane on which themodel is displayed. In this view, your model appears as a flat, two-dimen-sional object because the lines that comprise your model are parallel to theprojection plane. In this view, the scale of the objects are preserved, so thisview can be useful for analyzing the spatial relationship between two objectsin two-dimensional space.

You can navigate a model and change the model view while an animationis playing. In both types of views, you can pan and zoom into or out fromyour model. In the perspective view, you can also "tumble" the camera to

76 • 4 Simulating and Visualizing a Model

Page 87: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

view your model from above or below, and from any direction around yourmodel.

Adding Shapes to a 3-D ModelBy default, basic spheres and cylinders called implicit geometry are displayedin the viewport to represent physical components in your model. For example,consider the following double pendulum model created in MapleSim.

This model contains two revolute joints and two subsystems that representplanar links.

After you run a simulation, the implicit geometry of the pendulum model isdisplayed as follows in the viewport:

The spheres represent the rigid bodies and the cylinders represent the planarlinks.

To create a more realistic representation of your model, you can add shapesand lines called attached shapes to your model. You first add and connectattached shape components from the Multibody palette to your diagram inthe model workspace.

4.5 Visualizing a Model • 77

Page 88: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

When you simulate your model, the attached shapes are displayed in additionto the implicit geometry in the viewport. In the following image, shapes havebeen added to represent the stem and bob of the pendulum pictorially. Also,a trace line, as represented by the red curved line in the image, is used todepict the locus of points that will be traced by a particular part of the modelduring a simulation.

You customize the color, size, scale, and other visual aspects of attachedgeometry by setting parameter values for individual components in theParameters pane before running a simulation.

If you want to view only the implicit geometry in the 3-D visualization

window, you can hide the attached shapes by clicking the button in thetoolbar. Similarly, if you want to view the attached shapes only, you can

hide the implicit geometry by clicking the button.

For more information about attached geometry components, see theMapleSim Library Reference → Multibody → Visualization topic in theMapleSim help system.

Example: Adding Attached Shapes to a DoublePendulum ModelIn the following example, you will add cylinder shapes to represent thependulum stem and a sphere component to represent the pendulum bob. Youwill also add a Path Trace component to display the path along which therevolute joint will move during an animation.

78 • 4 Simulating and Visualizing a Model

Page 89: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

1. From the Examples → Multibody menu, open the Double Pendulumexample.

2. From the Multibody → Visualization menu, add two Cylindrical Geo-metry components below the planar link subsystems in the model workspace.

3. Connect the components as shown below:

4. From the same menu, add an instance of a Sphere Geometry componentand place it beside the subsystem to the right of the model workspace.

5. Right-click (Control-click for Macintosh) the Sphere Geometry compon-ent and select Flip Horizontal.

6. Add an instance of a Path Trace component and place it between the twoCylindrical Geometry components.

7. Connect the components as shown below:

4.5 Visualizing a Model • 79

Page 90: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

8. Select the first Cylindrical Geometry component ( ) in the model

workspace.

9. In the Parameters pane, change the radius of the cylinder to 0.3 m.

10. To specify a cylinder color, click the box beside the color field. Thecolor selection dialog box is displayed.

11. Click one of the color swatches.

12. Select the second Cylindrical Geometry component ( ) in the model

workspace.

13. Change its radius to 0.3 m and change its color.

14. To simulate the model, click Run Simulation. The simulation graphsare displayed and the viewport displays the 3-D representation of yourmodel with attached geometry.

15. To play the animation, click the button at the bottom of the window.

80 • 4 Simulating and Visualizing a Model

Page 91: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

5 Analyzing and Manipulatinga ModelIn this chapter:

• Overview (page 81)

• Retrieving Equations and Properties from a Model (page 83)

• Analyzing Linear Systems (page 84)

• Optimizing Parameters (page 85)

• Generating C Code from a Model (page 88)

• Working with Maple Embedded Components (page 89)

• Example: Working With a Model in Maple (page 89)

5.1 OverviewYou can use Maple commands and technical document features to analyzethe dynamic behavior of a MapleSim model or subsystem. For example, youcan view model equations in a Maple worksheet, test input and output values,and use plotting tools to visualize possible simulation results. Model orsubsystem equations can be retrieved using routines from the MapleSimpackage. You can also manipulate your model as a DynamicSystems objectto analyze the model or subsystem behavior using any input functions.

As a starting point, you can use the pre-built templates provided in theMapleSim document folder. Each template contains embedded components,which are graphical user interface elements that you can use to open yourmodel in Maple and perform specific analysis tasks:

TaskTemplate Name

Translate your model into C code.Code Generation Template

Retrieve equations from linear or non-linear models.Equation Analysis Template

81

Page 92: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

TaskTemplate Name

View and analyze the equations of a linear system.Linear System Equation Template

Analyze and edit the parameters of a model and viewpossible simulation results.Parameter Optimization Template

Define and generate a set of random data points tobe used in MapleSim, for example, a data set for anInterpolation Table component.

Random Data Template

Alternatively, you can insert a MapleSim Model embedded component intoa Maple worksheet to edit and analyze a model programmatically. For moreinformation about the MapleSim Model component, see Working with MapleEmbedded Components (page 89).

Note: After using a document folder template, save the .mw file and thensave the .msim file to which that .mw file is attached.

Tip: The code associated with the pre-built analysis tools uses commandsfrom several Maple packages, including MapleSim and DynamicSystems.To view the Maple code, right-click (Control-click for Macintosh) an em-bedded component in a Maple worksheet, select Component Properties,and click Edit. For more information, see the ?EmbeddedComponentstopic in the Maple help system.

Working with Equations and Properties in a MapleWorksheetWhen viewing equations or properties in a Maple worksheet, note the follow-ing:

• The original Modelica names of parameters, variables, and connectorsare displayed in the Maple worksheet; these names may differ from thenames displayed for the corresponding elements in the MapleSim inter-face. For more information about the mappings of the element names,see the MapleSim Library Reference Guide in the MapleSim helpsystem.

82 • 5 Analyzing and Manipulating a Model

Page 93: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

• Subscripts and superscripts displayed in the MapleSim interface arerepresented differently in a Maple worksheet. Subscripts in the MapleSiminterface are displayed with an underscore character in a Maple work-sheet. For example, a connector called in the MapleSim inter-

face would be displayed as flange_a in a Maple worksheet. Also, super-scripts are formatted differently in a Maple worksheet. For example, a

variable called in the MapleSim interface would be displayed as

in a Maple worksheet.

5.2 Retrieving Equations andProperties from a ModelYou can use the Equation Analysis Template to retrieve and analyze equationsand properties such as parameters, initial equations, and variables in yourmodel.

1. In MapleSim, open the model for which you want to retrieve equationsor properties.

2. Click View Document Folder... above the drawing and layout toolbar.

3. From the drop-down menu, select Equations.

4. Click New.

5. Enter a name for the template and click OK.

6. In the document list, select the template entry and click Open Selected.Your model is opened in the Equation Analysis Template in Maple.

7. In the Equation Analysis Template, click System Update.

8. If applicable, from the drop-down menu, select the subsystem for whichyou want to view equations. By default, the drop-down menu is set to Main,which allows you to view equations for the entire system.

5.2 Retrieving Equations and Properties from a Model • 83

Page 94: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

9. To retrieve model equations, click Get Equations. The equations aredisplayed.

Alternatively, to retrieve model properties, click the buttons for the propertiesthat you want to view.

10. If you want to work with the equations or properties that you displayed,assign them to a variable by clicking the Assign to variable button.

You can now manipulate the equations using any Maple packages, for ex-ample, DynamicSystems and MapleSim. For more information, see the?DynamicSystems and ?MapleSim help topics in the Maple help system.

5.3 Analyzing Linear SystemsYou can use the Linear System Analysis Template to view and analyze theequations of a linear system, test system input and output values, and viewpossible simulation results in a Bode or root locus plot.

1. In MapleSim, open the linear system model that you want to analyze.

2. Click View Document Folder... above the drawing and layout toolbar.

3. From the drop-down menu, select Analysis.

4. Click New.

84 • 5 Analyzing and Manipulating a Model

Page 95: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

5. Enter a name for the template and click OK.

6. In the document list, select the template entry and click Open Selected.Your model is opened in the Linear System Analysis Template in Maple.

7. In the Linear System Analysis Template, click System Update.

8. If applicable, from the drop-down menu, select the subsystem for whichyou want to analyze equations. By default, the drop-down menu is set toMain, which allows you to analyze equations for the entire system.

9. To retrieve model equations, click Get Equations. The equations aredisplayed in the box.

Alternatively, to retrieve model properties, click the buttons for the propertiesthat you want to view.

10. If you want to work with the equations or properties that you displayed,assign them to a variable by clicking the Assign to variable button. You cannow use the embedded components provided in the Analysis and Simulationsection of the template to perform analysis tasks.

11. Define system input and output values. To add a value, select an entry

from the System IO and probes menu, and click . To add all of the

values, click .

12. Click Build System Object.

You can now select a parameter from the list, change the value of that para-meter, and use the plotting tools at the bottom of the worksheet to viewpossible simulation results.

5.4 Optimizing ParametersYou can use the Parameter Optimization Template to test various conditionsusing the embedded components provided in the worksheet and view possiblesimulation results in a plot.

5.4 Optimizing Parameters • 85

Page 96: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

Tip: You can also use commands from the Global Optimization Toolbox toperform parameter optimization tasks. For more information about thisproduct, visit the Maplesoft Global Optimization Toolbox web site at ht-tp://www.maplesoft.com/products/toolboxes/globaloptimization/.

1. In MapleSim, open the linear system model that you want to analyze.

2. Click View Document Folder... above the drawing and layout toolbar.

3. From the drop-down menu, select Optimization.

4. Click New.

5. Enter a name for the template and click OK.

6. In the document list, select the template entry and click Open Selected.Your model is opened in the Parameter Optimization Template in Maple.

7. In the Parameter Optimization Template, in the Parameter Investigationsection, click Retrieve System Parameters.

86 • 5 Analyzing and Manipulating a Model

Page 97: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

8. Specify the simulation time, solver, and number of points to be used inthe plot.

9. In the table below the Number of points field, from the first drop-downmenu, select the parameter that you want to test.

Note: When a parameter is selected, its assigned value is displayed in thefield next to the slider.

10. In the Range fields beside the slider and parameter value field, specifythe range of the slider. By default, the range is 0 to 10 unless the selectedparameter value is outside of this range.

11. Using the process described in steps 9 and 10, in the rows below yourfirst entry, specify other parameters that you want to test.

When you have defined all of the parameters, you can move the sliders totest different values and view possible simulation results in the plot. You

5.4 Optimizing Parameters • 87

Page 98: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

can also assign the parameters you defined to a Maple procedure to performfurther analysis tasks.

5.5 Generating C Code from a ModelIf you want to use or test your model in an application that supports the Cprogramming language, you can translate your model into source code.

1. In MapleSim, open the model for which you want to generate code.

2. Click View Document Folder... above the drawing and layout toolbar.

3. From the drop-down menu, select Code Generation.

4. Click New.

5. Enter a name for the template and click OK.

6. In the document list, select the template entry and click Open Selected.Your model is opened in the Code Generation Template in Maple.

7. In the template, click System Update.

8. From the drop-down menu, select the subsystem for which you want togenerate code.

9. (Optional) If you want to retrieve model equations, click Get Equations.The equations are displayed. Alternatively, to retrieve model properties, clickthe buttons for the properties that you want to view.

10. To assign the equations to the variable eq, click the Assign to variablebutton.

11. In the Code Generation Setting section, select the input and outputvalues for your system and click Build System Object.

12. In the Generating Code section, click Code Generation.

13. Click Save C Function Library. A dialog box prompts you to save yourcode as a C file.

88 • 5 Analyzing and Manipulating a Model

Page 99: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

5.6 Working with Maple EmbeddedComponentsIn Maple, you can use the MapleSim Model embedded component to view,edit, and analyze the properties of MapleSim models programmatically. Forexample, you can view and change parameter values using commands in theDocumentTools package. You can also associate model properties withother Maple embedded components, including sliders and plots. This func-tionality is particularly useful if you want to create custom analysis tools.

For more information about the MapleSim Model component, see the?MapleSimModel topic in the Maple help system.

5.7 Example: Working With a Modelin MapleUsing the frictionless sliding table model as an example, the following sectionpresents an overview of the underlying commands that you can use to analyzea MapleSim model in Maple.

In the following image, the top level of the frictionless sliding table modelis shown in a MapleSim Model embedded component.

5.6 Working with Maple Embedded Components • 89

Page 100: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

The top level is the highest level in a MapleSim model: it represents thecomplete system, which can include individual modeling components andcomponents grouped in subsystem blocks. Using calls to various MapleSimroutines, you can extract equations from the complete system or from asubsystem in your model.

These equations can then be manipulated to create a DynamicSystems object,which can be used to extract analytical information from your model. Formore information about advanced analysis tasks, open this Sliding Tablemodel from the Examples → Multidomain palette, and open the AdvancedAnalysis Worksheet from its document folder.

Opening a MapleSim Model in an EmbeddedComponent1. Open a new Maple worksheet.

2. From the Components palette, click the following button to insert aMapleSim Model component in the worksheet:

3. Right-click (Control-click for Macintosh) anywhere in the MapleSimModel component and select Component Properties.

4. In the File field, click Select...

5. Browse to and select $MAPLE_ROOT/Maple 13/toolbox/MapleS-im/data/examples/FrictionlessSlidingTable.mw, where $MAPLE_ROOTis the directory in which Maple is installed.

6. Click Open.

7. Click OK. The frictionless sliding table model is opened in the embeddedcomponent.

You can now work with your model programmatically.

90 • 5 Analyzing and Manipulating a Model

Page 101: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

Library RoutinesThe restart command clears the internal memory of the Maple kernel. Thewith(MapleSim) command makes the commands in the MapleSim packageavailable for use in a worksheet.

Enter the following commands at a prompt in the Maple worksheet:

restart;

with(MapleSim);

Extracting Equations From the ModelTo extract equations from the model:

1. Extract a model record (that is, an internal representation) from theMapleSim model using references to the embedded component.

2. Extract equations from the model record.

In this example, the embedded component name is Simulation0.

Step 1: Extract a Model Record Using the DocumentToolsPackage

The DocumentTools package provides the overall interface to embeddedcomponents in a worksheet. Enter the following command to load the pack-age:

with(DocumentTools);

The and commands are used to extract thetop-level model record from the MapleSim model. The record, which isstored in the variable, is an internal representation of the systemand is not meant to be manipulated directly. For more information aboutthese commands, see the DocumentTools topic in the Maple help system.

5.7 Example: Working With a Model in Maple • 91

Page 102: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

To extract the record, enter the following commands in the worksheet:

SetProperty("Simulation0", "activesubsys",""):

mysys GetProperty "Simulation0",'system');

Step 2: Extract Equations From the Model Record

The GetEquations command is used extract the system equations from themodel record. It returns seven arguments:

DescriptionArgument

set of "core" equations of the systemeqs

set of initial conditionsics

set of constraint equationsconstrs

set of symbolic parametersparams

set of variable namesvars

set of "auxiliary" equationsaux

set of probe namesprobes

To extract the equations from the top-level model, enter the following in theworksheet:

eOutDefault

For more information, see the ?MapleSim[GetEquations] topic in the Maplehelp system.

Options for the GetEquations Command

The simplify keyword option controls the degree to which the system equa-tions are manipulated before they are returned.

92 • 5 Analyzing and Manipulating a Model

Page 103: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

There are three levels of simplification:

• simplify = false (or none): returns the raw equations from the underlyingmodel description of the system. Typically, several redundant equationsare displayed.

• simplify = true: applies the elimination algorithm to remove most of theredundant (linear) equations. This is the default value.

• simplify = tryhard : applies further simplification techniques, such asindex reduction, to reduce the size of the system equations.

Enter the following in the worksheet to specify a simplification level of try-hard:

The symbolicname keyword parameter specifies a list of parameter namesto be kept as symbolic in the returned equations.

Simulating the ModelThe top-level model can be simulated in Maple using the RunSimulationcommand.

To display simulation graphs, enter the following in the worksheet:

5.7 Example: Working With a Model in Maple • 93

Page 104: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

This command returns the same graphs as those obtained when you clickthe Run Simulation button in MapleSim.

For more information, see the ?MapleSim[RunSimulation] topic in theMaple help system.

94 • 5 Analyzing and Manipulating a Model

Page 105: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

6 Advanced TutorialsIn this chapter:

• Tutorial 1: Modeling a DC Motor with a Gearbox (page 95)

• Tutorial 2: Modeling a Cable Tension Controller (page 103)

• Tutorial 3: Modeling a Non-linear Damper (page 108)

• Tutorial 4: Modeling a Planar Slider-Crank Mechanism (page 116)

6.1 Tutorial 1: Modeling a DC Motorwith a GearboxIn this tutorial, you will extend the model that you created in the basic tutorialand perform the following tasks:

1. Add a gearbox to the DC motor that you created in the basic tutorial.

2. Simulate the DC motor with gearbox model.

3. Group the DC motor components into a subsystem.

4. Assign global parameters to the model.

5. Add signal block components and a PI controller to the model.

6. Simulate the modified DC motor model under different conditions.

Adding a Gearbox to the DC Motor ModelIn this task, you will build a gearbox by adding and connecting an idealgearbox, a backlash component with a linear spring and damper, and an in-ertia component from the 1-D Mechanical library.

1. Open the DC_Motor1.msim file that you created in the basic tutorial.Alternatively, open the Simple DC Motor example in the Examples →Tutorial palette.

95

Page 106: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

2. Perform the following tasks:

• From the 1-D Mechanical → Rotational → Bearings and Gears menu,add an Ideal Gear component to the model workspace and place it tothe right of the Inertia component.

• From the 1-D Mechanical →Rotational → Springs and Dampersmenu, add an ElastoBacklash component to the model workspace andplace it to the right of the Ideal Gear component.

• From the 1-D Mechanical → Rotational → Common menu, add anotherInertia component to the model workspace and place it to the right ofthe ElastoBacklash component.

Tip: Use the selection tool ( ) in the drawing and layout toolbar to dragand position components in the model workspace.

3. Connect the components as shown below.

4. In the model workspace, click the Ideal Gear component.

5. In the Parameters pane, to change the transmission ratio between theflanges, in the r field, enter 10 and press Enter.

6. Specify the following parameter values for the other components:

• For the ElastoBacklash component, in the b field, specify a total backlash

of 0.3 rad. In the d field, specify a damping constant of .

96 • 6 Advanced Tutorials

Page 107: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

• For the first Inertia component ( ), in the J field, specify a moment

of inertia of 10 kg .

• For the Step source, in the height field, specify a height of 100.

Simulating the DC Motor with Gearbox Model1. Delete Probe1 from the model workspace.

2. From the drawing and layout toolbar, click the probe icon ( ).

3. Hover your mouse pointer over the line that connects the ElastoBacklashcomponent and the second Inertia component ( ). The line is highlighted.

4. Click the line once. The Select probe properties dialog box is displayed.

5. To include the angle ( ), speed (w), acceleration (a), and torque ( )values in the simulation graphs, select Angle, Speed, Acceleration, andTorque.

6. Click OK.

7. Click the probe to position it on the line.

8. In the Parameters pane, set the parameter to 10 seconds and press

Enter.

9. Click Run Simulation. When the simulation is complete, the followinggraphs are displayed.

6.1 Tutorial 1: Modeling a DC Motor with a Gearbox • 97

Page 108: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

Grouping the DC Motor Components into aSubsystem

1. Using the selection tool ( ), draw a box around the electrical componentsand the first inertia component that you added.

98 • 6 Advanced Tutorials

Page 109: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

2. From the Edit menu, select Create Subsystem.

3. In the Create Subsystem dialog box, enter DC motor.

4. Click OK. A white box, which represents the DC motor, is displayed inthe model workspace.

Tip: To view the components in the subsystem, double-click the DC motorsubsystem in the model workspace. To browse to the top level of the model,in the model tree, click [Top].

Assigning Global Parameters to a ModelYou can define a global parameter and assign its value as a variable to mul-tiple components in your model.

1. In the model tree, click [Top] to browse to the top level of the model.

2. Click the Parameters button above the drawing and layout toolbar. TheGlobal Parameters view is displayed.

3. In the first row of the Main subsystem default settings table, define aparameter called R and press Enter.

4. Specify a default value of 24 and enter Global resistance variable as thedescription.

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

6.1 Tutorial 1: Modeling a DC Motor with a Gearbox • 99

Page 110: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

6. Specify a default value of 10 and enter Global moment of inertia valueas the description.

7. To navigate back to the Diagram view, click the Diagram button abovethe drawing and layout toolbar. The new R and J parameters are displayedin the Parameters pane below the plot points field.

You can now assign these values to other components in your model.

8. Click the Parameters button to switch to the Global Parameters view.

9. In the component table, in the value field for the moment of inertia

parameter, enter J and press Enter.

The moment of inertia parameter now inherits the numeric value of theglobal parameter, J (in this example, 10).

10. Switch to the Diagram view and double-click the DC Motor subsystem.

11. Click the Parameters button.

12. In the component table, in the value field for the transformation

coefficient, enter and press Enter.

100 • 6 Advanced Tutorials

Page 111: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

Note: This value is an approximation of the transformation coefficient.

13. In the component table, in the value field for the resistance paramet-

er, enter R and press Enter.

14. Switch to the Diagram view and browse to the top level of your model.

15. Save the model as DC_Motor2.msim.

Changing Input and Output ValuesIn this example, you will change the input and output values of the modelto simulate different conditions.

1. From the 1-D Mechanical → Rotational → Sensors menu, add the An-gular Velocity Sensor component to the model workspace and place it belowthe gearbox components.

2. Right-click (Control-click for Macintosh) the Angular Velocity Sensorcomponent and select Flip Horizontal.

3. Delete the connection line between the Step source and the DC Motorsubsystem.

4. From the Signal Blocks → Controllers menu, add the PI component tothe model workspace and place it to the left of the DC Motor subsystem.

5. From the Signal Blocks → Mathematical → Operators menu, add theFeedback component to the model workspace and place it to the left of thePI component.

6. Connect the components as shown below.

6.1 Tutorial 1: Modeling a DC Motor with a Gearbox • 101

Page 112: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

Tip: To draw a perpendicular line, click a point in the model workspace asyou draw a connection line and then move your mouse cursor in a differentdirection to draw the second line segment.

7. Click the PI component in the model workspace.

8. In the Parameters pane, specify a gain of 20 in the k field, and a timeconstant of 3 seconds in the T field.

9. Run the simulation again. When the simulation is complete, the followinggraphs are displayed.

102 • 6 Advanced Tutorials

Page 113: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

10. Save the model as DC_Motor3.msim.

6.2 Tutorial 2: Modeling a CableTension ControllerIn this tutorial, you will extend the DC motor example to model a cable thatis stretched with a pre-defined tension. The tension is defined by a Constantsource and the PI controller provides the voltage to drive the motor. Youwill perform the following tasks:

1. Build a cable tension controller model.

6.2 Tutorial 2: Modeling a Cable Tension Controller • 103

Page 114: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

2. Specify simulation conditions.

3. Simulate the cable tension controller model.

Building a Cable Tension Controller ModelIn this task, you will build the cable tension controller model using a com-bination of 1-D mechanical rotational and translational components. Youwill also group components into a Gear subsystem and add subsystem ports.

1. Open the DC_Motor3.msim file that you created in the previous tutorialand save the file as Cable_Tension.msim. Alternatively, open the DC Motorwith PI Control example in the Examples → Tutorial palette.

2. Delete Probe3 attached to the line connecting the ElastoBacklash andInertia components.

3. Delete Angular Velocity Sensor component and its connection lines.

4. Select the ElastoBacklash, Ideal Gear, and Inertia components andgroup them into a subsystem called Gear Components.

5. Add the following components to the model workspace:

• From the 1-D Mechanical → Rotational → Bearings and Gears menu,add the Ideal Rotation to Translation Gear component and place it tothe right of the Gear Components subsystem.

• From the 1-D Mechanical → Translational → Sensors menu, add theForce Sensor component and place it to the right of the Ideal Rotationto Translation Gear component.

• From the 1-D Mechanical → Translational → Springs and Dampersmenu, add the Translational Spring component and place it to the rightof the Force Sensor component.

• From the 1-D Mechanical → Translational → Common menu, addthe Translational Fixed component and place it to the right of theTranslational Spring component.

104 • 6 Advanced Tutorials

Page 115: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

6. Right-click (Control-click for Macintosh) the Translational Fixed com-ponent in the model workspace and select Rotate Counterclockwise.

7. Delete the Step source and replace it with a Constant source from theSignal Blocks → Sources → Real menu.

Tip: You can connect the Constant source by dragging it onto the unattachedline end.

8. Double-click the Gear Components subsystem. You will now add a portto connect this subsystem with other components.

9. Click the negative (white) flange of the Inertia component and drag yourmouse pointer to the boundary that surrounds the subsystem components.

10. Click the line once. The subsystem port is added to the line.

11. In the model tree, click [Top] to browse to the top level of your model.

12. Connect the components as shown below.

6.2 Tutorial 2: Modeling a Cable Tension Controller • 105

Page 116: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

Specifying Simulation Conditions1. In the model workspace, double-click the Gear Components subsystem.

2. Specify the following parameter values for the subsystem components:

• For the Ideal Gear component, specify a transmission ratio of 0.01.

• For the Inertia component, specify a moment of inertia of 0.1

3. In the model tree, click [Top] to browse to the top level of the model.

4. Specify the following parameter values for the other components in themodel workspace:

• For the Translational Spring component, in the c field, specify a spring

constant value of .

• For the PI controller, specify a T value of 0.1 s.

• For the Constant source, in the k field, specify a constant output valueof 77.448.

Simulating the Cable Tension Controller

1. Click the probe icon ( ) and click the line that connects the Feedbackand PI components.

2. In the Probe Properties dialog box, select Real, change the quantity nameto Error, and click OK.

106 • 6 Advanced Tutorials

Page 117: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

3. Click the probe once to position it on the line.

4. Add a probe that measures the Real quantity to the line connecting the PIcomponent and DC motor subsystem. Change the quantity name to Control-ler.

6. In the Parameters pane, specify a value of 5 seconds and make sure

that the Stiff Solver option is set to true.

7. Click Run Simulation. When the simulation is complete, the followinggraphs are displayed.

8. Save the file as CableTension.msim.

6.2 Tutorial 2: Modeling a Cable Tension Controller • 107

Page 118: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

6.3 Tutorial 3: Modeling a Non-linearDamperIn this tutorial, you will model a non-linear damper with a linear spring. Thistutorial builds upon the concepts demonstrated in the previous tutorials. Youwill perform the following tasks:

1. Generate a custom spring damper defined by differential equations.

2. Provide custom damping coefficient values as input signals.

3. Build the non-linear damper with linear spring model.

4. Assign a variable to a subsystem.

5. Simulate the non-linear damper with linear spring model.

Generating a Custom Spring DamperIn MapleSim, you can create a custom component that is based on a math-ematical model. Typically, you would define the component equations andports before making the component available in MapleSim. For the the pur-pose of this tutorial, you will generate a sample custom component with pre-defined differential equations.

1. Open a new MapleSim document.

2. Click View Document Folder... above the drawing and layout toolbar.

3. Click More Templates...

4. In the Browse Templates dialog box, browse to the Component Tem-plates folder.

5. Select the NonLinearMSD.mw file and click Attach Template...

6. In the Enter Document Name dialog box, enter NonLinearMSD.

108 • 6 Advanced Tutorials

Page 119: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

7. Click OK. An instance of the template is attached to the MapleSim docu-ment folder.

8. Select the entry that you created and click Open Selected. The CustomComponent Template is opened in Maple.

9. To generate the component, click Generate MapleSim Component atthe bottom of the worksheet.

In MapleSim, the NonLinearMSD component is displayed in the Subsystemspane.

You will use this component later in this tutorial.

Providing Damping Coefficient ValuesYou can provide custom values for interpolation tables that you add to yourmodel. In this example, you will provide damping coefficient values in anexternal file.

1. Create a Microsoft Excel spreadsheet or comma-separated values (.csv)file that contains the following values:

6.3 Tutorial 3: Modeling a Non-linear Damper • 109

Page 120: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

The first column contains values for the relative displacement of the damperand the second column contains values for the damping coefficients.

2. Save the file on your hard drive as DamperCurve.xls or Damper-Curve.csv.

3. In MapleSim, click View Document Folder... above the drawing andlayout toolbar.

4. Click Attach...

5. Browse to and select the Excel spreadsheet or .csv file that you created,and click Attach... The file containing the data set is attached to your model.You will use this file in the next task.

6. Close the dialog box.

Building the Non-linear Damper Model1. From the Subsystems pane, drag the NonLinearMSD component intothe model workspace.

2. Add the following components to the model workspace:

• From the Signal Blocks → Mathematical → Operators menu, add aGain component and place it above the NonLinearMSD component.

• From the Signal Blocks → Sources → Real menu, add a Constantcomponent and place it between the NonLinearMSD and Gain compon-ents.

• From the Signal Blocks → Interpolation Tables menu, add a 1DLookup Table component and place it to the left of the Gain component.

• From the 1-D Mechanical → Translational → Sensors menu, add aPosition Sensor component and place it to the left of the 1D LookupTable component.

3. Connect the components as shown below.

110 • 6 Advanced Tutorials

Page 121: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

4. Add the following components to the model workspace:

• From the 1-D Mechanical → Translational → Common menu, add aTranslational Fixed component, rotate it counterclockwise, and placeit to the right of the NonLinearMSD component.

• From the same menu, add Sliding Mass and Force components andplace them to the left of the Position Sensor component.

• From the Signal Blocks →Sources → Real menu, add a Step source.

5. Connect the components as shown below.

6. In the model workspace, select the 1D Lookup Table component. In theParameters pane, the data drop-down menu lists all of the documents thatyou have attached to the model.

6.3 Tutorial 3: Modeling a Non-linear Damper • 111

Page 122: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

7. Select the DamperCurve.xls or DamperCurve.csv file that you createdin the previous task.

You will now define the stiffness of the spring.

8. In the model workspace, select the Constant component.

9. In the Parameters pane, in the Component field, change the componentname to Stiffness.

10. Select the Step component and change the step height to 100.

11. Select the Sliding Mass component and change the mass to 100 kg.

12. Using the selection tool ( ), draw a box around all of the componentsin the non-linear damper model.

112 • 6 Advanced Tutorials

Page 123: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

13. Group the selected components into a subsystem called Non-lineardamper. The complete model is shown below.

Assigning a Parameter to a Subsystem1. In the model workspace, double-click the Non-linear damper subsystem.

2. To switch to the Subsystems Parameters view, click the Parametersbutton above the drawing and layout toolbar.

3. In the first row of the Non-linear damper subsystem default settingstable, define a spring constant parameter called Ks and press Enter.

4. In the same row, specify a default value of 1000 and enter Spring constantas the description. You can now assign the parameter value to other compon-ents in the Non-linear damper subsystem.

5. To navigate back to the Diagram view, click Diagram above the drawingand layout toolbar. The Ks parameter is now displayed as a field in theParameters pane with the default value that you defined.

6.3 Tutorial 3: Modeling a Non-linear Damper • 113

Page 124: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

6. In the model workspace, select the Stiffness component and change theconstant output parameter, k, to Ks.

This component now inherits the numeric value of Ks (in this example,1000). Therefore, if you edit the numeric value of Ks at the subsystem level,the k parameter that has been assigned the variable, Ks, also inherits thatchange.

Simulating the Non-linear Damper with LinearSpring Model

1.From the drawing and layout toolbar, click the probe icon ( ).

2. Click the line that connects the Gain and NonLinearMSD component.

114 • 6 Advanced Tutorials

Page 125: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

3. In the Select probe properties dialog box, select the Real quantity andchange its name to Damping.

4. Click OK and position the probe on the line.

5. Browse to the top level of the model.

6. On the line that connects the Sliding Mass component and the Non-lineardamper subsystem, add a probe that measures the length, speed, and accel-eration quantities.

7. In the Parameters pane, set the parameter to 10 seconds.

8. Click Run Simulation. When the simulation is complete, the followinggraphs are displayed.

6.3 Tutorial 3: Modeling a Non-linear Damper • 115

Page 126: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

9. Save the file as NonLinearMSD.msim.

6.4 Tutorial 4: Modeling a PlanarSlider-Crank MechanismUsing components from the Multibody mechanical library, you will modelthe planar slider-crank mechanism shown in the following schematic diagram:

This model consists of a revolute joint, A, which is attached to a planar link.This planar link is attached to a connecting rod by a second revolute joint,B. The connecting rod is then connected to a sliding mass by a third revolutejoint, C, and the sliding mass is connected to ground by a prismatic joint. Inpractice, this mechanism is used to convert rotational motion at the crank totranslational motion at the sliding mass or vice versa. For the system shownin the diagram, gravity is assumed to be the only external force, acting alongthe negative Y axis (the y axis for the inertial frame).

In this tutorial, you will perform the following tasks:

1. Create a planar link subsystem

2. Define and assign subsystem parameters.

3. Create the crank and connecting rod elements.

116 • 6 Advanced Tutorials

Page 127: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

4. Add the fixed frame, sliding mass, and joint elements to the model.

5. Specify initial conditions.

6. Simulate the planar slider-crank mechanism.

Creating a Planar Link SubsystemFrom the diagram, you can see that the slider-crank has two associated planarlinks: the crank (the link from point A to B) and the connecting rod (the linkfrom B to C). In both cases, these links have their longitudinal axis alongtheir local x axis (x1 and x2, respectively). Thus, you will first create a gen-

eric planar link with two ports. The inboard port (base) will be located

units along the x axis of the link, while the outboard port (tip) will be located

units along the x axis of the link. In this example, refers to the length

of the link and the center-of-mass is assumed to be located in the middle ofthe link.

6.4 Tutorial 4: Modeling a Planar Slider-Crank Mechanism • 117

Page 128: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

1. Open a new MapleSim document.

2. From the Multibody → Bodies and Frames menu, add two Rigid BodyFrame components and a Rigid Body component.

3. In the model workspace, right-click (Control-click for Macintosh) thecomponent and select Flip Horizontal.

4. Right-click or Control-click the Rigid Body component and select RotateCounter Clockwise.

5. Drag the components in the arrangement shown below.

You can now connect the components, effectively welding the connectedcomponents together.

When connecting a Rigid Body Frame component to a Rigid Body com-ponent, it is helpful to connect the inboard port of the Rigid Body Frame(that is, the port with the cross-hatched circle) to the center-of-mass frameof the Rigid Body component. This ensures that the local reference frameused to describe displacements and rotations for the Rigid Body Framecomponent match with the center-of-mass reference frame defined on theRigid Body component.

6. Draw a connection line between the Rigid Body component and the rightframe of the component.

118 • 6 Advanced Tutorials

Page 129: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

7. Draw another connection line between the Rigid Body component andthe left frame of the component.

8. Using the selection tool ( ), draw a box around the components.

9. From the Edit menu, select Create Subsystem.

10. In the Create Subsystem dialog box, enter Link and click OK.

You will now add ports to connect this subsystem to other components.

11. Double-click the Link subsystem.

6.4 Tutorial 4: Modeling a Planar Slider-Crank Mechanism • 119

Page 130: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

12. Click the left frame of the component and drag your mouse

cursor to the left of the subsystem boundary.

13. Click the line once. A subsystem port is added.

14. In the same way, using the right frame of the component, create

another port on the right side of the subsystem boundary.

120 • 6 Advanced Tutorials

Page 131: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

Defining and Assigning ParametersIn this task, you will define a subsystem parameter, L, to represent the lengthof the link and assign the parameter value as a variable to the parameters ofthe Rigid Body Frame components. The Rigid Body Frame componentswill, then, inherit the numeric value of L defined at the top level of yourmodel. You can set parameter values for any aspect of your model; however,for demonstration purposes, the length values are investigated in this tutorial.

1. Click the Parameters button above the drawing and layout toolbar. Thesubsystem parameters view is displayed.

2. In the first row of the Link subsystem default settings table, define aparameter called L, and press Enter.

3. Specify a default value of 1 and enter Length as the description.

4. Click Diagram to switch to the diagram view.

5. In the Parameters pane, specify the following parameter values:

• For the component, in the field, specify an offset of

• For the component, in the field, specify an offset of

Tip: To enter a fraction, use the forward slash key (/).

Creating the Crank and Connecting Rod ElementsIn this task, to create the crank and connecting rod elements, you will addanother instance of the Link subsystem to your model and rename the sub-

6.4 Tutorial 4: Modeling a Planar Slider-Crank Mechanism • 121

Page 132: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

systems. You will also assign a different length value to the connecting rodelement.

1. In the model tree, click [Top] to navigate to the top level of the model.

2. Select the Link subsystem in the model workspace.

3. In the Parameters pane, in the Component field, change the name of thatsubsystem instance to Crank.

4. To display the Subsystems pane, click the Subsystems button below themodel workspace.

5. From the Subsystems pane, drag the Link icon to the model workspaceand place it to the right of the subsystem.

6. In the model workspace, select the second instance of the Link subsys-tem.

7. In the Parameters pane, in the Component field, change the subsystemname to ConnectingRod.

8. In the L field, change the length value to 2.

Adding the Fixed Frame, Sliding Mass, and JointElementsIn this task, you will add a Fixed Frame component, a Rigid Body compon-ent to represent the sliding mass, and the joint elements.

1. From the Multibody → Bodies and Frames menu, add the Fixed Framecomponent and place it to the left of the Crank subsystem.

2. From the same menu, add a Rigid Body component and place it slightlybelow and to the right of the Connecting Rod subsystem.

3. Add the following joints:

122 • 6 Advanced Tutorials

Page 133: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

• From the Multibody → Joints and Motions menu, add a Revolute jointbetween the Fixed Frame component and the crank, a second Revolutejoint between the crank and the connecting rod, and a third Revolutejoint between the connection rod and the sliding mass.

• From the same menu, add a Prismatic joint and place it below the Cranksubsystem.

4. Select the component in the model workspace and rename it Sliding

Mass.

5. Right-click or Control-click the Sliding Mass component and select FlipHorizontal. In the same way, flip the the revolute joint horizontally.

6. Connect the components as shown below.

6.4 Tutorial 4: Modeling a Planar Slider-Crank Mechanism • 123

Page 134: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

In this example, the default axes of motion for the revolute and prismaticjoints line up with the desired axes of motion. For example, the revolutejoints initially assume that they rotate about the z axis of the inboard frame,which always coincides with the inertial Z axis for XY-planar systems. Whencreating non-planar models, these axes may need to be changed to ensurethat they allow motion along or about the correct directions.

Specifying Initial ConditionsTo specify initial conditions, you set parameters values for certain componentsin your model.

1. For the first revolute joint, in field, set the initial angle of the joint to

rad.

Tip: To enter , type Pi, press Ctrl + Space (or Ctrl + Shift + Space for

Macintosh), and select the symbol from the menu.

2. From the drop-down menu, select Strictly Enforce.

When MapleSim solves for the initial conditions, it will set the first angle

to rad before setting the angles for the other joints.

Simulating the Planar Slider-Crank Mechanism

1.From the drawing and layout toolbar, click the probe icon ( ).

2. In the model workspace, click the white 1-D translational flange at thetop right of the Prismatic joint icon.

3. In the Select probe properties dialog box, select the Length quantity tomeasure the displacement.

124 • 6 Advanced Tutorials

Page 135: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

4. Click OK and position the probe on the connector.

5. In the same way, add a probe that measures the Angle quantity to the white1-D rotational flange at the top right of the joint icon.

6. In the Parameters pane, set the parameter to 10 seconds.

7. Click Run Simulation. When the simulation is complete, the followinggraphs are displayed.

8. Save the file as SliderCrank.msim.

6.4 Tutorial 4: Modeling a Planar Slider-Crank Mechanism • 125

Page 136: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

126 • 6 Advanced Tutorials

Page 137: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

7 Reference: MapleSimKeyboard ShortcutsOpening, Closing, and Saving a Model

Macintosh ShortcutsWindows and LinuxShortcutsTask

Command + NCtrl + NCreate a new model

Command + OCtrl + OOpen an existing model

Command + WCtrl + Shift + F4Close the active document

Command + SCtrl + SSave a model as an .msim file

Exporting and Printing a ModelMacintosh ShortcutsWindows and Linux

ShortcutsTask

Command + ECtrl + EExport a model as an image

Command + PCtrl + PPrint a model

Building a ModelMacintosh ShortcutsWindows and Linux

ShortcutsTask

Command + RCtrl + RRotate the selected modelingcomponent 90 degrees clockwise

Command + LCtrl + LRotate the selected modelingcomponent 90 degrees counter-clockwise

Command + FCtrl + FFlip the selected modeling com-ponent vertically

127

Page 138: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

Macintosh ShortcutsWindows and LinuxShortcutsTask

Command + HCtrl + HFlip the selected modeling com-ponent horizontally

Command + GCtrl + GGroup the selected modelingcomponents into a subsystem

Command + DCtrl + DDisplay or hide probes in themodel workspace

Navigating a ModelMacintosh ShortcutsWindows and Linux

ShortcutsTask

Command + MCtrl + MView the selected modeling com-ponent or subsystem in detail

Command + numerickeypad plus key

Ctrl + numeric keypadplus keyZoom in to the model workspace

Command + numerickeypad minus key

Ctrl + numeric keypadminus key

Zoom out from the model work-space

Drawing and Layout ToolsShortcuts (all platforms)

SSwitch to the selection tool

ESwitch to the eraser tool

TSwitch to the text box tool

LSwitch to the line tool

RSwitch to the rectangle tool

OSwitch to the oval tool

128 • 7 Reference: MapleSim Keyboard Shortcuts

Page 139: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

IndexSymbols3-D display controls

Attached shapes, 77Implicit geometry, 77Trace lines, 78

3-D view navigation, 763-D views

Orthographic, 76Perspective, 76

AAcausal modeling, 2Annotations, 45

CCausal modeling, 2Code generation

C, 88Connection lines, 21

Colors, 21Connection ports, 21Custom components

Defining equations, 55Defining ports, 56Editing, 59Examples, 52Overview, 51

Custom libraries, 39Custom library

Editing, 42

DDifferential algebraic equations, 2

Document folder, 48, 81Drawing, 44

EEmbedded components, 89

MapleSim Model, 89Equations

Retrieving, 83Retrieving programmatically, 91Simplifying, 92

Error tolerance, 66

GGlobal parameters, 99

IInitial conditions, 23Interpolation tables, 109

LLinear systems

Analyzing, 84

MMaple, 89MapleSim component library, 8, 19MapleSim package, 90

GetEquations command, 92RunSimulation command, 93

Mathematical model, 1Model tree, 20Model workspace, 7Modelica, 61Modeling components

Connecting, 11

129

Page 140: MapleSim User's Guide...• MapleSim User's Guide: contains conceptual inform-ation about MapleSim, an overview of MapleSim fea-tures, and tutorials to help you get started using the

NNon-stiff solver, 62

PPalettes, 7, 19Parameter block, 34Parameter optimization, 86Parameter values, 13Parameters

Global parameters, 33Parameter sets, 68Parameter values, 22Subsystem parameters, 34

Physical modelsAnalyzing, 81Building, 8Navigating, 20

Probes, 65Adding, 13

Progress information messages, 70

SSimulating, 65

Programmatically, 93Simulation graphs

Display options, 70Simulation parameters, 65

Compiler, 67Simulation results

Comparing, 69Exporting, 69Managing, 69Viewing, 69

SolversAdaptive, 66

Fixed-step, 66Stiff solver, 62, 66Subsystems, 24

Editing multiple instances, 29Managing, 27Multiple instances, 28Navigating, 26

Subsystems pane, 27

TTemplates

Code Generation, 88Custom Component, 54Equation Analysis, 83Linear System Analysis, 84Overview, 81Parameter Optimization, 85

UUnits, 22

VVariables, 3Visualization, 74

130 • Index


Recommended