University coursework · 2019 · classical control

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
Two step responses to a 5 volt reference: the plant alone rings up to 8.6 volts and takes about 80 milliseconds to settle; with the op-amp lead-lag controller the output rises smoothly with no overshoot and settles to 4.99 volts in about 65 milliseconds
The course project in one picture: a lightly damped RLC plant (orange) overshoots by 72 %. Closing the loop through the op-amp lead-lag compensator (blue) removes the overshoot and leaves 0.1 % steady-state error. LTspice transient, re-plotted.

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:

G(s) = V(s) / U(s) = K / (τ s + 1) K = v_ss / u_step → 0.476, 0.517, 0.513 (m/s)/V at 0.5, 1.0, 1.5 V τ = t(63 %) → 0.159 – 0.167 s lab model: K = 0.505 (m/s)/V, τ = 0.164 s
Measured cart speed per volt for 0.5, 1 and 1.5 volt steps lying almost on top of each other, with the first-order lab model and a re-fit model with a 51 millisecond delay that tracks the measured curves more closely
Lab 1: three step amplitudes, each divided by its input voltage. The curves collapse onto one shape, so the drive is close to linear over this range. Measured data, re-plotted; the dotted curve is an illustrative re-fit added for this page.

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

type 0 (unity feedback): e_ss = r / (1 + K) = 0.5 / 1.505 ≈ 0.33 m/s type 1 (add an integrator): e_ss = lim s→0 r / (1 + K / (s (τ s + 1))) = 0

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:

T(s) = Kp K / (τ s + 1 + Kp K) pole at −(1 + Kp K) / τ e_ss = 1 / (1 + Kp K) Kp = 2, 4, 8 → 50 %, 33 %, 20 % of the reference PID: C(s) = Kp + Ki / s + Kd s

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:

G(s) = 1 / (L C s² + R C s + 1) ω_n = 1 / √(LC) = 461 rad/s (73 Hz) ζ = (R/2) · √(C/L) = 0.108 poles −50 ± j459 overshoot 71 %, 2 % settling ≈ 4 / (ζ ω_n) = 80 ms

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.

Scatter of the complex open-loop poles of the RLC plant for nominal values and for each of R, L and C halved and doubled; doubling R or halving L moves the poles furthest left
Sensitivity check before any design: each component halved or doubled. Resistance only moves the real part (damping), capacitance mostly moves the imaginary part (frequency), and inductance moves both.

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:

1 + Kp G = 0 → L C s² + R C s + (1 + Kp) = 0 ω_n' = ω_n √(1 + Kp), ζ' = ζ / √(1 + Kp) Kp = 45 → ζ' = 0.016
Unit step of the RLC plant alone, ringing at about 73 hertz, and with a proportional gain of 45, ringing much faster and longer and settling at 0.978
Proportional gain alone on the RLC plant: the loop gets faster but the damping ratio falls from 0.108 to 0.016, and a 2.2 % steady-state error remains. Simulated from the plant model.

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:

K(s) = Kc · [ (1/α)(s + 1/T₂) / (s + 1/(α T₂)) ] · [ β (T₃ s + 1) / (β T₃ s + 1) ] lag: α = (R₁ + R₂)/R₂ ≈ 4,350, T₂ = R₂C₂ → zero 435 rad/s, pole 0.1 rad/s lead: β = R₄/(R₃ + R₄) ≈ 0.086, T₃ = R₃C₃ → zero 706 rad/s, pole 8.2 krad/s

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);
Bode magnitude and phase of the plant, the lead-lag compensator and the loop gain; the loop has about 113 decibels of low-frequency gain, crosses 0 decibels near 15 kilorad per second, and has about 25 degrees of phase margin
Linear design view: the lag stage buys low-frequency gain (steady-state accuracy), the lead stage lifts the phase where the loop crosses 0 dB. Computed from the team's design values.

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.

Block diagram: 5 volt reference, summing junction, lag stage, lead stage, op-amp gain stage, RLC plant, with unity feedback of the capacitor voltage
How the controller was built: every block is an op-amp stage or a passive RC network. Redrawn for this page.

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.

Skills shown

  • System identification
  • Transfer functions
  • Final-value theorem
  • PID tuning
  • Root locus
  • Bode & Nyquist
  • Lead-lag compensation
  • Op-amp circuits
  • LTspice
  • MATLAB
  • Simulink / QUARC