Control: Plant Output

Model ElementThe Control_PlantOutput element defines the outputs from a mechanical system or plant.


This is part of the information necessary to create a linearized model of the plant or for co-simulation. You also need to specify the inputs to the plant using the Control_PlantInput element. Given the inputs and outputs, you may use the Simulate command of type Linear to compute the matrices in the following linearized, state space form:

x ˙ ( t ) = A   x ( t ) + B   u ( t ) y ( t ) = C   x ( t ) + D   u ( t )

x is the state vector, u is the input variable, and y is the output variable. A, B, C, and D denote the state matrix, the input matrix, the output matrix, and the direct feed-through matrix, respectively. These matrices are often useful as a starting point in control systems design.


   id                    = "integer"
   num_element           = "integer"
   variable_id_list      = "integer, integer, ..., integer"
   type                = "USERSUB"
   usrsub_dll_name     = "valid_path_name"
   usrsub_fnc_name     = "custom_fnc_name"
   usrsub_param_string = "USER(par_1, ..., par_n)"

  label            = "string"
  hold_order       = "integer"
  sampling_period  = "real"
  offset_time      = "real"


Element identification number (integer>0). This number is unique among all Control_PlantOutput elements.
An optional label for the element. This could be the name for the Control_PlantOutput element.
Number of outputs from the plant that are to be specified using this Control_PlantOutput element.

num_element > 0

Specifies the order of extrapolation applied to the control signal(s) propagating out from Control_PlantOutput. Note that for the first time step, the value is held constant (order zero), since there is no past history to extrapolate.

The default value is 1.0.

Specifies the list of IDs of the variables that define the outputs from the plant. The length of this list is equal to num_element.
Specifies the sample time of an output port. A value of 0.0 specifies continuous sampling while any other non-zero value specifies discrete sampling. This value cannot be negative. The default value is 0.0. In most cases, this value need not be changed from its default, except in models where a discrete sampling is required. This parameter is to be used only in case of co-simulation with MATLAB/Simulink. 3
Specifies the sample time offset for each output port. The sample time offset must be strictly less than the sampling_period if the latter is non-zero. If the sampling_period is 0.0 (continuous), then offset_time defaults to 0.0 as well In most cases, this value need not be changed from its default, except in models where a discrete sampling is required. This parameter is to be used only in case of co-simulation with MATLAB/Simulink.
Specifies the path and name of the DLL or shared library containing the user subroutine. MotionSolve uses this information to load the user subroutine in the DLL at run time. Use this keyword only when type = USERSUB.
This parameter allows you to specify the name for the user subroutine. The default name, POUTSUB, is used when the attribute is not specified. Use this keyword only when type = USERSUB.
The list of parameters that are passed from the data file to the user-defined POUTSUB. Use this keyword only when type = USERSUB. Set this parameter equal to "USER(parameter 1, par 2,…, par n)", where the parameters are chosen by you.


Consider the control problem of stabilizing an inverted pendulum mounted on a slider. The image below shows one such setup. The slider, the green block, is constrained to move along the global x-axis by a translational joint with ground, depicted as the red strip. The pendulum is hinged to the slider with the axis of rotation parallel to the global y-axis. The slider motion is opposed by a linear spring-damper.

Figure 1. Inverted Pendulum Model
Assume that the task is to design a controller to stabilize the unstable configuration shown in the image above. Start by computing the state space form of equations of motion with the intent to use MATLAB to design a controller. We are given:
  • Plant input: Control force Fc acting on slider along global X.
  • Plant output: Pendulum angle θ.

The plant output may be defined as follows:

     id               = "303001"
     num_element      = "1"
     variable_id_list = "12"
     hold_order       = "1"

Reference_Variable 12 defines the pendulum angle θ.


  1. The output specified using the Control_PlantOutput element is accessed using the function POUVAL. This function can be called directly from within MotionSolve expressions and used from within user subroutines using SYSFNC() and SYSARY().
  2. Control_PlantOutput and Control_PlantInput are used for co-simulation. This is a scenario where a problem is split between two solvers. The two solvers work in tandem to solve the problem, exchanging information as required by them with Control_PlantOutput and Control_PlantInput objects. A common scenario is the control of a mechanical system. The control system is modeled in controls software and the mechanical system is in MotionSolve. The mechanical systems tells the controller what it is doing; the controller uses this to determine the control forces to apply. This information is exchanged continuously or at discrete sampling steps. Control_PlantInput tells MotionSolve what the controller inputs to the model are. Control_PlantOutput tells MotionSolve what information to send to the controller. The user subroutine options are used for co-simulation. For more information on co-simulation, see Interface with Third Party Software.
  3. A discrete (only) system in Simulink will require that the sampling_period be set to a discrete time (for example,non-zero; zero is continuous sampling). Otherwise, the simulation will not run and an error will occur.
  4. For co-simulation from a Simulink-driven model, create the number Control_PlantOutput's in a manner that is convenient to you, and the S-Function that represents the MotionSolve model will update accordingly. See MV-7002: Co-simulation with Simulink.
  5. For co-simulation with a Simulink Coder library, create as many Control_PlantOutput's as Inports (for example, one Control_PlantOutput for each Inport; the input of the Simulink model is the output to the MotionSolve (plant) model) in the Simulink model to setup the proper interface communication. See MV-7005: Linking Matlab/Simulink Generated Code (Simulink Coder) with MotionSolve for an example.
  6. The order of the Control_PlantOutput's found in the MotionSolve model (.xml) (by line number, from top to bottom) should match the order of the IDs for the Outports in the Simulink model to ensure the variables are exchanged in the proper order. The same is true for the order of the inputs to an S-Function for a Simulink-driven co-simulation.
  7. For a Simulink Coder library co-simulation, set usrsub_param_string to have one integer that will uniquely identify the Simulink Coder library used. This number (id) should be the same for all Control_PlantInput's and Control_PlantOutput's that are used for this Simulink Coder library.