control planta térmica
Dependencies: KeyPad LCDLib PID mbed
Revision 0:4ab7407d5d98, committed 2017-05-10
- Comitter:
- davroina
- Date:
- Wed May 10 00:51:24 2017 +0000
- Commit message:
- Programa de control de la planta t?rmica
Changed in this revision
diff -r 000000000000 -r 4ab7407d5d98 KeyPad.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/KeyPad.lib Wed May 10 00:51:24 2017 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/users/anevil14/code/KeyPad/#795c6863bbc2
diff -r 000000000000 -r 4ab7407d5d98 LCDLib.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LCDLib.lib Wed May 10 00:51:24 2017 +0000 @@ -0,0 +1,1 @@ +https://mbed.org/users/rlanghbv/code/LCDLib/#241842336d78
diff -r 000000000000 -r 4ab7407d5d98 PID.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/PID.lib Wed May 10 00:51:24 2017 +0000 @@ -0,0 +1,1 @@ +https://mbed.org/users/aberk/code/PID/#6e12a3e5af19
diff -r 000000000000 -r 4ab7407d5d98 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed May 10 00:51:24 2017 +0000 @@ -0,0 +1,92 @@ +#include "mbed.h" +#include "TextLCD.h" +//#include "PID.h" +#define RATE 0.1 + +Ticker tick; +AnalogIn pv(A0); +PwmOut co(PTE21); +DigitalIn PVMAS(PTC13); +DigitalIn PVMENOS(PTC12); +TextLCD lcd(D11,D10,D9,D5,D4,D3,D2); +DigitalOut led2(LED_GREEN); + +float SP = 0.7; +float val; +float M, MA, C; //muestra , muestra anterior y control +float P, I, D; +float a = 15, b = 13 ; +float tempCi, tempCo; + +void visualizacion(){ + + tempCi=(pv.read()*3.685503686*100); + tempCo=((SP/5.00)*3.685503686*100); + + lcd.gotoxy(1,1); + lcd.printf("PV = %2.2f C ",tempCi); + lcd.gotoxy(1,2); + lcd.printf("SP = %2.2f C ",tempCo); + + if(PVMAS==1){ + SP += 0.01; + //controller.setSetPoint(SP); + } + if(PVMENOS==1){ + SP -= 0.01; + //controller.setSetPoint(SP); + } + wait(RATE); +} + +void control() { + + led2 = !led2; + val = pv.read()*5.00; + + if(SP >= val){ + + M = val; + P = a*M; + D = MA + b*M; + I = P + a*M; + MA = M; + C = P + I + D; + C = C/5.00; + co = C; + + }else{ + //co = 0; + M = val; + P = a*M; + D = MA + b*M; + I = P + a*M; + MA = M; + C = P + I + D; + C = C/5.00; + co = -C; + } +} + +int main(){ + + tick.attach(&control, 0.1); // setup ticker to call flip led2 after 0.7 seconds + lcd.gotoxy(1,1); + lcd.printf("CONTROL PID"); + lcd.gotoxy(1,2); + lcd.printf("PLANTA TERMICA"); + wait(1.5); + lcd.gotoxy(1,1); + lcd.printf(""); + lcd.printf("MARISOL "); + lcd.gotoxy(1,2); + lcd.printf("MESA "); + wait(1.5); + + while(1){ + + visualizacion(); + + } + +}
diff -r 000000000000 -r 4ab7407d5d98 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Wed May 10 00:51:24 2017 +0000 @@ -0,0 +1,1 @@ +https://mbed.org/users/mbed_official/code/mbed/builds/794e51388b66 \ No newline at end of file