Versions Compared

Key

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

...

I used the following MATLAB code to calculate all the above values using a 0 to 360 degree input of theta 2. The position graph for the same point shown in the PMKS analysis has a slightly different shape, indicating the code did not match as well as the real life result.

Code:

a = 5;
b = 14;
c = 2;
d = 6.85;
f = 9;
p_b = 7.48;
p_h = 8.55;

alpha2 = 90*2*pi;
delta3 = 156.35*2*pi;
alpha6 = 90*2*pi;
delta5 = 251.82*2*pi;
w2 = 40;

theta2= 0:1:360;

o2 = zeros(1,length(theta2));
o4 = 90*2*pi;
o6 = 90*2*pi;

o3 = zeros(1,length(theta2));
w3 = zeros(1,length(theta2));
a3 = zeros(1,length(theta2));

o5 = zeros(1,length(theta2));
w5 = zeros(1,length(theta2));
a5 = zeros(1,length(theta2));

b_pos = zeros(1,length(theta2));
bdot = zeros(1,length(theta2));
bdotdot = zeros(1,length(theta2));

h_pos = zeros(1,length(theta2));
hdot = zeros(1,length(theta2));
hdotdot = zeros(1,length(theta2));

Vpa = zeros(1,length(theta2));
Vp = zeros(1,length(theta2));
Ra = zeros(1,length(theta2));
Rba = zeros(1,length(theta2));
Rpx = zeros(1,length(theta2));
Rpy = zeros(1,length(theta2));
xb = zeros(1,length(theta2));
yb = zeros(1,length(theta2));

Rf = zeros(1,length(theta2));
Rhf = zeros(1,length(theta2));
Rhx = zeros(1,length(theta2));
Rhy = zeros(1,length(theta2));
xh = zeros(1,length(theta2));
yh = zeros(1,length(theta2));


for i = 1:length(theta2)
o2 = i*pi/180;
o3(i) = atan((a*sin(o2)-c)/(a*cos(o2)-d));
b_pos(i) = (a*cos(o2)-d)/cos(o3(i));
w3(i) = (a*w2*cos(o2)+a*w2*sin(o2)*tan(o3(i)))/(b_pos(i)*sin(o3(i))*tan(o3(i))+b_pos(i)*cos(o3(i)));
bdot(i) = (b_pos(i)*w3(i)*sin(o3(i))-a*w2*sin(o2))/(cos(o3(i)));
a3(i) = (-a*w2^2*sin(o2)+a*w2^2*cos(o2)*tan(o3(i))-2*bdot(i)*w3(i)*tan(o3(i))*sin(o3(i))-b_pos(i)*w3(i)^2*sin(o3(i))-2*bdot(i)*w3(i)*cos(o3(i))+b_pos(i)*w3(i)^2*sin(o3(i)))/(b_pos(i)*sin(o3(i))*tan(o3(i))+b_pos(i)*cos(o3(i)));
bdotdot(i) = 1/cos(o3(i))*(-a*w2^2*cos(o2)+2*bdot(i)*w3(i)*sin(o3(i))+b_pos(i)*w3(i)^2*cos(o3(i))+b_pos(i)*a3(i)*sin(o3(i)));o5(i) = acos(1/f*(a*cos(o2)-b*cos(o3(i))-d));
h_pos(i) = a*sin(o2)-b*sin(o3(i))-f*sin(o5(i));
w5(i) = (a*w2*sin(o2)-b*w3(i)*sin(o3(i)))/(f*sin(o5(i)));
hdot(i) = a*w2*cos(o2)-b*w3(i)*cos(o3(i))-cot(o5(i))*(a*w2*sin(o2)-b*cos(o3(i)));
a5(i)= (a*w2*cos(o2)-b*a3(i)*sin(o3(i))-b*w3(i)^2*cos(o3(i))-f*w5(i)^2*cos(o5(i)))/(f*sin(o5(i)));
hdotdot(i) = -a*w2^2*sin(o2)-b*a3(i)*cos(o3(i))+b*w3(i)^2*sin(o3(i))+f*w5(i)^2*sin(o5(i))-f*a5(i)*cos(o5(i));
Ra(i) = a*(cos(o2)+1i*sin(o2));
Rba(i) = p_b*(cos(o3(i)+delta3)+1i*sin(o3(i)+delta3));
Rpx(i)=a*cos(o2)+ p_b*cos(o3(i)+delta3);
Rpy(i)=a*sin(o2)+p_b*sin(o3(i)+delta3);
xb(i)=Rpx(i).*cos(alpha2)-Rpy(i).*sin(alpha2);
yb(i)=Rpx(i).*sin(alpha2)+Rpy(i).*cos(alpha2);
Rf(i) = f*(cos(o6)+1i*sin(o6));
Rhf(i)= p_h*(cos(o5(i)+delta5)+1i*sin(o5(i)+delta5));
Rhx(i)= f*cos(o6)+ p_h*cos(o5(i)+delta5);
Rhy(i)= f*sin(o6)+p_h*sin(o5(i)+delta5);
xh = zeros(361,1)+15.63;
yh(i) = Rhx(i).*sin(alpha6)+Rhy(i).*cos(alpha6);
endfigure(1)
plot(xb, yb)
title ('path of link 2')
xlabel('x axis (in)')
ylabel('y axis (in)')*Refer to Appendix for MATLAB Code