S9 · Lesson 51 · Project
Modeling a DC motor with angle, speed and current as states, designing state feedback and an observer by pole placement, and simulating the observer-based servo with a saturating 12 V amplifier to check overshoot, settling and estimator convergence
This project puts the second half of the course to work on one real plant: the DC motor from lesson 2, now turning a shaft whose angle you want to control, with only the angle measured. You'll write its three-state model, place the controller's and the observer's poles, and simulate the whole loop with an amplifier that clips at ±12 V. The tests check what a bench test would: overshoot and settling time for a small step, graceful behavior when a large step saturates the amplifier, and an observer that finds the true state after starting out wrong.
Predict
The design places the controller's poles at −60 ± j60 and −600. A 1 rad step then needs at most 4.4 V. What happens on a 5 rad step with a 12 V amplifier?
A linear loop would need 22 V for that step, so the input clips and the early response is slower than the linear design. Because this controller has no integrator, there's no windup: once the error is small enough for the command to come back inside ±12 V, the loop is linear again and finishes like the small-step response. The test requires settling within 2% of 5 rad in under 0.2 s.
Name it
The model
With states x = (θ, ω, i) and input voltage V:
For R = 2 Ω, L = 0.5 mH, = 0.05, J = 2 × 10⁻⁵ kg·m², b = 10⁻⁵: poles at 0, −64.0 and −3936 s⁻¹.
The design
- Controller: dominant poles at −60 ± j60 (ζ = 0.707, = 84.9 rad/s) and a third at −600, ten times farther out. Ackermann (lesson 50) gives K = (0.864, −0.0342, −1.640) and = 0.864.
- Observer: −300 ± j300 and −5000, five times faster than the controller, computed by duality as
place(A.T, C, poles). - Simulation: RK4 on the plant and observer together, with , the observer driven by the clipped u that the plant actually receives.
Why the observer gets the clipped input
If the observer were fed the unclipped command while the plant got the clipped one, the model and the plant would diverge every time the amplifier saturated, and the estimate would be wrong exactly when it matters. Feeding the model the actual applied input keeps the estimation error obeying , saturated or not.
Worked example
Why is the current gain in K negative?
Show the solution
- The two poles. The motor's electrical pole is at −3936, but the design asks for a third pole at −600.
- Feedback can slow a pole. State feedback can slow a pole as well as speed it up. The current row of A − BK has on its diagonal
- What the negative gain does. A negative current gain feeds back positively on current, so the controller weakens the motor's natural current regulation.
- The alternative. Placing the third pole near the electrical one instead would need much larger gains and a noisier current loop.
Answer the design puts the third pole at −600, much slower than the motor's electrical pole at −3936, and a negative current gain is what slows it.
Worked example
What does the observer do in the first few milliseconds after it starts 0.1 rad wrong?
Show the solution
- Error dynamics. The error obeys , with poles at
- The fast pole. It removes part of the error within about a millisecond.
- The slower pair. It decays as , falling to 0.1% of the initial error by about 23 ms, well before the controller's 72 ms settling.
- What the test checks. That the largest error is below 0.001 after 50 ms.
Answer the fast pole removes part of the error within a millisecond, and the rest decays as , down to 0.1% by about 23 ms.
Check
Step 1. Write motor_model(R, L, Kt, J, b): the three-state motor.
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Check
Step 2. Write design(A, B, C, ctrl_poles, obs_poles): state feedback, observer and reference gain.
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Check
Step 3. Write simulate(...): the observer-based servo with a saturating amplifier.
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Explain why
Why can the controller and the observer be designed separately even though the controller uses the observer's estimate?
Write the closed loop in terms of the plant's state x and the estimation error e = x − x̂. The control law makes , while the error obeys , which doesn't involve x or K at all. The system matrix is block triangular, so its eigenvalues are those of A − BK together with those of A − LC. The controller's poles are exactly where they were designed for full-state feedback, and the observer's are where they were placed, with the error acting only as a decaying disturbance on the controlled plant.
Practice
Keep practicing
3 kinds of problem on this topic, dealt one at a time with new numbers every time, for as long as you like.