SimMechanics    

Constrained Example: Four-Bar System

Consider a planar four-bar system consisting of a crank, a coupler, and a rocker. The following figure shows a block diagram and a convex hull diagram of the four-bar system. The model is the demo mech_four_bar_trim.

Suppose you want to find out the torque required to turn the crank at a constant angular velocity of 1 radian/sec over a range of crank angles. The following procedure uses the trim command and the SimMechanics Trimming mode to determine the torque:

  1. Cut the closed loop that represents the four-bar system at the joint (Revolute1) connecting the rocker to ground (see Modeling Bodies).
  1. Manually cutting the rocker joint ensures that SimMechanics does not cut the four-bar loop at the crank joint and thereby eliminate the crank's position and velocity from the system's state vector.

  1. Select Signal Dimensions from the model's Format menu.
  1. This causes Simulink to display the width of signals on the model diagram and hence enables you to read the number of constraints on the four-bar system from the diagram in the next step.

  1. Set the analysis mode for the model to Trimming (see Trimming Mode).
  1. This causes SimMechanics to insert a subsystem and an output block that output a signal representing the mechanical constraints on the four-bar system.

    The width of the constraint signal (4) reflects the fact that the four-bar system is constrained to move in a plane and thus has only four constraints: two position constraints and two velocity constraints.

  1. Determine the layout of the system's state vector.
  1. Use the state vector manager mech_stateVectorMgr to perform this task:

  1. Specify the initial state vector x0 and the index array ix:
  1. The array x0 specifies that the trim command should start its search for a solution with the four-bar system in its initial position and with the crank moving at an angular velocity (state 6) of 1 radian/sec. The array ix specifies that the angular position (state 3) and velocity (state 6) of the crank must equal their initial values, 0 radians and 1 radian/sec, respectively, at the equilibrium point. It is not necessary to constrain the other states because the four-bar system has only one global position DoF and only one global velocity DoF.

  1. Specify zero as the initial estimate for the crank torque:
  2. Set up the trim command to drive the constraint outputs to 0:
  1. The y0 array specifies that the initial values of the constraint outputs are 0. The iy array specifies that the constraint outputs at the solution point must equal their initial values (0). This assures that the solution satisfies the mechanical constraints on the system.

  1. Specify the state derivatives to be trimmed:
  1. The dx0 array specifies the initial derivatives of the four-bar system's states. In particular, it specifies that the initial derivative of the crank angle (i.e., the crank angle velocity) is 1 radian/sec and all the other derivatives (i.e., velocities and accelerations) are 0. The idx array specifies that the acceleration of the crank at the solution point must be 0, i.e., the crank must be moving at a constant velocity. It is not necessary to constrain the accelerations of the other states because the system has only one velocity DoF.

  1. Trim the system at the initial crank angle to verify that you have correctly set up the trim operation:
  1. Trim the system over a range of angles. Use the following program to perform this task.

  1. Plot the results.
  1. Use the following program to perform this task:

    The following figure shows the resulting plot.


  Trimming Mechanical Systems Linearizing SimMechanics Models