Académique Documents
Professionnel Documents
Culture Documents
MECATRONICA
EQUIPOS DE LA MATERIA
TOPICOS SELECTOS DE
MECATRONICA
-MECATRONICA -
MECATRONICA
OBJETIVO
Que el grupo de la materia Tpicos Selectos de Mecatrnica sea capaz de desarrollar el funcionamiento
completo de un omni phantom.
MARCO TEORICO
ENCODER
Tipos de Encoders
En el estator hay como mnimo dos pares de fotorreceptor pticos, escalados un nmero entero
de pasos ms de paso. Al girar el rotor genera una seal cuadrada, el escalado hace que las
seales tengan un desfase de de periodo si el rotor gira en un sentido y de si gira en el
sentido contrario, lo que se utiliza para discriminar el sentido de giro.
2
-MECATRONICA -
El estator tiene un fotorreceptor por cada bit representado en el disco. El valor binario obtenido
de los fotorreceptores es nico para cada posicin del rotor y representa su posicin absoluta.
Se utiliza el cdigo Gray en lugar de un binario clsico porque en cada cambio de sector slo
cambia el estado de una de las bandas, evitando errores por falta de alineacin de los
captadores.
Para un encoder con n bandas en el disco, el rotor permite 2^n combinaciones, por lo cual la
resolucin ser 360 dividido entre los 2^n sectores; Por ejemplo para encoders de 12 y 16 bits
se obtiene una resolucin angular de 0.0879 y 0.00549 respectivamente.
Tpicamente un encoder incrmental solo tiene cuatro lneas: 2 de cuadratura, una de poder y
una tierra. Un encoder absoluto tiene una lnea de salida por cada bit, una lnea de poder y la
tierra.
3
-MECATRONICA -
4
-MECATRONICA -
ACELEROMETRO
Actualmente es posible construir acelermetros de tres ejes (X,Y,Z) en un slo chip de silicio, incluyendo en
el mismo la parte electrnica que se encarga de procesar las seales.
El Pololu minimu-9 es una unidad de medicin inercial (IMU), que viene equipado con un L3G4200D
giroscopio de 3 ejes y un LSM303DLH 3 ejes acelermetro y magnetmetro de 3 ejes en un pequeo 0.9 "x
0.6" tablero. Una interfaz IC accede a nueve rotaciones independientes, aceleracin y mediciones
magnticas que se pueden utilizar para calcular la orientacin absoluta del sensor.
Caractersticas
5
-MECATRONICA -
MATERIAL
- Encoders
- Sensor acelerometro
- Resistencias
- Conectores
- Cautin
- Estao
- Arduino
- Conectores hembra
- Cable plano
6
-MECATRONICA -
DESARROLLO
En este reporte se explicara en dos bloques para mejor una mejor explicacin del proyecto (Hardware y
Software)
HARDWARE
En esta seccin se busca que nuestro omni phantom se mueva de la siguiente manera:
Para ello se plantea incrustar a presin en las siguientes zonas los encoder:
7
-MECATRONICA -
Para la lectura de posicionamiento en grados del modelo mecnico, utilizaremos el Encoder Marca BOURNS
Modelo ACE-128. Absolute Contacting Encoder (ACE) para cada articulacin.
Vcc
10K
R8
10K
R7
10K
R6
10K
R5
10K
R4
10K
R3
10K
R2
10K
R1
8
1
GND
GND
4
3
2
1
Vcc
8
7
6
5
4
3
2
1
6
5
4
3
2
1
10
9
8
7
6
5
4
3
2
1
SIL-100-06
J2
SIL-100-10
J1
SIL-100-06
J3
1
2
3
4
5
6
5
6
7
8
8
-MECATRONICA -
9
-MECATRONICA -
Una vez soldados los componentes, se soldan las conexiones en pines para mejor manipulacin de
informacion y dispositivo
10
-MECATRONICA -
11
-MECATRONICA -
En la la punta de nuestro omni phantom se es necesaria una pieza de agarre para nuestro sensor el cual nos
brindara otros dos grados de movilidad para una mejor manipulacin de nuestro dispositivo.
El diseo es el siguiente:
PIEZA 1 PIEZA 2
PIEZA 3 ENSAMBLE
12
-MECATRONICA -
13
-MECATRONICA -
Pieza fisica
14
-MECATRONICA -
SOFTWARE:
};
float L1 = 14;
float L2 = 11.5;
float h1 = 7;
float h2 = 14;
float th1;
float gam1;
float gam2;
float gam3;
class Puerto
{ public:
int Pin;
int PinAcarreo;
int Resultado;
int Resultado2;
int k;
int r;
int i;
int PinIniObj;
Puerto(int PortIni,int PortEnd){
for (i=PortIni;i<=PortEnd;i++){
pinMode(i,INPUT);
}
Pin=0;
PinAcarreo=0;
Resultado=0;
Resultado2;
k=0;
i=0;
PinIniObj=PortIni;
}
int Leer(){
for(i=0; i<8;i++){
15
-MECATRONICA -
Pin=digitalRead(PinIniObj+i);
PinAcarreo=Pin<<i;
Resultado=Resultado|PinAcarreo;
}
for(k=0;k<=127;k++){
if (Resultado==M[k][1]){
Resultado2=M[k][0];
r=map(Resultado2,0,127,0,359);
return (r);
}
}
Resultado=0;
}
};
void end_effector(int th1,int gam1,int gam2,int gam3){
float Link1 = (cos(th1)*(L1*cos(gam1 + gam2) + h2*sin(gam1) + L2*cos(gam1 + gam2 + gam3)));
float Link2 = (sin(th1)*(L1*cos(gam1 + gam2) + h2*sin(gam1) + L2*cos(gam1 + gam2 + gam3)));
float Link3 = (h1 - L1*sin(gam1 + gam2) + h2*cos(gam1) - L2*sin(gam1 + gam2 + gam3));
Serial.print(th1);
Serial.print(" ");
Serial.print(gam1);
Serial.print(" ");
Serial.print(gam2);
Serial.print(" ");
Serial.print(gam3);
Serial.print(" ");
Serial.print(Link1);
Serial.print(" ");
Serial.print(Link2);
Serial.print(" ");
Serial.println(Link3);
}
//------------------- OBJETOS-------------------------------
Puerto portA = Puerto (22,29);
Puerto portB = Puerto (30,37);
Puerto portC = Puerto (38,45);
Puerto portD = Puerto (46,53);
//----------------------------------------------------------
void setup()
{
Serial.begin(9600);
}
void loop()
{
int th1=portA.Leer();
int gam1=portB.Leer();
int gam2=portC.Leer();
int gam3=portD.Leer();
end_effector(th1,gam1,gam2,gam3);
}
16
-MECATRONICA -
17
-MECATRONICA -
#define PRINT_EULER 1 //Will print the Euler angles Roll, Pitch and Yaw
#define STATUS_LED 13
float G_Dt=0.02; // Integration time (DCM algorithm) We will run the integration loop at 50Hz if possible
int gyro_x;
int gyro_y;
int gyro_z;
int accel_x;
int accel_y;
int accel_z;
int magnetom_x;
int magnetom_y;
int magnetom_z;
float c_magnetom_x;
float c_magnetom_y;
float c_magnetom_z;
float MAG_Heading;
// Euler angles
float roll;
float pitch;
float yaw;
float DCM_Matrix[3][3]= {
18
-MECATRONICA -
{
1,0,0 }
,{
0,1,0 }
,{
0,0,1 }
};
float Update_Matrix[3][3]={{0,1,2},{3,4,5},{6,7,8}}; //Gyros here
float Temporary_Matrix[3][3]={
{
0,0,0 }
,{
0,0,0 }
,{
0,0,0 }
};
};
float h1 = 14;
float L1 = 14;
float L2 = 14;
float L3 = 11.5;
19
-MECATRONICA -
int th1;
int gam1;
int gam2;
int gam3;
class Puerto
{ public:
int Pin;
int PinAcarreo;
int Resultado;
int Resultado2;
int k;
int r;
int i;
int PinIniObj;
int Leer(){
for(i=0; i<8;i++){
Pin=digitalRead(PinIniObj+i);
PinAcarreo=Pin<<i;
Resultado=Resultado|PinAcarreo;
}
for(k=0;k<=127;k++){
if (Resultado==M[k][1]){
Resultado2=M[k][0];
r=map(Resultado2,0,127,0,359);
return (r);
}
}
Resultado=0;
20
-MECATRONICA -
}
};
Serial.print(th1);
Serial.print(" ");
Serial.print(gam1);
Serial.print(" ");
Serial.print(gam2);
Serial.print(" ");
Serial.print(gam3);
Serial.print(" ");
Serial.print(Link1);
Serial.print(" ");
Serial.print(Link2);
Serial.print(" ");
Serial.println(Link3);
}
//------------------- OBJETOS-------------------------------
Puerto portA = Puerto (22,29);
Puerto portB = Puerto (30,37);
Puerto portC = Puerto (38,45);
Puerto portD = Puerto (46,53);
//----------------------------------------------------------
void setup()
{
Serial.begin(115200);
pinMode (STATUS_LED,OUTPUT); // Status LED
21
-MECATRONICA -
I2C_Init();
digitalWrite(STATUS_LED,LOW);
delay(1500);
Accel_Init();
Compass_Init();
Gyro_Init();
delay(20);
AN_OFFSET[5]-=GRAVITY*SENSOR_SIGN[5];
//Serial.println("Offset:");
for(int y=0; y<6; y++)
Serial.println(AN_OFFSET[y]);
delay(2000);
digitalWrite(STATUS_LED,HIGH);
timer=millis();
delay(20);
counter=0;
}
22
-MECATRONICA -
timer=millis();
if (timer>timer_old)
G_Dt = (timer-timer_old)/1000.0; // Real time of loop run. We use this on the DCM algorithm (gyro
integration time)
else
G_Dt = 0;
// Calculations...
Matrix_update();
Normalize();
Drift_correction();
Euler_angles();
// ***
printdata();
}
///////////////////////////////////////////////////////PHANTOM
th1=portA.Leer();
gam1=portB.Leer();
gam2=portC.Leer();
gam3=portD.Leer();
end_effector(th1,gam1,gam2,gam3);
23
-MECATRONICA -
float cos_pitch;
float sin_pitch;
cos_roll = cos(roll);
sin_roll = sin(roll);
cos_pitch = cos(pitch);
sin_pitch = sin(pitch);
// adjust for LSM303 compass axis offsets/sensitivity differences by scaling to +/-0.5 range
c_magnetom_x = (float)(magnetom_x - SENSOR_SIGN[6]*M_X_MIN) / (M_X_MAX - M_X_MIN) -
SENSOR_SIGN[6]*0.5;
c_magnetom_y = (float)(magnetom_y - SENSOR_SIGN[7]*M_Y_MIN) / (M_Y_MAX - M_Y_MIN) -
SENSOR_SIGN[7]*0.5;
c_magnetom_z = (float)(magnetom_z - SENSOR_SIGN[8]*M_Z_MIN) / (M_Z_MAX - M_Z_MIN) -
SENSOR_SIGN[8]*0.5;
Vector_Cross_Product(&temporary[2][0],&temporary[0][0],&temporary[1][0]); // c= a x b //eq.20
24
-MECATRONICA -
/**************************************************/
void Drift_correction(void)
{
float mag_heading_x;
float mag_heading_y;
float errorCourse;
//Compensation the Roll, Pitch and Yaw drift.
static float Scaled_Omega_P[3];
static float Scaled_Omega_I[3];
float Accel_magnitude;
float Accel_weight;
Vector_Scale(&Scaled_Omega_I[0],&errorRollPitch[0],Ki_ROLLPITCH*Accel_weight);
Vector_Add(Omega_I,Omega_I,Scaled_Omega_I);
//*****YAW***************
// We make the gyro YAW drift correction based on compass magnetic heading
mag_heading_x = cos(MAG_Heading);
mag_heading_y = sin(MAG_Heading);
errorCourse=(DCM_Matrix[0][0]*mag_heading_y) - (DCM_Matrix[1][0]*mag_heading_x); //Calculating
YAW error
Vector_Scale(errorYaw,&DCM_Matrix[2][0],errorCourse); //Applys the yaw correction to the XYZ rotation
of the aircraft, depeding the position.
25
-MECATRONICA -
Vector_Scale(&Scaled_Omega_P[0],&errorYaw[0],Kp_YAW);//.01proportional of YAW.
Vector_Add(Omega_P,Omega_P,Scaled_Omega_P);//Adding Proportional.
Vector_Scale(&Scaled_Omega_I[0],&errorYaw[0],Ki_YAW);//.00001Integrator
Vector_Add(Omega_I,Omega_I,Scaled_Omega_I);//adding integrator to the Omega_I
}
/**************************************************/
/*
void Accel_adjust(void)
{
Accel_Vector[1] += Accel_Scale(speed_3d*Omega[2]); // Centrifugal force on Acc_y = GPS_speed*GyroZ
Accel_Vector[2] -= Accel_Scale(speed_3d*Omega[1]); // Centrifugal force on Acc_z = GPS_speed*GyroY
}
*/
/**************************************************/
void Matrix_update(void)
{
Gyro_Vector[0]=Gyro_Scaled_X(gyro_x); //gyro x roll
Gyro_Vector[1]=Gyro_Scaled_Y(gyro_y); //gyro y pitch
Gyro_Vector[2]=Gyro_Scaled_Z(gyro_z); //gyro Z yaw
Accel_Vector[0]=accel_x;
Accel_Vector[1]=accel_y;
Accel_Vector[2]=accel_z;
//Accel_adjust(); //Remove centrifugal acceleration. We are not using this function in this version - we
have no speed measurement
#if OUTPUTMODE==1
Update_Matrix[0][0]=0;
Update_Matrix[0][1]=-G_Dt*Omega_Vector[2];//-z
Update_Matrix[0][2]=G_Dt*Omega_Vector[1];//y
Update_Matrix[1][0]=G_Dt*Omega_Vector[2];//z
Update_Matrix[1][1]=0;
Update_Matrix[1][2]=-G_Dt*Omega_Vector[0];//-x
Update_Matrix[2][0]=-G_Dt*Omega_Vector[1];//-y
Update_Matrix[2][1]=G_Dt*Omega_Vector[0];//x
Update_Matrix[2][2]=0;
#else // Uncorrected data (no drift correction)
Update_Matrix[0][0]=0;
Update_Matrix[0][1]=-G_Dt*Gyro_Vector[2];//-z
26
-MECATRONICA -
Update_Matrix[0][2]=G_Dt*Gyro_Vector[1];//y
Update_Matrix[1][0]=G_Dt*Gyro_Vector[2];//z
Update_Matrix[1][1]=0;
Update_Matrix[1][2]=-G_Dt*Gyro_Vector[0];
Update_Matrix[2][0]=-G_Dt*Gyro_Vector[1];
Update_Matrix[2][1]=G_Dt*Gyro_Vector[0];
Update_Matrix[2][2]=0;
#endif
Matrix_Multiply(DCM_Matrix,Update_Matrix,Temporary_Matrix); //a*b=c
void Euler_angles(void)
{
pitch = -asin(DCM_Matrix[2][0]);
roll = atan2(DCM_Matrix[2][1],DCM_Matrix[2][2]);
yaw = atan2(DCM_Matrix[1][0],DCM_Matrix[0][0]);
}
#include <L3G.h>
#include <LSM303.h>
L3G gyro;
LSM303 compass;
void I2C_Init()
{
Wire.begin();
}
void Gyro_Init()
{
gyro.init();
gyro.writeReg(L3G_CTRL_REG4, 0x20); // 2000 dps full scale
gyro.writeReg(L3G_CTRL_REG1, 0x0F); // normal power mode, all axes enabled, 100 Hz
}
void Read_Gyro()
27
-MECATRONICA -
{
gyro.read();
AN[0] = gyro.g.x;
AN[1] = gyro.g.y;
AN[2] = gyro.g.z;
gyro_x = SENSOR_SIGN[0] * (AN[0] - AN_OFFSET[0]);
gyro_y = SENSOR_SIGN[1] * (AN[1] - AN_OFFSET[1]);
gyro_z = SENSOR_SIGN[2] * (AN[2] - AN_OFFSET[2]);
}
void Accel_Init()
{
compass.init();
compass.enableDefault();
switch (compass.getDeviceType())
{
case LSM303::device_D:
compass.writeReg(LSM303::CTRL2, 0x18); // 8 g full scale: AFS = 011
break;
case LSM303::device_DLHC:
compass.writeReg(LSM303::CTRL_REG4_A, 0x28); // 8 g full scale: FS = 10; high resolution output mode
break;
default: // DLM, DLH
compass.writeReg(LSM303::CTRL_REG4_A, 0x30); // 8 g full scale: FS = 11
}
}
AN[3] = compass.a.x >> 4; // shift left 4 bits to use 12-bit representation (1 g = 256)
AN[4] = compass.a.y >> 4;
AN[5] = compass.a.z >> 4;
accel_x = SENSOR_SIGN[3] * (AN[3] - AN_OFFSET[3]);
accel_y = SENSOR_SIGN[4] * (AN[4] - AN_OFFSET[4]);
accel_z = SENSOR_SIGN[5] * (AN[5] - AN_OFFSET[5]);
}
void Compass_Init()
{
// doesn't need to do anything because Accel_Init() should have already called compass.enableDefault()
}
28
-MECATRONICA -
void Read_Compass()
{
compass.readMag();
#if PRINT_EULER == 1
Serial.print("ANG:");
Serial.print(ToDeg(roll));
Serial.print(",");
Serial.print(ToDeg(pitch));
Serial.print(",");
Serial.print(ToDeg(yaw));
#endif
#if PRINT_ANALOGS==1
Serial.print(",AN:");
Serial.print(AN[0]); //(int)read_adc(0)
Serial.print(",");
Serial.print(AN[1]);
Serial.print(",");
Serial.print(AN[2]);
Serial.print(",");
Serial.print(AN[3]);
Serial.print (",");
Serial.print(AN[4]);
Serial.print (",");
Serial.print(AN[5]);
Serial.print(",");
Serial.print(c_magnetom_x);
Serial.print (",");
Serial.print(c_magnetom_y);
Serial.print (",");
Serial.print(c_magnetom_z);
#endif
/*#if PRINT_DCM == 1
Serial.print (",DCM:");
Serial.print(convert_to_dec(DCM_Matrix[0][0]));
Serial.print (",");
29
-MECATRONICA -
Serial.print(convert_to_dec(DCM_Matrix[0][1]));
Serial.print (",");
Serial.print(convert_to_dec(DCM_Matrix[0][2]));
Serial.print (",");
Serial.print(convert_to_dec(DCM_Matrix[1][0]));
Serial.print (",");
Serial.print(convert_to_dec(DCM_Matrix[1][1]));
Serial.print (",");
Serial.print(convert_to_dec(DCM_Matrix[1][2]));
Serial.print (",");
Serial.print(convert_to_dec(DCM_Matrix[2][0]));
Serial.print (",");
Serial.print(convert_to_dec(DCM_Matrix[2][1]));
Serial.print (",");
Serial.print(convert_to_dec(DCM_Matrix[2][2]));
#endif*/
Serial.println();
long convert_to_dec(float x)
{
return x*10000000;
}
float Vector_Dot_Product(float vector1[3],float vector2[3])
{
float op=0;
return op;
}
30
-MECATRONICA -
float test=mat[x][y];
}
}
}
31
-MECATRONICA -
32
-MECATRONICA -
MODELO MATEMATICO
%T4 = obtenT( L2, 0, 0, 0, 0, 0,1);
clear all
close all
clc %T04 = T0*T1*T2*T3*T4
%Ts = simple(T04)
%%Esta bien pero debo considerar los angulos en %Pos = Ts(1:3,4)
los que se encuentran
%%los links, ya que sino considera que estan T0 = obtenT( 0, 0, 0, 0, 0,th1,1);
desplazados el linea recta. T1 = obtenT( 0, 0, h1, 0, gam1, 0,1);
syms h1 h2 real T2 = obtenT( 0, 0, L1, 0, gam2, 0,1);
syms L1 L2 L3 real T3 = obtenT( 0, 0, L2, 0, gam3, 0,1);
syms th1 gam1 gam2 gam3 real T4 = obtenT( 0, 0, L3, 0, 0, 0,1);
33
-MECATRONICA -
OBSERVACIONES Y CONCLUSIONES
Para la correcta realizacin de este proyecto, se cuenta con la colaboracin de cada uno de los equipos que
forman el grupo de tpicos selectos de Mecatrnica. Donde se definieron partes necesarias para lograr la
lectura de la posicin del brazo.
En orden del cumplimiento de dicha tarea, se colocaron encoders absolutos en cada articulacin del brazo.
Para lo cual se necesit ajustar el orificio, para que al mover el brazo el movimiento se transmita al eje del
encoder. Sumando un total de 4 articulaciones. La interpretacin de cada posicin es ofrecida por el
software de Arduino.
Primeramente se dise una pieza que agregara dos grados de libertad al brazo, con la finalidad de recrear
los movimientos de un Omniphantom, dando la capacidad al proyecto de tener ms fluidez a la hora de
realizar sus movimientos y cubrir todos los grados de libertad en los ejes x, y, z. Sin embargo por cuestiones
de suministro no fue posible imprimir en 3D dicha pieza. Lo cual nos oblig a recurrir a un modelo
experimental en papel cascaron.
En adicin, se simula el posicionamiento en el espacio con el software de MATLAB. Lo que lleva a concluir
que el trabajo presentado puede ser implementado para un proyecto ms avanzado en robtica, utilizando
la cinemtica para cerrar el lazo de control, haciendo que se tenga un brazo robtico didctico con capacidad
para recordar coordenadas y que se asemeje a un brazo industrial.
BIBLIOGRAFIA
http://www.pololu.com/product/1264
https://www.bourns.com/pdfs/ace.pdf
http://www.forosdeelectronica.com/f16/encoders-informacion-tecnica-25/
http://www.dynamoelectronics.com/index.php?product_id=1004&page=shop.product_details&category_id
=128&flypage=dynamo.tpl&option=com_virtuemart&Itemid=58
34