MAE171A Summer 2024 Homework #6
This homework is due 5pm, Monday, August 5, 2024. Homework document should be
uploaded to Bruin Learn in PDF format. Late submission will not be accepted.
When you submit your assignment, make sure that the correct document is uploaded
properly. You will not receive any points if the file is missing or inaccessible.
You can collaborate with other class members but you must hand in your own analysis,
computer programs and plots.
1. 4.34 (Modified) Consider the following feedback system
𝑤(𝑡)
𝑟(𝑡) 𝐷𝑐 𝑠 𝐺𝑠
𝑦(𝑡)
10s + 5
where G(s) = .
(s + 8)(s − 1)
(a) (1pt) Design a proportional gain controller Dc(s) = Kp ∈ Z (integer) to stabilize the
system. Select the smallest integer value of Kp and verify the closed–loop stability.
What is the steady–state output yss to a unit–step reference input r(t) = µ(t)?
1
2
(b) (1pt) Design a stabilizing gain controller Dc(s) = Kp ∈ Z (integer) so that the steady–
state step–response error |ess| ≤ 0.01. Select the smallest integer value of Kp and verify
the closed–loop stability. What is the steady–state output yss to a unit–step reference
input r(t) = µ(t)?
3
4
% Given system
num = [10 5];
den = conv([1 8], [1 -1]);
% Proportional controller
Kp = 159;
sys_open = Kp * tf(num, den);
sys_closed = feedback(sys_open, 1);
% Step response
figure;
step(sys_closed)
title('Step Response of Proportional Controller K_p = 159')
grid on
5
% Steady-state value
[y_ss, t] = step(sys_closed);
steady_state_value = y_ss(end)
steady_state_error = 1 - steady_state_value
% Display results
fprintf('Smallest integer Kp: %d\n', Kp);
fprintf('Steady-state output y_ss: %.4f\n', steady_state_value);
fprintf('Steady-state error e_ss: %.4f\n', steady_state_error);
6
(c) (2pt) Design a PD controller Dc(s) = Kp + KDs where Kp ̸= 0, KD 0 ∈ R (real) by
cancelling out a “stable” pole of the plant. What is the closed–loop transfer function
from r to y? Select Kp and KD so that the steady–state error to a unit step reference
− Verify the closed–loop stability. Determine the system type and the
input is 0.2.
corresponding error constant with respect to the reference input.
7
8
9
% Given system
num = [10 5];
den = conv([1 8], [1 -1]);
% PD controller
Kp = 9.6;
Kd = 1 / 8;
sys_open = tf([Kd Kp], 1) * tf(num, den);
sys_closed = feedback(sys_open, 1);
% Step response
figure;
step(sys_closed)
title('Step Response of PD Controller')
grid on
% Steady-state value
[y_ss, t] = step(sys_closed);
steady_state_value = y_ss(end);
steady_state_error = 1 - steady_state_value;
% Display results
fprintf('Selected Kp: %.2f\n', Kp);
fprintf('Selected Kd: %.2f\n', Kd);
fprintf('Steady-state output y_ss: %.4f\n', steady_state_value);
fprintf('Steady-state error e_ss: %.4f\n', steady_state_error);
% System type
system_type = 'Type 0';
% Error constants
Kp_error_constant = -5 * Kp / 8; % For position error
10
Kv_error_constant = 0; % For velocity error
Ka_error_constant = 0; % For acceleration error
fprintf('System Type: %s\n', system_type);
fprintf('Position Error Constant (Kp): %.2f\n', Kp_error_constant);
fprintf('Velocity Error Constant (Kv): %.2f\n', Kv_error_constant);
fprintf('Acceleration Error Constant (Ka): %.2f\n', Ka_error_constant);
11
KI
(d) (2pt) Design a PI controller Dc(s) = Kp + with Kp = 1 by cancelling out a “stable”
s
pole of the plant. What is the closed–loop transfer function from r to y? What is
the steady–state error to a unit–step reference input? Verify the closed–loop stability.
Determine the system type and the corresponding error constant with respect to the
reference input.
12
13
14
% Given system
num = [10 5];
den = conv([1 8], [1 -1]);
% PI controller
Kp = 1;
Ki = 8;
sys_open = tf([Kp Ki], [1 0]) * tf(num, den);
sys_closed = feedback(sys_open, 1);
% Step response
figure;
step(sys_closed)
title('Step Response of PI Controller')
grid on
% Steady-state value
[y_ss, t] = step(sys_closed);
steady_state_value = y_ss(end);
steady_state_error = 1 - steady_state_value;
% Display results
fprintf('Selected Kp: %.2f\n', Kp);
fprintf('Selected Ki: %.2f\n', Ki);
fprintf('Steady-state output y_ss: %.4f\n', steady_state_value);
fprintf('Steady-state error e_ss: %.4f\n', steady_state_error);
% System type
system_type = 'Type 1';
% Error constants
Kp_error_constant = Inf; % For position error
Kv_error_constant = Ki; % For velocity error
Ka_error_constant = 0; % For acceleration error
fprintf('System Type: %s\n', system_type);
fprintf('Position Error Constant (Kp): %.2f\n', Kp_error_constant);
fprintf('Velocity Error Constant (Kv): %.2f\n', Kv_error_constant);
fprintf('Acceleration Error Constant (Ka): %.2f\n', Ka_error_constant);
15
16
2. 4.35 (Modified) Consider the following feedback system
𝑤(𝑡)
𝑟(𝑡) 𝐷𝑐 𝑠 𝐺𝑠
𝑦(𝑡)
1
where G(s) = .
(s + 1)2
(a) (1pt) Design a proportional gain controller so that the closed–loop system has damping
of ζ = 0.707. Specify the range of Kp for the closed–loop stability.
17
18
3. % Given system
4. num = 1;
5. den = conv([1 1], [1 1]);
6.
7. % Proportional controller
8. Kp = 1;
9. sys_open = Kp * tf(num, den);
10. sys_closed = feedback(sys_open, 1);
11.
12. % Step response
13. figure;
14. step(sys_closed)
15. title('Step Response of Proportional Controller
K_p = 1')
16. grid on
17.
18. % Display results
19. damping_ratio = 0.707;
20. fprintf('Proportional Gain K_p: %.2f\n', Kp);
21. fprintf('Damping Ratio: %.3f\n',
damping_ratio);
19
22.
23.
(a) (1pt) Design a PI controller (by cancelling out one of the “stable” poles of the plant) so
the closed-loop system has damping of ζ = 1 (no overshoot). Under what conditions
on (Kp, KI) is the closed-loop system stable?
20
21
22
24. % Given system
25. num = 1;
26. den = conv([1 1], [1 1]);
27.
28. % PI controller
29. Kp = 1;
30. Ki = 1;
31. sys_open = tf([Kp Ki], [1 0]) * tf(num, den);
32. sys_closed = feedback(sys_open, 1);
33.
34. % Step response
35. figure;
36. step(sys_closed)
37. title('Step Response of PI Controller K_p = 1, K_I =
1')
38. grid on
39.
40. % Display results
41. damping_ratio = 1;
42. fprintf('Proportional Gain K_p: %.2f\n', Kp);
43. fprintf('Integral Gain K_I: %.2f\n', Ki);
44. fprintf('Damping Ratio: %.3f\n', damping_ratio);
23
45.4.44 (Modified) Consider the following feedback system
𝑤(𝑡)
𝑟(𝑡) 𝐷𝑐 𝑠 𝐺𝑠
𝑦(𝑡)
24
1 1
where e(t) = r(t) − y(t) and G(s) = · .
10 s2
KI
(a) (1pt) With Dc(s) = Kp + +K s, determine the system type and the corresponding
D
s
error constant with respect to the reference input r(t).
25
26
27
% Given system
num = 1;
den = [10 0 0];
% PD controller
Kp = 1;
Ki = 10;
Kd = 1;
sys_open = tf([Kd Kp Ki], [1 0]) * tf(num, den);
sys_closed = feedback(sys_open, 1);
% Step response
figure;
step(sys_closed)
title('Step Response of PID Controller with K_p, K_I, K_D')
grid on
% Display results
system_type = 'Type 2';
Kp_error_constant = 0; % For position error
Kv_error_constant = 0; % For velocity error
Ka_error_constant = Ki / 10; % For acceleration error
fprintf('System Type: %s\n', system_type);
fprintf('Position Error Constant (Kp): %.2f\n', Kp_error_constant);
28
fprintf('Velocity Error Constant (Kv): %.2f\n', Kv_error_constant);
fprintf('Acceleration Error Constant (Ka): %.2f\n', Ka_error_constant);
KI
(b) (1pt) With Dc(s) = Kp + +K s, determine the system type and the corresponding
D
s
error constant with respect to the disturbance input, w(t).
29
% Given system
num = 1;
den = [10 0 0];
% PD controller
Kp = 1;
Ki = 10;
Kd = 1;
sys_open = tf([Kd Kp Ki], [1 0]) * tf(num, den);
sys_closed = feedback(sys_open, 1);
30
% Disturbance rejection
sys_dist = feedback(tf(num, den), sys_open);
% Step response to disturbance
figure;
step(sys_dist)
title('Step Response to Disturbance with PID Controller')
grid on
% Display results
system_type = 'Type 2';
Kp_error_constant = Inf; % For position error
Kv_error_constant = Inf; % For velocity error
Ka_error_constant = 10 / Ki; % For acceleration error
fprintf('System Type: %s\n', system_type);
fprintf('Position Error Constant (Kp): %.2f\n', Kp_error_constant);
fprintf('Velocity Error Constant (Kv): %.2f\n', Kv_error_constant);
fprintf('Acceleration Error Constant (Ka): %.2f\n', Ka_error_constant);
31
32