Products & Services Solutions Academia Support User Community Company

Learn more about SimMechanics   

Creating a Closed-Loop Mechanical Model

Modeling the Four Bar Mechanism

In this tutorial, you build a model of a planar, four bar mechanism and practice using some of the important SimMechanics features.

You are urged to work through Creating a Simple Mechanical Model and Visualizing a Simple Mechanical Model in this chapter before proceeding with this section. Learn more about how to position and orient bodies in the Representing Motion chapter.

The system consists of three moving bars of homogeneous steel, two connected at one end each to ground points and a third crossbar connecting the first two. The base acts as an immobile fourth bar, with a Ground at each end. The mechanism forms a single closed loop, and its motion is confined to two dimensions.

A Four Bar Mechanism

The elementary parts of the mechanism are the bodies, while the revolute joints are the idealized rotational degrees of freedom (DoFs) at each body-to-body contact point. The bodies and the joints expressing the bodies' relative motions must be translated into corresponding SimMechanics blocks. If you want, you can add elaborations such as Constraints, Drivers, Sensors, and Actuators to this essential block diagram.

Viewing a Mechanical Drawing of the Four Bar Mechanism

Click here to open a detailed mechanical drawing of the four bar system.

Counting the Degrees of Freedom

The three moving bars are constrained to move in a plane. So each bar has two translational and one rotational DoFs, and the total number of mechanical DoFs, before counting constraints, is 3*(2+1) = 9.

Because the motion of the bars is constrained, however, not all of these nine DoFs are independent:

The eight restrictions on the nine apparent DoFs reduce the DoFs to one, 9 - 8 = 1. There are four rotational DoFs between bars or between bars and grounds. But three of these are dependent. Specifying the state of one rotational DoF fully specifies the other three.

Configuring the Mechanical Environment

Open a new blank model window from the SimMechanics library. From the Bodies library, drag in and drop a Machine Environment block and a Ground block. Enable the Ground's Machine Environment port and connect the environment block to the Ground.

First you need to configure the machine's mechanical settings. Open the Machine Environment block. The block dialog box appears.

The Machine Environment Dialog Box Tabs

Click the four tabs in succession to display each pane.

TabFunction
ParametersControls general settings for mechanical simulations
ConstraintsSets constraint tolerances and how constraints are interpreted
LinearizationControls how SimMechanics models are linearized with Simulink
VisualizationChooses whether or not to visualize the machine

Note some important features of this dialog box:

Close the dialog by clicking OK.

Starting Visualization

To visualize the bodies as you build the model, go to the SimMechanics node of the Configuration Parameters dialog:

  1. Select the Display machines after updating diagram check box. If you want to animate the simulation later when you run the model, select the Show animation during simulation check box as well. Click OK or Apply.

    Then select Update Diagram from the Edit menu or enter Crtl+D at the keyboard. The visualization window opens.

  2. In the Model menu, select Body Geometries, then Ellipsoids.

    As you add and change bodies in your model, you can update the display in your window at any time by updating your diagram.

Setting Up the Block Diagram

In this set of steps, you create Bodies, position them, connect them with Joints, then configure the Body and Joint properties. The Body dialog boxes give you many ways to represent the same system in the same physical state. This section explains one way.

Alternative, equivalent ways of configuring Bodies are discussed in Body Coordinate Systems.

MAT-File Data Entry

The geometric and mass properties you need to specify for the Grounds and Bodies in this model are listed in the tables of the following two sections, Configuring the Ground and Joint Blocks and Configuring the Body Blocks.

Instead of typing the numerical values of these properties into the dialog boxes, you can load the variable set you need into the workspace by entering

load fourbar_data

at the MATLAB command line. The variable name for each property is given in the tables. Just enter the appropriate variable names in the appropriate fields as you come to them in the dialog boxes.

If you are working with online Help, you can click here to load the fourbar_data.mat file into the workspace.

Block Diagram Setup

Your model already has one environment block and one ground block. Assemble the full model with these steps:

  1. In the block library, open the Bodies library. Drag and drop another Ground block and three Body blocks into the new model window. Close the Bodies library.

  2. From the Joints library, drag and drop four Revolute blocks into the model window.

  3. Rotate and connect the blocks in the pattern shown in the following figure or with an equivalent block diagram topology.

    Use the block names shown in this figure for later consistency.

    Connected Environment, Ground, Body, and Joint Blocks for the Four Bar

Block Diagram Topology.   The topology of the block diagram is the connectivity of its elements. The elements are the Bodies and Grounds, connected by the Joints. Unlike the model of Creating a Simple Mechanical Model, the four bar mechanism is a closed-loop mechanism. The two Ground blocks represent points on the same absolute, immobile body, and they close the loop of blocks. The simple pendulum has only one ground and does not close its block connections.

To maintain consistent Body motion direction, make sure the Body coordinate system (CS) port pairs on each Body follow the sequence CS1-CS2, CS1-CS2, etc., for each bar, moving from Ground_1 to Ground_2, from right to left, as shown. To make the Joints consistent with the Body motion, the base-follower pairs B-F, B-F, etc., should follow the same right-to-left sequence.

Configuring the Ground and Joint Blocks

Now configure the Ground blocks with the data from the following table. Grounded coordinate systems (CSs) are automatically created.

Geometry of the Four Bar Base

This table summarizes the geometry of ground points.

Geometric Properties of the Four Bar Grounds

PropertyValueMAT-File Variable
Ground_1 point (m)[ 0.433 0.04 0 ]gpoint_1
Ground_2 point (m)[-0.434 0.04 0 ]gpoint_2

The base of the mechanism has these measurements:

Setting Up the Grounds

To represent ground points on the immobile base, you need to configure the Ground blocks. Use the variable names if you've loaded fourbar_data.mat into your workspace:

  1. Open Ground_1 and enter [ 0.433 0.04 0 ] or gpoint_1 in the Location field.

  2. Open Ground_2 and enter [-0.434 0.04 0 ] or gpoint_2 in the Location field.

  3. Leave both pull-down menus for units at default m (meters).

Configuring the Revolute Joints

The three nongrounded bars move in the plane of your screen (x-y plane), so you need to make all the Revolute axes the z-axis (out of the screen):

  1. Open each Revolute's dialog box in turn. In its Parameters area, note on the Axes tab that the z-axis is the default: Axis of Action is set to [0 0 1] in each, relative to Reference CS World. Leave these defaults.

    A Revolute block contains only one primitive joint, a single revolute DoF. So the Primitive is automatically revolute. Its name within the block is R1.

  2. Leave these Revolute joint block defaults and ignore the Advanced tab.

The Body CS and base-follower joint directionality should be set up as shown in the block diagram of the figure Connected Environment, Ground, Body, and Joint Blocks for the Four Bar. In the Connection parameters area, the default Joint directionality for each Revolute automatically follows the right-to-left sequence of Grounded and Body CSs:

In this Joint directionality convention,

Configuring the Body Blocks

Setting the Body properties is similar for each bar, but with different parameter values entered into each dialog box:

In contrast to the first tutorial, where you specify Body CS properties with respect to the absolute World CS, in this tutorial, you specify Body CS origins on the bars in relative coordinates, displacing Bar1's CS1 relative to Ground_1, Bar2's CS1 relative to Bar1, and so on, around the loop. You can refer the definition of a Body CS to three types of coordinate systems:

The components of the displacement vectors for each Body CS origin continue to be oriented with respect to the World axes. The rotation of each Body's CG CS axes is also with respect to the World axes, in the Euler X-Y-Z convention.

The following three tables summarize the body properties for the three bars.

Bar1 Mass and Body CS Data (MKS Units)

PropertyValueVariable Name
Mass5.357m_1
Inertia tensor[1.07e-3 0 0;
0 0.143 0;
0 0 0.143]
inertia_1
CG Origin[0.03 0.282 0] from CS1 in axes of Worldcg_1
CS1 Origin[0 0 0] from Adjoining in axes of Worldcs1_1
CS2 Origin[0.063 0.597 0] from CS1 in axes of Worldcs2_1
CG Orientation[0 0 83.1] from World in convention Euler X-Y-Zorientcg_1

Bar2 Mass and Body CS Data (MKS Units)

PropertyValueVariable Name
Mass9.028m_2
Inertia tensor[1.8e-3 0 0;
0 0.678 0;
0 0 0.678]
inertia_2
CG Origin[-0.427 0.242 0] from CS1 in axes of Worldcg_2
CS1 Origin[0 0 0] from Adjoining in axes of Worldcs1_2
CS2 Origin[-0.87 0.493 0] from CS1 in axes of Worldcs2_2
CG Orientation[0 0 29.5] from World in convention Euler X-Y-Zorientcg_2

Bar3 Mass and Body CS Data (MKS Units)

PropertyValueVariable Name
Mass0.991m_3
Inertia tensor[2.06e-4 0 0;
0 1.1e-3 0;
0 0 1.1e-3]
inertia_3
CG Origin[-0.027 -0.048 0] from CS1 in axes of Worldcg_3
CS1 Origin[0 0 0] from Adjoining in axes of Worldcs1_3
CS2 Origin[0 0 0] from Adjoining in axes of Worldcs2_3
CG Orientation[0 0 60] from World in convention Euler X-Y-Zorientcg_3

Configuring the Bodies

Here are the common steps for configuring the Body dialogs of all three bars. See the three preceding tables for Body dialog box mass property (mass and inertia tensor) entries. The units are MKS: lengths in meters (m), masses in kilograms (kg), and inertia tensors in kilogram-meters2 (kg-m2).

  1. Open all three Body dialogs for each bar. Enter the mass properties for each from the tables in the Mass and Inertia fields.

  2. Now work in the Body coordinate systems area, the Position tab:

    1. Set the Components in Axes of menu, for each Body CS on each bar, to World.

    2. Leave units as default m (meters).

  3. Set the Body CS properties for each Body CS on each bar from the data of the preceding tables:

    1. Enter the Body CS origin position data for CG, CS1, and CS2 on each bar from the tables or from the corresponding MAT-file variables.

    2. Set the Translated from Origin of menu entries for each Body CS on each bar according to the values in the tables.

  4. Select the Orientation tab by clicking its tab:

    1. Enter the Orientation Vector for the CG on each bar from the tables or from the corresponding MAT-file variables.

    2. Choose World for Relative CS in each case.

    3. Leave the other fields in their default values.

Visualizing the Bodies

The front view of the four bar mechanism, with the bodies displayed as equivalent ellipsoids, looks like this:

Sensing Motion and Running the Model

You finish building your model by setting initial conditions and inserting Sensors.

Before you start a simulation, you need to set its kinematic state or initial conditions. These include positions/angles and linear/angular velocities. This information, the machine's initial kinematic state, is discussed further in Kinematics and the Machine's State of Motion and Applying Motions and Forces.

You can sense motion in any model in two basic ways: sensing bodies or sensing joints. Here you sense Joint motion, using Joint Sensor blocks and feeding their Simulink signal outputs to Scope blocks.

Connecting the Joint Sensors

To sense the motion of the Revolute2 and Revolute3 blocks,

  1. From the Sensors & Actuators library, drag and drop two Joint Sensor blocks into the model window. Drag Joint Sensor next to Revolute2 and Joint Sensor1 next to Revolute3.

  2. Before you can attach a Joint Sensor block to a Revolute block, you need to create a new open round connector port on the Revolute. Open Revolute2's dialog box:

    1. In the Connection parameters area in the middle, adjust the spinner menu Number of sensor/actuator ports to the value 1. Click OK.

      A new connector port appears on Revolute2.

    2. Connect this connector port to the open round connector port on Joint Sensor.

  3. Now repeat the same steps with Revolute3:

    1. Create one new connector port on Revolute 3.

    2. Connect this port to Joint Sensor1.

  4. Be sure to connect the outports > of the Sensor blocks to a Simulink Sink block. These outports are normal Simulink signals.

Graphical Plot of Joint Motion with a Scope Block

Here you can view the Joint Sensor measurements of Revolute2 and Revolute3's motions using a Scope block from the Simulink Sinks library:

  1. Open the Simulink Library Browser. From the Sinks library, drag and drop a Scope block into your model window in between Joint Sensor and Joint Sensor1 blocks. Rename the Scope block "Angle."

  2. Open the Angle block. In this scope window's toolbar, open the Parameters box. Under Axes, reset Number of axes to 2. Click OK. A second inport > appears on the Angle block.

  3. Expand the scope window for ease of viewing.

  4. Connect the Joint Sensor and Joint Sensor1 block outports > to the Angle block inports >.

  5. Open Joint Sensor and Joint Sensor1:

    1. In the Measurements area, Connected to primitive is set to R1 in both blocks, indicating the first and only primitive revolute inside Revolute2 and Revolute3 to which each Sensor can be connected.

    2. Select the Angle check box to measure just the angle. Leave the units in default as deg (degrees). The Simulink line will contain one scalar.

Your completed model should look similar to the mech_four_bar demo model.

Configuring and Running the Simulation

Now take the final steps to prepare and start the model:

  1. In the model window Simulation menu, select Configuration Parameters:

    1. In the Solver node, change Absolute tolerance to 1e-6.

    2. Leave the other defaults and click OK.

  2. Now run the model by clicking Start in the Simulink toolbar. The four bar mechanism will fall under the influence of gravity.

Note some features of the simulation:

Animation

If you leave your visualization window open at the time you start the simulation and select the Animate machine during simulation check box in the SimMechanics node of the Configuration Parameters dialog, the visualized machine moves in step with the simulation.

You can now compare the animated motion with the Scope plots of the Revolute2 and Revolute3 angles.

Viewing a Four Bar Mechanism Animation

If you are connected to the Internet, have an AVI-compatible media streaming application installed on your system, and want to play a recorded animation of this system:

  1. Click the following link. When the download dialog opens, choose Save to file and specify a file name and location on your system.

  2. Click OK to save the AVI file to your system.

  3. Once the downloading is complete, start the AVI animation on your system.

If you do not have an AVI-compatible application, consider using the MATLAB aviread and movie commands instead.

This is a compressed AVI recording, which requires that you have the Indeo 5 video codec installed to decompress and play.

Download animation

For More About the Four Bar Mechanism

The four bar system is also discussed in the context of advanced SimMechanics features and methods: Modeling Degrees of Freedom, Validating Mechanical Models, Finding Forces from Motions, Trimming Mechanical Models, and Linearizing Mechanical Models.

  


Related Products & Applications

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS