Proyecto de Tesis en Mecatrónica. Universidad Técnica del Norte. Ernesto Palacios <mecatronica.mid@gmail.com>
Dependencies: EthernetNetIf HTTPServer QEI_hw RPCInterface mbed
Diff: main.cpp
- Revision:
- 9:6976ac1a430e
- Parent:
- 8:958dfe5052b9
- Child:
- 12:c02b08dacc45
--- a/main.cpp Tue Apr 03 00:31:03 2012 +0000 +++ b/main.cpp Tue Apr 03 00:55:48 2012 +0000 @@ -8,18 +8,23 @@ #include "RPCVariable.h" #include "SerialRPCInterface.h" + +DigitalOut pin_son( p30 ); // SON +DigitalOut pin_dir( p29 ); // SIGN+ +InterruptIn pin_alm( p14 ); // ALM +AnalogOut aout( p18 ); // 0.0 a 1.0 float + LocalFileSystem fs("webfs"); EthernetNetIf eth; HTTPServer svr; -void setFq( char * input, char * output ); //Cambiar frecuencia -void setPTO( char * input, char * output ); // Encender/Apagar Pulse Train Output - +void setAout_eth( char * input, char * output ); //Cambiar frecuencia +void setPTO_eth( char * input, char * output ); // Encender/Apagar Pulse Train Output //Set up custom RPC -RPCFunction SetFQ(&setPTO, "PTO"); -RPCFunction SetAout(&setAOUT, "AOUT"); +RPCFunction SetFQ(&setPTO_eth, "PTO"); +RPCFunction SetAout(&setAout_eth, "AOUT"); int main() { @@ -41,7 +46,7 @@ EthernetErr ethErr = eth.setup(); if( ethErr ) { - printf( "Error %d in setup\n", ethErr ); + printf( "Error %d en setup\n", ethErr ); return -1; } @@ -69,33 +74,28 @@ } -void setAOUT( char * input, char * output ) +void setAout_eth( char * input, char * output ) { - int vout = atoi( input ); - + int vout = atoi( input ); aout = (float)( vout + 100 ) / 200; - - sprintf(" Ok, Aout = %f ", aout.read() ); - + sprintf( output, " Ok, Aout = %f ", aout.read() ); } -void setPTO( char * input, char * output ) +void setPTO_eth( char * input, char * output ) { int freq = atoi( input ); - if( freq != 0 ) - { + if( freq != 0 ){ + LPC_TIM2->TC = 0x00; // Resetear Timer + setMR2( getMRvalue( freq ) ); // Cambiar frefuencia + startTimer2(); // Iniciar Timer + sprintf( output, "Ok, Freq = %d", freq ); + + }else{ + stopTimer2(); LPC_TIM2->TC = 0x00; // Resetear Timer - setMR2( getMRvalue( frequency ) ); //Cambiar frefuencia - startTimer2(); - sprintf( output, "Ok, Freq = %d", frequency); - } else { - - LPC_TIM2->TC = 0x00; // Resetear Timer - stopTimer2(); sprintf( output, "Ok, ALTO" ); - } - + } }