Simulate the Time Domain for the Cruise Control Case Study with Pylab

By Mark Wickert

In this cruise control case study, you can use Pylab and the SciPy function lsim() to evaluate the cruise control performance with a 4 percent grade. Note that a grade of 4 percent means rise over run of 4/100, which is equivalent to


Set T = 10 s, vmax = 120 mph and v0 = 75 mph. Units conversion is handled inside cruise_control(). The loop damping factor is


(critically damped, meaning the closed-loop poles are repeated on the negative real axis, and ωn takes on values of 0.5, 0.1, and 0.2 rad/s).

In [241]: t = arange(0,100,.01)
In [242]: b,a = ssd.cruise_control(0.05,1.0,10.,75.,120.,'HED')
In [243]: tv,v,xs = signal.lsim((b,a),0.04*ones(len(t)),t)
In [245]: plot(tv,v)
In [247]: # similarly for wn = 0.1 and 0.2

Velocity error results can be found in the following figure.

[Credit: Illustration by Mark Wickert, PhD]

Credit: Illustration by Mark Wickert, PhD

You see that at hill onset the vehicle velocity error begins to rise, meaning the actual vehicle velocity is falling below the set point value. Over time, the cruise control responds increasing the throttle setting to correct for the hill disturbance, and the velocity error drops to zero. If you increase ωn the control loop response time decreases, thereby lowering the velocity error when the 4 percent grade onset occurs.