Representing Machines with Models

About Machines

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.

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

Comparison to Other Simulink Models

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.

Creating a SimMechanics Model

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:

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.

Connecting SimMechanics Blocks

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.

Connection Lines

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.

Connector Ports

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.

Interfacing SimMechanics Blocks to Simulink Blocks

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.

Creating SimMechanics Subsystems

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:

  • Automatically

  • Manually

The Simulink documentation explains more about creating subsystems.

Creating a Subsystem Automatically

To create a SimMechanics subsystem automatically,

  1. Create the subsystem block diagram in your model window, leaving unconnected ports for external connections.

  2. Group-select the subsystem block diagram.

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

Creating a Subsystem Manually

Sometimes you need to make a subsystem configured differently from an automatically created one. To create a SimMechanics subsystem manually,

  1. Drag a Subsystem block into your model window.

  2. Open the Subsystem block.

  3. Create the subsystem block diagram in the subsystem window.

  4. Drag a Connection Port block from the Simscape Utilities library into the subsystem window for each port that you want to be available externally.

  5. Connect the external connector ports to the Connection Port blocks.

Creating Custom SimMechanics Blocks with Masks

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.

Was this topic helpful?