Documentation Center

  • Trial Software
  • Product Updates

Model Pendulum

Model Overview

The pendulum is the simplest mechanical system you can model. This system contains two rigid bodies, a link and a fixed pivot, connected by a revolute joint. In this tutorial, you model and simulate a pendulum using the custom link block you created in Model Simple Link. A Revolute Joint block provides the rotational degree of freedom between the link and the world frame.

Build Model

  1. At the MATLAB® command line, enter smnew. The SimMechanics™ block library and a new model open up.

  2. In the model, delete all blocks except Solver Configuration, World Frame, and Mechanism Configuration.

  3. Drag the custom Link block into the model.

    This is the block you created in the tutorial Model Simple Link.

  4. Drag the following SimMechanics blocks into the model.

    LibraryBlock
    SimMechanics > Second Generation > JointsRevolute Joint
    SimMechanics > Second Generation > Body ElementsSolid

  5. Connect the blocks as shown in the figure.

  6. In the Solid block dialog box, specify these parameters.

    ParameterValue
    Geometry > Dimensions[4 4 4] (units of cm)
    Graphic > Visual Properties > Color[0.80 0.45 0]

Specify Gravity

The Revolute Joint block sets the common Z axis of its base and follower frames as the rotation axis. To ensure that gravity acts in an orthogonal direction to the rotation axis, you must change the gravity vector—by default [0 0 -9.8] m/s^2. To specify gravity so it acts along the -Y axis:

  1. Double-click the Mechanism Configuration block.

  2. In Uniform Gravity > Gravity, enter [0 -9.81 0] and click OK..

Add Motion Sensing

You can sense motion between the joint frames using the joint block. To specify the angular position of the follower frame with respect to the base frame about the common Z axis:

  1. Double-click the Revolute Joint block.

  2. Select Sensing > Position and click OK.

  3. Drag the following blocks into the model.

    BlockLibrary
    PS-Simulink ConverterSimscape > Utilities
    ScopeSimulink > Sinks

  4. Connect the blocks as shown in the figure.

Guide Model Assembly

Specify the initial angle between the joint base and follower port frames:

  1. Double-click the Revolute Joint block.

  2. Select State Targets > Specify Position Target.

  3. In Value, enter -60 and click OK.

Assemble and Simulate Model

In the model window, press Ctrl+D. SimMechanics assembles the model in its initial configuration. Mechanics Explorer displays a 3-D view of this configuration with the Z axis pointing up. Since gravity acts along the -Y axis, it helps to change the view convention so the Y axis points up.

  1. In Mechanics Explorer, set View convention to Y up (XY Front).

  2. Click any of the view buttons to refresh the viewpoint. The figure shows the pendulum model from an isometric viewpoint.

  3. Simulate the model. You can do this in the Simulink Editor menu bar by selecting Simulation > Run. Mechanics Explorer shows a 3-D animation of the simple pendulum.

  4. Double-click the Scope block to analyze the time-varying revolute joint angle.

The figure shows the resulting plot in units of radians. Click the Autoscale button to fit the plot to the viewing area.

Was this topic helpful?