Proyecto de Tesis en Mecatrónica. Universidad Técnica del Norte. Ernesto Palacios <mecatronica.mid@gmail.com>

Dependencies:   EthernetNetIf HTTPServer QEI_hw RPCInterface mbed

Files at this revision

API Documentation at this revision

Comitter:
Yo_Robot
Date:
Mon Jul 07 15:53:02 2014 +0000
Parent:
34:bdf918bc9b59
Commit message:
Intento de evitar que la funcion -P no bloquee comandos, no se logro, control dinamico de posici?n va para LabVIEW

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
setup.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Sat Jul 05 04:11:35 2014 +0000
+++ b/main.cpp	Mon Jul 07 15:53:02 2014 +0000
@@ -33,7 +33,7 @@
                  QEI_INVINX_NONE      // Not inverted index
                  );
 
-Timer           crono;                 // Reloj Interno de mbed
+Timeout         temporizador;                 // Reloj Interno de mbed
 
 DigitalOut      pin_son( p7 );       // SON
 DigitalOut      pin_dir( p26 );     //  SIGN+
--- a/setup.cpp	Sat Jul 05 04:11:35 2014 +0000
+++ b/setup.cpp	Mon Jul 07 15:53:02 2014 +0000
@@ -18,7 +18,7 @@
 extern Serial       pc;        // Salida Serial de mbed
 extern Serial       RS_232;    // Salida Serial a  MAX232
 extern QEIHW        encoder;
-extern Timer        crono;     // Cronometro interno del microcontrolador
+extern Timeout      temporizador;  // Cronometro interno del microcontrolador
 extern DigitalIn    isPC;      // Bit de configuracion serial en la placa
 extern DigitalOut   pin_son;   // SON
 extern DigitalOut   pin_dir;   // SIGN+
@@ -31,6 +31,9 @@
 extern InterruptIn  limite_3;
 extern InterruptIn  limite_4;
 
+
+
+
 int fq_posicion = 10000;  // Variable global donde se almacenara 
                          // la velocidad de posicionamiento en Hz
 float t_alto;           // para el posicionamiento del motor
@@ -39,6 +42,20 @@
 
 int bandera_inicio = 0;
  
+
+
+
+void fin_posicion()
+{
+    stopTimer2();
+
+    // Envia un OK de comando recibido
+    if( isPC )
+        pc.printf("OK\r\n");
+    else
+        RS_232.printf("OK\r\n");
+}
+
 int velocidad_rpm()
 {
     return encoder.GetVelocityCap();
@@ -194,16 +211,9 @@
             stopTimer2();               //Deten el tren de pulsos
             setPTO( fq_posicion );      //Nueva frecuencia de salida
             startTimer2();              //Inicia el tren de pulsos
-            wait( t_alto );             //Espera hasta llegar a la posicion
-            stopTimer2();               //Posicion alcanzada ALTO. 
+            temporizador.attach( &fin_posicion, t_alto);
             
-
-            // Envia un OK de comando recibido
-                if( isPC )
-                    pc.printf("OK\r\n");
-                else
-                    RS_232.printf("OK\r\n");
-            
+                      
 
             break;
         }