# Control Systems/System Modeling

| The Wikibook of: Control Systems and Control Engineering | Table of Contents | All Versions | PDF Version |
| The Wikibook of: Control Systems and Control Engineering | ← System Metrics | Transforms → | Glossary |

## The Control Process

It is the job of a control engineer to analyze existing systems, and to design new systems to meet specific needs. Sometimes new systems need to be designed, but more frequently a controller unit needs to be designed to improve the performance of existing systems. When designing a system, or implementing a controller to augment an existing system, we need to follow some basic steps:
* Model the system mathematically
* Analyze the mathematical model
* Design system/controller
* Implement system/controller and test
The vast majority of this book is going to be focused on (2), the analysis of the mathematical systems. This chapter alone will be devoted to a discussion of the mathematical modeling of the systems.

## External Description

An external description of a system relates the system input to the system output without explicitly taking into account the internal workings of the system. The external description of a system is sometimes also referred to as the Input-Output Description of the system, because it only deals with the inputs and the outputs to the system.
If the system can be represented by a mathematical function h(t, r), where t is the time that the output is observed, and r is the time that the input is applied. We can relate the system function h(t, r) to the input x and the output y through the use of an integral:
[General System Description]
    $y(t)=\int _{-\infty }^{\infty }h(t,r)x(r)dr$
This integral form holds for all linear systems, and every linear system can be described by such an equation.
If a system is causal (i.e. an input at t=r affects system behaviour only for $t\geq r$) and there is no input of the system before t=0, we can change the limits of the integration:
    $y(t)=\int _{0}^{t}h(t,r)x(r)dr$

### Time-Invariant Systems

If furthermore a system is time-invariant, we can rewrite the system description equation as follows:
    $y(t)=\int _{0}^{t}h(t-r)x(r)dr$
This equation is known as the convolution integral, and we will discuss it more in the next chapter.
Every Linear Time-Invariant (LTI) system can be used with the Laplace Transform, a powerful tool that allows us to convert an equation from the time domain into the S-Domain, where many calculations are easier. Time-variant systems cannot be used with the Laplace Transform.

## Internal Description

If a system is linear and lumped, it can also be described using a system of equations known as state-space equations. In state-space equations, we use the variable x to represent the internal state of the system. We then use u as the system input, and we continue to use y as the system output. We can write the state-space equations as such:
    $x'(t)=A(t)x(t)+B(t)u(t)$
    $y(t)=C(t)x(t)+D(t)u(t)$
We will discuss the state-space equations more when we get to the section on modern controls.

## Complex Descriptions

Systems which are LTI and Lumped can also be described using a combination of the state-space equations, and the Laplace Transform. If we take the Laplace Transform of the state equations that we listed above, we can get a set of functions known as the Transfer Matrix Functions. We will discuss these functions in a later chapter.

## Representations

To recap, we will prepare a table with the various system properties, and the available methods for describing the system:
    PropertiesState-Space EquationsLaplace TransformTransfer Matrix Linear, Time-Variant, Distributednonono Linear, Time-Variant, Lumpedyesnono Linear, Time-Invariant, Distributednoyesno Linear, Time-Invariant, Lumpedyesyesyes
We will discuss all these different types of system representation later in the book.

## Analysis

Once a system is modeled using one of the representations listed above, the system needs to be analyzed. We can determine the system metrics and then we can compare those metrics to our specification. If our system meets the specifications we are finished with the design process. However if the system does not meet the specifications (as is typically the case), then suitable controllers and compensators need to be designed and added to the system.
Once the controllers and compensators have been designed, the job isn't finished: we need to analyze the new composite system to ensure that the controllers work properly. Also, we need to ensure that the systems are stable: unstable systems can be dangerous.

### Frequency Domain

For proposals, early stage designs, and quick turn around analyses a frequency domain model is often superior to a time domain model. Frequency domain models take disturbance PSDs (Power Spectral Densities) directly, use transfer functions directly, and produce output or residual PSDs directly. The answer is a steady-state response. Oftentimes the controller is shooting for 0 so the steady-state response is also the residual error that will be the analysis output or metric for report.
Table 1: Frequency Domain Model Inputs and Outputs :
| Input | Model | Output |
| PSD | Transfer Function | PSD |

#### Brief Overview of the Math

Frequency domain modeling is a matter of determining the impulse response of a system to a random process.
    $S_{YY}\left(\omega \right)=G^{*}\left(\omega \right)G\left(\omega \right)S_{XX}=\left|G\left(\omega \right)\right\vert S_{XX}$
where
       $S_{XX}\left(\omega \right)$ is the one-sided input PSD in ${\frac {magnitude^{2}}{Hz}}$
       $G\left(\omega \right)$ is the frequency response function of the system and
       $S_{YY}\left(\omega \right)$ is the one-sided output PSD or auto power spectral density function.
The frequency response function, $G\left(\omega \right)$, is related to the impulse response function (transfer function) by
    $g\left(\tau \right)={\frac {1}{2\pi }}\int _{-\infty }^{\infty }e^{i\omega t}H\left(\omega \right)\,d\omega$
Note some texts will state that this is only valid for random processes which are stationary. Other texts suggest stationary and ergodic while still others state weakly stationary processes. Some texts do not distinguish between strictly stationary and weakly stationary. From practice, the rule of thumb is if the PSD of the input process is the same from hour to hour and day to day then the input PSD can be used and the above equation is valid.

#### Notes

* ↑ Sun, Jian-Qiao (2006). Stochastic Dynamics and Control, Volume 4. Amsterdam: Elsevier Science. ISBN 0444522301.
See a full explanation with example at ControlTheoryPro.com

## Modeling Examples

Modeling in Control Systems is oftentimes a matter of judgement. This judgement is developed by creating models and learning from other people's models. ControlTheoryPro.com is a site with a lot of examples. Here are links to a few of them
* Hovering Helicopter Example
* Reaction Torque Cancellation Example
* List of all examples at ControlTheoryPro.com

## Manufacture

Once the system has been properly designed we can prototype our system and test it. Assuming our analysis was correct and our design is good, the prototype should work as expected. Now we can move on to manufacture and distribute our completed systems.
| ← System Metrics | Control Systems | Transforms → |