graphical interface for a PID controller
Dependencies: DebounceIn TextLCD mbed
Revision 0:527c9de31b3c, committed 2013-10-11
- Comitter:
- salondonog
- Date:
- Fri Oct 11 05:28:33 2013 +0000
- Commit message:
- GUI for a PID controller
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/DebounceIn.lib Fri Oct 11 05:28:33 2013 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/AjK/code/DebounceIn/#31ae5cfb44a4
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TextLCD.lib Fri Oct 11 05:28:33 2013 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/sbts/code/TextLCD/#122fc41ed965
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Fri Oct 11 05:28:33 2013 +0000 @@ -0,0 +1,117 @@ +#include "mbed.h" +#include "TextLCD.h" +#include "DebounceIn.h" + +TextLCD lcd(PTE0,PTE1,PTE2,PTE3,PTE4,PTE5); //configura los puestos PTE0,PTE1,PTE2,PTE3,PTE4,PTE5, donde se conectara el LCD 16x2 +DebounceIn mas(PTA1); +DebounceIn menos(PTA2); +DebounceIn salto(PTA3); + +int s=0; //set point +int p=0; //ganancia proporcional +int i=0; //ganancia integral +int d=0; //ganancia derivativa +int k=1; //variable de control} + +void def_posicion(int h){ + if (h==0){ + lcd.locate(3,0); + } + else if(h==1){ + lcd.locate(10,0); + } + else if (h==2){ + lcd.locate(3,1); + } + else { + lcd.locate(10,1); + } +} +void decremento(int u){ //Funcion que decrementa los valores +if(u==0){ + if(s<=0){ + s=0; + lcd.printf("%d",s); + } + else{ + s--; + lcd.printf("%d",s); + } + } +else if(u==1){ + if(p<=0){ + p=0; + lcd.printf("%d",p); + } + else{ + p--; + lcd.printf("%d",p); + } +} +else if(u==2){ + if(i<=0){ + i=0; + lcd.printf("%d",i); + } + else{ + i--; + lcd.printf("%d",i); + } + } +else if(d<=0){ + d=0; + lcd.printf("%d",d); + } +else { + d--; + lcd.printf("%d",d); + } +} + +void incremento(int h){ //Funcion que incremente los valores +if(h==0){ + s++; + lcd.printf("%d",s); + } +else if(h==1){ + p++; + lcd.printf("%d",p); + } +else if(h==2){ + i++; + lcd.printf("%d",i); + } +else{ + d++; + lcd.printf("%d",d); + } + +} + +void star_patch(void){ //funcion que imprime los caracteres que no van a variar en el display +lcd.printf("SP="); +lcd.locate(7,0); +lcd.printf("Kp="); +lcd.locate(0,1); +lcd.printf("Ki="); +lcd.locate(7,1); +lcd.printf("Kd="); +lcd.locate(3,0); +} + +int main(){ +star_patch(); +while(1){ + if(k==3)k=0; + if(salto.read()==0){ + def_posicion(k); + k++; + } + else if(mas.read()==0){ + incremento(k); + } + else if(menos.read()==0){ + decremento(k); + } +} +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Fri Oct 11 05:28:33 2013 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/a9913a65894f \ No newline at end of file