%% L7_1-cruise.m - cruise control example for Lecture 7.1 %% RMM, 8 Nov 02 %% %% This lecture uses two main examples: the cart pendulum system and the %% cruise control system. For each of these, we generate the various plots %% used in the lecture. %% %% Cruise controller %% %% This is the cruise controller that we studied in HW #2, 3, 4. It uses %% a modified PD control law. The main modification is replacing the %% integrator with a high gain, low pass filter to make the plots show %% the features more clearly. %% % Parameter definitions m = 1000; % mass of the car, kg b = 50; % damping coefficient, N sec/m a = 0.2; % engine lag coefficient r = 5; % transmission gain Ki = 50; % integral gain Kp = 1000; % proportional gain % Dynamics veh = tf([1/m], [1 b/m]); % vehicle eng = tf([r], [1 a]); % engine ctr = tf([Kp Ki], [1 0.01]); % control: PI w/ LF pole cruise = ctr*eng*veh; % loop transfer function %% Slide 8: Nyquist analysis (with zoom) nyquist(cruise); print -dmeta L7_6a.wmf nyquist(cruise, {1,1e5}); print -dmeta L7_6b.wmf %% Slide 12: robustness analysis lag = tf([10], [1 10]); bode(cruise, cruise*lag); print -dmeta L7_10a.wmf nyquist(cruise, cruise*lag); print -dmeta L7_10b.wmf nyquist(cruise, cruise*lag, {1,1e5}); print -dmeta L7_10c.wmf %% Slide 13: design example lag = tf([10], [1 10]); % sensor lag bode(cruise, 0.25*cruise*lag, 0.25*cruise); print -dmeta L7_13a.wmf nyquist(cruise, 0.25*cruise*lag, 0.25*cruise*lag); print -dmeta L7_13b.wmf nyquist(0.25*cruise*lag, 0.25*cruise*lag, {0.5,1e5}); print -dmeta L7_13c.wmf % Additional calculations cruise1_cl = feedback(cruise, 1); % closed loop dynamics cruise2_cl = feedback(0.25*cruise, 1); % closed loop with lower gain step(cruise1_cl, cruise2_cl); % compare step responses