|
| 1 | +# Step / Transient-Response Metrics |
| 2 | + |
| 3 | +## Overview & Motivation |
| 4 | + |
| 5 | +When a control system or filter receives a step input, its output traces a transient trajectory before settling at the final value. Quantifying that trajectory with standardised scalar metrics — rise time, settling time, percent overshoot, peak time, and steady-state error — is the primary acceptance test for any closed-loop design. These metrics translate the raw sample sequence into the language of control specifications, allowing automated pass/fail decisions without manual inspection of time-domain plots. |
| 6 | + |
| 7 | +## Mathematical Theory |
| 8 | + |
| 9 | +### Definitions |
| 10 | + |
| 11 | +Let $y[k]$, $k = 0, \ldots, N-1$ be the sampled step response and $y_{ss}$ the steady-state value. The sample period is $\Delta t$. |
| 12 | + |
| 13 | +**Rise Time** $T_r$ |
| 14 | + |
| 15 | +The elapsed time for the response to travel from 10 % to 90 % of steady state: |
| 16 | + |
| 17 | +$$T_r = (k_{90} - k_{10})\,\Delta t$$ |
| 18 | + |
| 19 | +where $k_{10} = \min\{k : y[k] \ge 0.1\,y_{ss}\}$ and $k_{90} = \min\{k \ge k_{10} : y[k] \ge 0.9\,y_{ss}\}$. |
| 20 | + |
| 21 | +**Settling Time** $T_s$ |
| 22 | + |
| 23 | +The first time after which the response remains permanently inside the band $[(1-\delta)y_{ss},\,(1+\delta)y_{ss}]$ (typically $\delta = 0.02$): |
| 24 | + |
| 25 | +$$T_s = (k^* + 1)\,\Delta t, \quad k^* = \max\{k : |y[k] - y_{ss}| > \delta\,|y_{ss}|\}$$ |
| 26 | + |
| 27 | +**Percent Overshoot** $\%OS$ |
| 28 | + |
| 29 | +$$\%OS = 100\,\frac{y_{\max} - y_{ss}}{y_{ss}}, \quad y_{\max} = \max_k y[k]$$ |
| 30 | + |
| 31 | +For an underdamped second-order system with damping ratio $\zeta$: |
| 32 | + |
| 33 | +$$\%OS = 100\,\exp\!\left(-\frac{\pi\zeta}{\sqrt{1-\zeta^2}}\right)$$ |
| 34 | + |
| 35 | +**Peak Time** $T_p$ |
| 36 | + |
| 37 | +$$T_p = k_p\,\Delta t, \quad k_p = \arg\max_k y[k]$$ |
| 38 | + |
| 39 | +For a continuous underdamped second-order system with natural frequency $\omega_n$: |
| 40 | + |
| 41 | +$$T_p = \frac{\pi}{\omega_n\sqrt{1-\zeta^2}}$$ |
| 42 | + |
| 43 | +**Steady-State Error** $e_{ss}$ |
| 44 | + |
| 45 | +$$e_{ss} = r - \bar{y}_{\text{tail}}$$ |
| 46 | + |
| 47 | +where $r$ is the reference (command) value and $\bar{y}_{\text{tail}}$ is the mean of the final quarter of the response buffer, providing a robust estimate of the achieved steady state. |
| 48 | + |
| 49 | +## Complexity Analysis |
| 50 | + |
| 51 | +| Case | Time | Space | Notes | |
| 52 | +|---------|----------|--------|--------------------------------------------| |
| 53 | +| All | $O(N)$ | $O(1)$ | Single forward pass; no auxiliary storage | |
| 54 | + |
| 55 | +Each metric requires at most one traversal of the $N$-element vector. The tail-mean for steady-state error adds a constant-fraction second scan of the same data — still $O(N)$ total. |
| 56 | + |
| 57 | +## Step-by-Step Walkthrough |
| 58 | + |
| 59 | +Consider a 10-sample ramp to $y_{ss} = 1$ followed by a constant plateau (N = 20): |
| 60 | + |
| 61 | +``` |
| 62 | +k: 0 1 2 3 4 5 6 7 8 9 10 11 … |
| 63 | +y: 0 .1 .2 .3 .4 .5 .6 .7 .8 .9 1 1 … |
| 64 | +``` |
| 65 | + |
| 66 | +- **Rise Time:** $k_{10} = 1$ (first sample $\ge 0.1$), $k_{90} = 9$ (first sample $\ge 0.9$). $T_r = 8\,\Delta t$. |
| 67 | +- **Settling Time:** With $\delta = 0.02$, last sample outside the band is $k = 9$. $T_s = 10\,\Delta t$. |
| 68 | +- **Percent Overshoot:** $y_{\max} = 1.0 = y_{ss}$, so $\%OS = 0$. |
| 69 | +- **Peak Time:** $k_p = 10$ (first occurrence of max). $T_p = 10\,\Delta t$. |
| 70 | +- **Steady-State Error:** Tail mean $= 1.0$, reference $= 1.0$. $e_{ss} = 0$. |
| 71 | + |
| 72 | +## Pitfalls & Edge Cases |
| 73 | + |
| 74 | +**Zero steady state.** Division by $y_{ss}$ in percent overshoot is guarded; the function returns zero when $y_{ss} = 0$ to avoid a NaN. |
| 75 | + |
| 76 | +**Non-monotone ramp.** If the response crosses 90 % before 10 % (e.g., DC offset or wrong initial condition), $k_{10}$ may be found after the first 90 % crossing. The implementation returns the first pair that satisfies the threshold order. |
| 77 | + |
| 78 | +**Oscillatory settling.** Settling time is defined as the last time the trajectory leaves the band, not the first time it enters it. Repeated crossings near the boundary extend the metric correctly. |
| 79 | + |
| 80 | +**Finite buffer.** With a bounded vector of length $N$, if the response has not yet settled by the final sample, `SettlingTime` returns $N\,\Delta t$ and `RiseTime` returns $(N-1)\,\Delta t$ as conservative bounds. |
| 81 | + |
| 82 | +**Tail-mean length.** Using the last $\lfloor N/4 \rfloor + 1$ samples for the steady-state estimate assumes the transient has decayed to within numerical noise by that point. Poorly chosen $N$ relative to the system time constant degrades the estimate. |
| 83 | + |
| 84 | +## Variants & Generalizations |
| 85 | + |
| 86 | +- **Delay Time** $T_d$: the time to reach 50 % of steady state — obtainable with the same threshold-scan pattern. |
| 87 | +- **Band-relative rise time**: using a band other than 10–90 % (e.g., 20–80 %) is a trivial parameter change. |
| 88 | +- **Multi-channel:** applying the scalar functions element-wise to each row of a response matrix generalises to MIMO systems without algorithmic change. |
| 89 | + |
| 90 | +## Applications |
| 91 | + |
| 92 | +- Automated controller tuning acceptance: verify that a PID or LQR design meets specification ($T_r < T_{r,\text{spec}}$, $\%OS < \%OS_{\text{spec}}$, etc.). |
| 93 | +- Filter characterisation: measure the transient of a step fed through an IIR or FIR filter. |
| 94 | +- Hardware-in-the-loop test harnesses: compute metrics directly from sampled actuator responses. |
| 95 | + |
| 96 | +## Connections to Other Algorithms |
| 97 | + |
| 98 | +- **Statistics** (this library): the tail-mean for steady-state error replicates the `Mean` function on a sub-range. |
| 99 | +- **LinearTimeInvariant**: the primary source of step responses whose metrics are evaluated here. |
| 100 | +- **Filters/active** (Kalman, EKF): step-excitation tests use these metrics to validate estimator transient behaviour. |
| 101 | +- **Controllers**: PID and LQR tuning loops iterate until all five metrics satisfy design targets. |
| 102 | + |
| 103 | +## References & Further Reading |
| 104 | + |
| 105 | +- K. J. Åström and R. M. Murray, *Feedback Systems: An Introduction for Scientists and Engineers*, Princeton University Press, 2008. Chapter 10. |
| 106 | +- G. F. Franklin, J. D. Powell, and A. Emami-Naeini, *Feedback Control of Dynamic Systems*, 8th ed., Pearson, 2019. Chapter 3. |
| 107 | +- N. S. Nise, *Control Systems Engineering*, 8th ed., Wiley, 2019. Chapter 4. |
0 commit comments