Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Revision 1:d86f732b4db0, committed 2015-10-16
- Comitter:
- Soto
- Date:
- Fri Oct 16 04:39:29 2015 +0000
- Parent:
- 0:294d306fd915
- Commit message:
- version 1.2
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 294d306fd915 -r d86f732b4db0 main.cpp
--- a/main.cpp Thu Oct 15 17:24:09 2015 +0000
+++ b/main.cpp Fri Oct 16 04:39:29 2015 +0000
@@ -43,7 +43,7 @@
int Casting();
void Ultima_Posicion(void);
void SlowMotion(float NewPos, float AlmostLast,Servo LowServo);
-
+void Home(void);
//Comando para iniciar un comunicacion entre la FRDM-KL-Z y la computador
@@ -63,17 +63,18 @@
DynHombro.push_back(0.5);
DynCodo.push_back(0.5);
DynMuneca.push_back(0.5);
- DynGarra.push_back(0.5);
+ DynGarra.push_back(0.7);
+ //*****************INTIT***********************
- Garra=DynGarra[0];
- Muneca=DynMuneca[0];
- Codo=DynCodo[0];
- Hombro=DynCodo[0];
- Eje=DynEje[0];
-
+ Eje=0.5;
+ Hombro=0.5;
+ Codo=0.5;
+ Muneca=0.5;
+ Garra=0.7;
+ //****************FOREVER**********************
while(1){ //Loop infinito
- printf("\n\nSleccion\n 'C' para calibarar,\n 'M' para mover los servos \n 'R' para correr rutina \n 'U' para ir a la ultima posicion guardad\n");
+ printf("\n\nSleccion\n 'C' para calibarar,\n 'M' para mover los servos \n 'L' para la ultima posicion\n 'U' para ir a la ultima posicion guardada\n");//'R' para correr rutina \n
Casted=Casting();
switch(Casted){
@@ -104,6 +105,10 @@
Eje.calibrate(RangeEje, 45.0);
break;
+
+ case 21:
+ void Home(void);
+ break;
case 22:
printf("\nIncializando la secuencia de movimiento de ejes\n"\
@@ -151,7 +156,7 @@
}while(Options!= 23);
break;
- case 27:
+ case 100:
printf("\nIntroduzca cuantas veces quiere repetir la rutina"\
"\nPara cantidades mayores a 10 siga la logica:"\
@@ -252,22 +257,34 @@
{
for(int j=0;j<=iteraciones-1;j++){
+ Garra=0.7;
+ SlowMotion(DynHombro[size-1],0.5,Hombro);
+ Muneca=0.5;
+ Codo=0.5;
+ Eje=0.5;
+
for(int i=0;i<=size-1;i++)
{
+ Hombro=DynHombro[(i-1)];
+ wait(0.5);
+ //SlowMotion(DynEje[i],DynEje[i-1],Eje);
+ Eje=DynEje[i];
wait(0.5);
- //Garra=DynGarra[i];
- SlowMotion(DynGarra[i], DynGarra[i-1],Garra);
-
- wait(0.5);
+ //SlowMotion(DynMuneca[i],DynMuneca[i-1],Muneca);
Muneca=DynMuneca[i];
wait(0.5);
Codo=DynCodo[i];
+ //SlowMotion(DynCodo[i],DynCodo[i-1],Codo);
wait(0.5);
+ //SlowMotion(DynHombro[i],DynHombro[i-1],Hombro);
Hombro=DynHombro[i];
- wait(0.5);
+ wait(0.5);
+ Garra=DynGarra[i];
+ wait(0.5);
}//Fin del ciclo for
printf("\nTerminada la iteracion %d", j+1);
- }
+
+ }
printf("\n\n\nTerminadas las iteraciones especificadas\n\n");
}//Fin de la funcion
@@ -315,24 +332,39 @@
void SlowMotion(float NewPos, float AlmostLast,Servo LowServo)
{
float temp=AlmostLast;
-
- if(NewPos<AlmostLast)
- {
- for(int i=0;i<4;i++)
- {
- temp-=0.01;
- LowServo=temp;
- wait_ms(10);
- }
- }
+
+ do{
+ if(NewPos<AlmostLast)
+ {
+ temp-=Changing;
+ LowServo=temp;
+ wait_ms(10);
+ }
+
+ else if(NewPos>AlmostLast)
+ {
+ temp+=Changing;
+ LowServo=temp;
+ wait_ms(10);
+ }
+ }while(NewPos!=AlmostLast);
+
+}
+
+void Home(void)
+{
+ Garra=0.975;
+ wait(0.2);
- if(NewPos>AlmostLast)
- {
- for(int i=0;i<3;i++)
- {
- temp+=0.01;
- LowServo=temp;
- wait_ms(10);
- }
- }
+ Hombro=0.5;
+ wait(0.2);
+
+ Eje=0.5;
+ wait(0.2);
+
+ Codo=0.5;
+ wait(0.2);
+
+ Muneca=0.5;
+ wait(0.2);
}
\ No newline at end of file