Está en la página 1de 4

CODIGO MATLAB USADO

%% CODIGO PARA CUALQUIER PUNTO P DE INTERES


% INICIO DEL CODIGO
clc
clear

a=1; b=2.06; c=2.33; d=2.22;% Medidas de los


eslabones.
ap=3.06; % Distancia del punto a y p.

k1=d/a; k2=d/c; k3=(a*a-b*b+c*c+d*d)/(2*a*c);


k4=d/b; k5=(c*c-d*d-a*a-b*b)/(2*a*b); % Constantes
k=1; % Variable independiente a usar

Th311=-31; % Angulo entre b y p.


VAn=zeros();
VV=zeros();
VAc=zeros();
for Th2=45:2:(360+45)

A=cosd(Th2)-k1-k2*cosd(Th2)+k3;
B=-1*(2*sind(Th2));
C=k1-(k2+1)*cosd(Th2)+k3;
D=cosd(Th2)-k1+k4*cosd(Th2)+k5;
E=-1*2*sind(Th2);
F=k1+(k4-1)*cosd(Th2)+k5;

S1=(-B-sqrt(B*B-4*A*C))/(2*A);
S2=(-B+sqrt(B*B-4*A*C))/(2*A);
S11=(-E-sqrt(E*E-4*D*F))/(2*D);
S22=(-E+sqrt(E*E-4*D*F))/(2*D);

Th41=2*atand(S1); % Angulo 4 para una posicion


abierta.
Th42=2*atand(S2); % Angulo 4 para una posicion
cerrada.
Th31=2*atand(S11); % Angulo 3 para una posicion
abierta.
Th32=2*atand(S22); % Angulo 3 para una posicion
cerrada.

% Coordenadas del punto A.


Ax=a*cosd(Th2);
Ay=a*sind(Th2);
% Coordenadas del punto B.
Bx=Ax + b*cosd(Th31);
By=Ay + b*sind(Th31);

Bu=b*cosd(Th31);
Bv=b*sind(Th31);

Cu=c*cosd(Th41);
Cv=c*sind(Th41);

% Coordenadas del origen .


Px=ap*cosd(Th31+Th311);
Py=ap*sind(Th31+Th311);

% ANALIIS DE VELOCIDAD
Omega2=10*pi/3;
Omega3=(a*Omega2*sind(Th41-Th2))/(b*sind(Th31-
Th41));
Omega4=(a*Omega2*sind(Th2-Th31))/(c*sind(Th41-
Th31));

VAx= -a*Omega2*sind(Th2);
VAy= a*Omega2*cosd(Th2);
VBAx=-b*Omega3*sind(Th31);
VBAy= b*Omega3*cosd(Th31);
VBx= -c*Omega4*sind(Th41);
VBy= c*Omega4*cosd(Th41);
VPx= -ap*Omega3*sind(Th31+Th311);
VPy= ap*Omega3*cosd(Th31+Th311);

vx=[Ax,Bx,Bx];
vy=[Ay,By,By];
uV=[VAx,VBAx,VBx];
vV=[VAy,VBAy,VBy];

VXc=[Ax,Bu,d,Cu];
VYc=[Ay,Bv,0,Cv];

VAn(k,1:3)=[Th2 Th31 Th41];


VV(k,1:3)=[sqrt(VAx^2+VAy^2) sqrt(VBx^2+VBy^2)
sqrt(VPx^2+VPy^2)];
VAc(k,1:3)=[Omega2 Omega3 Omega4];
% Coordenadas del punto P en referencia al punto A.
Px1=Ax+Px;
Py1=Ay+Py;

Pint(k, :) = [Ax, Ay]; % Traza los puntos A


Pint(k+1000, :) =[Bx By]; % Traza los puntos B
Pint(k+2000, :) =[Px1 Py1]; % Traza los puntos P

% Graficas y trayectorias.
figure(1)
plot([0 d],[0 0],'-ow',[0 Ax],[0 Ay],'or-',...
[Ax Bx],[Ay By],'-ok',Pint(:,1),Pint(:,2),'m.',...
[Bx d],[By 0],'og-',[Ax Px1],[Ay Py1],'k-',[Bx
Px1],[By Py1],'ok-','linewidth',2)

hold on
quiver(Ax,Ay,VAx,VAy,.2,'b','filled','linewidth',2);

quiver(Px1,Py1,VPx,VPy,.2,'b','filled','linewidth',2);
quiver(Bx,By,VBx,VBy,.2,'b','filled','linewidth',2);

% Texto
text(Ax+.1,Ay+.1,'A')
text(Bx+.1,By+.1,'B')
text(Px1+.1,Py1+.1,'P')

text(3, -2,['V_A= ', num2str(VV(1,1:1))]);


text(3,-3, ['V_B= ', num2str(VV(k,2:2))]);
text(3,-4, ['V_P= ', num2str(VV(k,3:3))]);

text(-3,-2, ['w_2= ', num2str(Omega2),' rad s^{-


1}']);
text(-3,-3, ['w_3= ', num2str(Omega3),' rad s^{-
1}']);
text(-3,-4, ['w_4= ', num2str(Omega4),' rad s^{-
1}']);

text(-3, 4, ['\theta_2= ', num2str(Th2)]);


text(-3, 3, ['\theta_3= ', num2str(Th31),]);
text(-3, 2, ['\theta_4= ', num2str(Th41)]);

grid on
axis ([-4 6 -5 5]);
title('MECANISMO DE 4L')
axis square;
pause(0.05);
k=k+1;
hold off
end

%%
figure(2)
plot(VAn(:,1), VAc(:,1:3),'*-','linewidth',.5)
grid on
xlabel('\theta_2')
ylabel('Velocidad angular rad s^{-1}')
legend('w_2','w_3','w_4')
title('\theta_2 vs w_2, w_3, w_4')
hold on

figure(3)
plot(VAn(:,1),VAn(:,2:3),'*-','linewidth',.5)
grid on
xlabel('\theta_2')
ylabel('\theta_3 , \theta_4')
legend('\theta_2','\theta_3','\theta_4')
title('\theta_2 vs \theta_3, \theta_4')
hold on

figure(4)
plot(VAn(:,1),VV(:,1:3),'*-','linewidth',.5)
xlabel('\theta_2')
ylabel('Velocidad lineal m/s')
legend('V_A','V_B','V_P')
title('\theta_2 vs V_A, V_B, V_P')

grid on

También podría gustarte