# Control Systems/Estimators and Observers

This page of the Control Systems book is a stub. You can help by expanding this page, but make sure to follow the local manual of style. If you would like to help, but you don't know how, you can ask on the main discussion page. (All Stubs)

## Estimators and Observers

A problem arises in which the internal states of many systems cannot be directly observed, and therefore state feedback is not possible. What we can do is try to design a separate system, known as an observer or an estimator that attempts to duplicate the values of the state vector of the plant, except in a way that is observable for use in state feedback. Some literature calls these components "observers", although they do not strictly observe the state directly. Instead, these devices use mathematical relations to try and determine an estimate of the state. Therefore, we will use the term "estimator", although the terms may be used interchangeably.

### Creating an Estimator

Notice that we know the A, B, C, and D matrices of our plant, so we can use these exact values in our estimator. We know the input to the system, we know the output of the system, and we have the system matrices of the system. What we do not know, necessarily, are the initial conditions of the plant. What the estimator tries to do is make the estimated state vector approach the actual state vector quickly, and then mirror the actual state vector. We do this using the following system for an observer:

$\hat{x}' = A\hat{x} + Bu + L(y - \hat{y})$
$\hat{y} = C\hat{x} + Du$

L is a matrix that we define that will help drive the error to zero, and therefore drive the estimate to the actual value of the state. We do this by taking the difference between the plant output and the estimator output.

In order to make the estimator state approach the plant state, we need to define a new additional state vector called state error signal $e_x(t)$. We define this error signal as:

$e_x(t) = x - \hat{x}$

and its derivative:

$e_x'(t) = x' - \hat{x}'$

We can show that the error signal will satisfy the following relationship:

$e_x'(t) = Ax + Bu - (A\hat{x} + Bu - L(y - \hat{y}))$
$e_x'(t) = A(x- \hat{x}) + L(Cx - C\hat{x})$
$e_x'(t) = (A + LC)e_x(t)$

We know that if the eigenvalues of the matrix (A + LC) all have negative real parts that:

$e_x(t) = e^{(A + LC)}e_x(t_0) \to 0$ when $t \to \infty$.

This $e_x(\infty) = 0$ means that the difference between the state of the plant $x(t)$ and the estimated state of the observer $\hat{x}(t)$ tends to fade as time approaches infinity.

### Separation Principle

We have two equations:

$e_x[k + 1] = (A - LC)e_x[k]$
$x[k + 1] = (A - BK)x[k] + BK \cdot e_x[k]$

We can combine them into a single system of equations to represent the entire system:

$\begin{bmatrix}e_x[k + 1] \\ x[k + 1]\end{bmatrix} = \begin{bmatrix}A - LC & 0 \\ +BK & A - BK\end{bmatrix} \begin{bmatrix}e_x[k] \\ x[k]\end{bmatrix}$

We can find the characteristic equation easily using the separation principle. We take the Z-Transform of this digital system, and take the determinant of the coefficient matrix to find the characteristic equation. The characteristic equation of the whole system is: (remember the well known $(zI-A)^{-1}$)

$\begin{vmatrix}zI - A + LC & 0 \\ -BK & zI - A + BK\end{vmatrix} = |zI - A + LC| |zI - A + BK|$

Notice that the determinant of the large matrix can be broken down into the product of two smaller determinants. The first determinant is clearly the characteristic equation of the estimator, and the second is clearly the characteristic equation of the plant. Notice also that we can design the L and K matrices independently of one another.

It is worth mentioning that if the order of the system is n, this characteristic equation (full-order state observer plus original system) becomes of order 2n and so has twice the number of roots of the original system.

### The L Matrix

You should select the L matrix in such a way that the error signal is driven towards zero as quickly as possible. The transient response of the estimator, that is the amount of time it takes the error to approximately reach zero, should be significantly shorter than the transient response of the plant. The poles of the estimator should be, by rule of thumb, at least 2-6 times faster then the poles of your plant. As we know from our study of classical controls, to make a pole faster we need to:

S-Domain
Move them further away from the imaginary axis (in the Left Half Plane!).
Z-Domain
Move them closer to the origin.

Notice that in these situations, the faster poles of the estimator will have less effect on the system, and we say that the plant poles dominate the response of the system.

$L = \alpha_e(z)Q\begin{bmatrix}0\\0\\ \vdots \\1\end{bmatrix}$

Where Q is the observability matrix of the plant, and αe is the characteristic equation of your estimator.

This can be computed in MATLAB with the following command:

L=acker(A', C', K)';


where L is the estimator gain and k is the poles for the estimator.

### Composite System

Once we have our L and K matrices, we can put these together into a single composite system equation for the case of state-feedback and zero input:

$\begin{bmatrix}x[n + 1]\\ \bar{y}[n]\end{bmatrix} = \begin{bmatrix} A & -BK \\ LH & A - BK - LH\end{bmatrix} \begin{bmatrix}x[n] \\ \bar{x}[n]\end{bmatrix}$
$u[n] = -Kx[n]$

Taking the Z-Transform of this discrete system and solving for an input-output relation gives us:

$\frac{U(z)}{Y(z)} = -K[zI - A + BK +L]^{-1}L$

Notice that this is not the same as the transfer function, because the input is on top of the fraction and the output is on bottom. To get the transfer function from this equation we need to take the inverse of both sides. The determinant of this inverse will then be the characteristic equation of the composite system.

Notice that this equation gives us the ability to derive the system input that created the particular output. This will be valuable later.

## Ackerman's Formula

Consider a linear feedback system with no reference input:

$u = -Kx$

where K is a vector of gain elements. Systems of this form are typically referred to as regulators. Notice that this system is a simplified version of the one we introduced above, except that we are ignoring the reference input. Substituting this into the state equation gives us:

$x' = Ax - BKx$

Ackerman's Formula gives us a way to select these gain values K in order to control the location's of the system poles. Using Ackerman's formula, if the system is controllable, we can select arbitrary poles for our regulator system.

[Ackerman's Formula]

$K = \begin{bmatrix}0 & 0 & \cdots & 1\end{bmatrix}\zeta^{-1}a(z)$

where a(z) is the desired characteristic equation of the system and ζ is the controllability matrix of the original system. The goal of this type of regulator is to drive the state vector to zero. By using a reference input instead of a linear state feedback, we can use the same kind of idea to drive the state vector to any arbitrary state, and to give the system arbitrary poles.

### Reference Inputs

The idea of the system above with a linear feedback and no reference input is to drive the system state vector to zero. If we have a system reference input r, we can define a vector N that is the desired value for our state. This combined input is equal to:

$rN = x_r$

where xr is the reference state we want our state x to reach. Here is a block diagram of a system that uses this kind of state reference:

We have our gain matrix, K, and our reference input rN. Mathematically, we can show that:

$u = -K(x - x_r)$

In this system, assuming the system is type 1 or higher, we can prove that

$x(\infty) = x_r$

The state will approach the reference state as time approaches infinity.

The Reference Input is calculated in the continuous domain using the below equations:

$\left[ \begin{matrix}N_x \\ N_u\end{matrix} \right]=\left[ \begin{matrix}A & B \\ C & D\end{matrix} \right]^{-1} \left[ \begin{matrix}0 \\ 1\end{matrix} \right]$

and $\bar{N}=N_u+KN_x$

## Reduced-Order Observers

In many systems, at least one state variable can be either measured directly, or calculated easily from the output. This can happen in the case where the C matrix has only a single non-zero entry per system output.

If one or more state variables can be measured or observed directly, the system only requires a reduced-order observer, that is an observer that has a lower order than the plant. The reduced order observer can estimate the unmeasurable states, and a direct feedback path can be used to obtain the measured state values.