electro
Dependencies: mbed mbed-os KeypadLib TextLCD
Revision 5:9869290cb13f, committed 2019-03-04
- Comitter:
- evanegasa
- Date:
- Mon Mar 04 18:24:53 2019 +0000
- Parent:
- 4:2636fe1c6527
- Commit message:
- Teclado
Changed in this revision
electrocoagulador_final.cpp | Show annotated file Show diff for this revision Revisions of this file |
mbed-os.lib | Show annotated file Show diff for this revision Revisions of this file |
diff -r 2636fe1c6527 -r 9869290cb13f electrocoagulador_final.cpp --- a/electrocoagulador_final.cpp Sat Mar 02 18:53:32 2019 +0000 +++ b/electrocoagulador_final.cpp Mon Mar 04 18:24:53 2019 +0000 @@ -13,6 +13,8 @@ PwmOut motor(PA_5); //variable temporal para el motor (se cambiará después) /*****************************************************/ + + /*******************INTERRUPCIONES********************/ InterruptIn button(USER_BUTTON); @@ -26,10 +28,11 @@ Timeout t_4; //tiempos de usuario -int temp_user_1=0; //tiempo tope de electrocoagulacion -int temp_user_2=0; //tiempo tope de reposo de la vinaza -int temp_user_3=0; //tiempo tope de vaciado del agua en el tanque 2 -int temp_user_4=0; //tiempo tope de vaciado de residuos en el tanque 2 +int temp_user_1=5; //tiempo tope de electrocoagulacion +int temp_user_2=5; //tiempo tope de reposo de la vinaza +int temp_user_3=5; //tiempo tope de vaciado del agua en el tanque 2 +int temp_user_4=5; //tiempo tope de vaciado de residuos en el tanque 2 +int pwm=5; //timers @@ -47,13 +50,12 @@ float num=0; char cadena[3]= {' ',' ',' '}; int llena=0; //verificar que la entrada es de 3 numeros - +int blinker = 1; /*********************FUNCIONES**************************/ void stop() //STOP { - while(1) { lcd.cls(); lcd.printf(" STOP!"); @@ -90,31 +92,66 @@ E_4=!E_4; } -void pwm_rise() -{ - if(keypad.getKey()=='7') { - double n=n+0.003; - if(n>=1) { - n=1; +void printLCD(){ + while(1){ + lcd.cls(); + lcd.locate(0,0); + lcd.printf("t1=%d",temp_user_1); + lcd.locate(6,0); + lcd.printf("t2=%d",temp_user_2); + lcd.locate(0,1); + lcd.printf("t3=%d",temp_user_3); + lcd.locate(6,1); + lcd.printf("t4=%d",temp_user_4); + lcd.locate(12,0); + lcd.printf("PWM"); + lcd.locate(12,1); + lcd.printf("%d",pwm); + wait_ms(350); + switch(blinker){ + case 1: + lcd.locate(0,0); + lcd.printf("t1= ",temp_user_1); break; + case 2: + lcd.locate(6,0); + lcd.printf("t2= ",temp_user_2); break; + case 3: + lcd.locate(0,1); + lcd.printf("t3= ",temp_user_3); break; + case 4: + lcd.locate(6,1); + lcd.printf("t4= ",temp_user_4); break; + case 5: + lcd.locate(12,1); + lcd.printf(" "); + default: ; break; } - motor.period(0.5); // 4 second period - motor.write(n); // % of duty cycle, relative to period - wait(150); - } + wait_ms(350); + } } -void pwm_fall() -{ - if(keypad.getKey()=='8') { - double n=n-0.003; - if(n<0) { - n=0; +int getNum(){ + while(1){ + char key = keypad.getKey(); + switch(key) { + case '0': return 0; + case '1': return 1; + case '2': return 2; + case '3': return 3; + case '4': return 4; + case '5': return 5; + case '6': return 6; + case '7': return 7; + case '8': return 8; + case '9': return 9; + case 'A': + blinker++; + if(blinker==6) blinker=1; return -1; + default: ; break; } - motor.period(0.5); // 4 second period - motor.write(n); // % of duty cycle, relative to period - wait(150); + wait_ms(100); } -} +} /***********************MAIN***************************/ @@ -129,172 +166,38 @@ lcd.printf("electrocoagular\n"); wait(1.5); lcd.cls(); - down.attach(&pwm_fall,0.013); - up.attach(&pwm_rise,0.011); - - - while(1) { -ini_1: - lcd.cls(); - lcd.locate(0,0); - lcd.printf("t_1=%d",temp_user_1); - lcd.locate(8,0); - lcd.printf("t_2=%d",temp_user_2); - lcd.locate(0,1); - lcd.printf("t_3=%d",temp_user_3); - lcd.locate(8,1); - lcd.printf("t_4=%d",temp_user_4); - wait_ms(100); - - char key = keypad.getKey(); - - //if(key=='A') { - //lcd.cls(); - //lcd.locate(0,0); - //lcd.printf("%c",key); - //wait(3); - - - - // lcd.printf("t_1=%f",temp_user_1); - + int a=0; + int b=0; + int c=0; - if(key=='1') { - temp_user_1=temp_user_1+10; - if(temp_user_1<00) { - temp_user_1=00; - } - wait_ms(150); - } - if(key=='2') { - temp_user_1=temp_user_1-1; - if(temp_user_1<00) { - temp_user_1=00; - } - wait_ms(150); - } - if(key=='3') { - temp_user_2=temp_user_2+10; - if(temp_user_2<00) { - temp_user_2=00; - } - wait_ms(150); - } - if(key=='A') { - temp_user_2=temp_user_2-1; - if(temp_user_2<00) { - temp_user_2=00; - } - wait_ms(150); - } - if(key=='4') { - temp_user_3=temp_user_3+10; - if(temp_user_3<00) { - temp_user_3=00; - } - wait_ms(150); - } - if(key=='5') { - temp_user_3=temp_user_3-1; - if(temp_user_3<00) { - temp_user_3=00; - } - wait_ms(150); - } - if(key=='6') { - temp_user_4=temp_user_4+10; - if(temp_user_4<00) { - temp_user_4=00; - } - wait_ms(150); + Thread lcdprint; + lcdprint.start(printLCD); + + while(1) { + setvalue: + a=100*getNum(); + wait_ms(250); + if(a<0)goto setvalue; + b=10*getNum(); + wait_ms(250); + if(b<0)goto setvalue; + c=getNum(); + wait_ms(250); + if(c<0)goto setvalue; + + switch(blinker){ + case 1: + temp_user_1=a+b+c; break; + case 2: + temp_user_2=a+b+c; break; + case 3: + temp_user_3=a+b+c; break; + case 4: + temp_user_4=a+b+c; break; + case 5: + pwm=a+b+c; break; } - if(key=='B') { - temp_user_4=temp_user_4-1; - if(temp_user_4<00) { - temp_user_4=00; - } - wait_ms(150); - } - - /***********************COMIENZA CONTROL***********************/ - if(key=='D' && temp_user_1!=0) { - E_1=1; - while(E_1==1) { - check_level.attach(&level, 0.5); - } - t_1.attach(&electro_2,temp_user_1); - //motor=1; - timer_1.start(); - while(timer_1.read()>=temp_user_1) { - timer_1.stop(); - motor.write(0); - timer_2.start(); - while(timer_2.read()<=timer_1) { - E_2=1; - } - electro_2(); - timer_2.stop(); - timer_3.start(); - while(timer_3.read()<= temp_user_2+temp_user_3+temp_user_4) { - t_2.attach(&electro_3,temp_user_2); - t_3.attach(&electro_3,temp_user_2+temp_user_3); - t_4.attach(&electro_4,temp_user_4); - } - } - - - - - - - } else if (key=='D' && temp_user_1==0) { - lcd.cls(); - lcd.printf(" t_1 empty"); - wait(1.5); - key='\0'; - goto ini_1; - } - - - /* - if(key=='A'){ - while(llena<=2){ - if(llena<3){ - cadena[llena]=keypad.getKey(); - temp_user_1=strtod(cadena,NULL); - llena++; - switch(llena){ - case 0: - if(llena==0 && keypad.getKey()!= '\0'){ - cadena[llena]=keypad.getKey(); - llena=llena +1; - break; - } - - case 1: - if(llena==1 && keypad.getKey()!= '\0'){ - cadena[llena]=keypad.getKey(); - llena=llena+1; - break; - } - - case 2: - if(llena==2 && keypad.getKey()!= '\0'){ - cadena[llena]=keypad.getKey(); - llena=llena+1; - break;} - - default: - break; - }*/ - //lcd.cls(); - //temp_user_1=strtod(cadena,NULL); - //lcd.locate(0,0); - //lcd.printf("t_1=%f",temp_user_1); - - - - + wait_ms(150); }//termina while de main }//termina main
diff -r 2636fe1c6527 -r 9869290cb13f mbed-os.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed-os.lib Mon Mar 04 18:24:53 2019 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/bLandais/code/mbed-os/#4c0e0edd4545