LCS Lab 6
LCS Lab 6
Lab #6
Object:
Generate a matlab code to find the transfer function of Mechanical and Electromechanical system.
Theory:In this lab we will use mechanical system , electromechanical system , mechanical
translational system and mechanical rotational system by using following commands
Solve
Syms
Pretty
simplify
Task 1: Find the tf X1/F of given mechanical translational system by using solve command.
Code
syms k b m f x1 s
t=solve('(m*(s^2)*x1)+(b*s*x1)+(k*x1)=f',f,x1)
F=t.f
X1=t.x1
g=X1/F
simplify(g)
pretty(g)
Result
ans =
1
--------------
2
m s + b s + k
Task 2: Find the tf X1/F & X2/F of given mechanical translational system by using solve command.
Code
For X1/F
syms k1 k2 b m1 m2 f x1 x2 s
t=solve('f=(((m2*(s^2))+k2+(b*s)+k1)*x2-
((b*s)+k1)*x1)','x1*((m1*(s^2))+(b*s)+k1)-x2((b*s)+k1)=0',f,x1,x2)
F=t.f;
X1=t.x1;
g=X1/F;
simplify(g)
pretty(g)
For X2/F
syms k1 k2 b m1 m2 f x1 x2 s
t=solve('f=(((m2*(s^2))+k2+(b*s)+k1)*x2-
((b*s)+k1)*x1)','x1*((m1*(s^2))+(b*s)+k1)-x2((b*s)+k1)=0',f,x1,x2)
F=t.f;
X2=t.x2;
g=X2/F;
simplify(g)
pretty(g)
Result
X1/F=
(k1 + b s)
-------------------------------------------------------------------------
/ 2 (k1 + b s) (k1 + b s) \ 2
| (m2 s + b s + k1 + k2) - ---------------------- | (m1 s + b s + k1)
| 2 |
\ m1 s + b s + k1 /
X2/F=
1
--------------------------------------------------
2 (k1 + b s) (k1 + b s)
(m2 s + b s + k1 + k2) - ----------------------
2
m1 s + b s + k1
Task 3: Find the tf X1/F of given mechanical translational system by using solve command.
Code
syms k b m x1 x2 s
t=solve('f=(((m*(s^2))+(b*s))*x1-((b*s)*x2))','((b*s)*x2-
(b*s)*x1+(k*x2))=0',f,x1,x2)
F=t.f;
X1=t.x1;
g=X1/F;
simplify(g)
pretty(g)
Result
ans=
k + b s
------------------------
2
s (b m s + k m s + b k)
Task 4: Find the tf Q2/T and Q3/T of given mechanical rotational system by using solve command.
Code
For Q2/T
syms T j1 j2 j3 b1 b2 k Q1 Q2 Q3 s
t=solve('T=Q1*((j1*(s^2))+(b1*s))-Q2*(b1*s)','Q2*((j2*(s^2))+(b1*s)+k)-
(b1*s*Q1)-(k*Q3)=0','Q3((j3*(s^2))+(b2*s)+k)-(k*Q2)=0',T,Q1,Q2,Q3)
h=t.T;
y=t.Q2;
g=y/h;
simplify(g)
For Q3/T
syms T j1 j2 j3 b1 b2 k Q1 Q2 Q3 s
t=solve('T=Q1*((j1*(s^2))+(b1*s))-Q2*(b1*s)','Q2*((j2*(s^2))+(b1*s)+k)-
(b1*s*Q1)-(k*Q3)=0','Q3((j3*(s^2))+(b2*s)+k)-(k*Q2)=0',T,Q1,Q2,Q3)
h=t.T;
y=t.Q3;
g=y/h;
simplify(g)
pretty(g)
Result
Q2/T =
(b1*(j3*s^2 + b2*s + k))/(b1*k(j3*s^2 + b2*s + k) - b1*k^2 +
b1*j1*s^2(j3*s^2 + b2*s + k) + b1*j2*s^2(j3*s^2 + b2*s + k) +
j1*j2*s^3(j3*s^2 + b2*s + k) - j1*k^2*s + j1*k*s(j3*s^2 + b2*s + k))
Q3/T=
(b1*k)/(b1*k(j3*s^2 + b2*s + k) - b1*k^2 + b1*j1*s^2(j3*s^2 + b2*s +
k) + b1*j2*s^2(j3*s^2 + b2*s + k) + j1*j2*s^3(j3*s^2 + b2*s + k) -
j1*k^2*s + j1*k*s(j3*s^2 + b2*s + k))
Task 5: Find the tf Q/Ea of given DC servo motor by using solve command.
Code
syms T Rm Lm ia Em Ea Q j b Kt Km s
t=solve('Ea=((Rm*ia)+(s*Lm*ia)+Em)','Em=Km*s*Q','T=Kt*ia','T=Q*(((s^2)*j)+(b*
s))',T,Ea,Q,Em)
h=t.Ea;
y=t.Q;
g=y/h;
simplify(g)
pretty(g)
Result
ans =
Kt (b + j s)
-------------------------------------------------------
2 2
(j s + b s) (Rm b + Km Kt + Lm b s + Rm j s + Lm j s )
Lab Assignment
Task 1: Find the tf Y/F of given mechanical translational system by using solve command.
Code
syms f b1 b2 k m y s
t=solve('f=((m*(s^2)*y)+(b2*s*y)+(k*y)+(b1*s*y))',f,y)
F=t.f;
Y=t.y;
g=Y/F;
simplify(g)
pretty(g)
Result
ans =
1/(k + b1*s + b2*s + m*s^2)
1
----------------------
2
k + b1 s + b2 s + m s
Task 2: Find the tf X1/F of given mechanical translational system by using solve command.
Code
syms f b k1 k2 m x1 x2 s
t=solve('f=(x1*((m*(s^2))+(b*s)+k2)-(b*s*x2))','((k1*x2)+(b*s*x2)-
(b*s*x1)=0)',f,x1,x2)
F=t.f;
X1=t.x1;
g=X1/F;
simplify(g)
pretty(g)
Result
ans =
k1 + b s
------------------------------------------
3 2
k1 k2 + b m s + k1 m s + b k1 s + b k2 s
Task 3: Find the tf X1/F, X2/F and X3/F of given mechanical translational system by using solve
command.
Code
syms f x1 x2 x3 s
t=solve('f=((6*s*x2)-(4*s*x3))','(5*(s^2)+(12*s)+3)*x3-(4*s*x2)-
(3*x1)=0','((s^2)+9)*x1-(3*x3)=0',f,x1,x2,x3)
F=t.f;
X1=t.x1;
g=X1/F;
simplify(g)
pretty(g)
Result
X1/F =
6
-----------------------------------
4 3 2
15 s + 28 s + 144 s + 252 s + 54
X2/F=
4 3 2
5 s + 12 s + 48 s + 108 s + 18
-----------------------------------------
4 3 2
2 s (15 s + 28 s + 144 s + 252 s + 54)
X3/F=
2
2 (s + 9)
-----------------------------------
4 3 2
15 s + 28 s + 144 s + 252 s + 54
Task 4: Find the tf Q2/T of given mechanical rotational system by using solve command.
Code
syms T j1 j2 b1 b2 k Q1 Q2
t=solve('T=Q1*((j1*(s^2))+(b1*s)+k)-(k*Q2)','Q2*((j2*(s^2))+(b2*s)+k)-
(k*Q1)',T,Q2,Q1)
a=t.T;
b=t.Q2
g=b/a;
simplify(g)
pretty(g)
Result
ans =
k
-------------------------------------------------------------------------------
4 2 2 2 3 3
j1 j2 s + j1 k s + j2 k s + b1 k s + b2 k s + b1 b2 s + b1 j2 s + b2 j1 s
Code
syms Ef Rf Lf if Eg Ra La Ia Ea z kg s
t=solve('Ef=((Rf*if)+(s*Lf*if))','Eg=((Ra*Ia)+(s*La*Ia)+Ea)','(Eg=kg*if)','(E
a=z*Ia)',Ea,Ef)
a=t.Ea;
b=t.Ef;
g=a/b;
simplify(g)
pretty(g)
Result
ans=
Kg z
-----------------------------
Conclusion:In this lab we simplify the mechanical and electromechanical system and find
there transfer functions. The modal of mechanical system obtain by using three basic elements
i.e. mass or inertia ,spring or elasticity and damper or friction.