Solution of Homework 5

HW#5
ME 3253 F ’08
For the system given in HW#4
1) Consider 80 < C <100 N*sec/m and 500 < K <1000 N/m ranges for two
parameters C and K. Create an objective function which will maintain the
goodness level of the response for:
a) Minimum overshoot (in x(t ) ), and
b) Fastest settling time (both for x(t ) and θ (t ) )
in response to a step input (say T=1×Unit step function (N/m))
Hint: You can evaluate the objective function over a grid in (C, K) domain
and pick the minimum objective function in the given ranges.
2) For the optimum values of (C, K) from (1), deploy the torque variation as
given in HW#4 and obtain x (t ) and θ (t ) responses.
Solution:
P = Over Shoot
S = Settling Time
Objective − Function = ( 4000 × P 2 + S 2 )
Notice that OF is always positive and it reflects some weighted representation of P and S.
The results of the MATLAB routine for optimization are given below:
Optimum K (K*): 200
Optimum C (C*): 130
The value of Optimum Objective Function: 43.4
Objective Function vs K(N/m) & C(N.Sec/m) & Optimum Point
Objective Function
8000
6000
4000
2000
0
1000
100
800
95
90
600
85
K(N/m)
400
80
C(N.Sec/m)
Teta(rad) => With With (K*) & (C*) ___ ; (K = 300) & (C = 500) ---
-3
2
Teta(rad) vs Time(Sec)
x 10
1.8
1.6
1.4
1.2
1
0.8
0.6
0.4
0.2
0
0
5
10
15
Time(Sec)
20
25
30
-3
X(m) => With (K*) & (C*) ___ ; (K = 300) & (C = 500) ---
2.5
X(m) vs Time(Sec)
x 10
2
1.5
1
0.5
0
0
5
10
15
Time(Sec)
20
25
30
Teta(rad) vs Time(Sec)
0.2
Teta(rad) => With (K*) & (C*)
0.15
0.1
0.05
0
-0.05
-0.1
-0.15
-0.2
0
5
10
15
20
25
30
Time(Sec)
35
40
45
50
X(m) vs Time(Sec)
0.3
X(m) => With (K*) & (C*)
0.2
0.1
0
-0.1
-0.2
-0.3
-0.4
0
5
10
15
20
25
30
Time(Sec)
35
40
45
50
Matlab Program:
% Assignment #5 ................................
% ............................................
% ............................................
clear
clc
close all
% ............................................
K = 300;
K1 = 1000;
L = .07;
R = 1;
M = 50;
J = (3/2)*M*R^2;
C = 500;
Original_K = K;
Original_C = C;
%::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
%Optimization Process::::::::::::::::::::::::::::::::::::::::::::::::::::::
K_Test = 500:10:1000;
C_Test = 80:10:100;
for i = 1:length(K_Test)
for j = 1:length(C_Test)
K = K_Test(i);
C = C_Test(j);
K1 = 1000;
L = .07;
R = 1;
M = 50;
J = (3/2)*M*R^2;
Numerator = [(C*L + C*R) (K*L + K*R)]*100;
Denominator = [(M*J) (2*M*C*L*R + M*C*R^2 + M*C*L^2 + C*J) (M*K1*R^2 +
M*K*L^2 + 2*M*K*L*R + M*K*R^2 + K*J) (C*K1*R^2) (K*K1*R^2)];
P = roots(Denominator);
X = step(Numerator,Denominator,5);
Steady_Value = Numerator(2) / Denominator(5);
Over_Shoot(i,j) = max(X) - Steady_Value;
Settling_Time(i,j) = 4*(1/min(abs(real(P))));
Objective_Function(i,j) = 4000*Over_Shoot(i,j)^2 +
Settling_Time(i,j)^2;
% This is the objective function
end
clc,disp('------------------------------------------------------------------------'),disp(i);
end
%::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
%Finding the optimum value of K and C::::::::::::::::::::::::::::::::::::::
Min_Objective_Function = min(min(Objective_Function));
[Place_K_Opt Place_C_Opt] = find(Objective_Function ==
Min_Objective_Function);
K = K_Test(Place_K_Opt);
C = C_Test(Place_C_Opt);
K_Opt = K;
C_Opt = C;
K1 = 1000;
L = .07;
R = 1;
M = 50;
J = (3/2)*M*R^2;
%::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
%Ploting objective function with respect to K & C::::::::::::::::::::::::::
figure,
mesh(C_Test,K_Test,Objective_Function),xlabel('C(N.Sec/m)'),ylabel('K(N/m)'),
zlabel('Objective Function'),title('Objective Function vs K(N/m) & C(N.Sec/m)
& Optimum Point'),grid,hold
plot3(C_Opt,K_Opt,Objective_Function(Place_K_Opt,Place_C_Opt),'*r','LineWidth
',2,'MarkerSize',20);
% Displaying
% Results::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
disp('-------------------------------------------------------------------')
disp('-------------------------------------------------------------------')
disp('This is the value of optimum K');disp(K_Opt)
disp('-------------------------------------------------------------------')
disp('-------------------------------------------------------------------')
disp('This is the value of optimum C');disp(C_Opt)
disp('-------------------------------------------------------------------')
disp('-------------------------------------------------------------------')
% Plot X(m) for Step Responce :::::::::::::::::::::::::::::::::::::::::::::
K = Original_K;
C = Original_C;
Numerator = [(C*L + C*R) (K*L + K*R)];
Denominator = [(M*J) (2*M*C*L*R + M*C*R^2 + M*C*L^2 + C*J) (M*K1*R^2 +
M*K*L^2 + 2*M*K*L*R + M*K*R^2 + K*J) (C*K1*R^2) (K*K1*R^2)];
Time = 0:0.01:30;
X = step(Numerator,Denominator,Time);
figure,plot(Time,X,'r--','LineWidth',2),hold
K = K_Opt;
C = C_Opt;
Numerator = [(C*L + C*R) (K*L + K*R)];
Denominator = [(M*J) (2*M*C*L*R + M*C*R^2 + M*C*L^2 + C*J) (M*K1*R^2 +
M*K*L^2 + 2*M*K*L*R + M*K*R^2 + K*J) (C*K1*R^2) (K*K1*R^2)];
Time = 0:0.01:30;
X = step(Numerator,Denominator,Time);
plot(Time,X,'LineWidth',2),xlabel('Time(Sec)'),ylabel('X(m) => With (K*) &
(C*) ___ ; (K = 300) & (C = 500) ---'),title('X(m) vs Time(Sec)'),grid
%::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
% Plot Teta(rad) for Step Responce ::::::::::::::::::::::::::::::::::::::::
K = Original_K;
C = Original_C;
Numerator = [M C K];
Denominator = [(M*J) (2*M*C*L*R + M*C*R^2 + M*C*L^2 + C*J) (M*K1*R^2 +
M*K*L^2 + 2*M*K*L*R + M*K*R^2 + K*J) (C*K1*R^2) (K*K1*R^2)];
Time = 0:0.01:30;
Teta = step(Numerator,Denominator,Time);
figure,plot(Time,Teta,'r--','LineWidth',2),hold
K = K_Opt;
C = C_Opt;
Numerator = [M C K];
Denominator = [(M*J) (2*M*C*L*R + M*C*R^2 + M*C*L^2 + C*J) (M*K1*R^2 +
M*K*L^2 + 2*M*K*L*R + M*K*R^2 + K*J) (C*K1*R^2) (K*K1*R^2)];
Time = 0:0.01:30;
Teta = step(Numerator,Denominator,Time);
plot(Time,Teta,'LineWidth',2),xlabel('Time(Sec)'),ylabel('Teta(rad) => With
With (K*) & (C*) ___ ; (K = 300) & (C = 500) ---'),title('Teta(rad) vs
Time(Sec)'),grid
%::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
%::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
A = [0 1 0 0;-K/M -C/M (K*L+K*R)/M (C*L+C*R)/M;0 0 0 1;+K*(L+R)/J C*(L+R)/J
(-K1*R^2-K*(L+R)^2)/J (-C*(L+R)^2)/J]; % This Matrix is used in Simulink
Only
sim('HW5_R13',50)
figure
plot(time, X_OUTPUT,'LineWidth',2),xlabel('Time(Sec)'),ylabel('X(m) => With
(K*) & (C*)'),title('X(m) vs Time(Sec)'),grid
figure
plot(time, T_OUTPUT,'LineWidth',2),xlabel('Time(Sec)'),ylabel('Teta(rad) =>
With (K*) & (C*)'),title('Teta(rad) vs Time(Sec)'),grid
%::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
%::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Simulink Diagram: