S9 · Lesson 12 · Response lab
A Routh-array stability counter, step-response metrics measured from data, numerical linearization by central differences, and the residues that decide which poles dominate
Lessons 3 to 10 gave closed forms: overshoot from ζ, settling from σ, stability from the Routh array, the residues that make some poles dominate. Real work runs these as code: a stability check inside a design loop, a script that reads overshoot and settling time off a measured response, a linearization of a model too messy to differentiate by hand. In this lab you'll write those tools and test each against the formulas it replaces.
- The curve is the step response of the standard second-order system with = 10 rad/s, ζ set by the slider.
- At ζ = 0.5 it peaks at 0.363 s with 16.3% overshoot and stays within 2% after 0.81 s, close to the estimate = 0.8 s.
- Your step_metrics function must recover those numbers from samples alone.
Predict
The Routh array of is built for K = 5. How many sign changes appear in its first column?
The first column is 1, 3, (3(K − 4) − K)/3 = (2K − 12)/3 = −2/3, and K = 5: signs +, +, −, +, two changes, so two roots in the right half-plane. The loop of lesson 9's example needs K > 6.
Name it
What the lab computes
- Routh array: rows from the polynomial's alternating coefficients, each new entry from the two rows above; the number of sign changes in the first column counts right-half-plane roots (assume no zero appears in the first column).
- Step metrics from samples with final value taken as the last sample: overshoot , peak time where the maximum occurs, 2% settling time as the last time .
- Linearization: , with error proportional to .
- Residues: for with distinct real poles, the step response is with
Check
Write routh(c): given polynomial coefficients from the highest power down, return the first column of the Routh array (a list) and the number of sign changes in it.
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Check
Write step_metrics(t, y): from sampled step-response data, return (overshoot as a fraction, peak time, 2% settling time), taking the final value as the last sample.
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Check
Write jacobian(f, x0, h): the matrix of partial derivatives of a function f (taking and returning lists) at x0, by central differences with step h.
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Check
Write step_residues(poles): for distinct real poles p (all negative) of , return the coefficients of in its step response.
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Explain why
Why is it worth computing step-response metrics from data rather than reading them from the ζ and ω_n formulas?
The formulas for overshoot, peak time and settling time are exact only for a pure second-order system with no zeros. Real loops have extra poles, zeros, delays and nonlinearities that shift those numbers, sometimes a lot, as lesson 8's tables show. Measuring the metrics directly from a simulated or recorded response gives the true values for the actual system, and comparing them with the formulas shows how well the dominant-pole approximation holds. The same code works on measured data from the real plant, which is how specifications are finally verified.