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:
Sun Apr 22 19:22:19 2012 +0000
Parent:
14:039d070732d5
Child:
16:d50665706f21
Commit message:
Version 1.2 Se agrego funciones de posicion. faltan probar

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
setup.h Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Sat Apr 21 14:50:06 2012 +0000
+++ b/main.cpp	Sun Apr 22 19:22:19 2012 +0000
@@ -28,7 +28,9 @@
 RPCFunction SetAOUT(&setAout_eth, "AOUT");
 RPCFunction SetDIR (&setDir_eth,  "DIR");
 RPCFunction SetSON (&setSON_eth,  "SON");
-// falta encoders y alarma.....
+RPCFuncrion SetANG (&setANG_eth,  "ANG"); 
+RPCFuncrion SetSpd (&setSPD_eth,  "VAN"); 
+RPCFuncrion ReadSpd(&getENC_eth,  "VLC");
 
 
 int main() {
@@ -71,7 +73,7 @@
         
         printf("Listening...\n");
     }
-    else  // Caso Contrario Añadir modo Serial
+    else  // Caso Contrario Anadir modo Serial
     {
         pc.attach( &ISR_Serial );
         if( isFast ) //Configurar Serial a alta velocidad
@@ -87,7 +89,7 @@
     while(1) 
     {
         if( isHTTP )
-            Net::poll();  // Revisa la red solo si la conección es HTTP
+            Net::poll();  // Revisa la red solo si la coneccion es HTTP
     }
 }
 
--- a/setup.cpp	Sat Apr 21 14:50:06 2012 +0000
+++ b/setup.cpp	Sun Apr 22 19:22:19 2012 +0000
@@ -20,6 +20,9 @@
 extern InterruptIn  pin_alm;   // ALM 
 extern AnalogOut    aout;      // +-10V
 
+int fq_posicion = 10000;  // Variable global donde se almacenara 
+                         // la velocidad de posicionamiento en Hz
+
 
 void setTimer2()
 {
@@ -131,6 +134,44 @@
     }           
 }
 
+void setANG_eth( char * input, char * output )
+{
+    long int pulsos = atol( input );       //Numero de pulsos a generar
+    float t_alto = pulsos / fq_posicion;  //Tiempo que debe ser generado el tren de pulsos.
+    
+    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();               //Posición alcanzada ALTO. 
+    
+    if( pin_alm == 0 )
+        sprintf( output,"Ok" );
+    else
+        sprintf( output,"AL" );    
+    
+}
+void setSPD_eth( char * input, char * output )
+{
+    fq_posicion = atoi( input );      
+    // Esta funcion cambia la velocidad con la que se
+    // posicionara el eje del motor en un angulo determinado
+    if( pin_alm == 0 )
+        sprintf( output,"Ok" );
+    else
+        sprintf( output,"AL" );    
+        
+}
+void getENC_eth( char * input, char * output )
+{
+    //Leer el Encoder  *******  F A L T A
+    if( pin_alm == 0 )
+        sprintf( output,"Ok" );
+    else
+        sprintf( output,"AL" );    
+    
+}
+
 
 void ISR_Alarm()
 {
@@ -139,7 +180,7 @@
     aout =  0.5 ;
  
     pc.printf( "ERROR_ALARMA" );
- 
+    
 }
 
 int getMRvalue( int fout  )
--- a/setup.h	Sat Apr 21 14:50:06 2012 +0000
+++ b/setup.h	Sun Apr 22 19:22:19 2012 +0000
@@ -79,6 +79,19 @@
 void setSON_eth ( char * input, char * output );    
 
 
+/** @brief: Cambiar Direccion @ PTO
+ */
+void setANG_eth( char * input, char * output );
+
+
+/** @brief: Cambiar Direccion @ PTO
+ */
+void setSPD_eth( char * input, char * output )
+
+
+/** @brief: Cambiar Direccion @ PTO
+ */
+void getENC_eth( char * input, char * output )
 
 
 // Legacy