Professional Documents
Culture Documents
B E
S43 S13
C D
x
L
Virtually disconnect joint B. And loop closure equation becomes; AB2= AD + DC + CE+ EB3
r2 e
i 12
= r1 + i b1 s13 + i s43
Real part :
r2 cos 12 = r1 s13 s13 := r1 r2 cos 12
( )
( )
Imaginary part:
r2 sin 12 = b1 + s43 s43 := r2 sin 12 b1
( )
( )
In order to be able to animate this Scotch-yoke mechanism, coordinates of ends of each line in the system should be determined.
xB := r2 cos 12
( ) ( )
yB := r2 sin 12
B r2 cos 12 , r2 sin 12
( )
( ) ) = B( xB , yB)
Now, we know the coordinates of the end points of the line AB. Then, we can draw AB line in MATLAB such as: x=[ xA xB]; y=[ yA yB]; plot(x,y) ( This is a 1-2 matrix) (This is a 1-2 matrix)
Note that xA, xB, yA and yB are found before. Let's rotate AB link 360 degrees in MATLAB for 12=0:0.1:(2*pi) xA=0; yA=0; xB= r2*cos(12); yB= r2*sin(12); x=[ xA xB]; y=[ yA yB]; plot(x,y) end this means that 12 is between 0 and 2pi and increases by an increment 0.1
AK = AD + DC + CE + EK
AK := r1 + i b1 s13 + ib.2 xK= r1 - s13; real part is x-coordinate
yK= b1 + b2;
yL := b1 b2
Then, we can plot line KL in MATLAB such as; xK=r1-s13; yK=b1+b2; xL= r1-s13; yL= b1 - b2; x=[ xA xB]; y=[ yA yB]; plot(x,y)
The CODE
%% the animation of scotch yoke mechanism
r2=15; % length of line AB b2=35; % the length of line KL r4=50; % length of line EM r1=60; b1=5; for teta12=0:0.01:2*pi % teta12 increases by 0.01, the idea is that for each teta12 value we draw the system s43=(r2*sin(teta12)-b1); % for every teta12, we have to find corresponding s13 and s43 s13=r1-r2*cos(teta12); %% Line AB XA=0; % x-coordinate of point A of the line AB YA=0; %y-coordinate of point A of the line AB XB=r2*cos(teta12); % x-coordinate of point B of the line AB YB=r2*sin(teta12); % y-coordinate of point B of the line AB X=[XA XB]; Y=[YA YB]; plot(X,Y,'-yo','LineWidth', 3,'MarkerEdgeColor','b', 'MarkerSize',8) %instead you can use only plot(X,Y) % -yo means that end points are circle and the color of the line is yellow. Linewidth,3, make the width of line 3. b means blue color. hold on % hold on enable us to draw another figure onto the figure drawn before which means by keeping the figure drawn before %% line KL XK=r1-s13; % x-coordinate of point K of the line KL YK=b1+b2; % y-coordinate of point K of the line KL XL=r1-s13; % x-coordinate of point L of the line KL YL=b1-b2; % y-coordinate of point L of the line KL
X=[XK XL]; Y=[YK YL]; plot(X,Y,'-go','LineWidth', 3, 'MarkerSize',8) %% line EM XE=r1-s13; YE=b1; XM=r1+r4-s13; YM=b1; X=[XE XM]; Y=[YM YM]; plot(X,Y,'-mo','LineWidth', 3,'MarkerSize',8) %% the lower ground line X=[r1-40 r1-20]; Y=[-1+b1 -1+b1]; plot(X,Y) % plots the lower ground line %% the upper ground line X=[r1-40 r1-20]; Y=[1+b1 1+b1]; plot(X,Y) % plots the upper ground line axis equal axis manual axis([-60 70 -30 50]) % this makes the boundray of the figure keeps constant. For x axis from -60 to 70. For y axis from -30 to 50. grid on hold off % after hold off command, if we plot a figure, the figure drawn before is deleted pause(0.005)% program waits, by changing 0.005,you can change the speed of the animation end