Compilation of Matlab Problems and Solutions
Compilation of Matlab Problems and Solutions
SUBMITTED BY
AGUIMBAG, GEM R.
ECE53
SUBMITTED TO
ENGR. JERNY KATIBAYAN
I. LAPLACE TRANSFORM
Derive the transfer function for the multisim DC Machine Permanent Magnet motor model.
Electrical Model
Where:
VRa=IaRa
VLa= Ladiadt , and
Vc= kv ωa
Where:
Kv=speed constant
ωa= torque constant of the motor
Mechanical Model
Using summation of torque in the given mechanical model to obtain the equation of the mechanical
model of the motor
Te-Tω’-Tω-TL=0
Where:
Te = ktia
Tω’ = Jdadt , and
Tω = Bωa
Where:
Kt= torque constant
Te=electromagnetic torque
Tω’=torque due to angular acceleration
Tω = torque due to angular velocity
J=shaft inertia
B= shaft friction
Converting said state equations to s-domain and solving for Ia(s) and as results in
Ias= Vas-kvΩ(s)Las+Ra
as= -TL+ktIa(s)Js+B
Which can be used to derive the block diagram of the DC motor below
Given that TL is stated to be =0 and the transfer function is the ratio of the angular velocity ωa and the
voltage source Va. T(s)=a(s)Va(s)
Cascading the three blocks in series results in
Simplifying further the given block diagram using the property of a feedback loop
T(s) = ktLas+Ra(Js+B)1+ktkvLas+Ra(Js+B)
= ktLas+RaJs+B+ktkv= ktLaJs2+LaB+RaJs+[RaB+ktkv]
Dividing the transfer function by the constant of S2 to simplify further the block diagram results in:
T(s) = kt/LaJs2+LaB+RaJLaJs+RaB+ktkvLaJ
Substituting the values in the transfer function for the ones given in the table below results in
USING MATLAB
clc
%checking
%parameters
la=0.0001;
ra=0.2;
kv=0.003;
kt=kv;
j=0.1e-3;
b=1e-006;
%Each individual Block
A1=tf([0 1],[la ra]);
A2=tf([kt],[1]);
A3=tf([0 1],[j, b]);
A4=tf([kv],[1]);
%Block reduction, since TL=0 the addition of the block and TL is equal to
%the block involved
sys1=series(A1,A2)
sys2=series(sys1,A3)
%feedback loop
sys3=1+sys2*A4
%reduction to single block
sys=minreal(sys2/sys3)
‘’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’OUTPUT
‘’’’’’’’’’’’’’’’’’’’’’’’’OUTPUT
V =
18.1107
17.9153
-22.6384
10.0000
The R-RRT (slider-crank) mechanism has the dimensions: AB = 0.5 m and BC = 1 m. The driver link 1
makes an angle φ = φ1 = 45◦ with the horizontal axis. Find the positions of the joints and the angles of
the links with the horizontal axis.
a.) Slider-crank (R-RRT) mechanism
b.) two solutions for joint C: C1 and C2
clear
clc
close all
% Input data
AB=0.5;
BC=1;
phi = pi/4;
% Position of joint C
yC = 0;
fprintf(’Results \n\n’)
% Print the coordinates of B
fprintf(’xB = %g (m)\n’, xB)
fprintf(’yB = %g (m)\n’, yB)
% Print the coordinates of C
fprintf(’xC = %g (m)\n’, xC)
fprintf(’yC = %g (m)\n’, yC)
% Print the angle phi2
fprintf(’phi2 = %g (degrees) \n’, phi2*180/pi)
‘’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’OUTPUT
xB = 0.353553 (m)
yB = 0.353553 (m)
xC = 1.28897 (m)
yC = 0 (m)
phi2 = -20.7048 (degrees)
The considered four-bar (R-RRR) planar mechanism is displayed. The driver link is the rigid link 1 (the
element AB) and the origin of the reference frame is at A. The following data are given: AB=0.150 m,
BC=0.35 m, CD=0.30 m, CE=0.15 m, xD=0.30 m, and yD=0.30 m. The angle of the driver link 1 with the
horizontal axis is φ = φ1 = 45◦. Find the positions of the joints and the angles of the links with the
horizontal axis.
clear all;
clc;
close all
% Input data
AB=0.15; %(m)
BC=0.35; %(m)
CD=0.30; %(m)
CE=0.15; %(m)
xD=0.30; %(m)
yD=0.30; %(m)
phi = pi/4 ; %(rad)
xA = 0; yA = 0;
rA = [xA yA 0];
rD = [xD yD 0];
% Position of joint C
% Distance formula: BC=constant
eqnC1 = ’(xCsol - xB)ˆ2 + (yCsol - yB)ˆ2 = BCˆ2 ’;
% Distance formula: CD=constant
eqnC2 = ’(xCsol - xD)ˆ2 + (yCsol - yD)ˆ2 = CDˆ2 ’;
% Select the correct position for C for the given input angle
if xC1 < xD
xC = xC1; yC=yC1;
else
xC = xC2; yC=yC2;
end
rC = [xC yC 0]; % Position vector of C
% Position of joint E
% Distance formula: CE=constant
eqnE1=’(xEsol-xC)ˆ2+(yEsol-yC)ˆ2=CEˆ2’;
% Slope formula:
% E, C, and D are on the same straight line
eqnE2=’(yD-yC)/(xD-xC)=(yEsol-yC)/(xEsol-xC)’;
xEpositions = eval(solE.xEsol);
yEpositions = eval(solE.yEsol);
if xE1 < xC
xE = xE1; yE=yE1;
else
xE = xE2; yE=yE2;
end
rE = [xE yE 0]; % Position vector of E
fprintf(’Results \n\n’)
plot([xA,xB],[yA,yB],’k-o’,’LineWidth’,1.5)
hold on % holds the current plot
plot([xB,xC],[yB,yC],’b-o’,’LineWidth’,1.5)
hold on
plot([xD,xE],[yD,yE],’r-o’,’LineWidth’,1.5)
grid on,...
xlabel(’x (m)’), ylabel(’y (m)’),...
title(’positions for \phi = 45 (deg)’),...
text(xA,yA,’\leftarrow A = ground’,...
’HorizontalAlignment’,’left’),...
text(xB,yB,’ B’),...
text(xC,yC,’\leftarrow C = ground’,...
’HorizontalAlignment’,’left’),...
text(xD,yD,’\leftarrow D = ground’,...
’HorizontalAlignment’,’left’),...
text(xE,yE,’ E’), axis([-0.2 0.45 -0.1 0.6])
% end of program
‘’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’OUTPUT
rA = [ 0, 0, 0 ] (m)
rD = [ 0.3, 0.3, 0 ] (m)
rB = [ 0.106066, 0.106066, 0 ] (m)
rC = [ 0.0400698, 0.449788, 0 ] (m)
rE = [ -0.0898952, 0.524681, 0 ] (m)
phi2 = -79.1312 (degrees)
phi3 = -29.9532 (degrees)
For a complete rotation of the driver link AB, 0 ≤ φ ≤ 360◦, a step angle of 60◦ is
selected. To calculate the position analysis for a complete cycle
clear all;
clc;
close all
% Input data
AB=0.15; AC=0.10; CD=0.15; %(m)
xA = 0; yA = 0; rA = [xA yA 0];
xC = 0; yC = AC; rC = [xC yC 0];
fprintf(’Results \n\n’)
fprintf(’rA = [ %g, %g, %g ] (m)\n’, rA)
fprintf(’rC = [ %g, %g, %g ] (m)\n’, rC)
fprintf(’\n’)
% Position of joint D
eqnD1=’(xDsol - xC)ˆ2 + (yDsol - yC)ˆ2 = CDˆ2 ’;
eqnD2=’(yB-yC)/(xB-xC)=(yDsol-yC)/(xDsol-xC)’;
xDpositions = eval(solD.xDsol);
yDpositions = eval(solD.yDsol);
rD = [xD yD 0];
fprintf(’rD = [ %g, %g, %g] (m)\n’, rD)
‘’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’OUTPUT
rA = [ 0, 0, 0 ] (m)
rC = [ 0, 0.1, 0 ] (m)
phi = 0 degrees
rB = [ 0.15, 0, 0 ] (m)
rD = [ -0.124808, 0.183205, 0] (m)
phi2 = phi3 = -33.6901 (degrees)
phi4 = phi5 = -55.7355 (degrees)
phi = 60 degrees
rB = [ 0.075, 0.129904, 0 ] (m)
rD = [ -0.139333, 0.0444455, 0] (m)
phi2 = phi3 = 21.738 (degrees)
phi4 = phi5 = -17.692 (degrees)