# Control: Plant Input

Model ElementThe Control_PlantInput element defines the inputs to a mechanical system or plant.

## Description

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 outputs to the plant using the Control_PlantOutput 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 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.

## Format

<Control_PlantInput
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"
]]
/>

## Attributes

id
Element identification number (integer>0). This number is unique among all Control_PlantInput elements.
label
The name of the Control_PlantInput element.
num_element
Number of inputs to the plant that are to be specified using this Control_PlantInput element. num_element > 0.
hold_order
Specifies the order of interpolation applied to the control signal(s) propagating out from Control_PlantInput. The default value is 1.0.
variable_id_list
Specifies the list of IDs of the variables that define the inputs to the plant. The length of this list is equal to num_element.
sampling_period
Specifies the sample time of an input 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 the case of co-simulation with MATLAB/Simulink. 3
offset_time
Specifies the sample time offset for each input 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.
usrsub_dll_name
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.
usrsub_fnc_name
This parameter allows you to specify the name for the user subroutine. The default name, PINSUB, is used when the attribute is not specified. Use this keyword only when type = USERSUB.
usrsub_param_string
The list of parameters that are passed from the data file to the user- defined PINSUB. 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.

## Example

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.
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 input may be defined as follows:

<Control_PlantOutput
id                = "303001"
num_element       = "1"
variable_id_list  = "12"
hold_order        = "1"
/>

Reference_Variable 6 defines the control force (Fc).

<Reference_Variable
id         = "6"
type       = "EXPRESSION"
expr       = "0.0"
/>