Simulate Motor Speed Control

Hard MATLAB Control Asked at Tesla
Solve this problem

Simulate a DC motor under PI speed control and report the rise time, overshoot and steady-state error for a step reference.

Constraints

  • First-order motor model with a time constant and gain.
  • PI controller with configurable Kp and Ki.
  • Include integrator anti-windup by clamping the integral term.
  • Return a struct with rise_time, overshoot_pct and steady_error.
  • Fixed timestep integration.
  • Simulate long enough to reach steady state.
Starter codeMATLAB
1function result = motor_pi(kp, ki, setpoint)2% TODO3end