SimMechanics Getting Started
SimMechanics Getting Started
R2012a
How to Contact MathWorks
www.mathworks.com Web
comp.soft-sys.matlab Newsgroup
www.mathworks.com/contact_TS.html Technical Support
508-647-7000 (Phone)
508-647-7001 (Fax)
Trademarks
MATLAB and Simulink are registered trademarks of The MathWorks, Inc. See
www.mathworks.com/trademarks for a list of additional trademarks. Other product or brand
names may be trademarks or registered trademarks of their respective holders.
Patents
MathWorks products are protected by one or more U.S. patents. Please see
www.mathworks.com/patents for more information.
Revision History
March 2012 Online only New for Release 2012a (Version 4.0)
Contents
Getting Started
iii
Modeling Workflow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-23
Joints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-21
Specifying Joints with Joint Blocks . . . . . . . . . . . . . . . . . . . 2-21
Examining the Joint Blocks . . . . . . . . . . . . . . . . . . . . . . . . . 2-22
iv Contents
Specifying Joint Initial State Targets . . . . . . . . . . . . . . . . . 2-27
v
vi Contents
_
Getting Started
Introduction to
SimMechanics Software
Product Description
Model and simulate multibody mechanical systems
SimMechanics provides a multibody simulation environment for 3D
mechanical systems, such as robots, vehicle suspensions, construction
equipment, and aircraft landing gear. You model the multibody system using
blocks representing bodies, joints, constraints, and force elements, and then
SimMechanics formulates and solves the equations of motion for the complete
mechanical system. Models from CAD systems, including mass, inertia,
joint, constraint, and 3D geometry, can be imported into SimMechanics. An
automatically generated 3D animation lets you visualize the system dynamics.
Key Features
• Blocks and modeling constructs for simulating and analyzing 3D
mechanical systems in Simulink
• Rigid body definition using standard geometry and custom extrusions
defined in MATLAB
• Automatic calculation of mass and inertia tensor
• Simulation modes for analyzing motion and calculating forces
• Visualization and animation of multibody system dynamics with 3D
geometry
• SimMechanics Link utility, providing an interface to Pro/ENGINEER®,
SolidWorks®, and Autodesk Inventor, and an API for interfacing with other
CAD platforms
• Support for C-code generation (with Simulink Coder)
1-2
Required and Related Products
Required Products
To use SimMechanics software, you must have installed current versions of
the following products:
• MATLAB
• Simulink
• Simscape
You can improve your speed and graphics resolution by adding a graphics
accelerator hardware card to your system. Animation of simulations
is sensitive to central processor and graphics card speed and memory.
Experiment with graphics hardware and system settings to find a reasonable
compromise between quality and speed for your system.
1-3
1 Introduction to SimMechanics™ Software
Related Products
You can extend the capability of SimMechanics using other physical modeling
products found in the Simscape family. Each physical modeling product gives
you a set of block libraries with which you can model common components
found in industry and academia: rigid bodies, gears, valves, solenoids, etc.
With the physical modeling products, you can model not only mechanical
systems, but also electrical, hydraulic, and power systems. You can model
each system separately, and then integrate them into a single multiphysics
model where you can analyze their combined performance.
1-4
First and Second Generation Technologies
1-5
1 Introduction to SimMechanics™ Software
SimMechanics Components
Blocks, ports, and connection lines form the backbone of any SimMechanics
model.
In this section...
“ Blocks” on page 1-6
“ Ports” on page 1-6
“ Connection Lines” on page 1-7
Blocks
What a Block Is
A block is a ported entity that represents a physical component used in a
machine, a geometric relationship or constraint, or a dynamic element like
force and torque. You can connect blocks to each other using ports and
connection lines. For more information, see “Description of SimMechanics
Block Libraries” on page 1-9.
Ports
What a Port Is
A port allows you to connect one block to other blocks, establishing a
relationship between them.
Types of Ports
In SimMechanics, there are two types of ports, frame and physical signal:
1-6
SimMechanics™ Components
Connecting Ports
To connect two compatible ports, you draw a connection line between them.
You can connect a frame port only to another frame port. Likewise, you can
connect a physical signal port only to another physical signal port. You cannot
mix frame and physical signal ports.
Connection Lines
• Frame connection line—makes two frame ports coincident with each other,
sharing the same location and orientation in space. To specify two different
frames, see .
Note A frame connection line represents a single frame along its length.
When you connect one connection line directly to other connection lines, all
lines represent the same frame along their lengths. Their frames share the
same origin and orientation in space for all time.
1-7
1 Introduction to SimMechanics™ Software
Frame and physical signal connection lines look identical in a model. You
identify them by the ports they connect to: a frame connection line always
connects two or more frame ports; a physical signal connection line always
connects two or more physical signal ports.
Note You can connect a frame connection line only to a frame port or to
another frame connection line. You can connect a physical signal connection
line only to a physical signal port or to another physical signal connection line.
You cannot mix frame and physical signal connection lines.
1-8
SimMechanics™ Block Libraries
Body Elements
The Body Elements library gives you the basic blocks to model a rigid body,
including blocks for specifying geometry, inertia, and graphic properties. You
can model rigid bodies with simple predefined, solid shapes and colors, or
with custom geometry and inertia. You can also rigidly connect multiple solid
shapes to form compound rigid bodies.
1-9
1 Introduction to SimMechanics™ Software
Constraints
The Constraints library provides blocks to restrict the relative motion
between two body frames. You can constrain two body frames to maintain a
specified distance or a specified angle between them.
Joints
The Joints library provides blocks that connect bodies to one another in
kinematic relationships representing different degrees of freedom between
two body frames. These are time-varying relationships that restrict
translation and rotation between the bodies to a specified set of axes.
Utilities
The Utilities library contains blocks to configure solver and simulation
parameters in the SimMechanics environment.
1-10
SimMechanics™ Block Libraries
1 On the MATLAB toolbar, click the Simulink icon to open the Simulink
Library Browser.
1-11
1 Introduction to SimMechanics™ Software
1-12
Starting a New SimMechanics™ Model
1-13
1 Introduction to SimMechanics™ Software
1-14
Starting a New SimMechanics™ Model
4 Select and add a block to the Simulink Editor window containing your
model.
1 Click and hold the appropriate port on the first block you wish to connect.
2 Drag the mouse to a compatible port on the second block you wish to
connect.
Note You can only connect a frame port to another frame port. Likewise,
you can only connect a physical signal port to another physical signal port.
For more information, see “ Ports” on page 1-6.
1-15
1 Introduction to SimMechanics™ Software
1 Click and hold the appropriate port on the first block you wish to connect.
Note You can only connect a frame port to a frame connection line.
Likewise, you can only connect a physical signal port to a physical signal
connection line. For more information, see “ Ports” on page 1-6.
2 Drag the mouse to a compatible port on the block you wish to connect.
1 Right-click and hold the first connection line you wish to connect
2 Drag the mouse to the second connection line you wish to connect.
1-16
Starting a New SimMechanics™ Model
1-17
1 Introduction to SimMechanics™ Software
World Frame
World Frame provides a unique inertial frame in a model, against which all
other frames are referenced. Most SimMechanics models employ at least
one World Frame block. This block belongs to the SimMechanics Frames
and Transforms sublibrary.
Mechanism Configuration
Mechanism Configuration provides a gravity vector and a numerical
linearization parameter. Each SimMechanics model can have multiple
Mechanism Configuration blocks, but only one per machine. This block
belongs to the SimMechanics Utilities sublibrary.
Solver Configuration
Solver Configuration provides solver settings for numerical simulation of
a kinematic model. Each SimMechanics model can have multiple Solver
Configuration blocks, but only one per machine. This block belongs to the
Simscape Utilities sublibrary.
1-18
Double Crank Aiming Mechanism Demo
For the suggested workflow to build a model, see the double crank aiming
mechanism demo on How To Build A Model.
1-19
1 Introduction to SimMechanics™ Software
In the model, you can see the rigid bodies and joints that make up the
mechanism. There are four links, connected by four joints: three revolute and
one prismatic. This system is an instance of a planar four-link mechanism, an
important topic in mechanical design.
Bodies
Each body is modeled as a self-contained subsystem, composed of other
SimMechanics blocks behind a mask. You can inspect and even modify the
subsystems in the demo model. To open a subsystem, right click its mask and
select Look Under Mask.
1-20
Double Crank Aiming Mechanism Demo
Inside each subsystem, there are blocks that specify geometry and inertia.
There are also blocks that specify any relevant coordinate frames — such as
those connected to joints. Subsystems are self-contained, and you can alter
them without affecting other subsystems or model architecture. The figure
below shows the block diagram for Rigid Body A in the demo model.
1-21
1 Introduction to SimMechanics™ Software
Joints
Each joint connects two rigid bodies. The joint confers relative degrees of
freedom (DOF) to the two connecting bodies. In the model:
In the joint block dialog box, you can specify initial state conditions. These
include position and velocity parameters. You can also actuate the two
connecting bodies at the joint with force or torque, and sense their relative
motion parameters — position, velocity and acceleration. To open the dialog
box, double-click the corresponding joint block.
Essential Blocks
Finally, note the use of the three essential blocks: World Frame, Solver
Configuration, and Mechanism Configuration.
World Frame and Solver Configuration are required in every model. The
former provides a common ground to all frame networks in a model; the latter
specifies model-level simulation parameters. Mechanism Configuration is not
required, but important in SimMechanics models — it specifies machine-level
simulation parameters, including the gravity vector. For more information,
see “Essential SimMechanics Blocks” on page 1-17.
1-22
Double Crank Aiming Mechanism Demo
Modeling Workflow
The demo illustrates the suggested workflow for building a model. It is good
practice to follow this workflow. The key steps highlighted in the demo are:
1 Identify the rigid bodies and joints that comprise the mechanism to model
4 Refine and troubleshoot assembly using Mechanics Explorer and the Model
Report tool
5 Specify the initial configuration using state targets in joint dialog boxes
For more information, refer to the supporting documentation for the demo
(see “Opening the Demo” on page 1-23).
1-23
1 Introduction to SimMechanics™ Software
1-24
2
Essentials of SimMechanics
Software
To model a system like this four-bar mechanism, you must specify a set
of properties and coordinate frames for each bar. You do this by adding
and connecting SimMechanics blocks on the Simulink Editor window, and
providing any relevant parameters through the block dialog box.
X
Z
Inertia
2-2
A Simple Mechanical Model
Each binary bar has two joints, one at each end. In this model, a binary bar
is represented by one solid block, specifying its physical properties, and two
Rigid Transform blocks, specifying its joint attachment points.
There are three highlighted areas. Each represents a key piece of the model:
a rigid body, a joint, and other essential blocks. The rigid body area has two
types of blocks:
• Solid
• Rigid Transform
You use these blocks to specify a set of properties and coordinate frames for
each rigid body. For more information, see “Rigid Bodies” on page 2-5 . See
also “Coordinate Frames” on page 2-12.
2-3
2 Essentials of SimMechanics™ Software
• Revolute Joint
You use this block specify the allowed degrees of freedom between two rigid
bodies. There are fourteen different Joint blocks that you can use. For more
information, see “Joints” on page 2-21.
• World Frame
• Mechanism Configuration
• Solver Configuration
You use these blocks to specify a unique inertial reference frame, a gravity
vector, as well as linearization and solver parameters. For more information,
see “Essential SimMechanics Blocks” on page 1-17.
The blocks shown above give you the basic tools to build a simple model.
With them, you can begin exploring the capability of SimMechanics. You are
not limited to these blocks. Add others as needed—to actuate your model,
constrain its motion, and sense force or motion parameters.
2-4
Rigid Bodies
Rigid Bodies
In this section...
“Specifying a Rigid Body with the Solid Block” on page 2-5
“Examining the Solid Block” on page 2-5
nce
e fere e
R ram
F Y’
X’
.
C.M Geometry
Z’
Inertia
Graphic
For solids with simple predefined shapes, the local reference frame has an
origin at the center of geometry, and axes aligned with the solid’s axes of
symmetry. The following table lists the solid properties which you can specify.
2-5
2 Essentials of SimMechanics™ Software
2-6
Modeling an H-Shaped Bar with the Solid Block
H-Bar Example
With the Solid block, you can select a pre-specified geometry (brick, cylinder,
or sphere) or a custom geometry with constant cross-section (regular and
general extrusion). A more advanced alternative allows you to import a
custom geometry using an .STL file.
In this example, you use the Solid block to specify an H-shaped bar. Later,
you can use Rigid Transform blocks to specify multiple joint attachment
points. For more information, see “Specifying a Joint Attachment Frame with
the Rigid Transform Block” on page 2-15.
The following figure illustrates the cross-section of the H-shaped bar modeled
in this example.
2-7
2 Essentials of SimMechanics™ Software
4 In the Utilities library, select one Solver Configuration block and drag it
onto the Simulink Editor window.
6 Select and drag one each of the following blocks onto the Simulink Editor
window:
Block Sublibrary
World Frame Frames and Transforms
Mechanism Configuration Utilities
Solid Body Elements library
2-8
Modeling an H-Shaped Bar with the Solid Block
Specifying Geometry
1 In your model, double-click the Solid block to open its dialog box.
2 In the Geometry section of the dialog box, select General Extrusion from
the Shape drop-down list.
Tip The General Extrusion option allows you to specify a solid with an
arbitrary cross-sectional shape.
5 In the Length field, enter 200, and select mm for the units.
Specifying Inertia
1 In the Inertia section of the dialog box, leave Type as Calculate from
Geometry.
2-9
2 Essentials of SimMechanics™ Software
Specifying Graphic
1 In the Graphic section of the dialog box, leave Type as From Geometry.
4 In the Color field, select the color you wish to apply to the H-shaped bar.
You can also specify the [R G B] color vector, for example [1 0.8 0.8].
5 In the Opacity field, specify a value smaller than 1.0 to make the H-shaped
bar transparent.
2-10
Modeling an H-Shaped Bar with the Solid Block
2-11
2 Essentials of SimMechanics™ Software
Coordinate Frames
In this section...
“Specifying Coordinate Frames with the Rigid Transform Block” on page
2-12
“Examining the Rigid Transform Block” on page 2-13
The Rigid Transform block operates on one frame (the base frame) to define a
second frame (the follower frame). You can use this block to specify a frame
with arbitrary position and orientation. Use multiple Rigid Transform blocks
to specify multiple frames in your model.
Note Itself, the Rigid Transform block does not represent a coordinate frame.
Instead, it represents the mathematical operation that is used to create one
frame from another.
• Translation
• Rotation
2-12
Coordinate Frames
Translate Rotate
Base Follower
When using a Rigid transform block, you are free to specify translation
only, rotation only, or both. When you specify both translation and rotation
operations, translation applies first, followed by rotation. If you do not
specify a transform operation, the Rigid Transform block behaves as a frame
connection line, making the base and follower frames coincident with each
other.
Note The follower frame of the Rigid Transform block is rigidly defined with
respect to the base frame. There is a static relationship between these two
frames. They cannot move independently, but only as a set.
2-13
2 Essentials of SimMechanics™ Software
e2
ram
rF
Y’ lo we
X’ Fol
.
C.M
Z’
me
Fra
Base
e1
ram
rF
lo we
Fol
The following table lists the properties which you can specify using the
Rigid Transform block. These properties correspond to the Rigid Transform
operations listed above (translation along and rotation about a single axis).
Property Function
Rotation Specify a method to rotate the
follower frame with respect to the
base frame
Translation Specify a method to translate the
follower frame with respect to the
base frame
For more information, see theRigid Transform block reference documentation.
2-14
Specifying a Joint Attachment Frame with the Rigid Transform Block
Note This example does not show you how to use the Joint block. For an
example showing how to connect two binary bars with a joint block, see
“Specifying a Joint Between Two Binary Bars” on page 2-23
2 Select and drag two Rigid Transform blocks to the Simulink Editor window
containing your model.
3 Connect the Base (B) frame ports to the connection line attached to the
Reference (R) frame port belonging to the Solid block.
2-15
2 Essentials of SimMechanics™ Software
Note You can rotate a block to better position its base frame port. To
rotate a block, on your keyboard press Ctrl+R. Each time you use this
shortcut, the selected block rotates 90 degrees clockwise.
Recall that a connection line represents a single frame along its entire length.
Also, two connection lines connected to each other share the same frame along
their entire lengths. In this figure, the two Rigid Transform base frames are
coincident with the Solid reference frame. The follower frames are defined
relative to the Solid reference frame.
Rotation
You can rotate the follower frame relative to the base frame. You do this in the
Rotation section of the Rigid Transform dialog box. With the graphic markers
added to your model, it is easy to visualize the orientation of each frame.
1 In your model, double-click the Rigid Transform block to open its dialog box.
2-16
Specifying a Joint Attachment Frame with the Rigid Transform Block
Translation
You can translate the follower frame relative to the base frame. You do this in
the Translation section of the Rigid Transform dialog box. With the graphic
markers added to your model, it is easy to visualize the location of each frame.
4 In the Offset field, specify the distance from the bar’s center of geometry to
the joint location. In the H-shaped bar example, specify +100 mm for the
first transform, and -100 mm for the second transform.
2 Select and drag three Graphic blocks to the Simulink Editor window
containing your model.
3 Connect two Graphic blocks to the follower frame port (F) on the Rigid
Transform blocks.
2-17
2 Essentials of SimMechanics™ Software
4 Connect the remaining Graphic block to the frame connection line attached
to the solid block.
Note Graphic icon size is defined in pixel units. The size remains constant
regardless of the zoom setting in the Mechanics Explorers window.
4 In the Visual Properties field, select a unique color for your graphic.
2-18
Specifying a Joint Attachment Frame with the Rigid Transform Block
2-19
2 Essentials of SimMechanics™ Software
2-20
Joints
Joints
In this section...
“Specifying Joints with Joint Blocks” on page 2-21
“Examining the Joint Blocks” on page 2-22
Base Follower
er Base
low
Fol Y Y
X
X
Z
2-21
2 Essentials of SimMechanics™ Software
er Base
Follow
Every Joint block has two frame ports, base and follower:
Base Follower
Y Y’
X
X’
Z
Z
The Joint block gives you the option to specify an initial state, apply forces
and sense motion for each joint primitive.
Property Function
State Targets Specify the initial position and
velocity of a joint primitive
Internal Mechanics Specify damping and spring forces
acting on a joint primitive
Actuation Select a mode of actuation for a joint
primitive
Sensing Select the motion parameters you
wish to sense in a joint primitive
2-22
Specifying a Joint Between Two Binary Bars
Specifying a Joint
You can use a Joint block to connect any two rigid bodies with a desired set
of degrees of freedom. In this example, you use a Joint block to connect two
H-shaped binary bars as defined above (see “Specifying a Joint Attachment
Frame with the Rigid Transform Block” on page 2-15.
2 In the Joints sublibrary, select and drag a Revolute Joint block into a
Simulink Editor window containing your model.
3 In each binary bar, identify the Rigid Transform block which specifies
the joint attachment point.
4 Connect the first Rigid Transform block to the base frame port on the
Revolute Joint block.
5 Connect the second Rigid Transform block to the follower frame port on the
Revolute Joint block.
2-23
2 Essentials of SimMechanics™ Software
2-24
Specifying a Joint Between Two Binary Bars
2 Model the four binary bars employed in the four-bar mechanism. For
more information, see “Specifying a Rigid Body with the Solid Block” on
page 2-5 and “Specifying Coordinate Frames with the Rigid Transform
Block” on page 2-12.
Tip When two rigid bodies are similar to each other, you can often build
a model for one body, then copy and paste it to model the second body.
You can change any properties as needed by opening the Solid and Rigid
Transform block dialog boxes.
2-25
2 Essentials of SimMechanics™ Software
3 Select and drag four Revolute Joint blocks from the SimMechanics Joints
library to your model window.
4 Connect each pair of binary bars with a single Revolute Joint box. For more
information, see “Specifying Joints with Joint Blocks” on page 2-21.
The following figure shows the model of a four-bar mechanism in its initial
state, using the Mechanics Explorers tool.
2-26
Specifying a Joint Between Two Binary Bars
Once you have a working SimMechanics model, you can simulate and
visualize its dynamic behavior using the Mechanics Explorers tool. The
following figure illustrates the model of a four-bar mechanism at different
points in time during the simulation. For more information, see “Model
Visualization and Animation” on page 2-48.
• Initial position
• Initial velocity
2-27
2 Essentials of SimMechanics™ Software
When you specify a joint’s initial state targets, there are two priority settings
which you can select:
1 In your model window, double-click any joint block whose initial state you
wish to specify.
2 In the Properties area of the dialog box, click the State Targets
expandable menu to display more options.
3 Check the box for the parameter you wish to specify, Position or Velocity.
Additional fields appear.
4 Specify a priority setting for the initial state target: High or Low.
The following figure shows a four bar mechanism in its default assembly
configuration, and in a guided assembly configuration.
2-28
Specifying a Joint Between Two Binary Bars
Guided Assembly
Default Assembly
2-29
2 Essentials of SimMechanics™ Software
Depending on the application, you can apply a force or torque either at a joint
or on a rigid body. Because joint actuation is very common in mechanical
systems, SimMechanics Joints blocks are designed to accept actuation inputs.
To actuate a rigid body or subsystem instead of a joint, use one of the blocks
provided in the Forces and Torques library.
To input and output forces and torques, SimMechanics blocks employ two
types of ports, outlined in the following table.
2-30
Applying a Force or Torque on a Joint
Actuating a Joint
To actuate a joint, perform the following steps:
1 In the Simulink window for your model, double-click the joint you wish to
actuate.
2-31
2 Essentials of SimMechanics™ Software
2 In the joint block dialog box, click the expandable menu for the joint
primitive you wish to actuate (e.g. Z Prismatic Primitive (Pz)).
4 In the Mode drop-down list, select the appropriate actuation input type to
expose a physical signal inport: none, force, or torque.
Note Force actuation mode is present in the Actuation menu for prismatic
joint primitives only. Torque actuation mode is present in the Actuation
menu for revolute joint primitives only.
2-32
Applying a Force or Torque on a Joint
1 In the Simulink window for your model, double-click the joint you wish to
actuate.
2 In the joint block dialog box, click the expandable menu for the joint
primitive you wish to actuate (e.g. Z Prismatic Primitive (Pz)).
2-33
2 Essentials of SimMechanics™ Software
2 From the Forces and Torques sublibrary, select and drag a force block
into the Simulink Editor window containing your model.
3 Connect the follower frame port of the force block to the frame you wish to
actuate.
4 Connect the base frame port of the force block to the frame where the
force originates.
Note Only two Forces and Torques blocks have a base frame port: Spring
and Damper Force, and Inverse Square Law Force. The External Force
and Torque block applies a force originating outside the system, and does
not need a base frame port.
2-34
Applying a Force or Torque on a Rigid Body
The following figure shows part of a SimMechanics model containing two rigid
bodies connected by a Spring and Damper Force.
2-35
2 Essentials of SimMechanics™ Software
2 In the block diagram box, enter the appropriate force constant and other
required force parameters.
1 Double-click the External Force & Torque block and select the force
components you wish to specify. The corresponding physical signal outports
appear on the affected block.
You can use Simulink source blocks to specify an arbitrary force or other
physical signal. However, Simulink signals are strictly numeric and carry no
physical units. To use a Simulink signal in a SimMechanics model, you must
first convert it to a physical signal.
2-36
Applying a Force or Torque on a Rigid Body
2-37
2 Essentials of SimMechanics™ Software
Sensing in SimMechanics
In SimMechanics, you can sense forces acting on a rigid body. When you
sense a force, SimMechanics records its value at each instant in time, so that
you can plot them in a chart or feed them into a control system. You can only
sense forces at points defined by a coordinate frame. Before you sense a force
at an arbitrary point, check that you’ve defined a coordinate frame at that
point. For more information, see“Coordinate Frames” on page 2-12.
You can only sense forces if your model includes one of these two Forces and
Torques blocks.
You can also sense motion parameters like the linear and angular position,
velocity, and acceleration at a point in a machine. Like forces, you can only
sense motion parameters at points defined by a coordinate frame. You can
sense motion parameters through all Joint blocks except the Weld Joint
block. You can only sense motion parameters if your model includes one of
these Joint blocks.
1 Confirm that your model uses at least one of the two following blocks:
2-38
Force and Motion Sensing
3 In the block dialog box, check the Sense Force box. A physical signal port
is exposed allowing you to output the force signal. You can plot the force
signal using a Simulink Scope or XY Graph block, or you can feed it to a
feedback loop used to control your model.
2-39
2 Essentials of SimMechanics™ Software
Adding spring and damping forces between two of the binary bars yields a
periodic force signal that decays as a function of time. In the model illustrated
above, you can double-click the scope block to open a plot of the time-varying
force signal between the two binary bars.
2-40
Force and Motion Sensing
Sensing Motion
To sense motion in a mechanical model:
1 Confirm that your model uses at least one Joint block other than Weld
Joint.
2 Double-click the Joint block at which you wish to sense motion parameters.
3 In the dialog box, click the expandable menu for the joint primitive you
wish to sense—for example Z Revolute Primitive (Rz).
5 Check the motion parameters which you wish to sense. Options include
Position, Velocity, and Acceleration.
2-41
2 Essentials of SimMechanics™ Software
For each motion parameters you choose to sense, a physical signal outport
appears on the selected joint block. You can plot each motion parameter in
a Simulink Sinks block—e.g. Scope or XY Graph.
2-42
Force and Motion Sensing
Configuring the Internal Mechanics section of the Joint dialog box to add
damping, yields periodic angle and angular velocity signals that decay as a
function of time. In the model illustrated above, you can double-click the
scope block during simulation to obtain a plot of the time-varying angle and
angular velocity signals.
2-43
2 Essentials of SimMechanics™ Software
2-44
Model and Machine Configuration
2-45
2 Essentials of SimMechanics™ Software
1 In the Simulink menu bar, open the Simulation menu and click
Configuration Parameters to open the Configuration Parameters dialog.
2 Select the Solver node of the dialog. Under Solver options, change
Relative tolerance to 1e-6 and Absolute tolerance to 1e-4. Change
Max step size to 0.2.
2 Note the default Gravity vector, [0 0 -9.81] m/s2, which points in the
–Z direction. The gravitational acceleration is g = 9.81 m/s2.
3 Note the default Linearization value, 0.001. This value specifies the
linearization delta perturbation value to compute the numerical partial
derivations for linearization. Change this value as necessary.
2-46
Model and Machine Configuration
2-47
2 Essentials of SimMechanics™ Software
The Mechanics Explorer has a number of controls that allow you to control
the visualization of the animation. For more information on these controls,
see “SimMechanics Visualization”.
In this section...
“Assembling and Visualizing a SimMechanics Model in its Initial State”
on page 2-48
“Simulating and Animating a Mechanical Model” on page 2-50
2-48
Model Visualization and Animation
To open an example model of a four-bar mechanism that you can visualize and
simulate, at the MATLAB command line, type sm_four_bar, or click here.
The following figure shows the sm_four_bar model in its initial state.
2-49
2 Essentials of SimMechanics™ Software
1 Check that your model has been properly configured. For more information,
see “Model and Machine Configuration” on page 2-45
2 Check that your model has been properly assembled in an initial state.
For more information, see “Assembling and Visualizing a SimMechanics
Model in its Initial State” on page 2-48
2-50
Model Visualization and Animation
2-51
2 Essentials of SimMechanics™ Software
• Click the loop button to automatically restart the animation from the
beginning once it reaches the end.
• Click and drag the animation speed slider bar to adjust the
animation speed
2-52
Model Visualization and Animation
2 Confirm the file directory and file name are correct, and click Save to save
the animation as a .AVI file in the given directory.
2-53
2 Essentials of SimMechanics™ Software
Note The software records the animation with the view you select before
you start the recording. For example, if you change the view to the
isometric view of the model, then record the animation, the viewpoint of
the animation is isometric.
3 Navigate to the directory where your animation file was saved, and open
it to play the recorded animation.
2-54