Versions Compared

Key

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

Appendix A: MATLAB Scripts

Note, all scripts are included as text below and as an .m file attachmentview

  A1 -

...

Main Script

Download here →  analysis7.mheight250

...

%This script performs calculations for a Jansen walking mechanism

...

%%
%%Double Check work by ensuring that links do not change lengths
errB=max(abs(Bdist-B));
errC=max(abs(Cdist-C));
errD=max(abs(Ddist-D));
errE=max(abs(Edist-E));
errF=max(abs(Fdist-F));
errG=max(abs(Gdist-G));
errH=max(abs(Hdist-H));
errI=max(abs(Idist-I));
errJ=max(abs(Jdist-J));
errK=max(abs(Kdist-K));
MaxError=max([errB,errC,errD,errE,errF,errG,errH,errI,errJ,errK]);
if MaxError>0.0001
disp('error, a link is changing length during animation')
disp(MaxError)
else
disp('Simulation successful')
end

  A2 -

...

mechanismState.m

Download here → mechanismState.m

function [xMJK,yMJK,xBDC,yBDC,xBEJ,yBEJ,xDEF,yDEF,xCIKG,yCIKG,xM,yM,xFGH,yFGH,xHI,yHI] = mechanismState(thetaA,thetaB,thetaC,thetaD,thetaE,thetaF,thetaG,thetaH,thetaI,thetaJ,thetaK,thetaM)
%DRAWS OUT THE POINTS FOR THE JANSEN MECHANISM GIVEN THE VECTOR OF ANGLES
%ASSUME ORIGIN POINT AT JOINT BDC
global A B C D E F G H I J K M

%Calculate Cartesian Distances
Ax=A*cosd(thetaA);
Ay=A*sind(thetaA);
Bx=B*cosd(thetaB);
By=B*sind(thetaB);
Cx=C*cosd(thetaC);
Cy=C*sind(thetaC);
Dx=D*cosd(thetaD);
Dy=D*sind(thetaD);
%Ex=E*cosd(thetaE);
%Ey=E*sind(thetaE);
%Fx=F*cosd(thetaF);
%Fy=F*sind(thetaF);
Gx=G*cosd(thetaG);
Gy=G*sind(thetaG);
%Hx=H*cosd(thetaH);
%Hy=H*sind(thetaH);
Ix=I*cosd(thetaI);
Iy=I*sind(thetaI);
%Jx=J*cosd(thetaJ);
%Jy=J*sind(thetaJ);
%Kx=K*cosd(thetaK);
%Ky=K*sind(thetaK);
Mx=M*cosd(thetaM);
My=M*sind(thetaM);

%Calculate Point Locations
xMJK=Ax+Mx;
yMJK=Ay+My;

xBDC=0;
yBDC=0;

xBEJ=Bx;
yBEJ=By;

xDEF=Dx;
yDEF=Dy;

xCIKG=Cx;
yCIKG=Cy;

xM=Ax;
yM=Ay;

xFGH=xCIKG+Gx;
yFGH=yCIKG+Gy;

xHI=xCIKG+Ix;
yHI=yCIKG+Iy;


end

  A3 - Range360Deg.m

Download here →Range360Deg.m

function [thetanew] = Range360Deg(theta)
%takes a vector of angles in degrees "theta" and converts all angles into
%the range between 0<theta<360
thetanew(1:length(theta))=0;

for i=1:length(theta)
key=true;
thetanew(i)=theta(i);
k=0;
while key==true
k=k+1;
if thetanew(i)>=0 && thetanew(i)<=360
key=false;

elseif thetanew(i)<0
a=ceil(abs(thetanew(i)/360));
thetanew(i)=thetanew(i)+a*360;
elseif thetanew(i)>360
a=floor(abs(thetanew(i)/360));
thetanew(i)=thetanew(i)-a*360;
end
if k>6
disp('error, Range360Deg is not fixing the angle')
disp(i)
end
end
end
end


  A4 - fourbarpos.m

Download here ->fourbarpos.m

function [theta]=fourbarpos(a,b,c,d,theta1,theta2,delta)
%%%%%%%%%%
% This code is downloaded from the RMD Canvas page.
% Originally written by Bonnie Chan 2020
type='fourbar';
if d==0
type='crank-slider';
end

switch type
case 'fourbar'
%vector loop equation for a fourbar linkage
k1=d/a;
k2=d/c;
k3=(a^2-b^2+c^2+d^2)/(2*a*c);
k4=d/b;
k5=(c^2-d^2-a^2-b^2)/(2*a*b);
A=cos(theta2)-k1-k2*cos(theta2)+k3;
B=-2*sin(theta2);
C=k1-(k2+1)*cos(theta2)+k3;
D=cos(theta2)-k1+k4*cos(theta2)+k5;
E=-2*sin(theta2);
F=k1+(k4-1)*cos(theta2)+k5;
if delta==1
theta4=2*atan((-B-sqrt(B^2-4*A*C))/(2*A));
theta3=2*atan((-E-sqrt(E^2-4*D*F))/(2*D));
elseif delta==-1
theta4=2*atan((-B+sqrt(B^2-4*A*C))/(2*A));
theta3=2*atan((-E+sqrt(E^2-4*D*F))/(2*D));
end
theta=[theta1,theta2,theta3,theta4];

case 'crank-slider'
%vector loop equation for a fourbar crank-slider linkage
theta4=0;
if delta==1
theta3=asin((a*sin(theta2)-c)/b);
d=a*cos(theta2)-b*cos(theta3);
elseif delta==-1
theta3=asin(-(a*sin(theta2)-c)/b)+pi;
d=a*cos(theta2)-b*cos(theta3);
end
theta=[theta1 theta2 theta3 theta4];


end


Appendix B: Additional Prototype Pictures

These pictures are supplemental to the pictures included in Section 3. 

Image Added

Image Added

Image Added


Image Added


Image Added