Analysis of Linear State Space Modelsanderson/me_313/ME... · ME313 Homework #7 Analysis of Linear...

13
1 ME313 Homework #7 Analysis of Linear State Space Models Last Updated November 6, 2013 Repeat the car-crash problem from HW#6. Use the Matlab function lsim to perform the simulation. Before the simulation, compute the eigenvalues of [ A], and the time constants and frequencies of oscillation. Set the time range for the simulation to be 5 times the longest time constant. Again consider the car-crash problem. Only now, write a Matlab script that will perform a simulation for a sequence of seat-belt stiffnesses k 2 ranging from k 2 =500 lb/ft to k 2 =50 klb/ft. After each simulation, extract the maximum force exerted by the seatbelt on the occupant, and the maximum relative displacement between the occupant and car. Plot both of these quantities versus the seat-belt stiffness k 2 . In your script, use ODE45 to perform each simulation and pass the masses m 1 , m 2 ; stiffnesses k 1 , k 2 ; and damping coefficients c 1 and c 2 in a structure from the script to your state system using anonymous function syntax. Your plots should look like 0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5 x 10 4 0 2 4 6 k2 (klb/ft) Max y (in) 0 5 10 15 20 25 30 35 40 45 50 250 300 350 400 450 k2 (klb/ft) Max f (lb)

Transcript of Analysis of Linear State Space Modelsanderson/me_313/ME... · ME313 Homework #7 Analysis of Linear...

Page 1: Analysis of Linear State Space Modelsanderson/me_313/ME... · ME313 Homework #7 Analysis of Linear State Space Models Last Updated November 6, 2013 Repeat the car-crash problem from

1

ME313 Homework #7

Analysis of Linear State Space Models Last Updated November 6, 2013

Repeat the car-crash problem from HW#6. Use the Matlab function lsim to perform the simulation. Before the simulation, compute the eigenvalues of [A], and the time constants and frequencies of oscillation. Set the time range for the simulation to be 5 times the longest time constant.

Again consider the car-crash problem. Only now, write a Matlab script that will perform a simulation for a sequence of seat-belt stiffnesses k2 ranging from k2=500 lb/ft to k2=50 klb/ft. After each simulation, extract the maximum force exerted by the seatbelt on the occupant, and the maximum relative displacement between the occupant and car. Plot both of these quantities versus the seat-belt stiffness k2. In your script, use ODE45 to perform each simulation and pass the masses m1, m2; stiffnesses k1, k2; and damping coefficients c1 and c2 in a structure from the script to your state system using anonymous function syntax. Your plots should look like

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

x 104

0

2

4

6

k2 (klb/ft)

Max y

(in

)

0 5 10 15 20 25 30 35 40 45 50250

300

350

400

450

k2 (klb/ft)

Max f

(lb

)

Page 2: Analysis of Linear State Space Modelsanderson/me_313/ME... · ME313 Homework #7 Analysis of Linear State Space Models Last Updated November 6, 2013 Repeat the car-crash problem from

2

A small gantry crane is used to move parts. A diagram of the crane is shown at the right. The part of weight 20 lb and mass m is suspended from the gantry by a cable of length l=2 ft. The horizontal displacement of the gantry is x, and the angular rotation of the mass m relative to

vertical is as shown. Using the methodology used in class to model the inverted pendulum, the dynamic model for the angular movement of the mass m is

,cos)(sin mltamglcI To

where Io=ml2 is the moment of inertia of the mass about the pivot point on the gantry,

cT=3 lbs models rotational friction of angular motion, and xta )( is the horizontal

acceleration of the gantry. If the angular motions of the mass m are small, it is relatively

accurate to replace sin and cos1 in the model above and obtain an approximation of the dynamic model as

.)( mltamglcI To

Note that the first model is nonlinear, while the approximate model is linear. In the following, you are to assume that the gantry is equipped with an apparatus that allows an engineer to control the acceleration of the gantry a(t).

o An engineer wishes to move the part to the right. To achieve this motion, the engineer specifies the following acceleration of the gantry, a(t)=5 ft/s2, t<1 sec, a(t)=0 ft/s2, t>1 sec. Simulate the angular movement of the mass using initial

conditions of zero angular displacement and velocity . Plot the angular

displacement and angular velocity over the time range 0t10 sec for this maneuver with the two models cited above. The plot should look like the one shown at the top of the following page.

x

Page 3: Analysis of Linear State Space Modelsanderson/me_313/ME... · ME313 Homework #7 Analysis of Linear State Space Models Last Updated November 6, 2013 Repeat the car-crash problem from

3

o At t=1 sec and t=10 sec, how far has the gantry travelled, and what is the velocity of the gantry?

o From the approximate model, compute the natural frequency n and the

damping ratio . o An engineer wishes to reduce the angular oscillations of the mass m after the

acceleration has been applied, i.e., the time range t>1 sec. Given that sensors

are installed that are capable of measuring the angular displacement and

angular velocity of the mass m, the engineer installs a feedback system that sets the acceleration of the cart a(t) to

,)( dp kkta

after the acceleration has been applied, i.e., when t>1 sec. In the above control law, kp and kd are the overall proportional and derivative gains for the control apparatus between measurement of the angular displacement and velocity, and the acceleration a(t) of the gantry.

0 1 2 3 4 5 6 7 8 9 10-20

-10

0

10 Accel Time=1 sec, Accel Dist=2.5 ft, Vel After Accel=5 ft/sec

Angula

r D

ispla

cem

ent

(deg)

0 1 2 3 4 5 6 7 8 9 10-50

0

50 wn=4.0125 rad/sec, z=0.15047 kp=0 kd=0 Mp=62.6675 ts=1.6563 sec

Time (sec)

Angula

r V

elo

city (

deg/s

ec)

Page 4: Analysis of Linear State Space Modelsanderson/me_313/ME... · ME313 Homework #7 Analysis of Linear State Space Models Last Updated November 6, 2013 Repeat the car-crash problem from

4

Using the approximate linear dynamic model, choose the proportional and derivate gains so that the natural frequency and damping ratio of the

controlled system will be n=10 rad/sec and =0.7 respectively Perform a simulation of the system performance, including a(t)= 5 ft/s2

for 0t1 sec, and ,)( dp kkta for 1t10 sec. Ye response should

look like the plot shown on the following page.

0 1 2 3 4 5 6 7 8 9 10-15

-10

-5

0

5 Accel Time=1 sec, Accel Dist=2.5 ft, Vel After Accel=5 ft/sec

Angula

r D

ispla

cem

ent

(deg)

0 1 2 3 4 5 6 7 8 9 10-50

0

50

100 wn=10 rad/sec, z=0.7 kp=167.8 kd=25.585 Mp=20.7945 ts=0.14286 sec

Time (sec)

Angula

r V

elo

city (

deg/s

ec)

Page 5: Analysis of Linear State Space Modelsanderson/me_313/ME... · ME313 Homework #7 Analysis of Linear State Space Models Last Updated November 6, 2013 Repeat the car-crash problem from

Simulation of Carcrash with lsim

clear all;close all;clc; % % HW 7 Linear Simulation Problem % % ICS % % x1= Vehicle position % x2= Vehicle velocity % x3= Occupant position (inertial) % x4= Occupant velocity (inertial) % xo(1)=0; xo(2)=-(5280/3600)*5; xo(3)=0; xo(4)=-(5280/3600)*5; k1=10e03; c1=500; m1=3000/32.2; k2=5e03; c2=50 ; m2=150/32.2; A=[ 0 1 0 0 ; -(k1+k2)/m1 -(c1+c2)/m1 k2/m1 c2/m1 ; 0 0 0 1 ; k2/m2 c2/m2 -k2/m2 -c2/m2]; B=[ 0 ; 0 ; 0 ; 0 ]; C=[1 0 -1 0]; D=0; [E,L]=eig(A) wn1=abs(L(1,1));z1=-real(L(1,1))/wn1;wd1=wn1*sqrt(1-z1^2);Td1=(2*pi)/wd1; tau1=1/(z1*wn1); wn2=abs(L(3,3));z2=-real(L(3,3))/wn2;wd2=wn2*sqrt(1-z2^2);Td2=(2*pi)/wd2; tau2=1/(z2*wn2); % % Set up time range % tend=5*max([tau1 tau2]); N=500; t=linspace(0,tend,N); dt=t(2)-t(1); % % Perform simulation % u=zeros(1,length(t)); sys=ss(A,B,C,D); [y,t,x]=lsim(sys,u,t,xo); y=x(:,1)-x(:,3); f=(-k2*(x(:,3)-x(:,1))-c2*(x(:,4)-x(:,2))); % subplot(3,1,1); plot(t,x(:,1)*12,t,x(:,3)*12) title('Inertial Coordinates of Car and Occupant') axis([0 tend -1*12 1*12]); legend('x1','x3'); ylabel('Displacement (in)'); % subplot(3,1,2); plot(t,y*12)

Page 6: Analysis of Linear State Space Modelsanderson/me_313/ME... · ME313 Homework #7 Analysis of Linear State Space Models Last Updated November 6, 2013 Repeat the car-crash problem from

title('Relative Displacement Between Car and Occupant') axis([0 tend 1.1*min(y)*12 1.1*max(y)*12 ]); ylabel('Displacement (in)'); % subplot(3,1,3); plot(t,f) title('Force of Seat-Belt on Occupant') axis([0 tend 1.1*min(f) 1.1*max(f)]); ylabel('Force (lb)'); xlabel('Time');

Eigenvalues, frequencies of oscillation, damping ratios, time constants:

L =

-5.7843 +33.1365i 0 0 0

0 -5.7843 -33.1365i 0 0

0 0 -2.5340 + 9.7671i 0

0 0 0 -2.5340 - 9.7671i

>> wn1 wn1 = 33.6376 >> z1 z1 = 0.1720 >> wd1 wd1 = 33.1365 >> Td1 Td1 = 0.1896 >> tau1 tau1 = 0.1729 >> wn2 wn2 = 10.0904 >> z2 z2 = 0.2511 >> wd2

Page 7: Analysis of Linear State Space Modelsanderson/me_313/ME... · ME313 Homework #7 Analysis of Linear State Space Models Last Updated November 6, 2013 Repeat the car-crash problem from

wd2 = 9.7671 >> Td2 Td2 = 0.6433 >> tau2 tau2 = 0.3946 >>

0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8

-10

0

10

Inertial Coordinates of Car and Occupant

Dis

pla

cem

ent

(in)

x1

x3

0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8

0

0.5

1

Relative Displacement Between Car and Occupant

Dis

pla

cem

ent

(in)

0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8

0

200

400

Force of Seat-Belt on Occupant

Forc

e (

lb)

Time

Page 8: Analysis of Linear State Space Modelsanderson/me_313/ME... · ME313 Homework #7 Analysis of Linear State Space Models Last Updated November 6, 2013 Repeat the car-crash problem from

Maximum Force and Displacement versus Seatbelt Stiffness

clear all; close all; % % Compute maximum force exerted by seatbelt on occupant for % a range of seatbelt stiffnesses % N=500; tend=0.5; t=linspace(0,tend,N); dt=t(2)-t(1);

k1=10e03; c1=500; m1=3000/32.2; k2=5e03; c2=50 ; m2=150/32.2; P.k1=k1 ; P.c1=c1 ; P.m1=m1; P.k2=k2 ; P.c2=c2 ; P.m2=m2; Nk2=50; k2t=linspace(500,50e03,Nk2); % % ICS % % x1= Vehicle position % x2= Vehicle velocity % x3= Occupant position (inertial) % x4= Occupant velocity (inertial) % xo(1)=0; xo(2)=-(5280/3600)*5; xo(3)=0; xo(4)=-(5280/3600)*5; for i1=1:Nk2 k2=k2t(i1) ; P.k2=k2; [t,x]=ode45(@(t,x)carcrash1(t,x,P),t,xo); y=x(:,1)-x(:,3); ymax(i1)=max(abs(y)); f=(-k2*(x(:,3)-x(:,1))-c2*(x(:,4)-x(:,2))); fmax(i1)=max(abs(f)); end % subplot(2,1,1); plot(k2t,ymax*12) title('Maximum Occupant Displacement Versus Seatbelt Stiffness') ylabel('Displacement (in)'); % subplot(2,1,2); plot(k2t/1000,fmax) ylabel('Force (lb)'); xlabel('Seatbelt Stiffness (klb/ft)')

Page 9: Analysis of Linear State Space Modelsanderson/me_313/ME... · ME313 Homework #7 Analysis of Linear State Space Models Last Updated November 6, 2013 Repeat the car-crash problem from

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

x 104

0

2

4

6Maximum Occupant Displacement Versus Seatbelt Stiffness

Dis

pla

cem

ent

(in)

0 5 10 15 20 25 30 35 40 45 50250

300

350

400

450

Forc

e (

lb)

Seatbelt Stiffness (klb/ft)

Page 10: Analysis of Linear State Space Modelsanderson/me_313/ME... · ME313 Homework #7 Analysis of Linear State Space Models Last Updated November 6, 2013 Repeat the car-crash problem from
Page 11: Analysis of Linear State Space Modelsanderson/me_313/ME... · ME313 Homework #7 Analysis of Linear State Space Models Last Updated November 6, 2013 Repeat the car-crash problem from

clear all; close all; clc; % % Gantry Control Problem % N=500; tend=10; t=linspace(0,tend,N); dt=t(2)-t(1); % % ICS (first set are for linear problem, second set % are for nonlinear problem % xo(1)=0; xo(2)=0; xo(3)=xo(1); xo(4)=xo(2); % % System Parameters- Uncompensated system % P.m=20/32.2; P.d=2; P.g=32.2; P.cT=3; P.Io=P.m*P.d^2;P.T=1;P.a=5; P.kp=0; P.kd=0; wn=sqrt((P.m*P.g*P.d)/P.Io) ; z=P.cT/(2*sqrt(P.Io*P.m*P.g*P.d)); Mp=100*exp(-pi*z*sqrt(1-z^2)); ts=1/(z*wn); % % Control gains for compensated system % wn=10 ; z=0.7; P.kp=(P.Io*wn^2)/(P.m*P.d)-P.g; P.kd=(P.Io/(P.m*P.d))*(2*z*wn-(P.cT/P.Io)); Mp=100*exp(-pi*z*sqrt(1-z^2)); ts=1/(z*wn); % [t,x]=ode45(@(t,x) gantry(t,x,P),t,xo); % subplot(2,1,1) ; plot(t,x(:,1)*(180/pi),t,x(:,3)*(180/pi)) xg=(1/2)*P.a*P.T^2; vg=P.a*P.T; title([' Accel Time=',num2str(P.T),' sec,', ... ' Accel Dist=',num2str(xg),' ft,', ... ' Vel After Accel=',num2str(vg),' ft/sec']) % axis([0 tend -1*12 1*12]); % legend('x1','x3'); ylabel('Angular Displacement (deg)'); grid on; % xg=(1/2)*P.a*P.T^2; subplot(2,1,2);plot(t,x(:,2)*(180/pi),t,x(:,4)*(180/pi)) title([' wn=',num2str(wn),' rad/sec,', ... ' z=', num2str(z), ... ' kp=', num2str(P.kp), ... ' kd=', num2str(P.kd), ... ' Mp=', num2str(Mp), ... ' ts=',num2str(ts),' sec']) xlabel('Time (sec)'); ylabel('Angular Velocity (deg/sec)'); grid on;

Page 12: Analysis of Linear State Space Modelsanderson/me_313/ME... · ME313 Homework #7 Analysis of Linear State Space Models Last Updated November 6, 2013 Repeat the car-crash problem from

function xdot=gantry(t,x,P) % % x1= Vehicle position % x2= Vehicle velocity % x3= Occupant position (nonlinear) % x4= Occupant velocity (nonlinear) % % Define the parameters m=P.m; d=P.d; g=P.g; cT=P.cT; Io=P.Io;T=P.T;kp=P.kp;kd=P.kd; % % Define the input % if (t < T) a=P.a; u=0; else a=0; u=kp*x(1)+kd*x(2); end % % Define the state equations % xdot(1)=x(2); xdot(2)=(1/Io)*(-m*g*d*sin(x(1))-cT*x(2)-P.m*P.d*(a+u)); xdot(3)=x(4); xdot(4)=(1/Io)*(-m*g*d*x(3)-cT*x(4)-P.m*P.d*(a+u)); xdot = xdot' ;

Page 13: Analysis of Linear State Space Modelsanderson/me_313/ME... · ME313 Homework #7 Analysis of Linear State Space Models Last Updated November 6, 2013 Repeat the car-crash problem from

0 1 2 3 4 5 6 7 8 9 10-20

-10

0

10 Accel Time=1 sec, Accel Dist=2.5 ft, Vel After Accel=5 ft/sec

Angula

r D

ispla

cem

ent

(deg)

0 1 2 3 4 5 6 7 8 9 10-50

0

50 wn=4.0125 rad/sec, z=0.15047 kp=0 kd=0 Mp=62.6675 ts=1.6563 sec

Time (sec)

Angula

r V

elo

city (

deg/s

ec)

0 1 2 3 4 5 6 7 8 9 10-15

-10

-5

0

5 Accel Time=1 sec, Accel Dist=2.5 ft, Vel After Accel=5 ft/sec

Angula

r D

ispla

cem

ent

(deg)

0 1 2 3 4 5 6 7 8 9 10-50

0

50

100 wn=10 rad/sec, z=0.7 kp=167.8 kd=25.585 Mp=20.7945 ts=0.14286 sec

Time (sec)

Angula

r V

elo

city (

deg/s

ec)