Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

MATLAB Code



theta2=linspace(131.1541*pi/180,228.8145*pi/180);
theta3=zeros(numel(theta2),1);
theta4=zeros(numel(theta2),1);
O2B=zeros(numel(theta2),1);
AC=zeros(numel(theta2),1);
O2Bdot=zeros(numel(theta2),1);
w3=zeros(numel(theta2),1);
w4=zeros(numel(theta2),1);
ACdot=zeros(numel(theta2),1);
O2Bdotdot=zeros(numel(theta2),1);
alpha3=zeros(numel(theta2),1);
alpha4=zeros(numel(theta2),1);
ACdotdot=zeros(numel(theta2),1);
ACdotdotC=zeros(numel(theta2),1);

O2A= 6.575;
AB=4.956;
O4B=5.088;
O4C=16.41476;
BA=4.95535;
w2=10*2*pi/60; % 10 rpm to rad/s
thetaO4O2=33.0205*pi/180; %rad
O4O2=7.951338;

% Position Analysis
for i=1:numel(theta2)
theta3(i)=asin(O2A*sin(theta2(i))/BA);
O2B(i)=-(BA*cos(asin(O2A*sin(theta2(i))/BA))-O2A*cos(theta2(i))); %negative sign because opposite direction
theta4(i)=asin(((O4O2*sin(thetaO4O2)+O2A*sin(theta2(i))-O4O2*cos(thetaO4O2)*tan(theta3(i))-O2A*cos(theta2(i))*tan(theta3(i)))/O4C)*cos(theta3(i)))+theta3(i);
AC(i)=(O4C*cos(theta4(i))-O4O2*cos(thetaO4O2)-O2A*cos(theta2(i)))/cos(theta3(i));

end

%Velocity Analysis
for i=1:numel(theta2)
w3(i)=O2A*w2*cos(theta2(i))/(BA*cos(theta3(i)));
O2Bdot(i)=-(O2A*w2*sin(theta2(i))-BA*w3(i)*sin(theta3(i)));
w4(i)=(O2A*w2*cos(theta2(i))+AC(i)*w3(i)*cos(theta3(i))+O2A*w2*sin(theta2(i))*tan(theta3(i))+AC(i)*w3(i)*sin(theta3(i))*tan(theta3(i)))/(O4C*sin(theta4(i))*tan(theta3(i))+O4C*cos(theta4(i)));
ACdot(i)=(O2A*w2*sin(theta2(i))+AC(i)*w3(i)*sin(theta3(i))-O4C*w4(i)*sin(theta4(i)))/cos(theta3(i));
end

%Acceleration Analysis
for i=1:numel(theta2)
alpha3(i)=(-O2A*w2^2*sin(theta2(i))+BA*(w3(i))^2*sin(theta3(i)))/(BA*cos(theta3(i)));
O2Bdotdot(i)=-(O2A*w2^2*cos(theta2(i))-BA*alpha3(i)*sin(theta3(i))-BA*w3(i)^2*cos(theta3(i)));
alpha4(i)=(-O2A*w2^2*sin(theta2(i))+AC(i)*alpha3(i)*cos(theta3(i))+ACdot(i)*w3(i)*cos(theta3(i))+AC(i)*w3(i)^2*sin(theta3(i))+O2A*w2^2*cos(theta2(i))*tan(theta3(i))+AC(i)*alpha3(i)*sin(theta3(i))*tan(theta3(i))+2*ACdot(i)*w3(i)*tan(theta3(i))*sin(theta3(i))+AC(i)*w3(i)^2*sin(theta3(i))-O4C*w4(i)^2*cos(theta4(i))*tan(theta3(i))+ACdot(i)*w3(i)*cos(theta3(i))+O4C*w4(i)^2*sin(theta4(i)))/(O4C*sin(theta4(i))*tan(theta3(i))+O4C*cos(theta4(i)));
ACdotdot(i)=(O2A*w2^2*cos(theta2(i))+AC(i)*alpha3(i)*sin(theta3(i))+2*ACdot(i)*w3(i)*sin(theta3(i))+AC(i)*w3(i)^2*cos(theta3(i))-O4C*alpha4(i)*sin(theta4(i))-O4C*w4(i)^2*cos(theta4(i)))/cos(theta3(i));
end

%Coriolis Acceleration Analysis
for i=1:numel(theta2)
ACdotdotC(i)=(2*ACdot(i)*w3(i)*sin(theta3(i)))/cos(theta3(i));
end

%Convert radians to degrees
theta2d=theta2*180/pi;
theta3d=theta3*180/pi;
theta4d=theta4*180/pi;

%Plots

figure(1)
plot(theta2d,O2B)
xlabel('Angle Of Input Link (deg)')
ylabel('Position of Slider B (in)')
title('Position of Slider B vs. Angle of Input Link')
saveas(figure(1),'figure1.jpg')

figure(2)
plot(theta2d,AC)
xlabel('Angle Of Input Link (deg)')
ylabel('Position of Slider C (in)')
title('Position of Slider C vs. Angle of Input Link')
saveas(figure(2),'figure2.jpg')

figure(3)
plot(theta2d,theta3d)
xlabel('Angle Of Input Link (deg)')
ylabel('Angle of Slider C (deg)')
title('Angle of Slider C vs. Angle of Input Link')
saveas(figure(3),'figure3.jpg')

figure(4)
plot(theta2d,theta4d)
xlabel('Angle Of Input Link (deg)')
ylabel('Angle of Link O4C (deg)')
title('Angle of Link O4 vs. Angle of Input Link')
saveas(figure(4),'figure4.jpg')

figure(5)
plot(theta2d,O2Bdot)
xlabel('Angle Of Input Link (deg)')
ylabel('Velocity of Slider B (in/s)')
title('Velocity of Slider B vs. Angle of Input Link')
saveas(figure(5),'figure5.jpg')

figure(6)
plot(theta2d,ACdot)
xlabel('Angle Of Input Link (deg)')
ylabel('Velocity of Slider C (in/s)')
title('Velocity of Slider C vs. Angle of Input Link')
saveas(figure(6),'figure6.jpg')

figure(7)
plot(theta2d,w3)
xlabel('Angle Of Input Link (deg)')
ylabel('Angular Velocity of Slider C (rad/s)')
title('Angular Velocity of Slider C vs. Angle of Input Link')
saveas(figure(7),'figure7.jpg')

figure(8)
plot(theta2d,w4)
xlabel('Angle Of Input Link (deg)')
ylabel('Angular Velocity of Link O4C (rad/s)')
title('Angular Velocity of Link O4C vs. Angle of Input Link')
saveas(figure(8),'figure8.jpg')

figure(9)
plot(theta2d,O2Bdotdot)
xlabel('Angle Of Input Link (deg)')
ylabel('Acceleration of Slider B (in/s^2)')
title('Acceleration of Slider B vs. Angle of Input Link')
saveas(figure(9),'figure9.jpg')

figure(10)
plot(theta2d,ACdotdot)
xlabel('Angle Of Input Link (deg)')
ylabel('Acceleration of Slider C (in/s^2)')
title('Acceleration of Slider C vs. Angle of Input Link')
saveas(figure(10),'figure10.jpg')

figure(11)
plot(theta2d,alpha3)
xlabel('Angle Of Input Link (deg)')
ylabel('Angular Acceleration of Slider C (rad/s^2)')
title('Angular Acceleration of Slider C vs. Angle of Input Link')
saveas(figure(11),'figure11.jpg')

figure(12)
plot(theta2d,alpha4)
xlabel('Angle Of Input Link (deg)')
ylabel('Angular Acceleration of Link O4C (rad/s^2)')
title('Angular Acceleration of Link O4C vs. Angle of Input Link')
saveas(figure(12),'figure12.jpg')

figure(14)
plot(theta2d,ACdotdotC)
xlabel('Angle Of Input Link (deg)')
ylabel('Coriolis Acceleration of Slider C (rad/s^2)')
title('Angular Acceleration of Link O4C vs. Angle of Input Link')
saveas(figure(12),'figure12.jpg')