Classical Control: System ID, PID and Lead-Lag
Third-year feedback control (MSE 381), done as a team: identify a DC motor drive from its step response, close P, PD and PID loops on the real rig, then design a lead-lag compensator for a lightly damped RLC plant with root locus and Bode plots, realise it with op-amps and E12 parts, and check it in LTspice.
- Course
- MSE 381 Feedback Control
- Year
- 2019
- Tools
- MATLAB, Simulink, QUARC, LTspice
- Methods
- Step-response ID, PID, root locus, Bode, lead-lag
Three pieces of work
- Lab 1, system identification. A DC motor drives a cart along a rack. From recorded step responses we fitted a first-order velocity model and checked how system type sets steady-state error.
- Lab 2, PID on hardware. P, PD and PID velocity loops and PI and PD+I position loops, tuned on the rig and compared with simulation of the identified model.
- Course project, compensator design. A series RLC circuit as the plant: open-loop analysis, P and PID attempts, then a lead-lag compensator designed in MATLAB and built as an op-amp circuit in LTspice.
Lab 1: identifying the motor drive
We applied 0.5, 1.0 and 1.5 V steps to the motor amplifier and logged cart speed through QUARC. For a first-order model the steady-state speed gives the gain and the 63 % point gives the time constant:
The gain at 0.5 V is about 7 % low, which points at Coulomb friction in the rack: a fixed friction force eats a larger share of a small input. We estimated that non-linearity by scaling the 0.5 V response up and subtracting it from the larger ones. With the mass removed from the cart the time constant fell to 0.11 – 0.12 s, as expected for lower inertia.
The second experiment closed the loop to show why system type matters. With unity feedback around the type-0 plant, the final-value theorem gives
Re-plotting the logged data years later, I also fitted a first-order-plus-dead-time model. It matches much better (K = 0.511 (m/s)/V, τ = 0.112 s, 51 ms delay): most of what we had absorbed into a longer time constant is actually transport delay, which matters for how hard the PID loop can be pushed.
Lab 2: P, PD and PID on the rig
With the identified model, a proportional velocity loop has one closed-loop pole and a predictable steady-state error:
On the hardware we swept Kp = 2, 4, 8, then Kd = 0.02 – 0.1 with Kp fixed, then Ki = 2 – 20. Each term did what the theory says, with one twist the model can't show: the real rig overshot even under P control, because the drive is not truly first order (the delay above, plus motor inductance). For position control the plant gains a free integrator, so we compared PI and PD+I loops; the best balance of speed and overshoot was Kd = 0.05 with Ki = 2.
Course project: a plant that rings
The project plant is a series RLC circuit with the capacitor voltage as output. With R = 10 Ω, L = 100 mH and C = 47 µF it is a textbook lightly damped second-order system:
Before designing anything we checked how sensitive those poles are to component tolerance, halving and doubling each part, and plotted step, Bode, Nyquist and root-locus views for every case.
The first attempt, proportional control, shows why this plant needs more than gain. Closing the loop with Kp adds to the stiffness term only, so ωn rises by √(1 + Kp) while ζ falls by the same factor:
A PID controller fixes this by adding damping through the derivative term and removing the offset with the integral. We sized it directly for an op-amp realisation with E12 parts: Kp = 56 kΩ / 120 Ω ≈ 467, Kd = 100 kΩ · 47 µF = 4.7 s and Ki = 1 / (3 × 4.7 kΩ · 47 µF) ≈ 1.5 s⁻¹, built as three parallel op-amp branches summed into the plant.
Lead-lag compensator
The main design was a lead-lag compensator, because both of its halves map onto passive RC networks between op-amp stages:
The lag pair sits well below the plant resonance and gives a DC loop gain of about 4.5 × 10⁵, so steady-state error is negligible. The lead pair straddles the resonance and adds close to 50° of phase where the loop crosses 0 dB. Here is the core of the design script (team code, lightly trimmed): component values in, compensator out, then the loop and closed-loop views we used to iterate.
% lag: passive R1–(R2 + C2) network
R2 = 48.88; C2 = 47e-6; R1 = 212696.432;
alpha = (R1 + R2)/R2; t2 = R2*C2;
lag = (1/alpha)*((s + 1/t2)/(s + 1/(alpha*t2)));
% lead: R3 || C3 in series, R4 to ground
R3 = 30.12; C3 = 47e-6; R4 = 2.835;
t3 = R3*C3; beta = R4/(R3 + R4);
lead = beta*((s*t3 + 1)/(s*beta*t3 + 1));
K = lead*lag*Kp; % compensator
F = G*K/(1 + G*K); % closed loop
margin(K*G); rlocus(K*G); nyquist(K*G); step(F, G);
In the linear model the loop crosses over near 15 krad/s with about 25° of phase margin. The circuit then went into LTspice: a difference amplifier forms the error, the lag and lead networks follow, a non-inverting stage supplies the gain, and the output drives the RLC plant, all on OP07 op-amps with ±10 V rails. In that simulation (the plot at the top of the page) the closed loop reaches 4.994 V for a 5 V step, a 0.11 % error, and settles within 2 % in about 65 ms with no overshoot, against 72 % overshoot for the plant alone. The difference from the linear prediction comes from what the circuit adds: rounded component values and op-amps that saturate at the rails and have finite bandwidth, which is exactly why we simulated the circuit rather than trusting the transfer function alone.
Results
- 0.505 (m/s)/Videntified drive gain, τ = 0.164 s, consistent across three step sizes
- ζ = 0.108RLC plant damping: 71 % overshoot, poles at −50 ± j459
- 72 % → 0 %overshoot, plant alone against the op-amp lead-lag loop in LTspice
- 0.11 %steady-state error of the lead-lag loop, 2 % settling in about 65 ms
How this page was made
We worked as a team on all three pieces. The original figures were low-resolution MATLAB exports, so the plots here were re-plotted for this site: the Lab 1 curves and the LTspice transient from the recorded data, the pole map, P-only step and Bode plot from the models and design values in our scripts. The equations and write-up are my own summary of the work.