---
title: Controllability and state feedback
heading: When an input can steer every state, the controllability matrix and its rank, placing every closed-loop pole with state feedback, Ackermann's formula, the reference gain, and adding integral action by augmenting the state
eyebrow: S9 · Lesson 34 · Controllability and state feedback
xp: 50
---

::: hook
A PID controller has three knobs and works from one measured error. If you can measure every state, position and velocity, current and speed, you can do better: feed each one back with its own gain, $u = -Kx$, and place every closed-loop pole wherever you like. That works exactly when the input can influence every state, a property called controllability that Rudolf Kálmán made precise in 1960. This lesson tests for it and places poles.
:::

::: play
- A double integrator, $\ddot{y} = u$ (a mass pushed by a force, a satellite turned by a thruster), under state feedback $u = -k_1y - k_2\dot{y} + k_1r$.
- The closed loop is $s^2 + k_2s + k_1$: $k_1$ sets the natural frequency ($\sqrt{k_1}$) and $k_2$ the damping ($k_2/2\sqrt{k_1}$). Each gain moves one coefficient.
- With no state feedback this plant can't even be stabilized by a proportional controller on y alone: that would give $s^2 + k_1$, a pure oscillator. The velocity feedback supplies the damping.
:::

```sim plot
view: graph
x: t = 0..6 s
y: y = 0..1.6
slider: k = 0.5..20 = 4 log
slider: c = 0.2..10 = 2.8 log
plot: Re(1 - exp(-c/2*t)*(cos(sqrt(k - c^2/4 + 0*j)*t) + c/2*sin(sqrt(k - c^2/4 + 0*j)*t)/sqrt(k - c^2/4 + 0*j))) | samples: 600 | label: y(t)
readout: natural frequency, rad/s = sqrt(k) | digits: 3
readout: damping ratio = c/(2*sqrt(k)) | digits: 3
```

::: predict
## Two identical tanks, each $\dot{x}_i = -x_i + u$, are fed by the same pump. Can state feedback place their two poles anywhere?

- [ ] Yes, with two gains you can place two poles
- [x] No: the pump can't make the tanks differ, so the difference between them decays on its own at −1 whatever you do
- [ ] Only if both levels are measured
- [ ] Only with integral action

::: reveal
The difference $x_1 - x_2$ obeys $\frac{d}{dt}(x_1 - x_2) = -(x_1 - x_2)$, with no input in it. The controllability matrix $[B, AB] = \begin{pmatrix} 1 & -1 \\ 1 & -1 \end{pmatrix}$ has rank 1: one mode is uncontrollable, and its pole stays at −1.
:::
:::

::: nameit
## Controllability

$\dot{x} = Ax + Bu$ is **controllable** (reachable) if the input can drive the state from any point to any other in finite time. The test:

$$W_r = \begin{pmatrix} B & AB & A^2B & \cdots & A^{n-1}B \end{pmatrix} \text{ has rank } n$$

For one input, $W_r$ is square and the test is $\det W_r \ne 0$.

## State feedback

With $u = -Kx + k_rr$ the closed loop is $\dot{x} = (A - BK)x + Bk_rr$. **If the system is controllable, the eigenvalues of A − BK can be placed anywhere** (in complex-conjugate pairs).

In **companion form** (last row $-a_0, -a_1, \dots$, $B = (0, \dots, 0, 1)^T$), the closed-loop polynomial's coefficients are $a_i + k_{i+1}$, so each gain is simply the desired coefficient minus the open-loop one. **Ackermann's formula** does the general case:

$$K = \begin{pmatrix} 0 & \cdots & 0 & 1 \end{pmatrix}W_r^{-1}p_d(A)$$

with $p_d$ the desired characteristic polynomial.

## Reference gain

To make y settle at r, choose $k_r = -1/\left(C(A - BK)^{-1}B\right)$.

## Integral action

Add a state $z = \int(r - y)\,dt$ and feed it back too: $u = -Kx - k_iz$. The augmented system has one more pole to place and zero steady error to steps and constant disturbances, as PI control had.
:::

::: example
## A position servo has $\ddot\theta = -62.5\dot\theta + 1250u$ (the motor of lesson 2 driving a shaft angle). Place its poles at $\omega_n$ = 50 rad/s, ζ = 0.7.

::: solution
1. **State matrices.** With $x = (\theta, \dot\theta)$:
   $$\begin{aligned} A &= \begin{pmatrix} 0 & 1 \\ 0 & -62.5 \end{pmatrix} \\ B &= \begin{pmatrix} 0 \\ 1250 \end{pmatrix} \end{aligned}$$
2. **Closed-loop polynomial.**
   $$\begin{aligned} &s^2 + (62.5 + 1250k_2)s \\ &\quad + 1250k_1 \end{aligned}$$
3. **Target polynomial.** For $\omega_n$ = 50 rad/s and ζ = 0.7:
   $$s^2 + 70s + 2500$$
4. **Match coefficients.**
   $$\begin{aligned} k_1 &= 2500/1250 \\ &= 2\ \text{V/rad} \\ k_2 &= (70 - 62.5)/1250 \\ &= 0.006\ \text{V·s/rad} \end{aligned}$$
   with $k_r = k_1$ = 2 for zero steady error.
5. **Check the response.** The poles are at −35 ± j35.7; the step overshoots 4.6% and settles in 0.12 s.

**Answer:** $k_1$ = 2 V/rad and $k_2$ = 0.006 V·s/rad, with $k_r$ = 2, which puts the poles at −35 ± j35.7.
:::
:::

::: example
## Is $A = \begin{pmatrix} -1 & 1 \\ 0 & -2 \end{pmatrix}$ with $B = \begin{pmatrix} 0 \\ 1 \end{pmatrix}$ controllable?

::: solution
1. **Second column.**
   $$AB = \begin{pmatrix} 1 \\ -2 \end{pmatrix}$$
2. **Controllability matrix.**
   $$W_r = \begin{pmatrix} 0 & 1 \\ 1 & -2 \end{pmatrix}$$
   with determinant −1 ≠ 0: controllable.
3. **How the input reaches both states.** The input drives $x_2$ directly and $x_1$ through the coupling term.
4. **Without the coupling.** Set that coupling to zero and $\det W_r$ = 0: $x_1$ would be on its own.

**Answer:** yes, it's controllable, since $\det W_r = -1 \ne 0$.
:::
:::

::: example
## Use Ackermann's formula to place the poles of $A = \begin{pmatrix} -1 & 1 \\ 0 & -2 \end{pmatrix}$, $B = \begin{pmatrix} 0 \\ 1 \end{pmatrix}$ at −4 ± j4.

::: solution
1. **Controllability matrix and its inverse.** With $W_r = (B\ \ AB)$:
   $$\begin{aligned} W_r &= \begin{pmatrix} 0 & 1 \\ 1 & -2 \end{pmatrix} \\ W_r^{-1} &= \begin{pmatrix} 2 & 1 \\ 1 & 0 \end{pmatrix} \end{aligned}$$
   whose last row is (1, 0).
2. **Desired polynomial.**
   $$s^2 + 8s + 32$$
3. **Evaluate it at A.**
   $$\begin{aligned} p_d(A) &= A^2 + 8A + 32I \\ &= \begin{pmatrix} 25 & 5 \\ 0 & 20 \end{pmatrix} \end{aligned}$$
4. **Gain.**
   $$\begin{aligned} K &= (1\ \ 0)\,p_d(A) \\ &= (25\ \ 5) \end{aligned}$$
5. **Check.**
   $$A - BK = \begin{pmatrix} -1 & 1 \\ -25 & -7 \end{pmatrix}$$
   has trace −8 and determinant 32.

**Answer:** K = (25, 5).
:::
:::

::: check
given: a = 1 | 2 | 6; w = 3 | 10; z = 0.5 | 0.8
answer: w^2 - a
tolerance: 0.5%

## A plant in companion form has characteristic polynomial $s^2 + cs + \given{a}$ and $B = (0, 1)^T$. What first gain $k_1$ places the closed loop at $\omega_n$ = {w} rad/s, ζ = {z}?

::: right
Right. The constant coefficient must become $\omega_n^2$: $k_1 = \omega_n^2 - a_0$ = {answer}.
:::

::: misses
- [w^2] Subtract the open-loop coefficient: feedback only adds to it.
- [any] Not yet. Match $a_0 + k_1$ to $\omega_n^2$.
:::
:::

::: check
given: c = 1 | 4; w = 5 | 12; z = 0.5 | 0.9
answer: 2*z*w - c
tolerance: 0.5%

## The same companion-form plant has $a_1$ = {c}. What $k_2$ gives $\omega_n$ = {w}, ζ = {z}?

::: right
Right. $k_2 = 2\zeta\omega_n - a_1$ = {answer}.
:::

::: misses
- [2*z*w] Subtract the open-loop $a_1$.
- [any] Not yet. Match $a_1 + k_2$ to $2\zeta\omega_n$.
:::
:::

::: check
given: a = -2 | -1; b = 1 | 3; c = 0.5 | 1.5; d = -3 | 1; e = 1 | 2; f = 1 | -1
answer: e*(c*e + d*f) - f*(a*e + b*f)
tolerance: 0.5%

## $A = \begin{pmatrix} \given{a} & \given{b} \\ \given{c} & \given{d} \end{pmatrix}$, $B = \begin{pmatrix} \given{e} \\ \given{f} \end{pmatrix}$. What's $\det[B, AB]$?

::: right
Right. {answer}: nonzero, so the pair is controllable.
:::

::: misses
- [f*(a*e + b*f) - e*(c*e + d*f)] Columns in the order B, then AB.
- [any] Not yet. Compute AB, then the 2 × 2 determinant.
:::
:::

::: check
given: p = 1 | 3; q = 4 | 10
answer: p + q
tolerance: 0.5%

## A double integrator gets state feedback placing its poles at −{p} and −{q}. What's the velocity gain $k_2$?

::: right
Right. $(s + p)(s + q) = s^2 + (p + q)s + pq$, so $k_2$ = {answer} and $k_1$ = pq.
:::

::: misses
- [p*q] That's $k_1$, the position gain.
- [any] Not yet. Expand the desired polynomial.
:::
:::

::: check
given: t = 50 | 100; K = 5 | 20; w = 20 | 60; z = 0.7 | 1
answer: (2*z*w - 1000/t)/(K*1000/t)
tolerance: 0.5%

## A servo $\ddot\theta = -\dot\theta/\tau + (K_0/\tau)u$ has τ = {t} ms and $K_0$ = {K}. What velocity gain $k_2$ gives $\omega_n$ = {w} rad/s and ζ = {z}?

::: right
Right. $1/\tau + (K_0/\tau)k_2 = 2\zeta\omega_n$, so $k_2$ = {answer}.
:::

::: misses
- [2*z*w/(K*1000/t)] The plant already has damping $1/\tau$; subtract it.
- [any] Not yet. Match the $s^1$ coefficient.
:::
:::

::: check
given: a = 1 | 5; b = 2 | 10; w = 4 | 15
answer: w^2/b
tolerance: 0.5%

## A first-order plant $\dot{x} = -\given{a}x + \given{b}u$ gets state feedback plus integral action, $u = -kx - k_i\int(x - r)$. What $k_i$ puts the closed-loop $\omega_n$ at {w} rad/s?

::: right
Right. The closed loop is $s^2 + (a + bk)s + bk_i$, so $k_i = \omega_n^2/b$ = {answer}.
:::

::: misses
- [w^2] The integral gain enters multiplied by b.
- [any] Not yet. Write the augmented system's characteristic polynomial.
:::
:::

::: check
kind: parts
given: a = 0 | 4 | 25; c = 0 | 2 | 5; b = 2 | 10 | 50; w = 10 | 20; z = 0.6 | 0.8

## A plant $\ddot y + \given{c}\dot y + \given{a}y = \given{b}u$ gets state feedback $u = -k_1y - k_2\dot y + k_rr$ for poles at $\omega_n$ = {w} rad/s, ζ = {z}.

::: part
answer: (w^2 - a)/b
tolerance: 0.5%

### What is $k_1$?

::: misses
- [w^2 - a] The input gain b scales every feedback gain.
- [any] $(\omega_n^2 - a_0)/b_0$.
:::
:::

::: part
answer: (2*z*w - c)/b
tolerance: 0.5%

### What is $k_2$?

::: misses
- [any] $(2\zeta\omega_n - a_1)/b_0$.
:::
:::

::: part
answer: w^2/b
tolerance: 0.5%

### What reference gain $k_r$ gives unit DC gain?

::: misses
- [any] The closed loop's DC gain is $b_0k_r/\omega_n^2$.
:::
:::
:::

::: check
kind: derivation
vars: p = 0.1..100, q = 0.1..100

## A double integrator $\ddot y = u$ gets state feedback placing its poles at −p and −q, with a reference gain for unit DC gain.

::: step
answer: p*q

### What is the position gain $k_1$?
:::

::: step
answer: p + q

### What is the velocity gain $k_2$?
:::

::: step
answer: p*q

### What is $k_r$?
:::

::: right
Right. With nothing to cancel, the gains are just the coefficients of the desired polynomial.
:::
:::

::: explain
## Why does state feedback place every pole when output feedback with a single gain can't?

::: model
A single gain on one output moves the closed-loop poles along a one-dimensional path, the root locus, so you get to choose one point on it and nothing more. State feedback has a separate gain for every state, n knobs for n poles. For a controllable system written in companion form, each gain adds directly to one coefficient of the characteristic polynomial, so any set of coefficients, and so any set of poles, is reachable. What you pay for this is knowing every state, which needs either a sensor for each one or an estimator that reconstructs them from the measurements, the subject of lesson 37.
:::
:::

::: practice

::: check
given: a = 1 | 8; w = 4 | 20
answer: w^2 - a
tolerance: 0.5%

## $k_1$ for $\omega_n$ = {w} on $s^2 + cs + \given{a}$?

::: misses
- [any] $\omega_n^2 - a_0$.
:::
:::

::: check
given: c = 0.5 | 6; w = 3 | 15; z = 0.6 | 0.8
answer: 2*z*w - c
tolerance: 0.5%

## $k_2$ for ζ = {z}, $\omega_n$ = {w}, with $a_1$ = {c}?

::: misses
- [any] $2\zeta\omega_n - a_1$.
:::
:::

::: check
given: p = 2 | 5; q = 6 | 20
answer: p*q
tolerance: 0.5%

## Position gain $k_1$ placing a double integrator's poles at −{p}, −{q}?

::: misses
- [any] pq.
:::
:::
:::
