SimMechanics | ![]() ![]() |
Sensing Motion and Running the Model
You finish building your model by setting initial conditions and inserting Sensors.
Before you start a machine 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 Modeling Sensors.
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.
Caution
Because they are immobile, ground points cannot be moved, nor do they have any motion to measure.
Therefore you cannot connect Ground blocks to Actuator or Sensor blocks. |
Connecting the Joint Sensors
To sense the motion of the Revolute2 and Revolute3 blocks:
1
. Click OK.
>
of the Sensor blocks to non-SimMechanics blocks. These ports 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:
2
. Click OK. A second inport >
appears on the Angle block.
>
to the Angle block inports >
.
R1
in both blocks, indicating the first and only primitive revolute inside
Revolute2 and Revolute3 to which each Sensor can be connected.
deg
(degrees). The Simulink line will contain one scalar.
Your completed model should look similar to the mech_four_bar
Demo model.
Caution Sensor and Actuator blocks are the only blocks that can connect SimMechanics blocks to non-SimMechanics Simulink blocks. |
Configuring and Running the Simulation
Now take the final steps to prepare and start the model:
Note some features of the simulation:
Animation
If you leave your visualization tool open at the time you start the simulation and select the Animate machine during simulation check box in the Visualization pane of the Mechanical Environment Settings dialog box, 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.
![]() | Configuring the Body Blocks | Summary of Technical Vocabulary | ![]() |