Main Content

Analyze a Simple Pendulum

Tutorial Overview

In this tutorial, you explore the various forces and torques that you can add to a model. Then, using blocks with motion sensing capability, you analyze the resulting dynamic response of the model. The end result is a set of time-domain and phase plots, one for each combination of forces and torques. You create these plots using MATLAB®commands withSimscape™ Multibody™motion outputs as arguments.

Your starting point is the simple pendulum model that you built inModel a Simple Pendulum. By adding forces and torques to this model, you incrementally change the pendulum from undamped and free to damped and driven. The forces and torques that you apply include:

  • Gravitational force (Fg) — Global force, acting on every body in direct proportion to its mass, that you specify in terms of the acceleration vector g. You specify this vector using the Mechanism Configuration block.

  • Joint damping (Fb) — Internal torque, between the pendulum and the joint fixture, that you parameterize in terms of a linear damping coefficient. You specify this parameter using the Revolute Joint block that connects the pendulum to the joint fixture.

  • Actuation torque (FA) — Driving torque, between the pendulum and the joint fixture, that you prescribe directly as a Simscape physical signal. You prescribe this signal using the Revolute Joint block that connects the pendulum to the joint fixture.

Sense Pendulum Motion

  1. Open the simple_pendulum model that you created in tutorialModel a Simple Pendulum.

  2. In the Sensing menu of the Revolute Joint block dialog box, select the following variables:

    • Position

    • Velocity

    The block exposes two additional physical signal ports, labeled q and w, that output the angular position and velocity of the pendulum with respect to the world frame.

  3. Add the following blocks to the model. You use them here to output the joint position and velocity to the MATLAB base workspace.

    Library Block Quantity
    Simscape>Utilities PS-Simulink Converter 2
    金宝app>Sinks To Workspace 2

  4. Change theVariable nameparameters in the To Workspace block dialog boxes toqandw. These variables make it easy to identify the joint variables that the To Workspace blocks output during simulation—position, through the Revolute Joint block port q, and velocity, through the Revolute Joint block port w.

  5. Connect the blocks as shown in the figure. Ensure that theTo Workspaceblock with variable nameqconnects, through thePS-Simulink Converterblock, to theRevolute Jointblock port q, and that the To Workspace block with variable namewconnects to theRevolute Jointblock portw.

  6. Save the model under a different name, e.g.,simple_pendulum_analysis, in a convenient folder.

Analyze Undamped Pendulum

  1. Run the simulation. Mechanics Explorer opens with a 3-D animation of the simple pendulum model.

  2. Plot the joint position and velocity with respect to time, e.g., by entering the following code at the MATLAB command prompt:

    figure; % Open a new figure hold on; plot(q); % Plot the pendulum angle plot(w); % Plot the pendulum angular velocity
    图显示了生成的阴谋。

  3. Plot the joint angular velocity with respect to the angular position, e.g., by entering the following code at the MATLAB command prompt.

    figure; plot(q.data, w.data);
    The result, shown in the figure, is the phase plot of the joint corresponding to a starting position of zero degrees with respect to the horizontal plane.

    Try simulating the model using different starting angles. You can change the starting angle in theState Targets>Position菜单的转动关节薄块对话框x. The figure shows a compound phase plot for starting angles of -80, -40, 0, 40, and 80 degrees.

Analyze Damped Pendulum

  1. In the Revolute Joint block dialog box, setInternal Mechanics>阻尼to8e-5(N*m)/(deg/s). The damping coefficient causes energy dissipation during motion, resulting in a gradual decay of the pendulum oscillation amplitude.

  2. Ensure thatState Targets>Position>Valueis set to0deg.

  3. Run the simulation.

  4. Plot the joint position and velocity with respect to time. To do this, at the MATLAB command prompt, you can enter this code:

    figure; hold on; plot(q); plot(w);
    图显示了生成的阴谋。请注意,pendulum oscillations decay with time due to damping. At larger damping values, the pendulum becomes overdamped, and the oscillations disappear altogether.

  5. Plot the joint phase plot. To do this, at the MATLAB command prompt, you can enter this code:

    figure; plot(q.data, w.data);
    图显示了生成的阴谋。

    Try simulating the model using different starting angles. You can change the starting angle in theState Targets>Position菜单的转动关节薄块对话框x. The figure shows a compound phase plot for starting angles of -240, -180, -120, -60, 0, and 60 degrees.

Analyze Damped and Driven Pendulum

  1. In the Revolute Joint block dialog box, setActuation>TorquetoProvided by Input. The block exposes a physical signal input port that you can use to prescribe the joint actuation torque.

  2. Add these blocks to the model.

    Library Block
    Simscape>Utilities Simulink-PS Converter
    金宝app>Sources Sine Wave

    The Sine Wave block provides a periodic torque input as a Simulink®signal. The Simulink-PS Converter block converts the Simulink signal to a Simscape physical signal compatible withSimscape Multibodyblocks.

  3. Connect the blocks as shown in the figure.

  4. In the Sine Wave block dialog box, setAmplitudeto0.06. This amplitude corresponds to an actuation torque oscillating between -0.06 N and 0.06 N.

  5. In the Revolute Joint block dialog box, ensure thatState Targets>Position>Valueis set to0deg.

  6. Run the simulation.

  7. Plot the joint position and velocity with respect to time. To do this, at the MATLAB command prompt, you can enter this code:

    figure; hold on; plot(q); plot(w);
    图显示了生成的阴谋。

  8. Plot the joint phase plot. To do this, at the MATLAB command prompt, you can enter this code:

    figure; plot(q.data, w.data);
    图显示了生成的阴谋。