The problem
An EV motor sees large and fast changes in load torque from road grade, wind and vehicle mass, and its parameters drift with temperature. A PI speed loop tuned at one point can degrade elsewhere. Sliding-mode control guarantees robustness to bounded disturbances by design, but its switching nature causes chattering. This project explores that trade-off carefully.
Objectives
- Model the motor and load as a speed dynamic with bounded disturbance and parameter uncertainty.
- Design a first-order sliding-mode controller with a Lyapunov-based switching gain.
- Reduce chattering with a boundary layer and with super-twisting second-order sliding mode.
- Compare with a PI controller under load steps, inertia change and measurement noise.
- Verify in a discrete-time implementation with an inner current loop.
What you need
Tools and toolboxes
- MATLAB — Controller design calculations, parameter sweeps and metric computation.
- Simulink — Motor and load model, sliding-mode controllers in MATLAB Function blocks, the PI baseline and logging.
- Control System Toolbox — Optional: PI baseline tuning. Manual tuning works on a base licence.
Software
- MATLAB R2023b or later
- Simulink
- Example motor and vehicle parameters
Extra parts and data
None beyond the software above.
Key concepts
- Sliding surface
- A chosen function of the error, for speed control often s = e + λ·∫e dt. The controller forces s to zero and keeps it there, after which the error decays as designed regardless of matched disturbances.
- Reaching condition
- s·ds/dt ≤ −η·|s| ensures the state reaches the surface in finite time. It sets the minimum switching gain needed to overcome the disturbance bound.
- Chattering
- High-frequency switching of the control signal around the surface, caused by the sign function, sampling and unmodelled dynamics. It can excite mechanical resonances and add losses.
- Super-twisting algorithm
- A second-order sliding-mode controller that produces a continuous control signal while still driving s and ds/dt to zero in finite time, greatly reducing chattering.
Step-by-step guide
- 1
Model and uncertainty bounds
Model the speed dynamics referred to the motor shaft: J·dω/dt = Kt·iq − B·ω − TL, with an example J = 0.6 kg·m² equivalent (including vehicle mass reflected through the gear), Kt = 0.5 N·m/A and TL from road load and grade. Define bounds: J varies ±30 per cent (passenger and cargo load), TL up to a stated maximum and its rate of change bounded.
Checkpoint: A parameter script with nominal values and written bounds for each uncertainty.
- 2
Design the PI baseline
Treat the current loop as ideal with a small lag. Design a PI speed controller for a bandwidth of about 10 rad/s with 60 degrees phase margin at nominal J. Test it against a load torque step and an inertia change. Record settling time, speed dip and recovery. Tune it fairly: give it the same current limit and test set as the sliding-mode controllers, so differences come from the control law and not from better tuning effort on one side.
Checkpoint: PI meets the targets at nominal parameters, with degraded response at +30 per cent inertia noted.
- 3
Design first-order SMC
Define s = e + λ·∫e dt with e = ω_ref − ω. Derive the equivalent control that keeps ds/dt = 0 for the nominal model, then add a switching term K·sign(s). Choose K from the disturbance and parameter bounds using the reaching condition. Implement in a MATLAB Function block with iq saturation. Show the derivation of the switching gain in the report. Plot s against time to show the reaching phase and the sliding phase separately.
Checkpoint: With continuous-time simulation, s reaches zero in finite time and speed error decays at the rate set by λ under the worst-case load step.
- 4
Observe chattering
Run the first-order SMC at a 100 µs fixed step and with a 1 ms controller sample time. Plot the current command and its spectrum. Quantify chattering as RMS of the high-pass filtered current command. Show how chattering amplitude grows with sample time and K. Explain how the chattering frequency and amplitude relate to the controller sample time and the switching gain. Note that in a real drive this would appear as current ripple and possibly audible noise.
Checkpoint: A plot showing visible high-frequency switching in the current command, with RMS chattering values for each sample time.
- 5
Add a boundary layer
Replace sign(s) with sat(s/φ), a linear region of width φ. Sweep φ and record the trade-off between chattering RMS and steady tracking error under disturbance. Explain why a boundary layer turns the controller into a high-gain linear controller near the surface and loses exact invariance. Choose a boundary layer width that keeps steady error within a stated bound while reducing chattering. Explain the choice with the trade-off plot. Keep this design for the robustness tests.
Checkpoint: A trade-off plot of chattering against tracking error for several φ values.
- 6
Implement super-twisting
Implement u = −k1·|s|^0.5·sign(s) + v, dv/dt = −k2·sign(s), with gains chosen from the bound on the disturbance derivative using conditions from the literature. Implement with a discrete integrator at the controller sample time. Compare chattering and tracking with the boundary-layer controller. Check stability with the chosen gains at the worst-case disturbance. Plot s and ds/dt together to show convergence to zero. Compare chattering RMS and tracking with the boundary-layer controller.
Checkpoint: Super-twisting gives a continuous current command with lower chattering than first-order SMC at similar tracking error.
- 7
Robustness tests
Run PI, boundary-layer SMC and super-twisting on a test set: load torque step, ramp in grade, inertia at −30, 0 and +30 per cent, and speed measurement noise with quantisation from an example encoder. Compute speed dip, recovery time, steady error and chattering RMS. Script the runs with sim() and Simulink.SimulationInput. Plot speed responses for the three inertia values on one figure for each controller to show consistency. Mark the targets on each plot.
Checkpoint: A table showing SMC variants maintaining consistent response across inertia changes where PI degrades.
- 8
Realistic implementation
Add an inner PI current loop with a first-order electrical model and voltage limit, a 10 kHz PWM delay approximated as a lag, and a 1 kHz speed loop. Recheck that the sliding-mode designs remain stable and effective. Note any need to retune gains because of the added delay. Use a fixed-step discrete solver with separate sample times for the current and speed loops. Report the speed and current responses for the main tests.
Checkpoint: All controllers remain stable with the inner loop and delay, with any changes in performance explained.
- 9
Analysis and report
Present the design equations, gain selection, chattering analysis and robustness comparison. Discuss the trade-off between robustness and chattering, the role of sampling and when SMC is worth using over PI in an EV drive. State limitations: a speed-loop study with simplified electrical dynamics and no field weakening. Include a short section on implementation cost in an embedded drive: the extra computation, tuning effort and the need for a disturbance bound.
Checkpoint: A report with the comparison table and plots regenerated by script.
Testing & validation
- Finite-time reaching observed in continuous-time simulation.
- Chattering quantified and reduced by boundary layer and super-twisting.
- Consistent response across ±30 per cent inertia for SMC variants.
- Stability maintained with inner current loop and sampling delay.
Expected results
A sliding-mode speed controller family for an EV motor with quantified robustness gains over PI and a clear chattering analysis, verified in a discrete-time model with an inner current loop.
Research angle for your M.Tech thesis
Research questions: how much robustness to inertia and load changes does sliding-mode control gain over a well-tuned PI in an EV speed loop, and what does it cost in chattering once realistic sampling and an inner current loop are included? Baselines: PI and PI with a disturbance observer. Metrics: speed dip and recovery under load steps, variation in response across inertia, chattering RMS of the current command and steady error with noise. A study that includes realistic discrete-time effects, which many papers omit, and compares fairly with a disturbance-observer baseline could be publishable.
Take it further
- Add a disturbance observer and compare with SMC.
- Apply sliding mode to the dq current loops.
- Use adaptive switching gain to reduce chattering further.
- Validate on a motor test bench if available.
Viva and review questions
Why is sliding-mode control robust to matched disturbances?
Once on the sliding surface the dynamics are set by the surface design, and the switching term is chosen large enough to overcome any disturbance within the bound.
What causes chattering and why is it worse in discrete time?
The sign function switches infinitely fast in theory, but with sampling the control can only change each sample, so the state overshoots the surface and the control oscillates. Longer samples mean larger oscillation.
What is the cost of a boundary layer?
It removes chattering but inside the layer the controller is linear, so exact invariance to disturbances is lost and a small steady error can remain.
Learn it at DIYguru
These DIYguru courses and programmes teach what this project needs.
