Asignación de valores controlador PID sencillo.
Fork of controlPID by
main.cpp
- Committer:
- jmcallef
- Date:
- 2013-10-18
- Revision:
- 2:434bb36fa59f
- Parent:
- 1:83ffe66ee756
File content as of revision 2:434bb36fa59f:
#include "mbed.h" #include "DebouncedIn.h" #include "TextLCD.h" AnalogIn Vin(PTC2); TextLCD lcd(PTB10, PTB11, PTE2, PTE3, PTE4, PTE5); // rs, e, d4-d7 DigitalOut led1(LED1); DigitalOut led2(LED2); DebouncedIn button1(PTC12); DebouncedIn button2(PTC13); DebouncedIn button3(PTC16); DebouncedIn button4(PTC17); /* codigos movimiento del curzor 18 para izquierda 1A para derecha */ int C1=0x0E; // solo muestra el curzor int C2=0x18; // desplaza izquierda int C3=0x1A; // desplaza derecha int C4=0x0C; // quito cursor bajo int i; // indice de la variable int j; int kp, ki, kd, sp, err, med, yr, pid, ap, ai, ad, err_v, cycle; int main() { lcd.writeCommand(C1); // Ubico el cursor en el Display. lcd.cls(); lcd.locate(0,0); lcd.printf("Sp%d",sp); lcd.locate(8,0); lcd.printf("Kp%d",kp); lcd.locate(0,1); lcd.printf("Ki%d",ki); lcd.locate(8,1); lcd.printf("Kd%d",kd); lcd.locate(0,0); lcd.printf("Sp%d",sp); while(1) { if (button3.falling()) { ++j; } //INCREMENTA POSICION DEL MENU CON BOTON 3 if (j==0){ lcd.locate(3,0); lcd.printf("%d",sp); if (button1.falling()) { ++sp; // ademas revisa boton 1 para incrementar } if (button2.falling()) { --sp; // ademas revisa boton 2 para decrementar } } if (j==1) { lcd.locate(11,0); lcd.printf("%d",kp); if (button1.falling()) { ++kp; } if (button2.falling()) { --kp; } } if (j==2) { lcd.locate(3,1); lcd.printf("%d",ki); if (button1.falling()){ ++ki;9 } if (button2.falling()){ --ki; } } if (j==3) { lcd.locate(11,1); lcd.printf("%d",kd); if (button1.falling()){ ++kd; } if (button2.falling()){ --kd; } } if (j==4) { j=0; } if (button4.falling()){ break; //sale del bucle si pisan suiche4 } } }