# Documentation

## About Controllers and Plants

### Warning

This topic refers to Simscape™ Multibody™ First Generation software. The first-generation library will soon be deprecated. To avoid compatibility issues, create any new models and convert any existing models using second-generation blocks—those accessible by entering the command `smlib` at the MATLAB® command prompt.

### Note

The next two studies assume some knowledge of control systems. In addition to Simulink® and the Simscape Multibody product, the studies use these products:

You should have some experience with these tools before proceeding.

To understand trimming better, work through Trimming and Linearizing Through Inverse Dynamics.

A classic engineering problem is the design of controllers for a physical system, the plant [2]. A Simscape Multibody model can represent a complex mechanical system and helps you design and implement a control system for the plant, in conjunction with Simulink and related control design products.

In the next two case studies, you use Simscape Multibody software to model the plant and Simulink to analyze and synthesize controllers. You explore a basic challenge of control design, the tradeoff between responsiveness and stability, by implementing first a simple controller, then a more complex and robust one [4]. This section is preliminary to those studies.

### Nature of the Control Problem

The motion of an uncontrolled physical system is represented by its position and velocity variables arranged into a state vector X. The dynamics of the system is described by a force law:

`$\text{d}X/\text{dt}=f\left(X\right)$`

Introducing control means introducing sensors and actuators that modify the system's otherwise natural motion. The actuators impose artificial forces — collectively, the inputs U — on the system, while the sensors detect motions and report outputs Y. The dynamics of the controlled system are modified:

`$\begin{array}{l}\text{d}X/\text{dt}=f\left(X,U\right)\\ Y=g\left(X,U\right)\end{array}$`

The U and Y are the control variables of the system.

By selecting the proper set of U and Y and a feedback control or compensator law U = c(Y) that modifies the system's motion X in a desired way, you impose control actuator forces for the relevant range of X, U, and Y.

Selecting c is the fundamental problem of control design. The desired trajectory of X is the reference or nominal trajectory. The difference of the actual and reference trajectories is the motion error. Finding the actuator forces needed to produce a desired motion is closely related to the problem of inverse dynamics. See the case study, Trimming and Linearizing Through Inverse Dynamics.

### Control Transfer Function Forms and Units

The controller and plant transfer functions are often called C and G, respectively. The combined controller-plant transfer function forms are the open-loop CG and the closed-loop CG/(1+CG).

Controller and plant response magnitudes are measured in decibels (dB).

### Controller-Plant Case Study Files

The next two case studies use these files, in addition to the initialization script and function.

FilePurpose
`mech_stewart_control`Main model
`mech_stewart_control_deriv`Configurable subsystem: Derivative block or transfer function (filtered)
`mech_stewart_controllers`Configurable subsystem: Null, PID, or H-infinity controller
`mech_stewartplatform_leg`Library model of Stewart platform leg; used six times in the Plant subsystem of the main model

### For More About Designing Controllers

The problems and techniques of the next two case studies only touch the basics of control design. In practice, you need to consider additional issues and goals. Also consult References.

#### Finding Other Operating Points

To fully understand the plant, you need to find plant operating points other than the simple ones used here and optimize the controller in other representative states.

See the preceding case study, Trimming and Linearizing Through Inverse Dynamics.

#### Compensating for Noise and Uncertainty

To design more robust controllers, you should consider the effect of parameter uncertainty and signal noise. This step involves comparing typical plant motion frequencies, noise frequencies, and filtered derivative cutoffs.

The following toolboxes can help with such tasks:

#### Designing for Hardware Implementation

To move toward hardware implementation, you must consider discretizing the controller [8]. Among other requirements, this necessitates using a fixed-step solver, optimizing the solver step size and sample rate, and adjusting the filtered derivative cutoff.

See the final two case studies: