Accelerating the pace of engineering and science

# Documentation

## Model Rack and Pinion

### Model Overview

In this tutorial, you model a kinematic constraint between rack and pinion components. The constraint causes the two components to move in sync such that a pinion rotation corresponds to a rack translation:

${V}_{F}={\omega }_{B}·{R}_{B},$

where:

• VF is the rack translational velocity.

• ωB is the pinion rotational velocity.

• RB is the radius of the pinion pitch circle, an imaginary circle intersecting the contact point between rack and pinion teeth.

The model uses three key blocks:

• Solid — Specify rack and pinion geometry, inertia, and color

• Joint — Provide motion degrees of freedom to the rack and pinion components. These degrees of freedom enable the rack to translate and the pinion to rotate with respect to the world frame.

• Rack and Pinion Constraint — Constrain the motion of the rack and pinion components so that they move in a meshed configuration.

The figure shows how these blocks connect in the model.

For simplicity, the rack has a brick shape and the pinion has a cylinder shape. These shapes depend on several dimensions, shown in the figure. You specify each dimension using a variable. After model assembly, you can add detail to the component shapes. For example, you can specify an involute tooth profile for the rack and pinion.

Rack and Pinion Dimensions

### Model Pinion

1. Start a new model.

2. Add these blocks to the model.

LibraryBlock
Simscape > UtilitiesSolver Configuration
SimMechanics > Second Generation > Frames and TransformsWorld Frame
SimMechanics > Second Generation > UtilitiesMechanism Configuration
SimMechanics > Second Generation > JointsRevolute Joint
SimMechanics > Second Generation > Body ElementsSolid

The Solid block specifies the component geometry, inertia, and color. The joint block provides the component its motion degrees of freedom—in this case, one rotational degree of freedom with respect to the world frame.

3. Connect and name the blocks as shown in the figure. Port frames joined by a connection line are coincident in space.

4. In the Pinion block dialog box, specify geometry, inertia, and color.

ParameterEnter or Select
Geometry > ShapeCylinder
Geometry > RadiusPinion.R, units of cm
Geometry > LengthPinion.T, units of cm
Inertia > DensityRho
Graphic > Visual Properties > ColorPinion.RGB

5. In the model workspace, initialize the MATLAB® variables you entered in the block dialog boxes:

```% Common Parameters
Rho = 2700; % Mass density of both rack and pinion components

% Pinion Parameters
Pinion.R = 10;
Pinion.T = 4;
Pinion.RGB = [0.8, 0.4, 0];```
6. Update the block diagram. You can do this by selecting Simulation > Update Diagram. Mechanics Explorer opens with a 3-D view of the pinion gear. To obtain the view shown in the figure, in the Mechanics Explorer toolstrip select the isometric view button .

### Model Rack

1. Add these blocks to the model.

LibraryBlock
SimMechanics > Second Generation > Frames and TransformsRigid Transform
SimMechanics > Second Generation > JointsPrismatic Joint
SimMechanics > Second Generation > Body ElementsSolid

The Rigid Transform block sets the rack position and pose with respect to the pinion. These quantities must satisfy the assembly conditions later imposed by the Rack and Pinion Constraint block.

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

3. In the Rack block dialog box, specify geometry, inertia, and color.

ParameterSelect or Enter
Geometry > ShapeBrick
Geometry > Dimensions[Rack.T, Rack.H, Rack.L], units of cm
Inertia > DensityRho
Graphic > Visual Properties > ColorRack.RGB

4. In the Rigid Transform block dialog box, specify the rack position and pose with respect to the pinion.

ParameterSelect or Enter
Rotation > MethodStandard Axis
Rotation > Axis+Y
Rotation > Angle90
Translation > MethodStandard Axis
Translation > Axis-Y
Translation > OffsetPinion.R in units of cm

The rotation transform makes the rack and pinion Z axes mutually orthogonal while keeping the Y axes parallel. The translation transform separates the rack and pinion frame origins by a distance equal to the pinion pitch radius. These transforms satisfy the assembly conditions imposed by the Rack and Pinion Constraint block.

5. In the model workspace, initialize the new MATLAB variables entered in the block dialog boxes:

```% Rack Parameters
Rack.L = 80;
Rack.H = 2;
Rack.T = Pinion.T;
Rack.RGB = [0.2, 0.4, 0.7];```
6. Update the block diagram. Mechanics Explorer displays a 3-D view of the rack and pinion assembly. Examine the assembly from different viewpoints and verify it is accurate. You can view the rack and pinion frames by clicking the frame button in the Mechanics Explorer tool bar.

### Add Rack and Pinion Constraint

The model is nearly complete. It remains to constrain the motion of the rack and pinion components. You add this kinematic constraint using the Rack and Pinion Constraint block.

1. From the Gears and Couplings > Gears library, drag a Rack and Pinion Constraint block to the model.

2. Connect the block as shown in the figure. The follower frame port connects to the Rack block, while the base frame port connects to the Pinion block.

3. In the dialog box of the Rack and Pinion Constraint block, enter Pinion.R in Pinion Radius.

4. Update the block diagram. Mechanics Explorer shows a 3-D display of the updated rack and pinion assembly. Assembly errors due to gear constraints become evident at this stage. If SimMechanics™ issues an error message, correct the model before attempting to run the simulation.

### Actuate Model

1. In the Revolute Joint block dialog box, for Z Revolute Primitive (Rz) > Actuation > Torque, select Provided by Input.

The block exposes a physical signal input port. You use this port to specify a driving torque acting on the pinion. During simulation, this torque will be the source of motion in the model.

2. Drag these blocks to specify and process the input torque signal.

LibraryBlock

The Simulink-PS Converter block converts the Simulink® input signal into a physical signal compatible with SimMechanics blocks. It also provides signal filtering, which enables you to smooth discontinuous signals.

3. Connect the blocks as shown in the figure.

4. In the Signal Builder block dialog box, draw the input signal as shown in the figure. This signal starts with a positive torque followed by a negative torque. The positive torque causes the pinion to rotate counterclockwise about the base frame +Z axis and the rack to translate along the follower frame +Z axis.

5. In the Simulink-PS Converter block dialog box, in the Input Handling tab, specify second-order filtering with a time constant of 0.1 s. This filter helps to smooth the discontinuities of the input signal.

ParameterSelect or Enter
Filtering and derivativesFilter input
Input filtering orderSecond-order filtering
Input filtering time constant (in seconds)0.1

### Simulate Model

Run the simulation. You can do this by selecting Simulation > Run. Mechanics Explorer plays a physics-based animation of the rack and pinion assembly. To better see motion during playback, select the frame button in the Mechanics Explorer tool bar.

### Open Complete Model

To view a complete model of the rack and pinion mechanism, at the MATLAB command prompt enter:

`smdoc_rack_pinion_c`

For an example using a helper function to generate a rough involute tooth profile, enter

`smdoc_rack_pinion_d`