|On this page…|
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 this system using the custom link block you created in Model Simple Link. A Revolute Joint block represents the joint connecting the link to the fixed pivot.
At the MATLAB® command line, enter smnew. The SimMechanics™ block library and a new model open up.
In the model, delete all blocks except Solver Configuration, World Frame, and Mechanism Configuration.
Drag the custom Link block into the model.
This is the block you created in the tutorial Model Simple Link.
Drag the following SimMechanics blocks into the model.
|Revolute Joint||SimMechanics Second Generation (SM 2G) > Joints||1|
|Solid||SimMechanics Second Generation (SM 2G) > Body Elements||1|
Connect the blocks as shown in the figure.
In the Solid block dialog box, specify these parameters.
|Geometry > Dimensions||[4 4 4]cm|
|Graphic > Visual Properties > Color||[0.80 0.45 0]|
The Revolute Joint block sets the common Z axis of its base and follower frames as the rotation axis. To ensure gravity acts in an orthogonal direction to the rotation axis, you must change the gravity vector. In this procedure, you specify gravity so it acts along the -Y axis.
Double-click the Mechanism Configuration block.
In Gravity, enter [0 -9.81 0] and click OK.
For model analysis, you can sense joint motion directly from the joint block. In this procedure, you sense the angular position of the joint. This position is the angle of the joint follower frame with respect to the base frame.
Set the initial angle at the revolute joint between the link and the fixed pivot.
Double-click the Revolute Joint block.
Select State Targets > Specify Position Target.
In Value, enter -60 and click OK.
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.
In Mechanics Explorer, set View convention to Y up (XY Front).
Click any of the view buttons to refresh the viewpoint. The figure shows the pendulum model in the isometric view.
Simulate the model. Mechanics Explorer plays a 3-D animation of the model simulation.
Double-click the Scope block to analyze the angular position of the revolute joint.
The figure shows the angular position plot in radian units. Click the autoscale button to view the full plot.