
Balanceo Proporcional
Revision 0:75bb922e8f5a, committed 2016-04-21
- Comitter:
- DiegoRivera
- Date:
- Thu Apr 21 00:50:31 2016 +0000
- Commit message:
- Ok
Changed in this revision
diff -r 000000000000 -r 75bb922e8f5a MMA8451Q.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/MMA8451Q.lib Thu Apr 21 00:50:31 2016 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/quevedo/code/MMA8451Q/#7c9ab58f6af3
diff -r 000000000000 -r 75bb922e8f5a main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu Apr 21 00:50:31 2016 +0000 @@ -0,0 +1,32 @@ +#include "mbed.h" +#include "MMA8451Q.h" + +Serial pc(USBTX, USBRX); +MMA8451Q acc(PTE25, PTE24); + +PwmOut servo(PTB0); + +float errorstl; +float salida=0; +int16_t data[3]; + +int main() +{ + + while(1) + { + acc.getAccAllAxis(data); +// s0.printf("%d\t%d\t%d\n", data[0], data[1], data[2]); + errorstl=float(data[0])/16000.0/100.0; + pc.printf("%f\n", errorstl); + salida=salida + errorstl; + //pc.printf("%f\n", salida); + if(salida>1) + salida=1; + if(salida<0) + salida=0; +// pc.printf("%f\n", salida); + servo=salida/10.0+.01; + wait_ms(1); + } +}
diff -r 000000000000 -r 75bb922e8f5a mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Thu Apr 21 00:50:31 2016 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/99a22ba036c9 \ No newline at end of file