Image Added
Position:
Image AddedImage Added
Velocity:
Image AddedImage Added
Acceleration:
Image Added
Image Added
Animation:
Image AddedImage Added
MATLAB code:
clear all;
L=[4.72,3,4,5];
Lprime = [4.72,1.5,4,1]; % link dimensions
theta2 = 0:20; % theta 2 range
theta1 = 0;
theta = []; % empty vector used for storage of theta values from four bar pos/ function
t_angle = 58; % transformation angle of local coordinate
% evaluate local thetas with four bar position functions
for j = 1:length(theta2)
t_2 = (theta2(j)) + (360-t_angle); % find theta 2 in local coordinate by
q = fourbar(Lprime,theta1,t_2,-1);
theta(j,:) = q;
end
theta(:,1)=58;
theta(:,2)=theta2(:);
theta(:,3:4)= theta(:,3:4) + t_angle; % convert back to angle in respect to global XY coordina
%position
A=[L(2)/2.*cosd(theta(:,2)+180) L(2)/2.*sind(theta(:,2)+180)];
B=[L(2)/2.*cosd(theta(:,2)) L(2)/2.*sind(theta(:,2))];
C=[B(:,1)+L(3)*cosd(theta(:,3)) B(:,2)+L(3)*sind(theta(:,3))];
D=[C(:,1)+L(4)*cosd(theta(:,4)+180) C(:,2)+L(4)*sind(theta(:,4)+180)];
figure (1)
axis([-2 10 -2 5])
xlabel('x')
ylabel('y')
title('Position path')
hold on
plot(A(:,1),A(:,2),'r','LineWidth',2)
plot(B(:,1),B(:,2),'k','LineWidth',2)
plot(C(:,1),C(:,2),'b','LineWidth',2)
plot(D(:,1),D(:,2),'g','LineWidth',2)
legend('A','B','C','D')
hold off
%velocity
w2=0.05; %given
w3=-Lprime(2).*w2.*sind(theta(:,4)-theta(:,2))./(L(3).*sind(theta(:,4)-theta(:,3)));
w4=-Lprime(2).*w2.*sind(theta(:,3)-theta(:,2))./(Lprime(4).*sind(theta(:,4)-theta(:,3)));
figure (2) %angular
hold on
title('Angular Velocity vs \theta_2')
xlabel('\theta_2')
ylabel('\omega')
plot(theta2,w3,'r','LineWidth',2)
plot(theta2,w4,'k','LineWidth',2)
legend('\omega_3','\omega_4')
hold off
VB=Lprime(2).*w2;
VA=-VB;
VC=VB+L(3).*w3;
VD=(L(4)-1).*w4;
figure (3) %linear
hold on
title('Linear Velocity vs \theta_2')
xlabel('\theta_2')
ylabel('V(in/s)')
plot(theta2,VA.*ones(length(theta2),1),'r','LineWidth',2)
plot(theta2,VB.*ones(length(theta2),1),'k','LineWidth',2)
plot(theta2,VC,'b','LineWidth',2)
plot(theta2,VD,'g','LineWidth',2)
legend('VA','VB','VC','VD')
hold off
%acceleration
a2=0;
a3=(L(3).*w3.^2.*cosd(theta(:,3)-theta(:,4))+L(2)/2.*w2.^2.*cosd(theta(:,2)-theta(:,4))-w4.^2.*cosd(2.*theta(:,4)))./(L(3).*sind(theta(:,3)+theta(:,4)));
a4=(L(3).*w3.^2+L(2)/2.*w2.^2.*cosd(theta(:,2)-theta(:,3))-w4.^2.*cosd(theta(:,3)+theta(:,4))./(sind(theta(:,4)-theta(:,3))));
AAx=-w2.^2.*L(2)/2.*cosd(theta(:,2));
AAy=-w2.^2.*L(2)/2.*sind(theta(:,2));
AA=sqrt(AAx.^2+AAy.^2);
AB=-AA;
ACx=AAx-w3.^2.*L(3).*cosd(theta(:,3))-a3.*L(3).*sind(theta(:,3));
ACy=AAy-w3.^2.*L(3).*sind(theta(:,3))+a3.*L(3).*cosd(theta(:,3));
AC=sqrt(ACx.^2+ACy.^2);
ADx=4.*(-w4.^2.*cosd(theta(:,4))-a4.*sind(theta(:,4)));
ADy=4.*(-w4.^2.*sind(theta(:,4))+a4.*cosd(theta(:,4)));
AD=sqrt(ADx.^2+ADy.^2);
figure (4) %angular
hold on
title('Angular Acceleration vs \theta_2')
xlabel('\theta_2')
ylabel('\alpha')
plot(theta2,a3,'r','LineWidth',2)
plot(theta2,a4,'k','LineWidth',2)
legend('\alpha_3','\alpha_4')
hold off
figure (5) %linear
hold on
title('Linear Acceleration vs \theta_2')
xlabel('\theta_2')
ylabel('A(in/s^2)')
plot(theta2,AA,'r','LineWidth',2)
plot(theta2,AB,'k','LineWidth',2)
plot(theta2,AC,'b','LineWidth',2)
plot(theta2,AD,'g','LineWidth',2)
legend('A_A','A_B','A_C','A_D')
hold off
% Video file name
Filename = 'Kinematic analysis';
% Figure representing sinus function
Figure = figure('Color','w');
hold('on');
% Creation of a Video object
VR = VideoRecorder('Filename', Filename,...
'Fileformat', 'MPEG-4',...
'Figure', Figure,...
'Period', 0.05,...
'BusyMode', 'error');
% Saving start
VR.start();
hold on
axis([-2 10 -2 5])
link2=line([A(1,1) B(1,1)],[A(1,2) B(1,2)]);
link3=line([B(1,1) C(1,1)],[B(1,2) C(1,2)]);
link4=line([C(1,1) D(1,1)],[C(1,2) D(1,2)]);
plot(0,0,'r.');
plot(2.5,4,'r.');
for i=1:length(theta2)
link2.XData=[A(i,1) B(i,1)];
link2.YData=[A(i,2) B(i,2)];
link3.XData=[C(i,1) B(i,1)];
link3.YData=[C(i,2) B(i,2)];
link4.XData=[C(i,1) D(i,1)];
link4.YData=[C(i,2) D(i,2)];
drawnow;
f(i)=getframe;
end
hold off
VR.stop();
% Video_recorder reading
Filename = get(VR,'Filename');
try
winopen(Filename);
catch ME
error('Video_recorder "%s" cannot be read (%s).',Filenamename,ME.message);
end
{"serverDuration": 293, "requestCorrelationId": "574d37fb37e74b55bac72f70bb7c5dbe"}