Sei sulla pagina 1di 8

% Este script resuelve la velocidad angular y la aceleración de la barra o a

clc
clear all
b = 25; % distance between supports
d = 10;
tetp = 5; %angular speed of bar 1
teta = [0:1:360]*pi/180;
n = length(teta);
for i = 1:n
tet = teta(i)
er = [cos(tet) sin(tet)]'; %vector in radial direction
etet = [-sin(tet) cos(tet)]';
Rvect = [b+d*cos(tet) d*sin(tet)];
R = sqrt(dot(Rvect,Rvect));
v = d*tetp*etet; %velocity
a = -d*tetp^2*er; %acceleration
eR = Rvect'/R;
eAlfa = [-eR(2) eR(1)]';
K = [eR R*eAlfa];
RpAp = inv(K)*v;
Rp = RpAp(1);
Rpp(i) = Rp; %Rpunto
Ap = RpAp(2); %alfa punto
App(i) = Ap;
f = a + R*Ap^2*eR - 2*Rp*Ap*eAlfa;
R2pA2p = inv(K)*f;
R2p = R2pA2p(1);
R2pp(i) = R2p;
A2p = R2pA2p(2);
A2pp(i) = A2p;

end
teta = teta*180/pi;
plot(teta,Rpp,'k.')
figure(2)
plot(teta,App,'k+')
%legend('Rpunto','Alfa punto')
xlabel('teta(degrees)')
figure(3)
plot(teta,R2pp,'k.')
figure(4)
plot(teta,A2pp)
Matlab scrip donde se implementan el método de integración trapezoidal y el
método de Newton Rapzon

%Trapezoid rule
% clc
% clear all
% x0 = 0.00001;
% xf = 100;
% dx = 0.00001;
% x = [x0:dx:xf];
% n = (xf-x0)/dx;
% I = 0;
% for ik = 2:n
% xi = x(ik); x0 = x(ik-1);
% fi = 1/(sqrt(12*xi + 0.02*xi^2));
% f0 = 1/(sqrt(12*x0 + 0.02*x0^2));
% I = I + 0.5*dx*(fi+f0);
% end
% I

%%%%%%%%%%%%%%
%solve cosh(sqrt(0.02t))-1.3333=0
tn = 1;
rat = sqrt(0.02);
err=1
tol = 0.00001
cont = 0
while err>tol
tn = tn - (cosh(rat*tn)-1.3333)/(rat*sinh(rat*tn));
err = abs(cosh(rat*tn)-1.3333);
cont = cont + 1
if cont>100
error('There is no convergence')
end
end
tn
Scrip para resolver la velocidad y aceleración de un sistema mecánico. Debes agregar
este archivo para resolver otro problema. en un camino circular conducido por un
brazo excéntrico groved

%This matlab script solves the speed and acceleration of a particle


moving
%on a circular path driven by an excentric groved arm
tic
clear all
clc
b = 6; %radius of the circle
e = 2; %excentricity
w = 3; %rad/s angular speed of the grooved arm
theta = [0:1:180]*pi/180;
n = length(theta);
Sdot = zeros(1,n);
Rdot = Sdot;
Sdot2 = Sdot;
Rdot2 = Sdot;
for i = 1:n
th = theta(i);
alpha = asin(e*(sin(th))/b);
beta = alpha + th;
R = sqrt((e+b*cos(beta))^2+(b*sin(beta))^2);
Sp = R*w/(cos(alpha)); %Speed
Sdot(i) = Sp; %Speed vector
Rp = -R*w*tan(alpha); %R dot
Rdot(i) = Rp;
Spp2 = (2*Rp*w + Sp^2*sin(alpha)/b)/cos(alpha); % Tangential
acceleration
Sdot2(i) = Spp2;
Rdot2(i) = R*w^2 - Spp2*sin(alpha) - Sp^2*cos(alpha)/b;

end
an = Sdot.*Sdot/b; %normal acceleration
ac = [Sdot2' an'];
accel = sqrt(Sdot2.*Sdot2 + an.*an);

plot(theta,Sdot)
hold on
plot(theta,Rdot,'r--')
legend('Sdot','Rdot')
xlabel('Theta (rad)')
ylabel('Velocity components (m/s)')

figure (2)
plot(theta,Sdot2,'b.')
hold on
plot(theta,an,'r--')
plot(theta,accel,'k')
legend('Tangent','Normal','Total')
xlabel('Theta (rad)')
ylabel('Acceleration components (m/s^2)')

toc
Mecanismo Sliker-Crank cinemática.

%This script calculates the speed and velocity of the piston and
connecting
%rod of a slider-crank mechanism
clc
clear all

a = 3; %Crankshaft radius
b = 7; %Connecting rod length
w1 = 502.6;% Shaft angular speed (rad/s)
theta = [0:1:360]*pi/180; %Shaft angular position
n = length(theta);
w11 = [0 0 w1]; % Shaf angular velocity vector
for i = 1:n
th = theta(i);
alf = asin((a/b)*sin(th));
r1 = a*[cos(th) sin(th) 0];%vector of the shaft
r2 = b*[-cos(alf) sin(alf) 0];
VB = cross(w11,r1);
VB = VB(1:2); %Take only the i and j component
K = [1 -r2(2); 0 r2(1)];
VcW2 = inv(K)*VB';%vector containing Vc and w2
Vc(i) = VcW2(1);
w2 = VcW2(2);
w22(i) = w2;
aB = cross(w11,cross(w11,r1)); %Acceleration of B
f = aB' + w2^2*r2';
f = f(1:2);
aC_alfa2 = inv(K)*f;
aC(i) = aC_alfa2(1);
alfa2(i) = aC_alfa2(2);
pp = [0 0;r1(1:2)];
set(gcf,'position',[10,10,1000,533])%Set a good size of the figure
pp2 = [r1(1:2); (r1(1)-r2(1)), 0];
axis manual
pp2 = [r1(1:2); (r1(1)-r2(1)), 0];
plot(pp(:,1),pp(:,2),'ko-',pp2(:,1),pp2(:,2),'ro-');
AXIS([-4 11 -4 4])
pause(0.01)
end
theta = theta*180/pi;
figure(2)
plot(theta,Vc,'k')
hold on
plot(theta,w22,'r')
xlabel('Shaft angular position (Degrees)')
ylabel('Piston velocity (in/s); rod angular speed (rad/s)')
legend ('Piston velocity','Rod angular speed')
figure(3)
plot(theta,aC,'k')
hold on
plot(theta,alfa2,'ro')
xlabel('Shaft angular position (Degrees)')
ylabel('Piston acceleration (in/s2); rod angular acceleration (rad/s2)')
legend ('Piston acceleration','Rod angular acceleration')
Archivo para calcular fuerzas y momento en un mecanismo.
%File to solve a disc with a slider in a sloted arm.
clear all
clc
teta = [0:1:360]*pi/180; % Angular position of the crankshaft
n = length(teta);
w = 80; %disc angular speed
w1 = w*[0 0 1]; % disk angular velocity vector
mu = 0.2; %friction coefficient
W2 = 10; %lbf arm weight
m2 = W2/32.2;
W1 = 20; %disc weigth
m1 = W1/32.2; %disc weigth
s1 = 5/12; %pin-pivot distance in ft
s2 = 2; %horizontal distance between pivots
s3 = 15/12; %center of mass distance
k = 4.5/12; %radious of gyration
I = m2*k^2; %moment of inertia
w2 = zeros(1,n);
vrel = w2;
alfa = w2;
arel = w2;
N = w2;
Ax = w2; Ay = w2; M = w2;
for i = 1:n
tet = teta(i);
r1 = s1*[cos(tet) sin(tet) 0];
r2 = [(s2+s1*cos(tet)) s1*sin(tet) 0];
er = r2/sqrt(dot(r2,r2));
VB = cross(w1,r1);
VB = VB(1:2);

KK = [-r2(2) er(1); r2(1) er(2)];


w2vrel = inv(KK)*VB';
w22 = w2vrel(1);
VREL = w2vrel(2);
w2(i) = w22;
vrel(i)= VREL;
aB = -w*w*r1;
fact = aB + w22*w22*r2-2*cross(w22*[0 0 1],VREL*er);
fact = fact(1:2);
alfarel = inv(KK)*fact';
ALF = alfarel(1);
AREL = alfarel(2);
alfa(i) = ALF;
arel(i) = AREL;
aC = cross(ALF*[0 0 1],15*er/12)-w22*w22*15*er/12;
NN = ((I + (15/12)^2)*ALF + (5/12)*W2*er(1))/(sqrt(dot(r2,r2)));
N(i) = NN;
Ax(i) = m2*aC(1) + NN*(er(2) + mu*er(1));
Ay(i) = m2*aC(2) + W2 + NN*(er(1)+ mu*er(2));
Nv = NN*[er(2) -er(1) 0]; %make the vector normal force
Ff = mu*NN*er;
MM = -(cross(r1,Nv)+cross(r1,Ff));
M(i) = MM(3);

end
teta = 180*teta/pi;
plot(teta,Ax,'k')
hold on
plot(teta,Ay,'r.')
plot(teta,N,'c+')
%grid on
legend('Horizontal force','Vertical force','Pin normal force')
xlabel('Pin angular position (Degrees)')
ylabel('Force (lbf)')
figure(2)
plot(teta,M,'k')
xlabel('Pin angular position (Degrees)')
ylabel('Torque (lbf-ft)')
%grid on
Ejercicio Echeverry
clc

clear all

theta = [0:1:360]*pi/180; %Posicion angular cuerpo 2

a = 6; %Distancia entre soportes

b = 3; %Longitud cuerpo 2

w2 = [0 0 3]; %Velocidad angular cuerpo 2

aph2 = [0 0 0]; %Aceleracion angular cuerpo 2

n = length(theta);

for i =1:n

th = theta(i); %Angulo cuerpo 2

r1 = [a+(b*cos(th)) b*sin(th) 0]; %Vector Cuerpo 1

r2 = [b*cos(th) b*sin(th) 0]; %Vector cuerpo 2

VA = cross(w2,r2); %Producto cruz velocidad A

VA = VA(1:2); %Componente i y j velocidad A

Rvar = [r1(1) r1(2)]/sqrt(((r1(1))^2)+((r1(2))^2)); %Vector unitario Vrel y Arel

M = ((-r1(2)*Rvar(2))-(Rvar(1)*r1(1))); %Determinante

W1 = ((VA(1)*Rvar(2))-(Rvar(1)*VA(2)))/M; %Regla Cramer

w1 = [0 0 W1]; %Convertir w1 en vector con direccion k

w11(i) = W1; %Guarda los datos en un vector de longitud i

Vrel = ((-r1(2)*VA(2))-(VA(1)*r1(1)))/M; %Regla Cramer

Vr = Vrel*Rvar; %Vector Velocidad relativa

Vr = [Vr(1) Vr(2) 0]; %Agrega el componente k el vector Vr

AA = cross(w2,cross(w2,r2)); %Aceleracion del punto de contacto

H = AA-(cross(w1,cross(w1,r1)))-(cross((2*w1),Vr)); %Suma de componentes conocidos para


hallar Alpha1

H = H(1:2); %Vector H en componentes i y j

Alpha1 = ((H(1)*Rvar(2))-(Rvar(1)*H(2)))/M; %Aceleracion angular cuerpo 1

alpha(i) = Alpha1;
Arel = ((-r1(2)*H(2))-(H(1)*r1(1)))/M; %Aceleracion relativa

R = (10*Rvar)-[6 0];

pp = [-6 0;R(1:2)];

set(gcf,'position',[10,10,1000,533])

axis manual

pp2 = [0 0;r2(1:2)];

plot(pp(:,1),pp(:,2),'ko-',pp2(:,1),pp2(:,2),'ro-');

axis([-9 10 -6 6])

pause(0.01)

end

theta = theta*180/pi;

figure(2)

plot(theta,w11,'k')

hold on

plot(theta,alpha,'r')

xlabel('Posicion Angular cuerpo 2 (Grados)')

ylabel('Velocidad Angular(rad/s); Aceleracion Angular (rad/s^2)')

legend ('Velocidad angular','Aceleracion angular')

Potrebbero piacerti anche