# Documentation

## Model Pivot Mount

### Model Overview

In this example, you model a simple pivot mount. This mount is a compound rigid body with a hexagonal shape and a protruding cylindrical peg. You represent the hexagonal shape using solid shape ```Regular Extrusion```. You then offset the protruding peg from the hexagonal shape using a Rigid Transform block. In later examples, you use this mount to support mechanical linkages like the double pendulum and the four bar system.

### Modeling Approach

To model the pivot mount, you use two Solid blocks. Because the pivot mount has a hexagonal shape, you can model it using the `Regular Extrusion` shape. To represent the cylindrical peg, you use the `Cylinder` shape.

Each shape has a reference frame with origin at the geometry center. To offset the cylindrical peg with respect to the hexagonal mount, you apply a rigid transform between the two reference frames. You do this using the Rigid Transform block.

The Z axes of the two reference frames align with the cylindrical and extrusion axes of the peg and mount, respectively. Assuming the two solids both have thickness T, the rigid transform between the two reference frames is a translation T along the common Z axis.

In later examples, you connect the pivot mount to a binary link using a revolute joint. One example is a double pendulum that moves due to gravity. In this example, it helps to rotate the Z axis of the mount so that it is orthogonal to the world frame Z axis. This task, which involves a Rigid Transform block, makes the pivot rotation axis orthogonal to the gravity vector, `[0 0 -9.81] m/s^2`.

### Build Model

1. Drag these blocks into a new model.

BlockLibraryQuantity
SolidSimMechanics > Second Generation > Body Elements2
Rigid TransformSimMechanics > Second Generation > Frames and Transforms2
Solver ConfigurationSimscape > Utilities1

2. Connect and name the blocks as shown in the figure.

 Note:   Include the disconnected frame line. This line becomes important when you generate a subsystem for the pivot mount. To add this line, right-click on the solid frame line and drag to the right.

3. In the Hexagon block dialog box, specify these parameters.

ParameterValue
Geometry > ShapeSelect `Regular Extrusion`.
Geometry > Number of SidesEnter `6`.
Geometry > Outer RadiusEnter `HexagonR`. Select units of `cm`.
Geometry > LengthEnter `T`. Select units of `cm`.
Inertia > DensityEnter `Rho`.
Graphic > ColorEnter `HexagonRGB`.

4. In the Peg block dialog box, specify these parameters.

ParameterValue
Geometry > ShapeSelect `Cylinder`
Geometry > RadiusEnter `PegR`. Select units of `cm`.
Geometry > LengthEnter `2*T`.
Inertia > DensityEnter `Rho`.
Graphic > ColorEnter `PegRGB`.

5. In the To Peg block dialog box, specify these parameters.

ParameterValue
Translation > MethodSelect `Standard Axis`.
Translation > AxisSelect `+Z`.
Translation > OffsetEnter `3/2*T`. Select units of `cm`.

6. In the To World block dialog box, specify these parameters.

ParameterValue
Rotation > MethodSelect `Standard Axis`.
Rotation > AxisSelect `–Y`.
Rotation > AngleEnter `90`.

### Generate Subsystem

You can now generate a subsystem to encapsulate the pivot mount block diagram. The subsystem mask provides a convenient place to initialize the MATLAB® variables that you defined the block parameters with. To generate the subsystem:

1. Select all the blocks excluding Solver Configuration.

2. Press Ctrl+G to enclose the blocks in a subsystem. Name the subsystem block Pivot Mount.

3. Select the Pivot Mount block and create a subsystem mask, e.g., by pressing Ctrl+M.

4. In the Parameters & Dialog tab of the Mask Editor, drag six edit boxes into the Parameters group and specify their properties. Click OK.

PromptName
`Hexagon Outer Radius``HexagonR`
`Hexagon Thickness``T`
`Mass Density``Rho`
`Hexagon Color``HexagonRGB`
`Peg Radius``PegR`
`Peg Color``PegRGB`

5. In the Pivot Mount block dialog box, specify these parameters.

ParameterValue
Hexagon Outer Radius (m):`4`
Hexagon Thickness (m):`0.8`
Mass Density (kg/m^3):`2700`
Hexagon Color [R G B]:`[0.25 0.4 0.7]`
Peg Radius (m):`0.4`
Peg Color [R G B]:`[1 0.6 0.25]`

### Visualize Model

Update the block diagram. You can do this by pressing Ctrl+D. Mechanics Explorer opens with a static display of the pivot mount rigid body. To obtain the view shown in the figure, in the Mechanics Explorer toolstrip select the isometric view button .

### Open Reference Model

To view a completed version of the pivot mount model, at the MATLAB command prompt enter `smdoc_pivot_mount`.