MATLAB Position and Velocity Analysis
%Kinematic Analysis of Treadle Sewing Machine
clear;
a=6;
b=11.5;
c=1.25;
d=12;
e=6;
g=1.5;
h=22.38;
f=((e-g)^2+h^2)^.5;
%%%%% Calculate toggle point of Grashoff rocker-crank
tog1=acosd((a^2+d^2-(b+c)^2)/(2*a*d));
tog2=acosd((a^2+d^2-(b-c)^2)/(2*a*d));
theta2d_1=[tog1-.005:-.005:tog2+.005];
theta2d_2=[tog2+.005:.005:tog1-.005];
%%%%% Calculate position of rocker-crank
delta=1;
[theta3d_1,theta4d_1]=fourbarpos2(a,b,c,d,theta2d_1,delta);
delta=-1;
[theta3d_2,theta4d_2]=fourbarpos2(a,b,c,d,theta2d_2,delta);
theta2d=[theta2d_1 theta2d_2];
theta3d=[theta3d_1 theta3d_2];
theta4d=[theta4d_1 theta4d_2];
max(theta3d);
min(theta3d);
%%%%% Create Plots
figure(1)
plot(theta2d,theta3d,theta2d,theta4d,'k')
xlabel('Input Angle (deg)')
ylabel('Coupler & Crank Position (deg)')
%axis([55 85 -50 -20])
legend('theta3','theta4','Location','northwest')
title('Sewing Machine Position')
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Velocity Analysis
w2=1; %assumed value
w3=(a*w2.*sind(theta4d-theta2d))./(b.*sind(theta3d-theta4d));
w4=abs((a*w2.*sind(theta2d-theta3d))./(c.*sind(theta4d-theta3d)));
%%%%% Create Plot
figure(2)
plot(theta2d,w3,'r',theta2d,w4,'k')
axis([55 85 -20 20])
xlabel('Input Angle (deg)')
ylabel('Coupler and Crank Velocity')
legend('w3','w4')
title('Sewing Machine Angular Velocity')
w5=abs(w4);
m_G=g/e;
w7=w5./m_G;
MA=(w2./w7).*(a/g);
%Create Plot
figure(3)
plot(theta2d,w4,'k',theta2d,w7,'b')
axis([55 85 0 40])
xlabel('Input Angle (deg)')
ylabel('Pulley Input and Output Speeds')
legend('w4','w7')
title('Sewing Machine Angular Velocity')
%Create Plot
figure(4)
plot(theta2d,MA,'k')
xlabel('Input Angle (deg)')
ylabel('MA')
title('Sewing Machine Mechanical Advantage')
Function 'fourbarpos2'
function [theta3d,theta4d]=fourbarpos2(a,b,c,d,theta2d,delta)
%input and output in degrees
%Calculate position of 4-bar mechanism
K1=d/a; %4.8a textbook
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=cosd(theta2d)-K1-K2.*cosd(theta2d)+K3; %4.10a textbook
B=-2.*sind(theta2d);
C=K1-(K2+1).*cosd(theta2d)+K3;
D=cosd(theta2d)-K1+K4.*cosd(theta2d)+K5;
E=-2.*sind(theta2d);
F=K1+(K4-1).*cosd(theta2d)+K5;
theta3_1=2.*atand((-E-((E.^2)-4.*D.*F).^.5)./(2.*D)); %calculate open solution
theta3_2=2.*atand((-E+((E.^2)-4.*D.*F).^.5)./(2.*D)); %calculate crossed solution
theta4_1=2.*atand((-B-((B.^2)-4.*A.*C).^.5)./(2.*A)); %calculate open solution
theta4_2=2.*atand((-B+((B.^2)-4.*A.*C).^.5)./(2.*A)); %calculate crossed solution
if delta==1
theta3d=theta3_1;
theta4d=theta4_1;
else
theta3d=theta3_2;
theta4d=theta4_2;
end