The SimMechanics™ term machine has two meanings.
It refers to a physical system that includes at least one rigid body. The SimMechanics block library allows you to create Simulink® models of machines.
It also refers to a topologically distinct and separate block diagram representing one physical machine. A model can have one or more machines.
This section explains the nature of machines and SimMechanics models.
A SimMechanics model consists of a block diagram composed of one or more machines, each of which is a set of connected blocks representing a single physical machine. For example, the following model contains two machines.
A SimMechanics model differs significantly from other Simulink models in how it represents a machine.
An ordinary Simulink model represents the mathematics of a machine's motion, i.e., the algebraic and differential equations that predict the machine's future state from its present state. The mathematical model enables Simulink to simulate the machine.
A SimMechanics model represents the physical structure of a machine, the mass properties and geometric and kinematic relationships of its component bodies. SimMechanics software converts this structural representation to an internal, equivalent mathematical model. This saves you the time and effort of developing the mathematical model yourself.
You create a SimMechanics model in much the same way you create any other Simulink model. First, you open a Simulink model window. Then you drag instances of SimMechanics and other Simulink blocks from the Simulink block libraries into the window and draw lines to interconnect the blocks (see Connecting SimMechanics Blocks).
The SimMechanics block library provides the following blocks specifically for modeling machines:
Machine Environment blocks set the mechanical environment for a machine. Exactly one Ground block in each machine must be connected to a Machine Environment block.
Body blocks represent a machine's components and the machine's immobile surroundings (ground). See Modeling Grounds and Bodies.
Joint blocks represent the degrees of freedom of one body relative to another body or to a point on ground. See Modeling Degrees of Freedom.
Constraint and Driver blocks restrict motions of or impose motions on bodies relative to one another. See Constraining and Driving Degrees of Freedom.
Actuator blocks specify forces, motions, variable masses and inertias, or initial conditions applied to bodies, joints, and drivers. See Applying Motions and Forces.
Sensor blocks measure the forces on and motions of bodies, joints, and drivers. See Sensing Motions and Forces.
Force element blocks model interbody forces. See Sensing Motions and Forces.
Simscape™ mechanical elements model one-dimensional motion and, with certain restrictions, can be interfaced with SimMechanics machines. See Combining One- and Three-Dimensional Mechanical Elements.
You can use blocks from other Simulink libraries in SimMechanics models. For example, you can connect the output of SimMechanics Sensor blocks to Scope blocks from the Simulink Sinks library to display the forces and motions of your model's bodies and joints. Similarly, you can connect blocks from the Simulink Sources library to SimMechanics Driver blocks to specify relative motions of your machine's bodies.
In general, you connect SimMechanics blocks in the same way you connect other Simulink blocks: by drawing lines between them. Significant differences exist, however, between connecting standard Simulink blocks and connecting SimMechanics blocks. This section discusses these differences.
The lines that you draw between standard Simulink blocks, called signal lines, represent inputs to and outputs from the mathematical functions represented by the blocks. By contrast, the lines that you draw between SimMechanics blocks, called connection lines, represent physical connections and spatial relationships among the bodies represented by the blocks.
You can draw connection lines only between specialized connector ports available only on SimMechanics blocks (see next section) and you cannot branch existing connection lines. Connection lines appear as solid black when connected and as dashed red lines when either end is unconnected.
Standard Simulink blocks have input and output ports. By contrast, most SimMechanics blocks contain only specialized connector ports that permit you to draw connection lines among SimMechanics blocks. SimMechanics connector ports are of two types: Body CS ports and general-purpose ports.
Body CS ports appear on Body and Ground blocks and define connection points on a body or ground. Each is associated with a local coordinate system whose origin specifies the location of the associated connection point on the body.
General-purpose connector ports appear on Joint, Constraint, Driver, Sensor, and Actuator blocks. They permit you to connect Joints to Bodies and connect Sensors and Actuators to Joints, Constraints, and Drivers. General-purpose connector ports appear as circles on the block icon. The circle is unfilled if the port is unconnected and filled if the port is connected.
SimMechanics Actuator blocks (see Applying Motions and Forces) contain standard Simulink input ports. Thus, you can connect standard Simulink blocks to a SimMechanics model via Actuator blocks. Similarly, SimMechanics Sensor blocks contain output ports (see Sensing Motions and Forces). Thus, you can connect a SimMechanics model to Simulink blocks via Sensor blocks.
Large, complex block diagram models are often hard to analyze. Enclosing functionally related groups of blocks in subsystems alleviates this difficulty and facilitates reuse of block groups in different models.
You can create subsystems containing SimMechanics blocks that you can connect to other SimMechanics blocks. You do this in two ways:
The Simulink documentation explains more about creating subsystems.
To create a SimMechanics subsystem automatically,
Create the subsystem block diagram in your model window, leaving unconnected ports for external connections.
Group-select the subsystem block diagram.
Select Create subsystem from the Edit menu of the Simulink model window.
The last step replaces the block diagram with a Subsystem block containing the selected block diagram. It also creates and connects SimMechanics Connection Port blocks for the ports that you left unconnected in the block diagram. The Connection Port blocks in turn create connector port icons on the subsystem icon, enabling you to connect external SimMechanics blocks to the new subsystem.
Sometimes you need to make a subsystem configured differently from an automatically created one. To create a SimMechanics subsystem manually,
Drag a Subsystem block into your model window.
Open the Subsystem block.
Create the subsystem block diagram in the subsystem window.
Drag a Connection Port block from the Simscape Utilities library into the subsystem window for each port that you want to be available externally.
Connect the external connector ports to the Connection Port blocks.
You can create your own SimMechanics blocks from subsystems, for example, a spring-loaded Joint block or a sphere Body block. To do this, create a block diagram that implements the functionality of your custom block, enclose the diagram as a subsystem, and add a mask (i.e., a graphical user interface) to the subsystem. To facilitate sharing your custom blocks across models or with other users, create a Simulink block library and add these masked subsystem blocks to the library. The Simulink documentation explains how to create custom blocks with masks.