0% found this document useful (0 votes)
11 views22 pages

Experiment 6

This document outlines a series of control system lab tasks involving various systems such as cruise control, DC motors, suspension control, inverted pendulum, aircraft pitch, and ball and beam. Each task includes the definition of system parameters, transfer functions, and the design and analysis of controllers using MATLAB, focusing on performance metrics like gain and phase margins, step responses, settling times, and overshoot. The document provides detailed results and code snippets for simulating and optimizing the control systems.

Uploaded by

maqibwazir101
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views22 pages

Experiment 6

This document outlines a series of control system lab tasks involving various systems such as cruise control, DC motors, suspension control, inverted pendulum, aircraft pitch, and ball and beam. Each task includes the definition of system parameters, transfer functions, and the design and analysis of controllers using MATLAB, focusing on performance metrics like gain and phase margins, step responses, settling times, and overshoot. The document provides detailed results and code snippets for simulating and optimizing the control systems.

Uploaded by

maqibwazir101
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 22

Control Systems Lab

Aalyan Zahid (2022-EE-23)


Instructor: Dr. Habib Wajid
Lab # 6
Introduction and background:
Gain and phase margin:
Consider the following unity feedback system

where K is the variable constant and G(s) is the plant consideration. The gain margin is
defined as the change in open-loop gain required to make the closed-loop system unstable.
Systems with greater gain margins can withstand greater changes in system parameters
before becoming unstable in closed-loop. The phase margin is defined as the change in
open-loop phase shift required to make the closed-loop system unstable.
We can have MATLAB calculate and display the gain and phase margins using the margin(G)
command. This command returns the gain and phase margins, the gain and phase crossover
frequencies, and a graphical representation of these quantities on the Bode plot.

Bandwidth Frequency:
The bandwidth frequency is defined as the frequency at which the closed-loop magnitude
drops 3 dB below its magnitude at DC (magnitude as the frequency approaches 0).
Task1: Cruise Control
The transfer fuction for the cruise control car is

And the parameters given are


m = 1000;
b = 50;
r = 10;
u = 500;
Results:
Step response for gain K=1:

Open loop bode plot for gain K=1:


Closed Loop step response for gain K=1:

We optimize our response by increasing gain.

Open loop step response for gain K = 500:


Closed loop step response for K = 500:

Open Loop bode plot with Lag compensator:


Closed Loop step response with lag compensator:

Code:
m = 1000;
b = 50;
r = 10;
u = 500;
s = tf('s');
P_cruise = 1 / (m*s + b);
K = 1;
C = K;
T_open = C * P_cruise;
T_closed = feedback(T_open, 1);

figure;
step(T_closed);
title('Step Response (K = 1)');
grid on;
figure;
bode(T_open);
title('Open-loop Bode Plot (K = 1)');
grid on;
Kp = dcgain(T_open);
ess = 1 / (1 + Kp);

fprintf('Steady-State Error (K=1): %.4f\n', ess);


figure;
step(T_closed);
title('Closed-loop Step Response (K = 1)');
grid on;
K_new = 500;
C_new = K_new;
T_new_open = C_new * P_cruise;
T_new_closed = feedback(T_new_open, 1);

figure;
bode(T_new_open);
title('Open-loop Bode Plot (K = 500)');
grid on;

figure;
step(T_new_closed);
title('Closed-loop Step Response (K = 500)');
grid on;

Kp_new = dcgain(T_new_open);
ess_new = 1 / (1 + Kp_new);
fprintf('Steady-State Error (K=500): %.4f\n', ess_new);
z = 0.02;
p = 0.002;
C_lag = tf([1 z], [1 p]);

K_lag = 1000;
C_total = K_lag * C_lag;

T_lag_open = C_total * P_cruise;


T_lag_closed = feedback(T_lag_open, 1);

figure;
bode(T_lag_open);
title('Open-loop Bode Plot with Lag Compensator (K = 1000)');
grid on;

figure;
step(T_lag_closed);
title('Closed-loop Step Response with Lag Compensator (K = 1000)');
grid on;
Kp_lag = dcgain(T_lag_open);
ess_lag = 1 / (1 + Kp_lag);
fprintf('Steady-State Error with Lag Compensator: %.4f\n', ess_lag);

Task2: DC motor speed


The transfer function is given as

The system parameters are


J = 0.01;
b = 0.1;
K = 0.01;
R = 1;
L = 0.5;
Bode Plot of open loop DC motor plant:
Bode Plot of Open loop with P-Controller:

Step response with proportional controller:


Open Loop with lag compensator:

Step response with lag compensator and Gain:


Task3: DC motor position
The transfer function of the DC motor is given by

The design criteria is given as;


 Settling time less than 0.040 seconds
 Overshoot less than 16%
 No steady-state error, even in the presence of a step disturbance input.
System parameters are;
J = 3.2284e-6;
b = 3.5077e-6;
K = 0.0274;
R = 4;
L = 2.75e-6;
The bode plot in the control system designer initially appears to be like the image below.
We now add an integrator and observe our plot changes. A pole is added through edit
compensator of the control system designer.

Now we add a real zero to our plot and observe the changes, zero pulls down the response.
Now we add a lead compensator to our design with delta phase 50 and freq set at 250
through the compensator editor. The plot appears to change as this;

After adding a frequency of 350 for the compensator and a phase margin of 70 trhough hit
and trial, we adjust the gain to 670, and the final compensated plots are observed.
Task4: Suspension control
The dynamics equations from the transfer function are given as

where

The system parameters are give as


m1 = 2500;
m2 = 320;
k1 = 80000;
k2 = 500000;
b1 = 350;
b2 = 15020;
we want to design a feedback controller so that for any disturbance (W), the settling time is
less than 5 seconds and overshoot is less than 5%.
Bode plot of the system:
We can move the magnitude plot up or down, by adjusting the value of gain K. We adjust the
value of K to be 1000000, and our plot is now adjusted as shown in the image below.

Now we design 2 lead controllers and add them to our system. The positive phase needed is
140 degrees (70 degrees from each controller). The frequency should be 5.0 rad/sec. The
required space between the zero and the pole is calculated to be a=0.031091 .The corner
frequency and the maximum phase are T =1.13426 and aT =0.035265 . The plots observed as
shown below.
Now we plot the step response with 0.1-m step as disturbance.

The amplitude of the response is smaller than the percent overshoot. Since we can see that
an amplitude of the output's response less than 0.0001 m or 1% of input magnitude after 4
seconds. Therefore we can say that the settling time is 4 seconds from the above plot. From
the Bode plot above, we see that increasing the gain will increase the crossover frequency
and thus make the response faster. We will increase the gain and see if we can get a better
response.
The source code used for this task is given below.
m1 = 2500;
m2 = 320;
k1 = 80000;
k2 = 500000;
b1 = 350;
b2 = 15020;
s = tf('s');
Delta = (m1*s^2 + b1*s + k1)*(m2*s^2 + b2*s + k2) - (b1*s + k1)*(b1*s + k1);
G1 = ((m1 + m2)*s^2 + b2*s + k2)/Delta;
G2 = (-m1*b2*s^3 - m1*k2*s^2)/Delta;
F = G2/G1;
L_original = F * G1;
figure;
margin(L_original);
title('Original Open-Loop Bode Plot');
grid on;
K_norm = 1e5;
L_scaled = K_norm * L_original;

figure;
margin(L_scaled);
title('Normalized Open-Loop Bode Plot (K = 100,000)');
grid on;
phi_max = 70;
alpha = (1 - sind(phi_max)) / (1 + sind(phi_max));
wc = 5;
T = 1 / (wc * sqrt(alpha));
Lead1 = (T*s + 1) / (alpha*T*s + 1);
Lead2 = Lead1;
Kc = 1e5;
C = Kc * Lead1 * Lead2;
L_new = C * F * G1;
figure;
margin(L_new);
title('Bode Plot with 2-Lead Controller');
grid on;
T_cl = feedback(L_new, 1);
figure;
step(0.1 * T_cl);
title('Step Response with 2-Lead Controller (0.1 m Step Input)');
ylabel('Output X_1 - X_2 [m]');
grid on;
Kc_improved = 2e5;
C_improved = Kc_improved * Lead1 * Lead2;
L_improved = C_improved * F * G1;
T_improved = feedback(L_improved, 1);
figure;
step(0.1 * T_improved);
title('Improved Step Response (K increased)');
ylabel('Output X_1 - X_2 [m]');
grid on;
info = stepinfo(0.1 * T_improved)

Task 5: Inverted Pendulum


The transfer function for the pendulum is given by

Where

The design requirements are


 Settling time of less than 5 seconds
 Pendulum should not move more than 0.05 radians away from the vertical
System parameters given are
M = 0.5;
m = 0.2;
b = 0.1;
I = 0.006;
g = 9.8;
l = 0.3;
The schematic for this problem is given below.

We can re-arrange this schematic


The resulting transfer function is

We now add a controller to this design.

Re-arranging this schematic we can draw the block diagram as

Now the final transfer function is as follows

We generate the final response of the pendulum by running the following script in matlab.
M = 0.5;
m = 0.2;
b = 0.1;
I = 0.006;
g = 9.8;
l = 0.3;
q = (M+m)*(I+m*l^2) - (m*l)^2;
s = tf('s');
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);
K = 10;
C = K*(s+1)^2/s;
T = feedback(P_pend,C);
t = 0:0.01:10;
impulse(T,t), grid
title({'Response of Pendulum Position to an Impulse Disturbance';'under Closed-loop Control'});
K = 35;
C = K*(s+1)*(s+2)/s;
T = feedback(P_pend,C);
t = 0:0.01:10;
impulse(T, t), grid
title({'Response of Pendulum Position to an Impulse Disturbance';'under Closed-loop Control'});
P_cart = (((I+m*l^2)/q)*s^2 - (m*g*l/q))/(s^4 + (b*(I + m*l^2))*s^3/q - ((M + m)*m*g*l)*s^2/q -
b*m*g*l*s/q);
T2 = feedback(1,P_pend*C)*P_cart;
T2 = minreal(T2);
t = 0:0.01:10;
impulse(T2, t), grid
title({'Response of Cart Position to an Impulse Disturbance';'under Closed-loop Control'});

Result:

Task6: Aircraft Pitch


The open loop transfer function if given as

We have the following design requirements.


 Overshoot less than 10%
 Rise time less than 2 seconds
 Settling time less than 10 seconds
 Steady-state error less than 2%
We can determine the open loop step response. We can add a unity feedback and observe the
closed loop step response as well.

We now design a controller. We now set the new gain crossover and T.

Source code for compensator design:


Kp = 1;
tau = 10;
plant = tf(Kp, [tau, 0]);
t = 0:0.01:30;
u = 0.2 * ones(size(t));
figure;
subplot(2,1,1);
step(plant, t);
title('Open-Loop Step Response - Aircraft Pitch');
xlabel('Time (s)');
ylabel('Pitch Angle (radians)');
sys_closed_loop = feedback(plant, 1);
subplot(2,1,2);
step(sys_closed_loop, t);
title('Closed-Loop Step Response - Aircraft Pitch');
xlabel('Time (s)');
ylabel('Pitch Angle (radians)');
G = plant;
sys_open_loop = G;
[GM, PM, Wcg, Wcp] = margin(sys_open_loop);
disp(['Gain Margin: ', num2str(GM)]);
disp(['Phase Margin: ', num2str(PM)]);
zeta = 0.7;
wn = 4 / tau;
lead_compensator = tf([1, 2*zeta*wn], [1, 2*zeta*wn + wn^2]);
sys_with_compensator = feedback(lead_compensator * plant, 1);
figure;
step(sys_with_compensator, t);
title('Closed-Loop Step Response with Lead Compensator - Aircraft Pitch');
xlabel('Time (s)');
ylabel('Pitch Angle (radians)');

Result:

Task7: Ball and Beam


The open loop transfer function is given by

For this experiment, the design criteria is


 Settling time less than 3 seconds
 Overshoot less than 5%
The main idea of frequency based design is to use the Bode plot of the open-loop transfer
function to estimate the closed-loop response. Adding a controller to the system changes the
open-loop Bode plot, therefore changing the closed-loop response.
The design parameters that we use are:
m = 0.111;
R = 0.015;
g = -9.8;
L = 1.0;
d = 0.03;
J = 9.99e-6;
The bode plot as a result for this original transfer function is given in the image below
We want to increase the phase margin, for this purpose we use a controller with the following
transfer function.

The phase-lead compensator will add positive phase to our system over the corner
frequencies. The maximum added phase for one lead compensator is 90 degrees. For our
controller design we need a percent overshoot of less than 5%. We require a phase margin
greater than 70 degrees. We need at least 70 degrees from our controller. We need to
determine the frequency where the phase should be added (center frequency). In our case
this is difficult to determine because the phase vs. frequency graph in the bode plot is a flat
line. However, we have a relation between bandwidth frequency and settling time which tells
us that is approximately 1.92 rad/s. Therefore, we want a center frequency just before this.
For now we will choose 1 rad/sec. We need “a” that can be calculated from

where phi refers to the desired phase margin. For 70 degrees, a = 0.0311.

For 70 degrees and center frequency = 1, aT= 0.176 and T= 5.67.The plot after adding the
compensator can be observed
We can increase our phase-lead compensator to decrease the overshoot.

We can add a gain of 5 to compensate further.

You might also like