Model a Simple Link

Tutorial Overview

Mechanical links are common building blocks in linkages, mechanisms, and machines. The simple pendulum is an example with one link. In this tutorial, you model a simple link with two end frames that you can later connect to joints. Rigid Transform blocks provide the end frames, while a Solid block provides geometry, inertia, and color. For simplicity, the model assumes the link has a brick shape.

Build Model

  1. At the MATLAB® command line, enter smnew. The Simscape™ Multibody™ block library and a model template with commonly used blocks open up.

  2. Make a copy of the Rigid Transform block and paste it in the model. The Rigid Transform blocks enable you to create new frames to which you can connect joints during multibody assembly.

  3. Delete the blocks Simulink-PS Converter, PS-Simulink Converter, and Scope. You do not need these blocks in this tutorial.

  4. Connect the remaining blocks as shown in the figure. Ensure that the base frame ports (B) of the Rigid Transform blocks both face the Brick Solid block frame port. Since each Rigid Transform block applies a spatial transformation with respect to its base frame, switching port connections generally changes the spatial relationship between the two frames.

  5. In the Brick Solid block dialog box, specify the following parameters. Later, you define the MATLAB variables shown using a Subsystem block that contains the Solid and Rigid Transform blocks. Among its advantages, this approach enables you to update variables used in multiple blocks from a single place—the Subsystem block dialog box.

    Geometry > Dimensions[L W H]Change to cm
    Inertia > DensityrhoDefault units
    Graphic > Visual Properties > ColorrgbNot applicable

  6. In the dialog boxes of the Rigid Transform and Rigid Transform1 blocks, specify the following parameters. These parameters encode the offset between the base and follower port frames of the Rigid Transform blocks, located at the link ends, with respect to the Solid reference port frame.

    ParameterRigid Transform1Rigid TransformUnits
    Translation > MethodStandard AxisStandard AxisNot applicable
    Translation > Axis-X+XNot applicable
    Translation > OffsetL/2L/2Change to cm

Generate Subsystem

  1. Select the Brick Solid block and the two Rigid Transform blocks.

  2. Right-click the highlighted region and select Create Subsystem from Selection. Simulink® adds a new Subsystem block containing the Solid and Rigid Transform blocks. At the end of the tutorial, this will be a custom block representing the simple link body.

  3. Right-click the Subsystem block, and select Mask > Create Mask. A mask editor opens up, enabling you to specify the numerical values of the MATLAB variables you entered in the Solid and Rigid Transform block dialog boxes.

  4. In the Parameters & Dialog tab of the Mask Editor window, add five edit fields to the Parameters folder. You can find this folder in the Dialog box pane. In the edit fields, specify the following parameters and click OK. Prompt is the desired text for each parameter in the Subsystem block dialog box. Name is the MATLAB variable associated with each Subsystem block parameter.

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

  5. Double-click the Subsystem block dialog box and enter the following numerical values. These are the values of the MATLAB variables that you entered in the Solid and Rigid Transform block dialog boxes.

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

Visualize Model

Update the block diagram. In the Modeling tab, click Update Model. Mechanics Explorer opens with a front view of the simple link model. In the Mechanics Explorer toolstrip, select the isometric view button to obtain the 3-D view shown below. To view the frames present in the model—including those you created using the Rigid Transform blocks—select View > Show Frames in the Mechanics Explorer menu bar.

Save Custom Block

Rename the Subsystem block Simple Link and save it in a custom block library. You reuse this block in tutorial Model a Simple Pendulum.

Simple Link Custom Block