COMPILATION OF MATLAB PROBLEMS AND SOLUTIONS
FEEDBACK AND CONTROL SYSTEMS LAB
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.
DC Machine Permanent Magnet Motor
Electrical Equivalent Circuit
Electrical Model
Using KVL on the given circuit results in
Va-VRa-VLa-Vc=0
Where:
VRa=IaRa
VLa= Ladiadt , and
Vc= kv ωa
Where:
Kv=speed constant
ωa= torque constant of the motor
Therefore, the equation given by the KVL is
Ladia dt = Va - iaRa - kv ωa
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
Therefore, equation using the summation of torques is
Jdadt = ktia - Bωa - TL
State Space equation
Using both equations obtained from the electrical and mechanical model of the motor results in the
state space equation
ia=VaLa - RaLaia- kvLaa
a= -TLJ + ktJia- BJa
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
Parameters Numerical Values
Ra Armature Resistance (Ω) 0.2 Ω
La Armature Inductance (H) 0.1 mH
kv Speed Constant (Vs/rad) 0.003 Vs/rad
kt Torque Constant (Nm/A) 0.003 Nm/A
J Shaft Inertia (kg ∙m2) 0.0001 kg ∙m2
B Shaft Friction (Nms/rad) 1e-006 Nms/rad
The simplified transfer function of given system
T(s) = 300 000s2+ 2000s+920
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
II. NODAL ANALYSIS
Find the nodal voltages of the circuit shown below.
MATLAB SOLUTION
diary nodal.dat
% this program computes the nodal voltages
% given the admittance matrix Y and current vector I
% Y is the admittance matrix
% I is the current vector
% initialize the matrix y and vector I using YV=I
Y = [ 0.75 -0.2 0 -0.5;
-5 1 -1 5;
-0.2 0.45 0.166666667 -0.0666666667;
0 0 0 1];
% current vector is entered as a transpose of row vector
I = [5 0 0 10]';
% solve for nodal voltage
fprintf('Nodal voltages V1,V2,V3,V4 are \n')
V = inv(Y)*I
diary
‘’’’’’’’’’’’’’’’’’’’’’’’’OUTPUT
Nodal voltages V1,V2,V3,V4 are
V =
18.1107
17.9153
-22.6384
10.0000
III. Mechanical System: Two Degrees of Freedom
Slider Crank (R-RRT) Mechanism
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 A (origin)
xA = 0; yA = 0;
% Position of joint B - position of the driver link
xB = AB*cos(phi);
yB = AB*sin(phi);
% Position of joint C
yC = 0;
% Distance formula: BC=constant
eqnC = ’( xB - xCsol )ˆ2 + ( yB - yC )ˆ2 = BCˆ2’;
% Solve the above equation
solC = solve(eqnC, ’xCsol’);
% solve symbolic solution of algebraic equations
% Two solutions for xC - vector form
% first component of the vector solC
xC1=eval(solC(1));
% second component of the vector solC
xC2=eval(solC(2));
% eval executes string as an expression or statement
% Select the correct position for C for the given input angle
if xC1 > xB xC = xC1; else xC = xC2; end
% Angle of the link 2 with the horizontal
phi2 = atan((yB-yC)/(xB-xC));
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)
% Graphic of the mechanism
plot([xA,xB],[yA,yB],’r-o’,...
[xB,xC],[yB,yC],’b-o’),...
xlabel(’x (m)’),...
ylabel(’y (m)’),...
title(’positions for \phi = 45 (deg)’),...
text(xA,yA,’ A’),...
text(xB,yB,’ B’),...
text(xC,yC,’ C’),...
axis([-0.2 1.4 -0.2 1.4]),...
grid
% end of program
‘’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’OUTPUT
xB = 0.353553 (m)
yB = 0.353553 (m)
xC = 1.28897 (m)
yC = 0 (m)
phi2 = -20.7048 (degrees)
Positions for ф = 45°
II. Mechanical System: Three Degrees of Freedom
Four Bar (R-RRR) Mechanism
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];
xB = AB*cos(phi); yB = AB*sin(phi); rB = [xB yB 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 ’;
% Simultaneously solve above equations
solC = solve(eqnC1, eqnC2, ’xCsol, yCsol’);
% Two solutions for xC - vector form
xCpositions = eval(solC.xCsol);
% Two solutions for yC - vector form
yCpositions = eval(solC.yCsol);
% Separate the solutions in scalar form
% first component of the vector xCpositions
xC1 = xCpositions(1);
% second component of the vector xCpositions
xC2 = xCpositions(2);
% first component of the vector yCpositions
yC1 = yCpositions(1);
% second component of the vector yCpositions
yC2 = yCpositions(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)’;
solE = solve(eqnE1, eqnE2, ’xEsol, yEsol’);
xEpositions = eval(solE.xEsol);
yEpositions = eval(solE.yEsol);
xE1 = xEpositions(1); xE2 = xEpositions(2);
yE1 = yEpositions(1); yE2 = yEpositions(2);
if xE1 < xC
xE = xE1; yE=yE1;
else
xE = xE2; yE=yE2;
end
rE = [xE yE 0]; % Position vector of E
% Angles of the links with the horizontal
phi2 = atan((yB-yC)/(xB-xC));
phi3 = atan((yD-yC)/(xD-xC));
fprintf(’Results \n\n’)
fprintf(’rA = [ %g, %g, %g ] (m)\n’, rA)
fprintf(’rD = [ %g, %g, %g ] (m)\n’, rD)
fprintf(’rB = [ %g, %g, %g ] (m)\n’, rB)
fprintf(’rC = [ %g, %g, %g ] (m)\n’, rC)
fprintf(’rE = [ %g, %g, %g ] (m)\n’, rE)
fprintf(’phi2 = %g (degrees) \n’, phi2*180/pi)
fprintf(’phi3 = %g (degrees) \n’, phi3*180/pi)
% Graphic of the mechanism
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)
Positions for ф = 45°
V. Transfer Function for System with Gears
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’)
% complete rotation phi=0 to 2*pi step pi/3
for phi=0:pi/3:2*pi,
% for repeat statements a specific number of times
fprintf(’phi = %g degrees \n’, phi*180/pi)
% Position of joint B - position of the driver link
xB = AB*cos(phi); yB = AB*sin(phi); rB = [xB yB 0];
fprintf(’rB = [ %g, %g, %g ] (m)\n’, rB)
% Position of joint D
eqnD1=’(xDsol - xC)ˆ2 + (yDsol - yC)ˆ2 = CDˆ2 ’;
eqnD2=’(yB-yC)/(xB-xC)=(yDsol-yC)/(xDsol-xC)’;
% Simultaneously solve above equations
solD = solve(eqnD1, eqnD2, ’xDsol, yDsol’);
xDpositions = eval(solD.xDsol);
yDpositions = eval(solD.yDsol);
% Separate the solutions in scalar form
xD1 = xDpositions(1); xD2 = xDpositions(2);
yD1 = yDpositions(1); yD2 = yDpositions(2);
% Select the correct position for D for the angle phi
if(phi>=0 && phi<=pi/2)||(phi >= 3*pi/2 && phi<=2*pi)
if xD1 <= xC xD=xD1; yD=yD1; else xD=xD2; yD=yD2;
end
else
if xD1 >= xC xD=xD1; yD=yD1; else xD=xD2; yD=yD2;
end
end
% && short-circuit logical AND
% || short-circuit logical OR
rD = [xD yD 0];
fprintf(’rD = [ %g, %g, %g] (m)\n’, rD)
% Angles of the links with the horizontal
phi2 = atan((yB-yC)/(xB-xC));
phi3 = phi2;
fprintf(’phi2 = phi3 = %g (degrees) \n’, phi2*180/pi)
phi4 = atan(yD/xD);
phi5 = phi4;
fprintf(’phi4 = phi5 = %g (degrees) \n’, phi4*180/pi)
fprintf(’\n’)
% Graph of the mechanism
plot([xA,xB],[yA,yB],’k-o’,[xB,xC],[yB,yC],’b-o’,...
[xC,xD],[yC,yD],’b-o’)
hold on
plot([xD,xA],[yD,yA],’r-o’)
xlabel(’x (m)’),...
ylabel(’y (m)’),...
title(’positions for \phi=0 to 360 step 60(deg)’),...
text(xA,yA,’ A’),...
text(xB,yB,’ B’),...
text(xC,yC,’ C’),...
text(xD,yD,’ D’),...
axis([-0.3 0.3 -0.2 0.3])
end % end for
% end of program
‘’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’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)
phi = 120 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)
phi = 180 degrees
rB = [ -0.15, 1.83697e-17, 0 ] (m)
rD = [ 0.124808, 0.183205, 0] (m)
phi2 = phi3 = 33.6901 (degrees)
phi4 = phi5 = 55.7355 (degrees)
phi = 240 degrees
rB = [ -0.075, -0.129904, 0 ] (m)
rD = [ 0.0465207, 0.242604, 0] (m)
phi2 = phi3 = 71.9325 (degrees)
phi4 = phi5 = 79.145 (degrees)
phi = 300 degrees
rB = [ 0.075, -0.129904, 0 ] (m)
rD = [ -0.0465207, 0.242604, 0] (m)
phi2 = phi3 = -71.9325 (degrees)
phi4 = phi5 = -79.145 (degrees)
phi = 360 degrees
rB = [ 0.15, -3.67394e-17, 0 ] (m)
rD = [ -0.124808, 0.183205, 0] (m)
phi2 = phi3 = -33.6901 (degrees)
phi4 = phi5 = -55.7355 (degrees)