State Feedback and Pole Placement
A small DC motor turns a camera mount, and the specification reads: move with no more than 5 % overshoot, settle within , never ask the driver for more than its supply. A PID loop on the angle measurement has three knobs and a root locus that only bends so far. If the drive also measures the motor current and the encoder gives the speed, every state of the motor is available, and then something stronger is possible: state feedback puts every closed-loop pole wherever you want, provided the plant is controllable.
The idea
With the whole state measured, the control law is a weighted sum of the states plus a scaled reference:
The closed-loop poles are the eigenvalues of . For a single input, is a row of gains, and the characteristic polynomial has coefficients that depend linearly on them. Matching it to a desired polynomial gives equations for unknowns: a unique solution exactly when the plant is controllable. Ackermann's formula writes it in closed form,
and ct.acker(A, B, poles) evaluates it; ct.place(A, B, poles) uses a numerically better algorithm and also handles several inputs. Use place in practice.
Reference scaling. State feedback alone regulates to zero. To follow with zero steady-state error, scale the reference so the DC gain from to is one:
depends on the model being exact. A load disturbance or a model error leaves a steady-state error, just like a P controller. The cure is the same as in PID: integral action, here as an extra state added to the model and fed back like the others.
Choosing the poles
The specification picks the dominant pair through the second-order formulas of Second-Order Systems: overshoot needs ; settling within needs ; choosing , () leaves a margin for the approximations. The other poles go further left, but not too far: every pole moved a long way from its open-loop position costs gain, and gain costs actuator effort and noise amplification. A good habit is to move only the poles you must and leave fast, well-damped ones near where they are.
Worked example: motor position control
Given: the motor of State-Space Models with the angle added as a state, :
Find: and for a dominant pair with , , third pole at ; the step overshoot, the settling time and the largest voltage for a step.
Solve:
- Open-loop eigenvalues: (the angle integrates the speed), and .
- Desired: , and , close to the fast electrical pole, so the current gain stays small.
- Expected: overshoot about , settling about by the rule.
- At the states are still zero, so : the reference scale is also the first voltage step. The code finds , so a step asks for , inside the supply.
Check:
import numpy as np
import control as ct
Ra, La, k, J, b = 2.0, 1e-3, 0.02, 2e-6, 1e-6
A = np.array([[0, 1, 0], [0, -b / J, k / J], [0, -k / La, -Ra / La]])
B = np.array([[0], [0], [1 / La]])
C = np.array([[1, 0, 0]])
print("controllable:", np.linalg.matrix_rank(ct.ctrb(A, B)) == 3)
zeta, wn = 0.7, 150.0
wd = wn * np.sqrt(1 - zeta**2)
poles = [complex(-zeta * wn, wd), complex(-zeta * wn, -wd), -2000.0]
K = ct.place(A, B, poles)
Acl = A - B @ K
N = -1.0 / (C @ np.linalg.solve(Acl, B)).item()
print("K =", np.round(K, 4), f" N = {N:.3f} V/rad")
print("closed-loop poles:", np.round(np.sort_complex(np.linalg.eigvals(Acl)), 1))
cl = ct.ss(Acl, B * N, np.vstack([C, -K]), [[0], [N]]) # outputs: angle, voltage
t = np.linspace(0, 0.1, 10001)
y = ct.forced_response(cl, T=t, U=np.ones_like(t)).outputs
info = ct.step_info(ct.ss(Acl, B * N, C, 0), T=t)
print(f"overshoot {info['Overshoot']:.1f} %, 2 % settling {1e3 * info['SettlingTime']:.1f} ms, "
f"max |voltage| {np.abs(y[1]).max():.2f} V")controllable: True
K = [[4.5 0.0241 0.2095]] N = 4.500 V/rad
closed-loop poles: [-2000. +0.j -105.-107.1j -105.+107.1j]
overshoot 4.6 %, 2 % settling 40.4 ms, max |voltage| 4.50 V
The simulation gives and : the rule is an estimate, and the result is still inside the specification.
Integral action against a load
The camera mount has an unbalanced load torque of , entering the speed equation as . With the angle ends short of the target. Adding the integral state and a fourth pole at removes the error:
import numpy as np
import control as ct
Ra, La, k, J, b = 2.0, 1e-3, 0.02, 2e-6, 1e-6
A = np.array([[0, 1, 0], [0, -b / J, k / J], [0, -k / La, -Ra / La]])
B = np.array([[0], [0], [1 / La]])
C = np.array([[1, 0, 0]])
E = np.array([[0], [-1 / J], [0]]) # load torque input
wd = 150 * np.sqrt(1 - 0.7**2)
p3 = [complex(-105, wd), complex(-105, -wd), -2000.0]
K = ct.place(A, B, p3)
N = -1.0 / (C @ np.linalg.solve(A - B @ K, B)).item()
plain = ct.ss(A - B @ K, np.hstack([B * N, E]), C, 0)
Aa = np.block([[A, np.zeros((3, 1))], [-C, np.zeros((1, 1))]]) # x_I' = r - theta
Ba = np.vstack([B, [[0]]])
Ka = ct.place(Aa, Ba, p3 + [-300.0])
integ = ct.ss(Aa - Ba @ Ka, np.hstack([[[0], [0], [0], [1]], np.vstack([E, [[0]]])]),
np.hstack([C, [[0]]]), 0)
print("Ka =", ", ".join(f"{v:.4g}" for v in Ka.ravel()))
t = np.linspace(0, 0.1, 10001)
U = np.vstack([np.ones_like(t), np.where(t >= 0.05, 1e-3, 0.0)]) # 1 rad step, load at 50 ms
for name, sys in (("N-scaled state feedback", plain), ("with integral state", integ)):
th = np.atleast_2d(ct.forced_response(sys, T=t, U=U).outputs)[0]
print(f"{name:24s}: angle at 50 ms {th[5000]:.4f} rad, at 100 ms {th[-1]:.4f} rad")Ka = 17.77, 0.09042, 0.5095, -1350
N-scaled state feedback : angle at 50 ms 1.0014 rad, at 100 ms 0.9755 rad
with integral state : angle at 50 ms 1.0066 rad, at 100 ms 1.0002 rad
Without the integrator the load pushes the angle (2.5 %) short of the target for good; with it the error is gone later, as with a PI controller. The price is a fourth state in the controller, one more pole to choose, and an integrator that can wind up when the drive saturates (Anti-Windup).
Guided lab: a position servo on the bench
Hand calculation. The worked example asks for at most for a step and settles in about . Your motor's , and differ: measure them first (Modelling a DC Motor), then rerun ct.place with your numbers.
Simulation. Change poles in the first program to : the voltage peak grows roughly with and soon exceeds the supply, so the real loop saturates and the linear design no longer holds.
What you would measure. Motor with an incremental encoder (e.g. 1000 lines, 4000 counts per revolution: resolution), an H-bridge driver from a current-limited supply (limit ), a shunt for the current, and a microcontroller running the control law at (fast compared with the pole; see Sampled-Data Loops). The speed state comes from differentiating the encoder count, which is noisy at low speed: expect a measured overshoot within a few percent of the predicted and a settling time within , mostly from friction and the estimated .
Hazards and safe setup. Clamp the motor; limit the travel mechanically or in software; nothing loose on the shaft; set the supply current limit before enabling the drive; an encoder sign error turns negative feedback positive and the motor runs away at full speed, so test with a low voltage limit first.
Pitfalls
- Placing poles far to the left "for speed": gains, voltage peaks and noise sensitivity grow quickly, and the unmodelled dynamics (driver bandwidth, sampling) bite.
- Forgetting : state feedback alone regulates to zero, not to .
- Relying on for accuracy under load: only integral action gives zero error for a constant disturbance.
- Assuming all states are measured: usually they are not, and the missing ones come from an observer.
Practice
- A double integrator (, ): find for closed-loop poles at .
- What and satisfy "overshoot at most 10 %, settling within " with the smallest ?
- A pendulum balanced upright, linearised about the top (Linearisation), with a torque input scaled to an angular acceleration: , . Show that it is unstable and find for poles at .
Answer
- , characteristic polynomial ; desired : .
- 10 % overshoot: ; gives .
- has eigenvalues : one in the right half-plane. With the polynomial is ; matching gives (in and ).
Test yourself
With full state feedback , the closed-loop poles are
- the eigenvalues of
- the eigenvalues of
- the zeros of
- fixed by the plant
Arbitrary pole placement by state feedback is possible exactly when
- the plant is stable
- the plant is controllable
- the plant is observable
Why does leave a steady-state error under a constant load torque?
- is computed for the nominal model without the disturbance; there is no integrator
- is too small
- the observer is missing
- the poles are complex
In the motor example, what sets the voltage the drive applies at the instant of a reference step?
- times the final state
- the reference scale times the step
- the supply voltage always
- zero, because the integrator starts at zero