Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of pid-TAREA1 by
Diff: main.cpp
- Revision:
- 3:9c3e142c9896
- Parent:
- 2:88f8bc5d4e65
diff -r 88f8bc5d4e65 -r 9c3e142c9896 main.cpp
--- a/main.cpp Fri Nov 29 21:36:46 2013 +0000
+++ b/main.cpp Fri Dec 13 03:08:25 2013 +0000
@@ -4,19 +4,19 @@
TextLCD lcd(PTB10, PTB11, PTE2, PTE3, PTE4, PTE5); //Puertos LCD rs, e, d4, d5, d6, d7
-DigitalOut led1(LED1);//led de cambio de posición
-DigitalOut led2(LED2);// led incremento de parámetros
-DigitalOut led3(LED3);// led decremento de parámetros
-DebouncedIn bot1(PTC12); //cambiar la posición
-DebouncedIn bot2(PTC13); //incrementar variable
-DebouncedIn bot3(PTC16); //decrementar variable
-DebouncedIn bot4(PTC17); //salida de bucle
+DigitalOut led1(LED1); //led de cambio de posición
+DigitalOut led2(LED2); // led incremento de parámetros
+DigitalOut led3(LED3); // led decremento de parámetros
+DebouncedIn bot1(PTC12); //cambiar la posición
+DebouncedIn bot2(PTC13); //incrementar variable
+DebouncedIn bot3(PTC16); //decrementar variable
+DebouncedIn bot4(PTC17); //salida de bucle
//Códigos LCD
-int C1=0x0E; // Muestra el cursor
+int C1=0x0E; // Muestra el cursor
// 0x18; // desplazamiento izquierda
// 0x1A; // desplazamiento derecha
-int C4=0x0C; // Quita el cursor
+int C4=0x0C; // Quita el cursor
int a,kp, ki, kd, sp; // indice y variables del PID
@@ -26,24 +26,26 @@
int main() {
led1=led2=led3=1;
- lcd.printf("Control PID");
+ lcd.printf("PARAMETROS PID");
wait(1.5);
lcd.cls();
- // Ubica e imprime nombre de las variables en la LCD
- lcd.locate(0,0);
- lcd.printf("Sp=%d",sp);
+
+ lcd.writeCommand(C1);//comando para mostrar el cursor en el LCD
+
+ lcd.locate(0,0); // Ubica e imprime nombre de las variables en la LCD
+ lcd.printf("Sp=%i",sp);
lcd.locate(8,0);
- lcd.printf("Kp=%d",kp);
+ lcd.printf("Kp=%i",kp);
lcd.locate(0,1);
- lcd.printf("Ki=%d",ki);
+ lcd.printf("Ki=%i",ki);
lcd.locate(8,1);
- lcd.printf("Kd=%d",kd);
- lcd.writeCommand(C1);//comando para mostrar el cursor en el LCD
+ lcd.printf("Kd=%i",kd);
+
//Inicio del ciclo
while(1) {
- if (bot1.falling()) { //Aumenta de posición el cursor
+ if (bot1.falling()) { //Aumenta de posición el cursor para cada línea de menu
a++;
led1=0;
wait(.15);
@@ -75,7 +77,7 @@
}
}
- if (bot2.falling()) { //Incrementa la variable
+ if (bot2.falling()) { //Incrementa el valor del parámetro
led2=0;
wait(.15);
led2=1;
@@ -85,33 +87,33 @@
lcd.locate(2,0);
lcd.printf("=");
lcd.locate(3,0);
- lcd.printf("%d",++sp);
+ lcd.printf("%i",++sp);
break;
case 1:
lcd.locate(10,0);
lcd.printf("=");
lcd.locate(11,0);
- lcd.printf("%d",++kp);
+ lcd.printf("%i",++kp);
break;
case 2:
lcd.locate(2,1);
lcd.printf("=");
lcd.locate(3,1);
- lcd.printf("%d",++ki);
+ lcd.printf("%i",++ki);
break;
case 3:
lcd.locate(10,1);
lcd.printf("=");
lcd.locate(11,1);
- lcd.printf("%d",++kd);
+ lcd.printf("%i",++kd);
break;
}
}
- if (bot3.falling()) { //Decrementa la variable
+ if (bot3.falling()) { //Decrementa el valor del parámetro
led3=0;
wait(.15);
led3=1;
@@ -122,29 +124,29 @@
sp=0;
}
lcd.locate(2,0);
- lcd.printf("=");
+ lcd.printf("= ");
lcd.locate(3,0);
- lcd.printf("%d",sp--);
+ lcd.printf("%i",sp--);
break;
case 1:
- if (kp<0) { //No se admite valores negativos
+ if (kp<0) { //No se admite valores negativos
kp=0;
}
lcd.locate(10,0);
- lcd.printf("=");
+ lcd.printf("= ");
lcd.locate(11,0);
- lcd.printf("%d",kp--);
+ lcd.printf("%i",kp--);
break;
case 2:
- if (ki<0) { //No se admite valores negativos
+ if (ki<0) { //No se admite valores negativos
ki=0;
}
lcd.locate(2,1);
- lcd.printf("=");
+ lcd.printf("= ");
lcd.locate(3,1);
- lcd.printf("%d",ki--);
+ lcd.printf("%i",ki--);
break;
case 3:
@@ -152,9 +154,9 @@
kd=0;
}
lcd.locate(10,1);
- lcd.printf("=");
+ lcd.printf("= ");
lcd.locate(11,1);
- lcd.printf("%d",kd--);
+ lcd.printf("%i",kd--);
break;
}
}
