Tarea 2 Procesadores Botones pulsadores con sonido

Dependencies:   Debounced TextLCD mbed

Files at this revision

API Documentation at this revision

Comitter:
Jesse
Date:
Wed Apr 02 15:24:36 2014 +0000
Commit message:
Tarea 2 Procesadores

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 ad772c4ebc42 Debounced.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Debounced.lib	Wed Apr 02 15:24:36 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/WarwickRacing/code/Debounced/#8992c13bbb9b
diff -r 000000000000 -r ad772c4ebc42 TextLCD.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TextLCD.lib	Wed Apr 02 15:24:36 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/lcorralesc1/code/TextLCD/#0e0132807662
diff -r 000000000000 -r ad772c4ebc42 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed Apr 02 15:24:36 2014 +0000
@@ -0,0 +1,271 @@
+#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);
+
+PwmOut Pwm(PTA5);
+
+DebouncedIn button1(PTC10);
+DebouncedIn button2(PTC11);
+DebouncedIn button3(PTC6);
+ 
+float Du;
+float Du1;
+float pp;
+float Fi;
+int C1=0x0F;
+int sp=0,kp=0,kd=0,ki=0,p=1,Pp=0,Dd=1;
+int main()
+{
+    //Fi=(Dd)*100;
+    //pp=(1/Fi);
+    //Pwm.period(pp);
+    //Du=(Pp/100);
+    //Du1=(1-Du);
+    
+    lcd.cls();
+    lcd.writeCommand(C1);//escribimos un comando segun el manual del modulo LCD
+    lcd.locate(6,0);
+    lcd.printf("kp=%d", kp);
+    lcd.locate(0,1);
+    lcd.printf("Ki=%d", ki);
+    lcd.locate(6,1);
+    lcd.printf("Kd=%d", kd);
+    lcd.locate(0,0);
+    lcd.printf("Sp=%d", sp);
+    lcd.locate(12,0);
+    lcd.printf("F=%d",Dd);
+    lcd.locate(12,1);
+    lcd.printf("D=%d",Pp);
+ 
+    while(1)
+    {
+        Fi=(Dd)*100;
+        pp=(1/Fi);
+        Pwm.period(pp);
+        Du=(Pp/10);
+        Du1=(1-Du);
+        
+        if (button1.falling())
+        {
+            //Pwm.period);
+            Pwm.write(0.1);
+            wait(0.1);
+            Pwm.write(0);
+            wait(0.1);
+            led1 =!led1;
+            if (p==1)
+            {
+                ++sp;
+                lcd.locate(3,0);
+                lcd.printf("  ");
+                lcd.locate(3,0);
+                lcd.printf("%d", sp);
+                //lcd.locate(15,0);
+                //.printf("   ");
+            }
+            else if (p==2)
+            {
+                ++kp;
+                lcd.locate(9,0);
+                lcd.printf("  ");
+                lcd.locate(9,0);
+                lcd.printf("%d", kp);
+            }
+            else if (p==3)
+            {
+                ++ki;
+                lcd.locate(3,1);
+                lcd.printf("  ");
+                lcd.locate(3,1);
+                lcd.printf("%d", ki);
+            }
+            else if (p==4)
+            {
+                ++kd;
+                lcd.locate(9,1);
+                lcd.printf("  ");
+                lcd.locate(9,1);
+                lcd.printf("%d", kd);
+            }
+             else if (p==5)
+            {
+                ++Dd;
+                lcd.locate(14,0);
+                lcd.printf("  ");
+                lcd.locate(14,0);
+                lcd.printf("%d", Dd);
+            }
+             else if (p==6)
+            {
+                ++Pp;
+                lcd.locate(14,1);
+                lcd.printf("  ");
+                lcd.locate(14,1);
+                lcd.printf("%d", Pp);
+            }
+        }
+        if (button2.falling())
+        {
+            
+            Pwm.write(0.1);
+            wait(0.1);
+            Pwm.write(0);
+            wait(0.1);
+            //Pwm.period_us(2000);
+            //Pwm.write(0.5);
+            //wait(0.025);       
+            led2 =!led2;
+            if (p==1)
+            {
+                if (sp==0)  // no mostrar nada
+                {
+                }
+                else
+                {
+                    --sp;
+                    lcd.locate(3,0);
+                    lcd.printf("  ");
+                    lcd.locate(3,0);
+                    lcd.printf("%d", sp);
+                }
+            }
+            if (p==2)
+            {
+                if (kp==0)  // no mostrar nada
+                {
+                }
+                else
+                {
+                    --kp;
+                    lcd.locate(9,0);
+                    lcd.printf("  ");
+                    lcd.locate(9,0);
+                    lcd.printf("%d", kp);
+                }
+            }
+            if (p==3)
+            {
+                if (ki==0)  // no mostrar nada
+                {
+                } 
+                else
+                {
+                    --ki;
+                    lcd.locate(3,1);
+                    lcd.printf("  ");
+                    lcd.locate(3,1);
+                    lcd.printf("%d", ki);
+                }
+            }
+            if (p==4)
+            {
+                if (kd==0)  // no mostrar nada
+                {
+                }
+                else
+                {
+                    --kd;
+                    lcd.locate(9,1);
+                    lcd.printf("  ");
+                    lcd.locate(9,1);
+                    lcd.printf("%d", kd);
+                }
+            }
+            if (p==5)
+            {
+                if (Dd==1)  // no mostrar nada
+                {
+                }
+                else
+                {
+                    --Dd;
+                    lcd.locate(14,0);
+                    lcd.printf("  ");
+                    lcd.locate(14,0);
+                    lcd.printf("%d", Dd);
+                }
+            }
+            if (p==6)
+            {
+                if (Pp==0)  // no mostrar nada
+                {
+                }
+                else
+                {
+                    --Pp;
+                    lcd.locate(14,1);
+                    lcd.printf("  ");
+                    lcd.locate(14,1);
+                    lcd.printf("%d", Pp);
+                }
+            }
+        }
+        if (button3.falling())
+        {
+            
+            Pwm.write(0.1);
+            wait(0.1);
+            Pwm.write(0);
+            wait(0.1);
+            led3 =!led3;
+            if (p==1)
+            {
+                ++p;
+                lcd.locate(9,0);
+                lcd.printf("%d", kp);
+                
+                
+                
+            }
+            else if (p==2)
+            {
+                ++p;
+                lcd.locate(3,1);
+                lcd.printf("%d", ki);
+                lcd.locate(3,1);
+                
+            }
+            else if (p==3)
+            {
+                ++p;
+                lcd.locate(9,1);
+                lcd.printf("%d", kd);
+                
+                
+            }
+            else if (p==4)
+            {
+                ++p;
+                lcd.locate(3,0);
+                lcd.printf("%d", sp);
+                
+                
+            }
+             else if (p==5)
+            {
+                ++p;
+                lcd.locate(14,0);
+                lcd.printf("%d", Dd);
+                
+                
+            }
+             else if (p==6)
+            {
+                p=1;
+                lcd.locate(14,1);
+                lcd.printf("%d", Pp);
+                //p=1;
+                
+                
+            }
+        }
+    }
+}
\ No newline at end of file
diff -r 000000000000 -r ad772c4ebc42 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Wed Apr 02 15:24:36 2014 +0000
@@ -0,0 +1,1 @@
+http://world3.dev.mbed.org/users/mbed_official/code/mbed/builds/824293ae5e43
\ No newline at end of file