egrfgfrgg

Files at this revision

API Documentation at this revision

Comitter:
javiernegrette
Date:
Wed Oct 16 22:56:47 2013 +0000
Commit message:
This code can increase, decrease or change of parameter of sp, kp, ki, kd, by push-button. Has reset button too. This code is the first part of a PID controler design

Changed in this revision

Debounced.lib Show annotated file Show diff for this revision Revisions of this file
TextLCD.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 5d3dea91c85f Debounced.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Debounced.lib	Wed Oct 16 22:56:47 2013 +0000
@@ -0,0 +1,1 @@
+https://mbed.org/users/WarwickRacing/code/Debounced/#8992c13bbb9b
diff -r 000000000000 -r 5d3dea91c85f TextLCD.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TextLCD.lib	Wed Oct 16 22:56:47 2013 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/javiernegrette/code/TextLCD/#419979c1e228
diff -r 000000000000 -r 5d3dea91c85f main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed Oct 16 22:56:47 2013 +0000
@@ -0,0 +1,205 @@
+#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);
+DigitalOut led3(LED3);
+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; //variable controla cambio 4 posiciones
+int kp, ki, kd, sp; 
+
+int main() {
+    lcd.writeCommand(C1);//escribimos un comando segun el manual del modulo LCD
+    lcd.cls();
+    lcd.locate(0,0);
+    lcd.printf("Sp%d",sp);//primero print y luego locate?? o al contrario??
+    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);
+  
+        
+    while(1) {
+              led3 =1;
+           if (button3.falling()) {
+              led3 =!led3;              
+               ++j;
+               }                                     //INCREMENTA POSICION DEL MENU CON BOTON 3
+           if (j==0){
+               lcd.locate(2,0);
+               lcd.printf("%d",sp);
+               wait(0.5);
+                  led1 =1;
+                  if (button1.falling()) { 
+                  led1 =!led1;                           
+                  ++sp; // ademas revisa boton 1 para incrementar
+                                         }
+                   led2 =1;
+                  if (button2.falling()) {  
+                  led2 =!led2;                          
+                  --sp; // ademas revisa boton 2 para decrementar
+                                         } 
+                       if (sp>9999){
+                       sp=9999;
+                                } 
+                                         
+                       if (sp<0){
+                       sp=0;
+                                }   
+                 if (button4.falling()){
+                    sp=0;
+                    kp=0;
+                    ki=0;
+                    kd=0;
+                                       }               
+              }
+           if (j==1) {
+               lcd.locate(10,0);
+               lcd.printf("%d",kp);
+               wait(0.5);
+                  led1 =1;
+                  if (button1.falling()) {
+                  led1 =!led1;
+                  ++kp;
+                                         }
+                  led2 =1;
+                  if (button2.falling()) {  
+                  led2 =!led2;                          
+                  --kp;
+                                         }
+                 if (kp>9999){
+                       kp=9999;
+                       lcd.locate(10,0);
+                       lcd.printf("%d",kp);
+                                } 
+                                         
+                       if (kp<0){
+                       kp=0;
+                       lcd.locate(10,0);
+                       lcd.printf("%d",kp);
+                                }   
+                 if (button4.falling()){
+                    sp=0;
+                    kp=0;
+                    ki=0;
+                    kd=0;
+                    lcd.locate(10,1);
+                    lcd.printf("%d",kd);
+                    lcd.locate(2,1);
+                    lcd.printf("%d",ki);
+                    lcd.locate(10,0);
+                    lcd.printf("%d",kp);
+                    lcd.locate(2,0);
+                    lcd.printf("%d",sp);
+                                       }  
+              }
+           if (j==2) {
+               lcd.locate(2,1);
+               lcd.printf("%d",ki);
+               wait(0.5);
+                  led1 =1;
+                  if (button1.falling()){
+                  led1 =!led1;
+                  ++ki;
+                                        }
+                  led2 =1;
+                  if (button2.falling()){  
+                  led2 =!led2;                          
+                  --ki;
+                                        }   
+                       if (ki>9999){
+                       ki=9999;
+                       lcd.locate(2,1);
+                       lcd.printf("%d",ki);
+                                   } 
+                                         
+                       if (ki<0){
+                       ki=0;
+                       lcd.locate(2,1);
+                       lcd.printf("%d",ki);
+                                }   
+                 if (button4.falling()){
+                    sp=0;
+                    kp=0;
+                    ki=0;
+                    kd=0;
+                    lcd.locate(10,1);
+                    lcd.printf("%d",kd);
+                    lcd.locate(2,1);
+                    lcd.printf("%d",ki);
+                    lcd.locate(10,0);
+                    lcd.printf("%d",kp);
+                    lcd.locate(2,0);
+                    lcd.printf("%d",sp);
+                                       } 
+                              
+              }
+           if (j==3) {
+               lcd.locate(10,1);
+               lcd.printf("%d",kd);
+               wait(0.5);
+                  led1 =1;
+                  if (button1.falling()){
+                  led1 =!led1;
+                  ++kd;
+                  }
+                  led2 =1;
+                  if (button2.falling()){
+                  led2 =!led2;                            
+                  --kd;
+                  }
+                  if (kd>9999){
+                       kd=9999;
+                       lcd.locate(10,1);
+                       lcd.printf("%d",kd);
+                                   } 
+                                         
+                       if (kd<0){
+                       kd=0;
+                       lcd.locate(10,1);
+                       lcd.printf("%d",kd);
+                                }   
+                 if (button4.falling()){
+                    sp=0;
+                    kp=0;
+                    ki=0;
+                    kd=0;
+                    lcd.locate(10,1);
+                    lcd.printf("%d",kd);
+                    lcd.locate(2,1);
+                    lcd.printf("%d",ki);
+                    lcd.locate(10,0);
+                    lcd.printf("%d",kp);
+                    lcd.locate(2,0);
+                    lcd.printf("%d",sp);
+                                       } 
+                  
+              } 
+           if (j==4) {
+               j=0;
+               }                          
+    
+           
+                        
+                                        }
+        }
diff -r 000000000000 -r 5d3dea91c85f mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Wed Oct 16 22:56:47 2013 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/a9913a65894f
\ No newline at end of file