# Documentation

## Representing Machines with Models

### Warning

This content is specific to Simscape™ Multibody™ First Generation software. First-generation features are slated to be deprecated and should be avoided.

The Simscape Multibody term machine has two meanings.

• It refers to a physical system that includes at least one rigid body. The Simscape Multibody 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 Simscape Multibody models.

### About Simscape Multibody Models

A Simscape Multibody 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 Simscape Multibody 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 Simscape Multibody model represents the physical structure of a machine, the mass properties and geometric and kinematic relationships of its component bodies. Simscape Multibody 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 Simscape Multibody Model

You create a Simscape Multibody model in much the same way you create any other Simulink model. First, you open a Simulink model window. Then you drag instances of Simscape Multibody and other Simulink blocks from the Simulink block libraries into the window and draw lines to interconnect the blocks (see Connecting Simscape Multibody Blocks).

The Simscape Multibody block library provides the following blocks specifically for modeling machines:

You can use blocks from other Simulink libraries in Simscape Multibody models. For example, you can connect the output of Simscape Multibody 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 Simscape Multibody Driver blocks to specify relative motions of your machine's bodies.

### Connecting Simscape Multibody Blocks

In general, you connect Simscape Multibody 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 Simscape Multibody 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 Simscape Multibody 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 Simscape Multibody 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 Simscape Multibody blocks contain only specialized connector ports that permit you to draw connection lines among Simscape Multibody blocks. Simscape Multibody 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 Simscape Multibody Blocks to Simulink Blocks

Simscape Multibody Actuator blocks (see Applying Motions and Forces) contain standard Simulink input ports. Thus, you can connect standard Simulink blocks to a Simscape Multibody model via Actuator blocks. Similarly, Simscape Multibody Sensor blocks contain output ports (see Sensing Motions and Forces). Thus, you can connect a Simscape Multibody model to Simulink blocks via Sensor blocks.

### Creating Simscape Multibody 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 Simscape Multibody blocks that you can connect to other Simscape Multibody blocks. You do this in two ways:

• Automatically

• Manually

The Simulink documentation explains more about creating subsystems.

#### Creating a Subsystem Automatically

To create a Simscape Multibody 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. In the Simulink menu bar, select Diagram > Subsystem & Model Reference > Create Subsystem from Selection.

The last step replaces the block diagram with a Subsystem block containing the selected block diagram. It also creates and connects Simscape Multibody 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 Simscape Multibody 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 Simscape Multibody subsystem manually,

1. From the Simulink Ports & Subsystems library, add a Subsystem block to the model.

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.