Main Content

## Model a Simple Link

Mechanical links are common building blocks in linkages, mechanisms, and machines. In this example, you learn how to model a simple mechanical link using Simscape™ Multibody™. For simplicity, the model assumes the link has a brick shape and two end frames.

### Build Model

1. At the MATLAB® command line, enter `smnew`. A Simscape Multibody model template with commonly used blocks opens.

2. Delete the Simulink-PS Converter, PS-Simulink Converter, and Scope blocks because they are not used in this example.

3. Show the names of the Rigid Transform and Brick Solid blocks if they are not shown already. Right-click the block and select Format > Show Block Name > On.

4. Duplicate the Rigid Transform block to add a second end frame to the link.

5. Flip the Rigid Transform1 block so that you can connect the B ports of two Rigid Transform blocks to each other and the Brick Solid block.

6. Connect the remaining blocks like the following figure.

7. In the Brick Solid dialog box, specify the following parameters. These parameters define the simple link's physical properties, such as shape, mass, and appearance.

ParameterValueUnits
Geometry > Dimensions`[L W H]``cm`
Inertia > Density`rho``kg/m^3`
Graphic > Visual Properties > Color`rgb`Not applicable

8. In the Rigid Transform blocks, specify the following parameters. These parameters specify the locations of two end frames on the simple link. After you enter the parameters, the Brick Solid and Rigid Transform blocks will be highlighted in red because you have not defined the variables yet. This issue will be solved after inputting all the numerical values for the parameters, which will be described in the following section.

ParameterRigid Transform1Rigid TransformUnits
Translation > Method`Standard Axis``Standard Axis`Not applicable
Translation > Axis`-X``+X`Not applicable
Translation > Offset`L/2``L/2``cm`

### Generate Subsystem

You can build a complex multibody system using several simple models, such as a simple link model. The physical parameters of these simple models usually need to be adjusted to fit different design requirements. To simplify the parameter adjusting process, you can create Subsystem blocks for these simple models. A Subsystem block enables you to update many parameters in a single place—the Subsystem block dialog box. In this section, you learn how to create a Subsystem block for the simple link model.

1. Select the Brick Solid block and the two Rigid Transform blocks by holding shift and clicking the blocks.

2. Right-click one of the selected blocks and select Create Subsystem from Selection. Simulink® adds a new Subsystem block that contains the Brick Solid and Rigid Transform blocks.

3. Double-click the Subsystem box. A new tab displays the children blocks of the Subsystem block. Double-click the Conn1 and set Port location on parent subsystem to left. Click to apply the change and navigate back to the parent model by clicking the up arrow button next to the Subsystem tab.

4. Adjust the size and location of the Subsystem block as shown in the figure.

5. Right-click the Subsystem block and select Mask > Create Mask. The Mask Editor window opens, where you can define the MATLAB variables that you entered in the Brick Solid and Rigid Transform block dialog boxes.

6. Click the Parameters & Dialog tab and click Edit five times to create five Edit fields. In the Edit fields, specify the following parameters and click OK. The Prompt property specifies the names of the parameters that you can enter in the Subsystem block parameter window. The Name property specifies their corresponding MATLAB variables.

PromptName
`Length (cm)``L`
`Width (cm)``W`
`Thickness (cm)``H`
`Density (kg/m^3)``rho`
`Color [R G B]``rgb`

7. Double-click the Subsystem block. Enter the following numerical values in the Subsystem Block Parameters window and click OK. These values specify the shape of Brick Solid and the location of Rigid Transform blocks.

ParameterValue
`20`
Width (cm)`1`
Thickness (cm)`1`
Density (kg/m^3)`2700`
Color [R G B]`[0.25 0.40 0.70]`

### Visualize Model

Run the model. The Mechanics Explorer opens with a front view of the simple link model. To see the 3D view of the model, click the isometric view button . To view the frames in the model, in the Mechanics Explorers tab, select View > Show Frames in the Mechanics Explorer menu bar.

### Save Custom Block

To reuse this Subsystem block in other examples, such as the Model a Simple Pendulum example, you can change its name to Simple Link and save it as a custom block. For more information, see Design and Create a Custom Block.

Simple Link Custom Block