Accelerating the pace of engineering and science

Documentation Center

• Trials

Sense Double-Pendulum Motion

Model Overview

The Transform Sensor block provides the broadest motion-sensing capability in SimMechanics™ models. Using this block, you can sense motion variables between any two frames in a model. These variables can include translational and rotational position, velocity, and acceleration.

In this example, you use a Transform Sensor block to sense the lower link translational position with respect to the World frame. You output the position coordinates directly to the model workspace, and then plot these coordinates using MATLAB® commands. By varying the joint state targets you can analyze the lower-link motion under quasi-periodic and chaotic conditions.

Before continuing, you must have completed example Model Double Pendulum.

Modeling Approach

In this example, you rely on gravity to cause the double pendulum to move. You displace the links from equilibrium and then let gravity act on them. To displace the links at time zero, you use the State Targets section of the Revolute Joint block dialog box. You can specify position or velocity. When you are ready, you simulate the model to analyze its motion.

To sense motion, you use the Transform Sensor block. First, you connect the base and follower frame ports to the World Frame and lower link subsystem blocks. By connecting the ports to these blocks, you can sense motion in the lower link with respect to the World frame. Then, you select the translation parameters to sense. By selecting Y and Z, you can sense translation along the Y and Z axes, respectively. You can plot these coordinates with respect to each other and analyze the motion that they reveal.

Build Model

To sense motion in the double-pendulum model:

1. Open the double_pendulum that you created in example Model Double Pendulum.

2. Drag these blocks to the model.

BlockLibraryQuantity
Transform SensorSimMechanics Second Generation (SM 2G) > Frames and Transforms1
World FrameSimMechanics Second Generation (SM 2G) > Frames and Transforms1

3. In the Transform Sensor block dialog box, select Translation > Y and Translation > Z.

4. In the PS-Simulink Converter blocks, specify cm physical units.

5. In the two To Workspace blocks, enter the variable names y_link and z_link.

6. Connect the blocks to the model as shown in the figure.

Guide Model Assembly

Specify the initial state of each joint. Later, you can modify this state to explore different motion types. For the first iteration, rotate only the top link by a small angle:

1. Double-click block Revolute Joint.

This is the block between Pivot Mount and Binary Link subsystem blocks.

2. In the State Targets section of the block dialog box, select Specify Position Target.

3. In Value, enter 10.

Check that the physical unit is deg (degrees).

Simulate Model

To simulate the model, in the Simulink® tool bar click the Run button. Alternatively, with the model window active, press Ctrl+T. Mechanics Explorer displays the model simulation in the visualization pane.

You can now plot the position coordinates of the lower link. At the MATLAB command line, enter:

```figure(1);
hold;
axis([-10 10 -40 -39])
xlabel('Y Coordinate (cm)');
ylabel('Z Coordinate (cm)');
grid on;```

The figure shows the plot that opens. This plots shows that lower link path is nearly, but not quite, the same with each oscillation. This behavior is characteristic of quasi-periodic systems.

Simulate Chaotic Motion

By adjusting the revolute joint state targets, you can simulate the model under chaotic conditions. One way to obtain chaotic motion is to rotate the top revolute joint by a large angle. To do this, in the Revolute Joint dialog box, change State Targets > Position > Value to 90 and click OK.

Simulate the model with the new joint state target. To plot the position coordinates of the lower pendulum link with respect to the World frame, at the MATLAB command line enter this code:

```figure(2);
hold;
axis([-42 42 -42 15])
xlabel('Y Coordinate (cm)');
ylabel('Z Coordinate (cm)');
grid on;```

The figure shows the plot that opens. This plots shows that lower link path is very different with each oscillation. This behavior is characteristic of chaotic systems.

Save Model

So that you can reuse this model in subsequent examples, save it in a convenient folder as double_pendulum.