Control Systems Lab
Aalyan Zahid (2022-EE-23)
Instructor: Dr. Habib Wajid
Lab # 3
Objective:
The objective of this lab is to get familiarized with the basics of system
analysis for control purposes.
Reference Material:
1- Modern Control Engineering (5th Edition) by Katsuhiko Ogata
2- Feedback Control of Dynamic Systems (8th Edition/Global Edition) by
Gene F. Franklin, J. David Powell and Abbas Emami-Naeini
Task:1 Questions / Answers
a) Transient and Steady-State Responses
Transient response: Temporary behavior after a disturbance or
input change; it dies out over time.
Steady-state response: The long-term behavior after transient’s
decay.
Relation to differential equations: The homogeneous solution
gives the transient response (natural modes from characteristic
equation), and the particular solution gives the steady-state
(forced) response.
Governing factors: System poles (location), damping, natural
frequency, input type.
b) Steady-State Output for Sinusoidal Input
For an LTI system, if the input is sinusoidal (e.g., Asin(ωt)), the
steady-state output is also sinusoidal:
Bsin(ωt+ϕ)
where BB is the gain and ϕ is the phase shift, determined by the system’s
frequency response at ω.
c) Frequency Response and Bode/Nyquist
Frequency response: Replace ss with jωj\omega in the transfer
function H(s)H(s), i.e., H(jω)H(j ω).
Bode Plot: Plots of magnitude (in dB) and phase (in degrees) vs.
log10(ω).
Nyquist Diagram: Polar plot of H(jω) showing real vs. imaginary
parts.
Difference: Bode is logarithmic and shows magnitude/phase
separately; Nyquist is complex plane plot.
Similarity: Both represent the same frequency response data.
d) BIBO Stability
A system is BIBO stable if every bounded input results in a
bounded output.
For LTI systems, this means all poles of the transfer function must
lie in the left half of the s-plane (Re(s) < 0).
e) Stability from Transfer Function
Find the poles (roots of the denominator).
Stable: All poles have negative real parts.
Marginally stable: Poles on the imaginary axis but none repeated.
Unstable: Any pole with positive real part or repeated on imaginary
axis.
f) Poles and State Space
In state-space form x˙ = Ax + Bu, poles = eigenvalues of matrix
A.
These eigenvalues determine the system dynamics and match the
poles of the transfer function.
g) Stability of H(s)=1s2+2s+5
Transfer Function Approach:
o Characteristic equation: s2+2s+5=0s^2 + 2s + 5 = 0
o Roots: s=−1±2js → complex conjugate with negative real parts
→ Stable
State Space Approach:
MATLAB Verification:
H = tf(1, [1 2 5]);
isstable(H) % Returns true if stable
A = [0 1; -5 -2];
eig(A) % Should return [-1+2j, -1-2j]
h) Order of a Dynamic System
The order is the highest power of s in the denominator of the
transfer function or the number of state variables in state-space.
It determines the system’s memory and complexity.
Task:2
1. MATLAB code:
2. sys = tf([5],[10 1])
3.
4. subplot(2,1,1)
5. step(sys)
6.
7. subplot(2,1,2)
8. bode(sys)
9. %%
10. G = tf([5],[10 1])
11. linearSystemAnalyzer('step',G)
12.
13. linearSystemAnalyzer('bode',G)
1. Results:
Task:3
1. MATLAB code:
2. zeta = 0:0.2:1.2;
3. for zeta = [0,0.2,1,1.2]
4. G = tf([100],[1 20*zeta 100])
5. bode(G)
6. legend('undamped: zeta=0','under-damped: zeta<1','critically-damped:
zeta=1','over-damped: zeta>1')
7. hold on
8. end
2. Results:
Task:4
1. MATLAB code:
2.
3. G = tf([1],[1000 50]);
4. step(500*G);
5.
6. % 1st Order
7. % Overshoot = 0
8. % No Oscillations
9. % Rise Time ~50 to 60
10. %%
11.
12. pzplot(G);
13. grid;
14. %Stable System
15. %%
16. for m=[1000,100,10]
17. for b=[50,100,10]
18. G = tf(1,[m b]);
19. step(500*G);
20. legend('m=1000, b=50','m=1000, b=100', 'm=1000, b=10', 'm=100,
b=50','m=100, b=100', 'm=100, b=10', 'm=10, b=50', 'm=10, b=100', 'm=10,
b=10');
21. hold on
22. end
23. end
24.
25. %%
26. [H,W] = freqz([1],[1000 50]);
27. plot(W,20*log10(abs(H))); %20*log10(abs(H)) converts Calculated
frequencies into decibles
28. set(gca,'xlim',[0 pi]);
29. grid on;
30. xlabel('Radians/sample');
31. title('Frequency Response')
32.
3. Results:
Task:5
1. MATLAB code:
2. J = 0.01;
3. b = 0.1;
4. K = 0.01;
5. R = 1;
6. L = 0.5;
7. s = tf('s');
8. P_motor = K/(s*((J*s+b)*(L*s+R)+K^2));
9. figure;
10. step(P_motor);
11. grid on;
12. title('Open-Loop Step Response of DC Motor');
13. %%
14. Kp = 100;
15. C = pid(Kp);
16. sys_cl = feedback(C*P_motor,1);
17.
18. t = 0:0.01:5;
19. step(sys_cl,t)
20. grid
21. title('Step Response with Proportional Control')
22.
23. %%
24. Kp = 75;
25. Ki = 1;
26. Kd = 1;
27. C = pid(Kp,Ki,Kd);
28. sys_cl = feedback(C*P_motor,1);
29. step(sys_cl,[0:1:200])
30. title('PID Control with Small Ki and Small Kd')
31.
32. %%
33. Kp = 100;
34. Ki = 200;
35. Kd = 1;
36. C = pid(Kp,Ki,Kd);
37. sys_cl = feedback(C*P_motor,1);
38. step(sys_cl, 0:0.01:4)
39. grid
40. title('PID Control with Large Ki and Small Kd')
41.
42. %%
43.
44. Kp = 100;
45. Ki = 200;
46. Kd = 10;
47. C = pid(Kp,Ki,Kd);
48. sys_cl = feedback(C*P_motor,1);
49. step(sys_cl, 0:0.01:4)
50. grid
51. title('PID Control with Large Ki and Large Kd')
52.
4. Results:
Task:6
1. MATLAB code:
2. % Transfer function by putting values
3. G = tf([0.0274],[(8.8781*(10^(-12))) (1.29*(10^(-5))) (7.6479*(10^(-4)))
0]);
4.
5. step(G)
6.
7. %%
8. G = tf([0.0274],[(8.8781*(10^(-12))) (1.29*(10^(-5))) (7.6479*(10^(-4)))
0]);
9. t = 0:0.001:0.2;
10.
11. step(G,t)
12.
13. % System is not BIBO Stable
14.
15. isstable(G)% as ans = 0
16.
17. pole(G)
18.
19. %%
20.
21. sys_cl = feedback(G,1)
22.
23. step(sys_cl,t)
24.
25. %%
26. pzmap(sys_cl);
27. grid;
28.
5. Results:
Task:7
MATLAB code:
1. M1 = 2500;
2. M2 = 320;
3. K1 = 80000;
4. K2 = 500000;
5. b1 = 350;
6. b2 = 15020;
7.
8. s = tf('s');
9.
10.
Task:8
MATLAB code:
1. M = 0.5;
2. m = 0.2;
3. b = 0.1;
4. I = 0.006;
5. g = 9.8;
6. l = 0.3;
7. q = (M+m)*(I+m*l^2)-(m*l)^2;
8. s = tf('s');
9. P_pend = (m*l*s/q)/(s^3 + (b*(I + m*l^2))*s^2/q - ((M + m)*m*g*l)*s/q -
b*m*g*l/q)
10.
11. [zeros,poles] = zpkdata(P_pend,'v')
12.
13. [x,t] = stepseq(0,0,5);
14.
15. lsim(P_pend,x,t);
16.
17. [y,t] = step(P_pend);
18. s = lsiminfo(y,t,0)
19.
20.
21.
1. Results:
Task:9
1. MATLAB code:
2.
3. s = tf('s');
4. P_pitch = (1.151*s+0.1774)/(s^3+0.739*s^2+0.921*s)
5.
6. t = 0:0.01:10;
7. step(0.2*P_pitch,t);
8. %axis([0 10 0 0.8]);
9. ylabel('pitch angle (rad)');
10. title('Open-loop Step Response');
11.
12. [zeros,poles] = zpkdata(P_pitch,'v')
13. %%
14. pzmap(P_pitch)
15.
16. %%
17. s = tf('s');
18. M1 = (1.151*s+0.1774)/(s^3+0.739*s^2+0.921*s);
19.
20. M2 = 1;
21.
22. M = feedback(M1,M2)
23.
24. isstable(M)
25.
26. step(0.2*M);
27. ylabel('pitch angle (rad)');
28. title('Closed-loop Step Response');
29. legend('P_pitch');
2. Results:
Task:10
MATLAB code:
22. m = 0.111;
23. R = 0.015;
24. g = -9.8;
25. L = 1.0;
26. d = 0.03;
27. J = 9.99e-6;
28.
29. s = tf('s');
30. P = (m*g*d)/(L*((J/(R^2))+m)*s^2)
31.
32. %step(P)
33.
34. t = 0:0.01:10;
35. step(P,t);
36.
37. [zeros,poles] = zpkdata(P,'v')
38.
3. Results: