# Control Systems/Controllers and Compensators

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

## Controllers

There are a number of different standard types of control systems that have been studied extensively. These controllers, specifically the P, PD, PI, and PID controllers are very common in the production of physical systems, but as we will see they each carry several drawbacks.

## Proportional Controllers

Proportional controllers are simply gain values. These are essentially multiplicative coefficients, usually denoted with a K. A P controller can only force the system poles to a spot on the system's root locus. A P controller cannot be used for arbitrary pole placement.
We refer to this kind of controller by a number of different names: proportional controller, gain, and zeroth-order controller.

## Derivative Controllers

In the Laplace domain, we can show the derivative of a signal using the following notation:
    $D(s)={\mathcal {L}}\left\{f'(t)\right\}=sF(s)-f(0)$
Since most systems that we are considering have zero initial condition, this simplifies to:
    $D(s)={\mathcal {L}}\left\{f'(t)\right\}=sF(s)$
The derivative controllers are implemented to account for future values, by taking the derivative, and controlling based on where the signal is going to be in the future. Derivative controllers should be used with care, because even small amount of high-frequency noise can cause very large derivatives, which appear like amplified noise. Also, derivative controllers are difficult to implement perfectly in hardware or software, so frequently solutions involving only integral controllers or proportional controllers are preferred over using derivative controllers.
Notice that derivative controllers are not proper systems, in that the order of the numerator of the system is greater than the order of the denominator of the system. This quality of being a non-proper system also makes certain mathematical analysis of these systems difficult.

### Z-Domain Derivatives

We won't derive this equation here, but suffice it to say that the following equation in the Z-domain performs the same function as the Laplace-domain derivative:
    $D(z)={\frac {z-1}{Tz}}$
Where T is the sampling time of the signal.

## Integral Controllers

To implemenent an Integral in a Laplace domain transfer function, we use the following:
    ${\mathcal {L}}\left\{\int _{0}^{t}f(t)\,dt\right\}={1 \over s}F(s)$
Integral controllers of this type add up the area under the curve for past time. In this manner, a PI controller (and eventually a PID) can take account of the past performance of the controller, and correct based on past errors.

### Z-Domain Integral

The integral controller can be implemented in the Z domain using the following equation:
    $D(z)={\frac {z+1}{z-1}}$

## PID Controllers

PID controllers are combinations of the proportional, derivative, and integral controllers. Because of this, PID controllers have large amounts of flexibility. We will see below that there are definite limites on PID control.

### PID Transfer Function

The transfer function for a standard PID controller is an addition of the Proportional, the Integral, and the Differential controller transfer functions (hence the name, PID). Also, we give each term a gain constant, to control the weight that each factor has on the final output:
[PID]
    $D(s)=K_{p}+{K_{i} \over s}+K_{d}s$
Notice that we can write the transfer function of a PID controller in a slightly different way:
    $D(s)={\frac {A_{0}+A_{1}s}{B_{0}+B_{1}s}}$
This form of the equation will be especially useful to us when we look at polynomial design.

### PID Tuning

The process of selecting the various coefficient values to make a PID controller perform correctly is called PID Tuning. There are a number of different methods for determining these values:
1) Direct Synthesis (DS) method
2) Internal Model Control (IMC) method
3) Controller tuning relations
4) Frequency response techniques
5) Computer simulation
6) On-line tuning after the control system is installed
7)Trial and error
Notes:
* ↑ Seborg, Dale E.; Edgar, Thomas F.; Mellichamp, Duncan A. (2003). Process Dynamics and Control, Second Edition. John Wiley & Sons,Inc. ISBN 0471000779

### Digital PID

In the Z domain, the PID controller has the following transfer function:
[Digital PID]
    $D(z)=K_{p}+K_{i}{\frac {T}{2}}\left[{\frac {z+1}{z-1}}\right]+K_{d}\left[{\frac {z-1}{Tz}}\right]$
And we can convert this into a canonical equation by manipulating the above equation to obtain:
    $D(z)={\frac {a_{0}+a_{1}z^{-1}+a_{2}z^{-2}}{1+b_{1}z^{-1}+b_{2}z^{-2}}}$
Where:
    $a_{0}=K_{p}+{\frac {K_{i}T}{2}}+{\frac {K_{d}}{T}}$
    $a_{1}=-K_{p}+{\frac {K_{i}T}{2}}+{\frac {-2K_{d}}{T}}$
    $a_{2}={\frac {K_{d}}{T}}$
    $b_{1}=-1$
    $b_{2}=0$
Once we have the Z-domain transfer function of the PID controller, we can convert it into the digital time domain:
    $y[n]=x[n]a_{0}+x[n-1]a_{1}+x[n-2]a_{2}-y[n-1]b_{1}-y[n-2]b_{2}$
And finally, from this difference equation, we can create a digital filter structure to implement the PID.

## Bang-Bang Controllers

Despite the low-brow sounding name of the Bang-Bang controller, it is a very useful tool that is only really available using digital methods. A better name perhaps for a bang-bang controller is an on/off controller, where a digital system makes decisions based on target and threshold values, and decides whether to turn the controller on and off. Bang-bang controllers are a non-linear style of control.
Consider the example of a household furnace. The oil in a furnace burns at a specific temperature—it can't burn hotter or cooler. To control the temperature in your house then, the thermostat control unit decides when to turn the furnace on, and when to turn the furnace off. This on/off control scheme is a bang-bang controller.

## Compensation

There are a number of different compensation units that can be employed to help fix certain system metrics that are outside of a proper operating range. Most commonly, the phase characteristics are in need of compensation, especially if the magnitude response is to remain constant. There are four major types of compensation 1. Lead compensation 2. Lag compensation 3. Lead-lag compensation 4. Lag-lead compensation

## Phase Compensation

Occasionally, it is necessary to alter the phase characteristics of a given system, without altering the magnitude characteristics. To do this, we need to alter the frequency response in such a way that the phase response is altered, but the magnitude response is not altered. To do this, we implement a special variety of controllers known as phase compensators. They are called compensators because they help to improve the phase response of the system.
There are two general types of compensators: Lead Compensators, and Lag Compensators. If we combine the two types, we can get a special Lag-lead Compensator system.(lead-lag system is not practically realisable).
When designing and implementing a phase compensator, it is important to analyze the effects on the gain and phase margins of the system, to ensure that compensation doesn't cause the system to become unstable. phase lead compensation:- 1 it is same as addition of zero to open loop TF since from pole zero point of view zero is nearer to origin than pole hence effect of zero dominant.

## Phase Lead

The transfer function for a lead-compensator is as follows:
[Lead Compensator]
    $T_{lead}(s)={\frac {s-z}{s-p}}$
To make the compensator work correctly, the following property must be satisfied:
    $|z|<|p|$
And both the pole and zero location should be close to the origin, in the LHP. Because there is only one pole and one zero, they both should be located on the real axis.
Phase lead compensators help to shift the poles of the transfer function to the left, which is beneficial for stability purposes.

## Phase Lag

The transfer function for a lag compensator is the same as the lead-compensator, and is as follows:
[Lag Compensator]
    $T_{lag}(s)={\frac {s-z}{s-p}}$
However, in the lag compensator, the location of the pole and zero should be swapped:
    $|p|<|z|$
Both the pole and the zero should be close to the origin, on the real axis.
The Phase lag compensator helps to improve the steady-state error of the system. The poles of the lag compensator should be very close together to help prevent the poles of the system from shifting right, and therefore reducing system stability.

## Phase Lag-lead

The transfer function of a Lag-lead compensator is simply a multiplication of the lead and lag compensator transfer functions, and is given as:
[Lag-lead Compensator]
    $T_{Lag-lead}(s)={\frac {(s-z_{1})(s-z_{2})}{(s-p_{1})(s-p_{2})}}.$
Where typically the following relationship must hold true:
    $|p_{1}|>|z_{1}|>|z_{2}|>|p_{2}|$
| ← System Specifications | Control Systems | Compensators → |

## External links

* Standard Controller Forms on ControlTheoryPro.com
* PID Control on ControlTheoryPro.com
* PI Control on ControlTheoryPro.com