MotionSolve and Simulink Co-simulation Prerequisites

A few settings are needed to successfully run a co-simulation using MATLAB/Simulink. These steps can be performed in any order that is convenient. In other words, they don't have any dependencies.
  1. In the model, create the plant inputs and outputs from the model to the other (for example, Simulink) model.
    1. The inputs should be applied using PINVAL() or VARVAL() (for example, to define forces from Simulink).
      Note: The arguments that need to be specified for PINVAL() are different from the ones for VARVAL(). Please refer to the Reference Guide for details on the syntax.
    2. The outputs should use functions that provide values to Simulink (for example, DZ() for displacements).
  2. In the environment that will run MATLAB/Simulink, set the environment variables needed by to be called from the other simulation software (for example, Simulink).
  3. In MATLAB, set the search path for MATLAB/Simulink to find the S-Function library in the installation that is required for co-simulation.
  4. In the Simulink model used for co-simulation, add an S-Function block that represents the model, and enter the proper arguments for the S-Function.

Plant Inputs and Outputs

  1. Create one or more Control_PlantInput and Control_PlantOuput that stores a list of the input and output variables that are passed between MotionSolve and Simulink.
    For more details, see those statements in the MotionSolve Reference Guide.
  2. The input variables from Control_PlantInput can be accessed via a PINVAL() or VARVAL() function, and the output variables from Control_PlantOutput are usually runtime functions (for example, DZ(), for displacement) going to Simulink.
  3. Create the number Control_PlantInput's and Control_PlantOutput's in a manner that is convenient to you.
    The S-Function that represents the MotionSolve model will update accordingly.

    The order of the Control_PlantInput's and Control_PlantOutput's found in the MotionSolve model (.xml) (by line number, from top to bottom) should match the order of the inputs to and outputs from the S-Function.