Controllability and Observability
The two-zone plate of State-Space Models gets a cheaper design: one power stage drives both heaters in parallel, and one sensor sits in the middle between them. The loop works, the average temperature is perfect, yet one zone ends up warmer than the other after someone puts a cold part on it, and the controller never corrects it. Nothing is broken. The difference between the zones is a mode that this actuator cannot push and this sensor cannot see. Controllability asks whether the inputs can steer every state; observability asks whether the outputs reveal every state. Both are yes/no questions with a simple matrix test, and both must be answered before pole placement or an observer can work.
Intuition: a bridge with a capacitor across it
A Wheatstone bridge has a capacitor between its two midpoints. Its voltage is a state. When the bridge is balanced (, here ), the source raises both midpoints by exactly the same amount, so the capacitor voltage never moves, whatever the source does: that state is uncontrollable from the source. Unbalance the bridge with the slider and the two midpoints separate with a time constant: the state becomes controllable.
At both midpoints start at (the capacitor holds ) and separate towards and with ; at the lab shows and . Slide to and both traces stay at : the capacitor's state is decoupled from the input.
The definitions and the rank tests
A system is controllable if for any initial state and any target state there is an input that moves the system from one to the other in finite time. It is observable if the initial state can be worked out from the input and the output over a finite interval. For an -state LTI system both reduce to the rank of a matrix (Kalman's tests):
controllable , observable . The columns of are the directions the input can push the state, directly () and after the dynamics have acted once, twice, … (, ); the rows of are what the output and its derivatives reveal. In python-control: ct.ctrb(A, B) and ct.obsv(A, C).
The tests are dual: is observable exactly when is controllable. Every controller-design method therefore gives an observer-design method for free, which Observers uses.
A mode-by-mode view (the Popov–Belevitch–Hautus test): an eigenvalue of is uncontrollable if , unobservable if . It tells you which mode is the problem. An unstable or badly damped mode that is uncontrollable cannot be fixed by any feedback; such a plant is not stabilisable, and the hardware has to change.
Pole-zero cancellation hides modes
A transfer function shows only the part of the system that is both controllable and observable (Kalman's decomposition). If a zero of one block cancels a pole of another, the cancelled mode disappears from but not from the hardware. Cancelling a stable, fast pole is harmless; cancelling an unstable one ("put a zero at to remove the unstable pole") leaves an internal signal that grows without bound while the transfer function looks fine. ct.minreal removes cancelled modes from a model; when it shrinks a physical model, ask which mode went missing and why.
Worked example: the plate with one actuator and one sensor
Given: the plate model with , , , so . Both heaters wired in parallel: . Sensor in the middle reading the average: .
Find: the ranks of and , and which mode is lost.
Solve:
- : parallel to . So has rank 1, not 2.
- Similarly is parallel to : rank 1.
- The eigenvectors of are (zones together, ) and (zones apart, ). The input only excites the first, and the sensor only sees the first. The difference mode is both uncontrollable and unobservable: it decays on its own with a time constant, but nothing in the loop can speed it up or detect it.
Check: the code computes the ranks, then repairs the design two ways: separate heater drives, or a sensor on zone 1 only.
import numpy as np
import control as ct
Ch, g, g12 = 75.0, 1 / 8, 1 / 4
A = np.array([[-(g + g12), g12], [g12, -(g + g12)]]) / Ch
def ranks(B, C):
return np.linalg.matrix_rank(ct.ctrb(A, B)), np.linalg.matrix_rank(ct.obsv(A, C))
cases = {
"heaters in parallel, average sensor": (np.array([[1], [1]]) / Ch, np.array([[0.5, 0.5]])),
"two separate heaters, average sensor": (np.eye(2) / Ch, np.array([[0.5, 0.5]])),
"heaters in parallel, sensor on zone 1": (np.array([[1], [1]]) / Ch, np.array([[1.0, 0.0]])),
"one heater on zone 1, sensor on zone 1": (np.array([[1], [0]]) / Ch, np.array([[1.0, 0.0]])),
}
for name, (B, C) in cases.items():
rc, ro = ranks(B, C)
print(f"{name:40s}: rank ctrb {rc}, rank obsv {ro}")
# The transfer function of the first case shows one pole only
G = ct.ss2tf(ct.ss(A, cases["heaters in parallel, average sensor"][0], [[0.5, 0.5]], 0))
Gm = ct.minreal(G, verbose=False)
print("poles of G before minreal (1/s):", np.round(np.sort(ct.poles(G).real), 5))
print("poles after minreal (1/s): ", np.round(ct.poles(Gm).real, 5))heaters in parallel, average sensor : rank ctrb 1, rank obsv 1
two separate heaters, average sensor : rank ctrb 2, rank obsv 1
heaters in parallel, sensor on zone 1 : rank ctrb 1, rank obsv 2
one heater on zone 1, sensor on zone 1 : rank ctrb 2, rank obsv 2
poles of G before minreal (1/s): [-0.00833 -0.00167]
poles after minreal (1/s): [-0.00167]
The minimal model keeps only the slow common mode at ; the difference mode at is gone from the transfer function but not from the plate. A heater on one zone plus a sensor on that zone is enough: through the coupling resistance it reaches and sees both modes, because mixes them.
Nearly uncontrollable is a practical problem
The rank test is a yes/no answer; real hardware is often almost uncontrollable. If the two heater gains differ by 2 %, the rank is 2, but steering the difference mode then needs enormous, opposite heater powers. The condition number of (or the smallest singular value of the controllability Gramian, ct.gram) measures how hard a direction is to reach:
import numpy as np
import control as ct
Ch, g, g12 = 75.0, 1 / 8, 1 / 4
A = np.array([[-(g + g12), g12], [g12, -(g + g12)]]) / Ch
for mismatch in (0.0, 0.02, 0.2, 1.0):
B = np.array([[1.0], [1.0 - mismatch]]) / Ch
s = np.linalg.svd(ct.ctrb(A, B), compute_uv=False)
rank = np.linalg.matrix_rank(ct.ctrb(A, B))
ratio = s[0] / s[1] if s[1] > 1e-15 else float("inf")
print(f"heater 2 gain {1 - mismatch:4.2f}: rank {rank}, singular-value ratio {ratio:10.3g}")heater 2 gain 1.00: rank 1, singular-value ratio inf
heater 2 gain 0.98: rank 2, singular-value ratio 1.49e+04
heater 2 gain 0.80: rank 2, singular-value ratio 1.37e+03
heater 2 gain 0.00: rank 2, singular-value ratio 300
The ratio falls from very large to moderate as the second heater weakens: of the arrangements where the second heater gets between 0 and 100 % of the drive, a single heater on zone 1 (gain 0) reaches both modes most easily, which is not obvious without the test. (The ratio also depends on how the states are scaled, so compare arrangements of one plant, not different plants.)
Guided lab: the bridge on the bench
Hand calculation. For , , and a step: final , , . Balanced (): for all time.
Simulation. The netlist lab above; set to and see how small the controllable part becomes: final .
What you would measure. Build it on a breadboard with 1 % resistors and a film capacitor, drive it from a square wave at (function generator, output) and look at with the scope's math channel. Balanced, you see only a few millivolts (resistor tolerance: 1 % parts leave up to about ); unbalanced, a clean exponential with (capacitor tolerance).
Hazards and safe setup. only; nothing hazardous. Ground both scope probes to the generator ground, and use the math channel rather than floating one probe.
Pitfalls
- Calling a plant controllable because its transfer function has the right order: cancellations hide modes.
- Trusting
matrix_rankon badly scaled matrices: scale states to similar units first, and look at singular values, not only the rank. - Cancelling an unstable plant pole with a controller zero: the transfer function looks stable, the internal signals are not.
- Forgetting that adding a sensor (observability) or an actuator (controllability) is often cheaper than a clever controller.
Practice
- Is , (a double integrator, force to position) controllable? Is it observable with (velocity sensor only)?
- The motor of State-Space Models with only a current sensor, : observable?
Answer
- : rank 2, controllable. : rank 1, not observable: a velocity sensor cannot tell where the mass started.
- : rank 2, observable. The back-EMF term carries the speed into the current.
Test yourself
An -state system is controllable when
- has nonzero entries
- has rank
- all eigenvalues of are negative
- is square
Two identical zones heated by one shared drive and measured by one average sensor: which mode is lost?
- the common (both rising together) mode
- the difference (zones apart) mode
- neither
- both
Observability of is equivalent to
- controllability of
- stability of
- controllability of
Why is cancelling an unstable plant pole with a controller zero unacceptable?
- it lowers the DC gain
- the unstable mode is still in the hardware, now uncontrollable or unobservable, and internal signals grow
- python-control cannot simulate it
- it creates a zero in the right half-plane