The cart and its poles
Our plant is the cart from State-space models: 2 kg on a spring and damper, pushed by a force u. Its state x is position x₁ and velocity x₂, and it obeys ẋ = Ax + Bu.
Push it with a steady 10 N and it overshoots by 53% and rings for 3.9 s. The reason is in A: its eigenvalues, the poles, sit at −1 ± j4.90, close to the imaginary axis.
State feedback
State feedback needs every state variable, not just the output. Sensors read the position x₁ and the velocity x₂, and each one travels back along its own wire to a gain.
Multiply each state by a gain and subtract the sum from the input: u = −k₁x₁ − k₂x₂, or u = −Kx. The row K = [k₁ k₂] holds the only two numbers we get to choose.
Put u = −Kx into ẋ = Ax + Bu and you get ẋ = (A − BK)x. The loop acts like a new plant with matrix A − BK, so its poles are the eigenvalues of A − BK, not of A.
Here det(sI − (A − BK)) = s² + (2 + 0.5k₂)s + (25 + 0.5k₁). The velocity gain sets the damping term and the position gain sets the stiffness term: two gains, two coefficients.
Placing the poles
We want little ringing and a quick finish, so we pick poles at −4 ± j4: damping ratio 0.71, about 4.3% overshoot. Those two poles mean the polynomial (s + 4)² + 16 = s² + 8s + 32.
Match coefficients: 2 + 0.5k₂ = 8 gives k₂ = 12, and 25 + 0.5k₁ = 32 gives k₁ = 14. As the gains grow from zero, the poles slide from −1 ± j4.90 to −4 ± j4.
Matching works because the cart is controllable: [B AB] = [0 0.5; 0.5 −1] has determinant −0.25, not zero. Then K can put the poles anywhere, as long as complex poles come in conjugate pairs.
Tracking a target
u = −Kx only pulls the cart to zero. To aim at r = 0.2 m, add a reference gain: u = N̄r − Kx. N̄ = 64 makes the cart settle at r; with N̄ = 1 it would stop at 3.1 mm.
Ask for 0.2 m. The cart rises, overshoots by 4.3% to 0.209 m, and stays within 2% after 1.1 s. Open loop overshot 53% and took 3.9 s. Same cart, new poles.
The loop starts with 12.8 N, eases to 5.5 N to brake the cart, then settles at 10 N, the force the spring needs. Poles further left need bigger gains and more force than the motor may have.
What is happening
# step 1/12 · plant
# about: Cart (plant)
x = [x1, x2] position (m), velocity (m/s)
x' = A x + B u
A = [[ 0, 1],
[-25, -2]]
B = [0, 0.5]
2 kg · spring 50 N/m · damper 4 N·s/m
The cart is the same illustrative 2 kg cart as in State-space models. Every curve, pole and number in the figure is computed from its exact solution, and the Python on each step prints what the step says. The Python is plain Python 3. The simulation steps the state equation with Euler's method every 0.1 ms, close enough to the exact curve to print the same peak to three decimals.