@@ -41,8 +41,8 @@ The output is clamped to $[u_{\min}, u_{\max}]$ after each computation, which al
4141
4242## Complexity Analysis
4343
44- | Case | Time | Space | Notes |
45- | ------| ------| -------| -------|
44+ | Case | Time | Space | Notes |
45+ | ------------ | -------- | -------- | ---------------------------------- -------|
4646| Per sample | $O(1)$ | $O(1)$ | 3 multiplications, 3 additions, 1 clamp |
4747
4848The algorithm uses a fixed-size recursive buffer storing $e[ n-1] $, $e[ n-2] $, and $u[ n-1] $. No loops, no dynamic allocation, fully deterministic execution time.
@@ -56,12 +56,12 @@ The algorithm uses a fixed-size recursive buffer storing $e[n-1]$, $e[n-2]$, and
5656- $a_1 = -(2 + 0.2) = -2.2$
5757- $a_2 = 0.1$
5858
59- | Step | Measured | $e[ n] $ | $e[ n-1] $ | $e[ n-2] $ | $\Delta u$ | $u[ n] $ (clamped) |
60- | ------| ----------| --------| ----------- | -----------| ------------| -------------------|
61- | 0 | 0.0 | 5.0 | 0 | 0 | $2.6 \times 5 = 13$ | ** 10.0** (clamped) |
62- | 1 | 2.0 | 3.0 | 5.0 | 0 | $2.6(3) - 2.2(5) + 0.1(0) = -3.2$ | ** 6.8** |
63- | 2 | 4.0 | 1.0 | 3.0 | 5.0 | $2.6(1) - 2.2(3) + 0.1(5) = -3.5$ | ** 3.3** |
64- | 3 | 4.8 | 0.2 | 1.0 | 3.0 | $2.6(0.2) - 2.2(1) + 0.1(3) = -1.38$ | ** 1.92** |
59+ | Step | Measured | $e[ n] $ | $e[ n-1] $ | $e[ n-2] $ | $\Delta u$ | $u[ n] $ (clamped) |
60+ | ------| ----------| --------| ----------| ---------- | -------------------------------------- | - -------------------|
61+ | 0 | 0.0 | 5.0 | 0 | 0 | $2.6 \times 5 = 13$ | ** 10.0** (clamped) |
62+ | 1 | 2.0 | 3.0 | 5.0 | 0 | $2.6(3) - 2.2(5) + 0.1(0) = -3.2$ | ** 6.8** |
63+ | 2 | 4.0 | 1.0 | 3.0 | 5.0 | $2.6(1) - 2.2(3) + 0.1(5) = -3.5$ | ** 3.3** |
64+ | 3 | 4.8 | 0.2 | 1.0 | 3.0 | $2.6(0.2) - 2.2(1) + 0.1(3) = -1.38$ | ** 1.92** |
6565
6666The output converges toward the steady-state value needed to maintain the setpoint.
6767
@@ -75,14 +75,14 @@ The output converges toward the steady-state value needed to maintain the setpoi
7575
7676## Variants & Generalizations
7777
78- | Variant | Key Difference |
79- | ---------| ---------------|
80- | ** Standard (positional) PID** | Computes $u[ n] $ from scratch each step using an explicit integral accumulator |
81- | ** PI controller** | $K_d = 0$; simpler, no derivative noise issues |
82- | ** PD controller** | $K_i = 0$; no steady-state error correction, used when offset is acceptable |
83- | ** PID with derivative filter** | Low-passes the derivative term to reject high-frequency noise |
84- | ** Gain-scheduled PID** | Tuning parameters vary as a function of operating point |
85- | ** Cascade PID** | Inner and outer loops, each with its own PID — common in motor control |
78+ | Variant | Key Difference |
79+ | -------------------------------- | ---------------------------------------------------------------- ---------------|
80+ | ** Standard (positional) PID** | Computes $u[ n] $ from scratch each step using an explicit integral accumulator |
81+ | ** PI controller** | $K_d = 0$; simpler, no derivative noise issues |
82+ | ** PD controller** | $K_i = 0$; no steady-state error correction, used when offset is acceptable |
83+ | ** PID with derivative filter** | Low-passes the derivative term to reject high-frequency noise |
84+ | ** Gain-scheduled PID** | Tuning parameters vary as a function of operating point |
85+ | ** Cascade PID** | Inner and outer loops, each with its own PID — common in motor control |
8686
8787## Applications
8888
@@ -104,10 +104,10 @@ graph LR
104104 KF -->|"filtered measurement"| PID
105105```
106106
107- | Algorithm | Relationship |
108- | -----------| -------------|
109- | [ LQR Controller] ( Lqr.md ) | Optimal alternative when a state-space model is available; PID is model-free. |
110- | [ Kalman Filter] ( ../filters/active/KalmanFilter.md ) | Can provide filtered state estimates as input to either PID or LQR |
107+ | Algorithm | Relationship |
108+ | ---------------------------------------------------- | ------------------------------------------------------------------ -------------|
109+ | [ LQR Controller] ( Lqr.md ) | Optimal alternative when a state-space model is available; PID is model-free. |
110+ | [ Kalman Filter] ( ../filters/active/KalmanFilter.md ) | Can provide filtered state estimates as input to either PID or LQR |
111111
112112## References & Further Reading
113113
0 commit comments