Professional Documents
Culture Documents
Las siguientes lneas corresponden al desarrollo de las lneas de programacin con MATLAB para poder visualizar un sistema
de pndulos en pleno movimiento. La mayora de las lneas de programacin se encuentran comentadas
El tiempo que se pueda dedicar a implementar este programa es muy importante y espero que sirva para ayudar a otros
investigadores.
Se aprecia la ventana de MATLAB abierta y dentro de ella todas lneas del algoritmo respectivo, todas estas lneas se
encuentran ms abajo, solo deber copiarlas y ejecutarlas en MATLAB, asi de fcil. Ademas cada lnea importante
esta comentada.
Posteriormente estar publicando lneas de programacin en MATLAB de diversas aplicaciones como Sistema Gravitacional,
Interaccin de partculas, Cinemtica Directa y Cinemtica Inversa para robtica, Comunicacin RS232 con
microcontroladores, etc.
En siguientes publicaciones estar comentando acerca de la comunicacin RS232 en Visual Basic 6.0 con un
microcontrolador para controlar un sistema de conteo en display siete segmentos de cuatro dgitos pero desarrollado en
hardware, estar atentos.
Este deber ser el grafico que deber visualizar del sistema de pndulos en pleno movimiento, espero sea de mucha
utilidad.
Theta1_graf = [];
Theta2_graf = [];
Theta3_graf = [];
Theta4_graf = [];
Theta5_graf = [];
Theta6_graf = [];
Theta7_graf = [];
Theta8_graf = [];
Theta9_graf = [];
Theta10_graf = [];
Theta11_graf = [];
Theta12_graf = [];
Theta13_graf = [];
Theta14_graf = [];
Theta15_graf = [];
% Parametros iniciales
h = 0.12;
C = 0.75;
g = 9.81;
m = 50;
L1 = 9.00;
L2 = 8.70;
L3 = 8.40;
L4 = 8.10;
L5 = 7.80;
L6 = 7.50;
L7 = 7.20;
L8 = 6.90;
L9 = 6.60;
L10 = 6.30;
L11 = 6.00;
L12 = 5.70;
L13 = 5.40;
L14 = 5.10;
L15 = 4.80;
v1 = 0;
v2 = 0;
v3 = 0;
v4 = 0;
v5 = 0;
v6 = 0;
v7 = 0;
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
v8 = 0;
v9 = 0;
v10 = 0;
v11 = 0;
v12 = 0;
v13 = 0;
v14 = 0;
v15 = 0;
%
%
%
%
%
%
%
%
Velocidad
Velocidad
Velocidad
Velocidad
Velocidad
Velocidad
Velocidad
Velocidad
lineal
lineal
lineal
lineal
lineal
lineal
lineal
lineal
del
del
del
del
del
del
del
del
pendulo
pendulo
pendulo
pendulo
pendulo
pendulo
pendulo
pendulo
8
9
10
11
12
13
14
15
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
Matriz
Matriz
Matriz
Matriz
Matriz
Matriz
Matriz
Matriz
Matriz
Matriz
Matriz
Matriz
Matriz
Matriz
Matriz
de
de
de
de
de
de
de
de
de
de
de
de
de
de
de
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
Filas
Filas
Filas
Filas
Filas
Filas
Filas
Filas
Filas
Filas
Filas
Filas
Filas
Filas
Filas
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
Columna
Columna
Columna
Columna
Columna
Columna
Columna
Columna
Columna
Columna
Columna
Columna
Columna
Columna
Columna
w1 = v1/L1;
w2 = v2/L2;
w3 = v3/L3;
w4 = v4/L4;
w5 = v5/L5;
w6 = v6/L6;
w7 = v7/L7;
w8 = v8/L8;
w9 = v9/L9;
w10 = v10/L10;
w11 = v11/L11;
w12 = v12/L12;
w13 = v13/L13;
w14 = v14/L14;
w15 = v15/L15;
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
Velocidad
Velocidad
Velocidad
Velocidad
Velocidad
Velocidad
Velocidad
Velocidad
Velocidad
Velocidad
Velocidad
Velocidad
Velocidad
Velocidad
Velocidad
% Entrada inicial
Alpha1 = -(L1*w1*C + m*g*sin(Theta1))/(L1*m);
Alpha2 = -(L2*w2*C + m*g*sin(Theta2))/(L2*m);
Alpha3 = -(L3*w3*C + m*g*sin(Theta3))/(L3*m);
Alpha4 = -(L4*w4*C + m*g*sin(Theta4))/(L4*m);
Alpha5 = -(L5*w5*C + m*g*sin(Theta5))/(L5*m);
Alpha6 = -(L6*w6*C + m*g*sin(Theta6))/(L6*m);
Alpha7 = -(L7*w7*C + m*g*sin(Theta7))/(L7*m);
Alpha8 = -(L8*w8*C + m*g*sin(Theta8))/(L8*m);
Alpha9 = -(L9*w9*C + m*g*sin(Theta9))/(L9*m);
Alpha10 = -(L10*w10*C + m*g*sin(Theta10))/(L10*m);
Alpha11 = -(L11*w11*C + m*g*sin(Theta11))/(L11*m);
Alpha12 = -(L12*w12*C + m*g*sin(Theta12))/(L12*m);
Alpha13 = -(L13*w13*C + m*g*sin(Theta13))/(L13*m);
Alpha14 = -(L14*w14*C + m*g*sin(Theta14))/(L14*m);
Alpha15 = -(L15*w15*C + m*g*sin(Theta15))/(L15*m);
angular
angular
angular
angular
angular
angular
angular
angular
angular
angular
angular
angular
angular
angular
angular
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Aceleracion
Aceleracion
Aceleracion
Aceleracion
Aceleracion
Aceleracion
Aceleracion
Aceleracion
Aceleracion
Aceleracion
Aceleracion
Aceleracion
Aceleracion
Aceleracion
Aceleracion
angular
angular
angular
angular
angular
angular
angular
angular
angular
angular
angular
angular
angular
angular
angular
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
figure(1)
for step = 1:900
hold off
plot(x1(1),x1(2),'o', 'MarkerFaceColor','g','MarkerSize',15);
hold on
plot([0;x1(1)],[0;x1(2)],'g');
hold on
plot(x2(1),x2(2),'o', 'MarkerFaceColor','r','MarkerSize',15);
hold on
plot([0;x2(1)],[0;x2(2)],'r');
hold on
plot(x3(1),x3(2),'o', 'MarkerFaceColor','b','MarkerSize',15);
hold on
plot([0;x3(1)],[0;x3(2)],'b');
hold on
plot(x4(1),x4(2),'o', 'MarkerFaceColor','c','MarkerSize',15);
hold on
plot([0;x4(1)],[0;x4(2)],'c');
hold on
plot(x5(1),x5(2),'o', 'MarkerFaceColor','m','MarkerSize',15);
hold on
plot([0;x5(1)],[0;x5(2)],'m');
hold on
plot(x6(1),x6(2),'o', 'MarkerFaceColor','y','MarkerSize',15);
hold on
plot([0;x6(1)],[0;x6(2)],'y');
hold on
plot(x7(1),x7(2),'o', 'MarkerFaceColor','black','MarkerSize',15);
hold on
plot([0;x7(1)],[0;x7(2)],'black');
hold on
plot(x8(1),x8(2),'o', 'MarkerFaceColor','g','MarkerSize',15);
hold on
plot([0;x8(1)],[0;x8(2)],'g');
hold on
plot(x9(1),x9(2),'o', 'MarkerFaceColor','r','MarkerSize',15);
hold on
plot([0;x9(1)],[0;x9(2)],'r');
hold on
plot(x10(1),x10(2),'o', 'MarkerFaceColor','b','MarkerSize',15);
hold on
plot([0;x10(1)],[0;x10(2)],'b');
hold on
plot(x11(1),x11(2),'o', 'MarkerFaceColor','c','MarkerSize',15);
hold on
plot([0;x11(1)],[0;x11(2)],'c');
hold on
plot(x12(1),x12(2),'o', 'MarkerFaceColor','m','MarkerSize',15);
hold on
plot([0;x12(1)],[0;x12(2)],'m');
hold on
plot(x13(1),x13(2),'o', 'MarkerFaceColor','y','MarkerSize',15);
hold on
plot([0;x13(1)],[0;x13(2)],'y');
hold on
plot(x14(1),x14(2),'o', 'MarkerFaceColor','black','MarkerSize',15);
hold on
plot([0;x14(1)],[0;x14(2)],'black');
hold on
plot(x15(1),x15(2),'o', 'MarkerFaceColor','g','MarkerSize',15);
hold on
plot([0;x15(1)],[0;x15(2)],'g');
title(['Proceso de simulacion : ' num2str(step)]);
simulacion
grid on
axis([-(L1+2) (L1+2) -(L1+2) 0]);
mayor
set(gca,'dataAspectRatio',[1 1 1])
pause(0.001);
Theta1_ant = Theta1;
Theta2_ant = Theta2;
Theta3_ant = Theta3;
Theta4_ant = Theta4;
Theta5_ant = Theta5;
Theta6_ant = Theta6;
Theta7_ant = Theta7;
Theta8_ant = Theta8;
Theta9_ant = Theta9;
Theta10_ant = Theta10;
Theta11_ant = Theta11;
Theta12_ant = Theta12;
Theta13_ant = Theta13;
Theta14_ant = Theta14;
Theta15_ant = Theta15;
w1_ant
w2_ant
w3_ant
w4_ant
w5_ant
=
=
=
=
=
w1;
w2;
w3;
w4;
w5;
w6_ant = w6;
w7_ant = w7;
w8_ant = w8;
w9_ant = w9;
w10_ant = w10;
w11_ant = w11;
w12_ant = w12;
w13_ant = w13;
w14_ant = w14;
w15_ant = w15;
% Paso de integracin
wpm1 = w1_ant + (h/2)*Alpha1;
wpm2 = w2_ant + (h/2)*Alpha2;
wpm3 = w3_ant + (h/2)*Alpha3;
wpm4 = w4_ant + (h/2)*Alpha4;
wpm5 = w5_ant + (h/2)*Alpha5;
wpm6 = w6_ant + (h/2)*Alpha6;
wpm7 = w7_ant + (h/2)*Alpha7;
wpm8 = w8_ant + (h/2)*Alpha8;
wpm9 = w9_ant + (h/2)*Alpha9;
wpm10 = w10_ant + (h/2)*Alpha10;
wpm11 = w11_ant + (h/2)*Alpha11;
wpm12 = w12_ant + (h/2)*Alpha12;
wpm13 = w13_ant + (h/2)*Alpha13;
wpm14 = w14_ant + (h/2)*Alpha14;
wpm15 = w15_ant + (h/2)*Alpha15;
Theta1_pm = Theta1_ant +
Theta2_pm = Theta2_ant +
Theta3_pm = Theta3_ant +
Theta4_pm = Theta4_ant +
Theta5_pm = Theta5_ant +
Theta6_pm = Theta6_ant +
Theta7_pm = Theta7_ant +
Theta8_pm = Theta8_ant +
Theta9_pm = Theta9_ant +
Theta10_pm = Theta10_ant
Theta11_pm = Theta11_ant
Theta12_pm = Theta12_ant
Theta13_pm = Theta13_ant
(h/2)*w1_ant;
(h/2)*w2_ant;
(h/2)*w3_ant;
(h/2)*w4_ant;
(h/2)*w5_ant;
(h/2)*w6_ant;
(h/2)*w7_ant;
(h/2)*w8_ant;
(h/2)*w9_ant;
+ (h/2)*w10_ant;
+ (h/2)*w11_ant;
+ (h/2)*w12_ant;
+ (h/2)*w13_ant;
w1 = w1_ant +
w2 = w2_ant +
w3 = w3_ant +
w4 = w4_ant +
w5 = w5_ant +
w6 = w6_ant +
w7 = w7_ant +
w8 = w8_ant +
w9 = w9_ant +
w10 = w10_ant
w11 = w11_ant
w12 = w12_ant
w13 = w13_ant
w14 = w14_ant
w15 = w15_ant
Theta1
Theta2
Theta3
Theta4
Theta5
Theta6
=
=
=
=
=
=
h*Alpha1_pm;
h*Alpha2_pm;
h*Alpha3_pm;
h*Alpha4_pm;
h*Alpha5_pm;
h*Alpha6_pm;
h*Alpha7_pm;
h*Alpha8_pm;
h*Alpha9_pm;
+ h*Alpha10_pm;
+ h*Alpha11_pm;
+ h*Alpha12_pm;
+ h*Alpha13_pm;
+ h*Alpha14_pm;
+ h*Alpha15_pm;
Theta1_ant
Theta2_ant
Theta3_ant
Theta4_ant
Theta5_ant
Theta6_ant
+
+
+
+
+
+
h*wpm1;
h*wpm2;
h*wpm3;
h*wpm4;
h*wpm5;
h*wpm6;
Theta7 = Theta7_ant +
Theta8 = Theta8_ant +
Theta9 = Theta9_ant +
Theta10 = Theta10_ant
Theta11 = Theta11_ant
Theta12 = Theta12_ant
Theta13 = Theta13_ant
Theta14 = Theta14_ant
Theta15 = Theta15_ant
h*wpm7;
h*wpm8;
h*wpm9;
+ h*wpm10;
+ h*wpm11;
+ h*wpm12;
+ h*wpm13;
+ h*wpm14;
+ h*wpm15;
x1 = [L1*sin(Theta1);-L1*cos(Theta1)];
x2 = [L2*sin(Theta2);-L2*cos(Theta2)];
x3 = [L3*sin(Theta3);-L3*cos(Theta3)];
x4 = [L4*sin(Theta4);-L4*cos(Theta4)];
x5 = [L5*sin(Theta5);-L5*cos(Theta5)];
x6 = [L6*sin(Theta6);-L6*cos(Theta6)];
x7 = [L7*sin(Theta7);-L7*cos(Theta7)];
x8 = [L8*sin(Theta8);-L8*cos(Theta8)];
x9 = [L9*sin(Theta9);-L9*cos(Theta9)];
x10 = [L10*sin(Theta10);-L10*cos(Theta10)];
x11 = [L11*sin(Theta11);-L11*cos(Theta11)];
x12 = [L12*sin(Theta12);-L12*cos(Theta12)];
x13 = [L13*sin(Theta13);-L13*cos(Theta13)];
x14 = [L14*sin(Theta14);-L14*cos(Theta14)];
x15 = [L15*sin(Theta15);-L15*cos(Theta15)];
Alpha1 = -(L1*w1*C + m*g*sin(Theta1))/(L1*m);
Alpha2 = -(L2*w2*C + m*g*sin(Theta2))/(L2*m);
Alpha3 = -(L3*w3*C + m*g*sin(Theta3))/(L3*m);
Alpha4 = -(L4*w4*C + m*g*sin(Theta4))/(L4*m);
Alpha5 = -(L5*w5*C + m*g*sin(Theta5))/(L5*m);
Alpha6 = -(L6*w6*C + m*g*sin(Theta6))/(L6*m);
Alpha7 = -(L7*w7*C + m*g*sin(Theta7))/(L7*m);
Alpha8 = -(L8*w8*C + m*g*sin(Theta8))/(L8*m);
Alpha9 = -(L9*w9*C + m*g*sin(Theta9))/(L9*m);
Alpha10 = -(L10*w10*C + m*g*sin(Theta10))/(L10*m);
Alpha11 = -(L11*w11*C + m*g*sin(Theta11))/(L11*m);
Alpha12 = -(L12*w12*C + m*g*sin(Theta12))/(L12*m);
Alpha13 = -(L13*w13*C + m*g*sin(Theta13))/(L13*m);
Alpha14 = -(L14*w14*C + m*g*sin(Theta14))/(L14*m);
Alpha15 = -(L15*w15*C + m*g*sin(Theta15))/(L15*m);
figure(2)
plot(Theta1_graf,'g','MarkerSize',15);
hold on
plot(Theta2_graf,'r','MarkerSize',15);
hold on
plot(Theta3_graf,'b','MarkerSize',15);
hold on
plot(Theta4_graf,'c','MarkerSize',15);
hold on
plot(Theta5_graf,'m','MarkerSize',15);
hold on
plot(Theta6_graf,'y','MarkerSize',15);
hold on
plot(Theta7_graf,'black','MarkerSize',15);
hold on
plot(Theta8_graf,'g','MarkerSize',15);
hold on
plot(Theta9_graf,'r','MarkerSize',15);
hold on
plot(Theta10_graf,'b','MarkerSize',15);
hold on
plot(Theta11_graf,'c','MarkerSize',15);
hold on
plot(Theta12_graf,'m','MarkerSize',15);
%
%
%
%
%
%
hold on
plot(Theta13_graf,'y','MarkerSize',15);
hold on
plot(Theta14_graf,'black','MarkerSize',15);
hold on
plot(Theta15_graf,'g','MarkerSize',15);
Espero que esta aplicacin sea de mucha utilidad y de seguro debera tener mejoras, las que posteriormente estare publicando. Gracias
Ingeniero Electronico Monteza Zevallos Fidel Tomas
V.J.M.J.