Professional Documents
Culture Documents
Bài thí nghiệm 1 ĐIỀU KHIỂN HỆ PHI TUYẾN CON LẮC NGƯỢC QUAY
syms m1 m2 J1 J2 l1 l2 c1 c2;
syms Ra La Kt Ke;
%%
dth1= fulldiff(th1);
d2th1= fulldiff(dth1);
dth2= fulldiff(th2);
d2th2= fulldiff(dth2);
%%
x2 = l1*cos(th1) + l2*sin(th1)*sin(th2);
y2 = l1*sin(th1) - l2*cos(th1)*sin(th2);
z2 = l2*cos(th2);
%%
dx2 = fulldiff(x2,{th1 th2});
dy2 = fulldiff(y2,{ th1 th2});
dz2 = fulldiff(z2,{ th1 th2});
%%
v2_sq = simplify(dx2^2 + dy2^2 + dz2^2);
v2_sq = simplify((l2*dth1)^2*sin(th2)^2+simplify(v2_sq+
(l2*dth1)^2*(cos(th2)^21)));
%% Potential Energy
% Arm
Ep_1 = 0;
% Pendulum
Ep_2 = g*m2*l2*cos(th2);
% Total potential energy
Ep = Ep_1 + Ep_2;
%% Kinetic Energy
% Kinetic energy of the Arm
Ek_1_r = 0.5*J1*(dth1)^2;
Ek_1_t = 0;
Ek_1 = Ek_1_r + Ek_1_t;
% Kinetic energy of the Pendulum
Ek_2_r = 0.5*J2*(dth2)^2;
Ek_2_t = 0.5*m2*v2_sq;
Ek_2 = Ek_2_r + Ek_2_t;
% Total kinetic energy of the system
Ek = Ek_1 + Ek_2;
%% Langrangian operator
L = Ek - Ep;
%% Theta 1 a
% Derive the components that make up the Euler-Lagrange Equation
dL_dtheta1 = simplify(diff(L,th1));
% d/dt(dL/ddtheta1)
dL_ddtheta1_dt = simplify(fulldiff(diff(L,dth1),{th1 th2 dth1 dth2}));
Ftheta1 = simplify(dL_ddtheta1_dt - dL_dtheta1 + c1*dth1 - Tm)
%% Theta 2
% Derive the components that make up the Euler-Lagrange Equation
dL_dtheta2 = simplify(diff(L,th2));
% d/dt(dL/ddtheta1)
dL_ddtheta2_dt = simplify(fulldiff(diff(L,dth2),{th1 th2 dth1 dth2}));
Ftheta2 = simplify(dL_ddtheta2_dt - dL_dtheta2 + c2*dth2)
Ta có kết quả:
Ftheta1 =
c1*dth1 - Tm + d2th1*(J1 + (m2*(2*l2^2*cos(th2)^21 - 4*l2^2*cos(th2)^2
+ 2*l1^2 + 4*l2^2))/2) + (dth2*m2*(8*dth1*l2^2*cos(th2)*sin(th2) +
2*dth2*l1*l2*sin(th2) - 42*dth1*l2^2*cos(th2)^20*sin(th2)))/2 -
d2th2*l1*l2*m2*cos(th2)
Ftheta2 =
J2*d2th2 + c2*dth2 + d2th2*l2^2*m2 - g*l2*m2*sin(th2) -
2*dth1^2*l2^2*m2*cos(th2)*sin(th2) +
(21*dth1^2*l2^2*m2*cos(th2)^20*sin(th2))/2 - d2th1*l1*l2*m2*cos(th2)
Nhận xét:
B = [-c*sin(2*th2)*dth1*dth2-b*dth2^2*sin(th2)-d*dth1+e*vol;
(c*dth1^2*sin(2*th2))/2+h*sin(th2)-c2*dth2]
%% Math model of system
X = inv(A)*B;
X = simplify(X)
Kết quả thu được:
A =
[ c*sin(th2)^2 + a, -b*cos(th2)]
[ -b*cos(th2), f]
B = - b*sin(th2)*dth2^2 - c*dth1*sin(2*th2)*dth2 - d*dth1 +
e*vol(c*sin(2*th2)*dth1^2)/2 - c2*dth2 + h*sin(th2)
X = -(d*dth1*f - e*f*vol + b*c2*dth2*cos(th2) + b*dth2^2*f*sin(th2) -
b*h*cos(th2)*sin(th2) - b*c*dth1^2*cos(th2)^2*sin(th2) +
2*c*dth1*dth2*f*cos(th2)*sin(th2))/(a*f - b^2*cos(th2)^2 +
c*f*sin(th2)^2)
((c*sin(th2)^2 + a)*((c*sin(2*th2)*dth1^2)/2 - c2*dth2 +
h*sin(th2)))/(a*f - b^2*cos(th2)^2 + c*f*sin(th2)^2) -
(b*cos(th2)*(b*sin(th2)*dth2^2 + c*dth1*sin(2*th2)*dth2 + d*dth1 -
e*vol))/(a*f - b^2*cos(th2)^2 + c*f*sin(th2)^2)
0 1.0000 0 0
0 -0.2037 1.2667 -0.0326
0 0 0 1.0000
0 -0.0616 20.1514 -0.5187
Bs =
0
2.2203
0
0.6718