The problem
Classical design tools are still how most engineers reason about loop stability and robustness, and examiners expect students to use them confidently. A motor speed loop is a clear example: a two-time-constant plant, a target bandwidth, and margins that must survive parameter changes. This project designs the loop by hand with root locus and Bode plots and checks the design against a realistic simulation.
Objectives
- Derive the motor and load transfer function from electrical and mechanical equations.
- Design a proportional and a PI controller using root locus to meet damping and settling specifications.
- Design a lead or PI compensator using Bode plots to meet phase margin and bandwidth.
- Check robustness to inertia and resistance changes.
- Verify the design in Simulink with saturation and an inner current loop.
What you need
Tools and toolboxes
- MATLAB — Scripted design and plotting.
- Control System Toolbox — tf, rlocus, bode, margin, step, stepinfo, feedback and the Control System Designer app.
- Simulink — Verification model with saturation, inner current loop and load torque disturbance.
Software
- MATLAB R2023b or later
- Simulink
- Example motor parameters (R, L, Kt, Ke, J, B) from a datasheet
Extra parts and data
None beyond the software above.
Key concepts
- Root locus
- The paths of closed-loop poles as a gain varies from zero to infinity. Placing poles within a region set by damping and settling time gives the desired time response.
- Phase margin
- How much extra phase lag the loop can tolerate at the gain crossover frequency before becoming unstable. Around 45–60 degrees usually gives well-damped responses.
- Gain crossover and bandwidth
- The frequency where open-loop gain equals one. It sets how fast the closed loop responds; a higher crossover gives a faster response but less tolerance of delay and noise.
- Cascade control
- An inner fast current (torque) loop and an outer slower speed loop. The outer loop can treat the inner loop as nearly ideal if it is several times slower.
Step-by-step guide
- 1
Set parameters and specifications
Choose example motor and load values: R = 0.5 Ω, L = 1 mH, Kt = Ke = 0.1 N·m/A, J = 0.01 kg·m², B = 0.001 N·m·s. Specifications for the speed loop: settling time under 0.2 s, overshoot under 10 per cent, zero steady error to a step, phase margin at least 50 degrees and gain margin at least 10 dB.
Checkpoint: A parameter script and a specification table.
- 2
Derive the transfer function
From V = R·i + L·di/dt + Ke·ω and J·dω/dt = Kt·i − B·ω, derive ω(s)/V(s) = Kt / ((L·s + R)(J·s + B) + Kt·Ke). Build it in MATLAB with tf. Compute its poles with pole and identify the electrical and mechanical time constants. Plot the open-loop step response. Check the units of each term and confirm the DC gain against the steady-state motor equation Kt·V/(R·B + Kt·Ke). Note which pole dominates the response.
Checkpoint: Two real poles, one fast (electrical) and one slow (mechanical), and a step response that settles at the DC gain.
- 3
Root locus with proportional control
Plot rlocus of the plant. Overlay lines of constant damping for 10 per cent overshoot and a vertical line for the settling-time requirement using sgrid. Find the gain where the poles meet the damping line. Close the loop with feedback and check step response with stepinfo. Note the steady-state error, which proportional control cannot remove. Record the gain, closed-loop pole locations and step metrics in a table. Explain from the final value theorem why the steady-state error is not zero.
Checkpoint: A closed-loop step with the target overshoot but a visible steady-state error.
- 4
Root locus with PI control
Add a PI controller C(s) = Kp(s + z)/s, placing the zero near the slow mechanical pole to cancel or partly cancel it. Replot the root locus and choose Kp to meet the damping and settling specifications. Use Control System Designer to drag poles interactively if helpful. Check the step response and steady error. Compare the new root locus with the proportional one and explain how the added pole at the origin and the zero change the shape of the branches.
Checkpoint: Zero steady-state error, overshoot under 10 per cent and settling time under 0.2 s in the linear closed loop.
- 5
Bode design
Plot bode and margin of the open loop with the PI controller. Choose a crossover frequency that matches the settling requirement, roughly ωc ≈ 4/(ζ·Ts) as a starting estimate. Adjust Kp to place crossover, check phase margin and, if short, add a lead compensator with the maximum phase boost at crossover. If a lead compensator is needed, compute its alpha from the required phase boost and centre its frequency at the new crossover. Recheck crossover after adding it, since lead also raises gain.
Checkpoint: margin reports phase margin above 50 degrees and gain margin above 10 dB.
- 6
Compare the two designs
Compare root-locus and Bode designs on step response, disturbance rejection (apply a step load torque by modelling a second input) and sensitivity function peak using bode of 1/(1 + L). Discuss why two methods can arrive at similar gains and when one is more convenient than the other. Keep both designs in the same script so all plots use identical plant models. Note which method gave more insight into robustness and which into the time response.
Checkpoint: A table comparing overshoot, settling, phase margin and peak sensitivity for both designs.
- 7
Robustness check
Vary J by ±50 per cent and R by ±30 per cent (winding temperature) using a loop or a ureal parameter if Robust Control Toolbox is available. For each case, compute margins and step metrics. Identify the worst case and confirm the specifications still hold, or state which do not. Plot the step responses for all parameter combinations on one figure so the spread is visible. Note whether the worst case is set by inertia, by resistance or by their combination.
Checkpoint: A table of margins and step metrics across parameter variations, with the worst case identified.
- 8
Verify in Simulink
Build the motor in Simulink with an inner PI current loop (bandwidth around ten times the speed loop), voltage saturation and a load torque step. Use the designed speed controller in a PID Controller block with anti-windup. Use a fixed step of 50 µs. Compare simulated response with the linear prediction for small and large steps. Use the same numerical controller gains as in the MATLAB design, loaded from the parameter script. Log speed, current and voltage and compare them with the limits.
Checkpoint: Small steps match the linear prediction closely; large steps show saturation effects that the linear design did not capture, and these are explained.
- 9
Report
Present the derivation, both design methods with plots, the comparison, robustness results and Simulink verification. Explain the cascade assumption and where it breaks down. State the simplifications: a DC-motor equivalent, no PWM delay and no sensor quantisation. Include a short discussion of which design you would choose for an embedded implementation and why. Add the scripts so every figure can be regenerated by running one file, and list the MATLAB release used.
Checkpoint: A report with root locus, Bode, step and verification plots generated by one script.
Testing & validation
- Open-loop poles match the hand-derived time constants.
- Linear designs meet every specification.
- Robustness table across parameter variation.
- Simulink verification agrees with linear prediction for small signals.
Expected results
A speed-loop design by root locus and Bode methods meeting stated specifications, with a robustness check and Simulink verification including saturation and an inner current loop.
Take it further
- Add PWM and sampling delay and study its effect on phase margin.
- Discretise the controller with c2d and compare methods.
- Design the inner current loop by the same methods.
- Apply the same design to a PMSM in the dq frame.
Viva and review questions
Why place the PI zero near the slow mechanical pole?
It cancels or partly cancels the slow pole, leaving a faster, simpler loop. The integrator still removes steady-state error.
What does phase margin tell you physically?
How much extra delay or phase lag the loop can tolerate before oscillating. Low margin means a lightly damped, oscillatory response.
Why must the current loop be much faster than the speed loop?
So the speed controller can treat the current loop as an almost ideal torque source. If their bandwidths are close they interact and the simple design no longer holds.
Learn it at DIYguru
These DIYguru courses and programmes teach what this project needs.
