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.
Dependencies: DebouncedIn TextLCD mbed
Fork of TAREA_3_PID by
Revision 1:93e71ac5cf91, committed 2017-11-08
- Comitter:
- demo71
- Date:
- Wed Nov 08 21:04:13 2017 +0000
- Parent:
- 0:694446246c35
- Commit message:
- PID CONTINUO
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Mon Sep 28 22:43:43 2015 +0000
+++ b/main.cpp Wed Nov 08 21:04:13 2017 +0000
@@ -22,6 +22,7 @@
int C4=0x0C; // quito cursor bajo
int C1=0x0F; // solo muestra el cursor
+//Variables y parametros del Controlador PID
int Kp=0,Ki=0,Kd=0,Sp=0,p,i;
float rT,eT,iT,dT,yT,uT,iT0=0,eT0=0,iT_1=0,eT_1=0;
Timer tu;
@@ -30,7 +31,6 @@
int main() {
lcd.cls();
- //escribimos un comando segun el manual del modulo LCD
lcd.locate(1,0);
lcd.printf("Kp=%d",Kp);
lcd.locate(9,0);
@@ -40,7 +40,7 @@
lcd.locate(9,1);
lcd.printf("Sp=%d",Sp);
-
+ //Configuracion del parametro Kp
set_Kp:
lcd.cls();
lcd.locate(0,0);
@@ -54,7 +54,7 @@
lcd.printf("Sp=%d",Sp);
- //Kp=0;
+
while(1){
if(Boton2.falling()){
@@ -114,6 +114,7 @@
}
+ //Configuracion del parametro Ki
set_Ki:
lcd.cls();
@@ -187,6 +188,7 @@
}
+ //Configuracion del parametro Kd
set_Kd:
lcd.cls();
@@ -201,7 +203,7 @@
lcd.printf("Sp=%d",Sp);
- //Kd=0;
+
while(1){
if(Boton2.falling()){
@@ -261,6 +263,7 @@
}
+ //Configuracion del parametro Sp
set_Sp:
lcd.cls();
@@ -274,7 +277,7 @@
lcd.locate(1,1);
lcd.printf("Kd=%d",Kd);
- //Sp=0;
+
while(1){
if(Boton2.falling()){
@@ -333,14 +336,10 @@
}
}
-
+ //Inicia algoritmo del PID
PID:
lcd.cls();
- //Sp=2;
- //Kp=(float)12.105;
- //Ki=(float)5.32;
- //Kd=(float)2;
while(1){
yT=vcond.read()*3.3;
@@ -353,19 +352,18 @@
else if (uT<0){ //Salida PID si es menor que el MIN
uT=0;
}
- iT0=iT; //Guardar variables
+ iT0=iT; //Actualizando variables para el paso siguiente
eT0=eT;
- control=(float)uT/3.3;
+ control=(float)uT/3.3;//Accion de control mapeada a PWM; salida de la tarjeta.
+ //Mostrando error y salida actual
lcd.locate(0,0);
lcd.printf("Error=%.2f ",eT);
lcd.locate(0,1);
lcd.printf("Y_act=%.2f",yT);
wait(0.2);
}
- //lcd.locate(3,0);
- //lcd.writeCommand(C1);
-
+
}
