Segundo ejercicio
Dependencies: Debounced TextLCDa mbed
Revision 0:dff84c672b7e, committed 2013-12-04
- Comitter:
- mandres7
- Date:
- Wed Dec 04 21:35:20 2013 +0000
- Commit message:
- ejercicio2
Changed in this revision
diff -r 000000000000 -r dff84c672b7e Debounced.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Debounced.lib Wed Dec 04 21:35:20 2013 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/WarwickRacing/code/Debounced/#8992c13bbb9b
diff -r 000000000000 -r dff84c672b7e TextLCD.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TextLCD.lib Wed Dec 04 21:35:20 2013 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mandres7/code/TextLCDa/#ffba16465f33
diff -r 000000000000 -r dff84c672b7e main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed Dec 04 21:35:20 2013 +0000 @@ -0,0 +1,79 @@ +#include "mbed.h" +#include "TextLCD.h" +#include "DebouncedIn.h" + +Timer timer1; +TextLCD lcd(PTC10, PTC11, PTC12, PTC13, PTC16, PTC17); // rs, e, d4-d7TextLCD lcd(PTC10, PTC11, PTC12, PTC13, PTC16, PTC17); // rs, e, d4-d7 +DigitalOut myled(LED1); +AnalogOut Aout(PTE30); +AnalogIn Ain(PTC2); +DebouncedIn Arriba(PTE2); +DebouncedIn Abajo(PTE3); +DebouncedIn Ganancia(PTE4); + +float i=0.7; // set point +float j=0; // salida planta +float k=0; // entrada planta +float m=3.4; // ganancia +float js=0; +float ji=1; +float re=0; +float jo=0; +float jd=0; +float t=0; //tiempo + +int main() { +//float Setpoint=0.6; + while(1) { + + if(Arriba.falling()){ + i+=0.01; + } + + if(Abajo.falling()){ + i-=0.01; + } + + if(Ganancia.falling()){ + m+=0.01; + } + + if(i<0.999){ + + j=Ain; + k=m*(i-j); + Aout=k; + wait(0.1); + jo=j-jo; + lcd.locate(0,0); + lcd.printf("y:%.3f jd:%.2f", j, jd); + lcd.locate(0,1); + lcd.printf("t:%f",t); + lcd.locate(10,1); + lcd.printf("K:%.2f",m); + } + + if(j>js){ + js=j; + } + + if(j<ji){ + ji=j; + } + //wait(0.2); + jo=j; + re=js-ji; + jd=ji+(re/2); + + if(abs(jd-j)<=0.001){ + + t=timer1.read(); + timer1.stop(); + timer1.reset(); + timer1.start(); + + } + + } + +} \ No newline at end of file
diff -r 000000000000 -r dff84c672b7e mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Wed Dec 04 21:35:20 2013 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/a9913a65894f \ No newline at end of file