SimMechanics    

Modeling Sensors

The SimMechanics Sensors & Actuators library provides a set of Sensor blocks that enable you to measure

Sensing Body Motions

To sense the position, velocity, or acceleration of a body represented by a Body block:

  1. If the Body block does not have a spare local coordinate system with a Body CS port, create one (see Managing Body Coordinate Systems).
  2. Drag a Body Sensor block from the Sensors & Actuators library into your model.
  3. Connect its Connector Port to a spare Body CS port on the Body.
  4. Open the Sensor's dialog box.

  5. Select the coordinate system relative to which the sensor measures its output from the With respect to coordinate system list.
  6. Select the check boxes next to the motions that you want to sense (see the Body Sensor block reference page).
  7. If you have chosen to sense more than one type of motion and want the Sensor to multiplex the motions into a single output signal, select the Output selected parameters as one signal check box.
  8. Click OK or Apply.
  9. Connect the output of the Body Sensor block to a Simulink Scope or other signal sink or to a motion feedback loop, depending on your needs.

Sensing Joint Motions and Forces

The SimMechanics Joint Sensor block enables you to measure the motions of joints. It can also measure the relative forces and torques between the bodies connected to the joint. These include the computed force or torque (the force or torque needed to reproduce the joint's motion) and the reaction force and torque on a joint primitive. (You cannot measure the computed force or torque on a spherical or weld primitive.) You must connect a separate Joint Sensor block to a Joint block for each joint primitive that you want to sense.

To sense the motions, forces, and torques of a joint primitive contained by a Joint block:

  1. If the Joint block does not have a spare Sensor port, create one (see Creating Actuator and Sensor Ports on a Joint).
  2. Drag a Joint Sensor block from the Sensors & Actuators library into your model.
  3. Connect its Connector Port to the spare Sensor port on the joint.
  4. Use the Sensor's dialog box to configure the Sensor to measure the motions, forces, and torques that you want to measure (see the Joint Sensor block reference page).
  5. Connect the output of the Joint Sensor block to a Simulink Scope or other signal sink or to a motion feedback loop, depending on your needs.

Sensing Constraint Reaction Forces

The SimMechanics Constraint & Driver Sensor block enables you to measure the reaction forces and torques induced on the constraints modeled by SimMechanics Constraint and Driver blocks.

To sense the reaction force and/or torque induced by a Constraint or Driver block:

  1. If the Constraint or Driver block does not have a spare Sensor port, create one.
  2. Drag a Constraint & Driver Sensor block from the Sensors & Actuators library into your model.
  3. Connect its Connector Port to a spare Sensor port on the Constraint or Driver block.
  4. Open the Sensor block's dialog box.

  5. Select the body (follower or base) on which to measure the reaction force from the Reactions measured on list.
  6. Select the coordinate system relative to which the Sensor measures its output from the With respect to coordinate system list.
  7. Select the Reaction torque check box if you want the Sensor to output the reaction torque on the base (or follower) body.
  8. Select the Reaction force check box if you want the Sensor to output the reaction force on the base (or follower) body.
  9. If you have chosen to output both reaction force and torque and want the Sensor to multiplex them into a single output signal, select the Output selected parameters as one signal check box.
  10. Click OK or Apply.
  11. Connect the output of the Body Sensor block to a Simulink Scope or other signal sink or to a motion feedback loop, depending on your needs.

Modeling Sensor-Actuator Feedback

You can use sensor-actuator feedback loops to model springs, dampers, and more complex internal forces (forces the machine applies to itself as a result of its motion). For example, Hooke's law states that the force exerted by an extended spring is proportional to its displacement from its unextended position: F = -kx.

The following SimMechanics model models a spring that obeys Hooke's law.

The model uses the Gain block labeled Spring Constant to multiply the displacement of the prismatic joint labeled Spring along the World's y-axis by the spring constant -0.8. The output of the Gain block is the force exerted by the spring. The model feeds the force back into the prismatic joint via the Actuator labeled Force. The model encapsulates the spring block diagram in a subsystem to clarify the model and to allow a spring to be inserted elsewhere.


  Modeling Actuators Checking Model Validity