SOLDADOR DE DOBLE PULSO CON BLUEPILL STM32F103
Dependencies: mbed QEI Debounced TextLCD
SOLDADOR DE PUNTO PARA SOLDAR BATERIAS DE IONES DE LITIO CON LAMINAS DE NICKEL. EMPLEA UN STM32F103 BLUEPILL. CON UN ENCODER ROTATORIO SE CONFIGURAN TRES TIEMPOS PARA LOS DOS PULSOS Y UN PERIODO DE ESPERA. EL PROGRAMA INICIA CON LA CARGA DEL CONDENSADOR (IGBT1)DE 5 FARADIOS Y TERMINADA LA CARGA DESCONECTA LA FUENTE DEL CONDENSADOR Y LUEGO ENVÍA EL DOBLE PULSO A LAS PUNTAS DEL SOLDADOR(IGBT). EL PULSO SE PUEDE REPETIR SOLO ACCIONANDO EL SUICHE DE PEDAL. (fire). UN PULSADOR ESTA INCORPORADO AL ENCODER (button) Y SIRVE PARA SELECCIONAR EL TIEMPO A CONFIGURAR. UNA VES LOS TIEMPOS SON LOS DESEADOS, SE PISA EL BOTON DE PIE (fire) Y LA SOLDADURA SE INICIA.
LOS tres TIEMPOS SE PUEDEN CAMBIAR ENTRE CERO Y 99 milisegundos
IMAGEN DE PRUEBA CON OSCILOSCOPIO PULSO CORTO DE 5mS DESCANSO Y PULSO LARGO 20mS
main.cpp@2:75153c8d2ef0, 2019-04-29 (annotated)
- Committer:
- tony63
- Date:
- Mon Apr 29 23:26:21 2019 +0000
- Revision:
- 2:75153c8d2ef0
- Parent:
- 1:e10c603cf0ae
SOLDADOR DE PUNTO DE DOBLE PULSO
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
tony63 | 2:75153c8d2ef0 | 1 | //demo display y encoder |
tony63 | 2:75153c8d2ef0 | 2 | //programa para probar un bluepill con encoder y lcd y pulsadores |
tony63 | 2:75153c8d2ef0 | 3 | //control de soldador de punto de doble pulso |
tony63 | 2:75153c8d2ef0 | 4 | //se emiten dos pulsos y una espera intermedia |
tony63 | 2:75153c8d2ef0 | 5 | //antes de hacer esto se carga un condensador de 5F por 3seg con el IGBT1 |
tony63 | 2:75153c8d2ef0 | 6 | //luego se envian los pulsos de soldadura por el IGBT, con los tiempos configurados |
hudakz | 0:271d74b09d64 | 7 | #include "mbed.h" |
hudakz | 0:271d74b09d64 | 8 | #include "TextLCD.h" |
tony63 | 2:75153c8d2ef0 | 9 | #include "QEI.h" |
hudakz | 1:e10c603cf0ae | 10 | |
tony63 | 2:75153c8d2ef0 | 11 | // se configura el lcd en este caso uno de cuatro filas |
tony63 | 2:75153c8d2ef0 | 12 | TextLCD lcd(PA_8, PA_9, PA_10, PA_11, PA_12, PA_15, TextLCD::LCD16x4); // 4-bit bus: RS, E, D4, D5, D6, D7 |
hudakz | 0:271d74b09d64 | 13 | |
tony63 | 2:75153c8d2ef0 | 14 | int p=0,p1=0,p2=0,espera=0,pulsos=0; //variables del programa |
tony63 | 2:75153c8d2ef0 | 15 | int i=0; //posicion de la variable en el display |
tony63 | 2:75153c8d2ef0 | 16 | QEI wheel (PB_3, PB_4, NC, 100); //configuramos encoder de libreria. dos fases y pulsos x rev |
tony63 | 2:75153c8d2ef0 | 17 | InterruptIn button(PB_5); |
tony63 | 2:75153c8d2ef0 | 18 | DigitalIn fire(PB_7); //boton pedal para soldar |
tony63 | 2:75153c8d2ef0 | 19 | DigitalOut IGBT(PB_6); //señal para el igbt |
tony63 | 2:75153c8d2ef0 | 20 | DigitalOut IGBT1(PB_8); //señal para el igbt1 de carga del condensador |
hudakz | 0:271d74b09d64 | 21 | |
tony63 | 2:75153c8d2ef0 | 22 | void flip() { |
tony63 | 2:75153c8d2ef0 | 23 | wait_ms(100); |
tony63 | 2:75153c8d2ef0 | 24 | if(button==0){ |
tony63 | 2:75153c8d2ef0 | 25 | i++; |
tony63 | 2:75153c8d2ef0 | 26 | if(i>2){ |
tony63 | 2:75153c8d2ef0 | 27 | i=0; |
tony63 | 2:75153c8d2ef0 | 28 | } |
tony63 | 2:75153c8d2ef0 | 29 | } |
tony63 | 2:75153c8d2ef0 | 30 | } |
hudakz | 0:271d74b09d64 | 31 | |
tony63 | 2:75153c8d2ef0 | 32 | void weld() { |
tony63 | 2:75153c8d2ef0 | 33 | if(fire==0){ |
tony63 | 2:75153c8d2ef0 | 34 | IGBT1=1; // carga el condensador |
tony63 | 2:75153c8d2ef0 | 35 | wait(3); //tres segundos |
tony63 | 2:75153c8d2ef0 | 36 | IGBT1=0; //fin de la carga |
tony63 | 2:75153c8d2ef0 | 37 | |
tony63 | 2:75153c8d2ef0 | 38 | IGBT=0; |
tony63 | 2:75153c8d2ef0 | 39 | wait_ms(10); |
tony63 | 2:75153c8d2ef0 | 40 | IGBT=1; |
tony63 | 2:75153c8d2ef0 | 41 | wait_ms(p1); |
tony63 | 2:75153c8d2ef0 | 42 | IGBT=0; |
tony63 | 2:75153c8d2ef0 | 43 | wait_ms(espera); |
tony63 | 2:75153c8d2ef0 | 44 | IGBT=1; |
tony63 | 2:75153c8d2ef0 | 45 | wait_ms(p2); |
tony63 | 2:75153c8d2ef0 | 46 | IGBT=0; |
tony63 | 2:75153c8d2ef0 | 47 | wait(3); |
tony63 | 2:75153c8d2ef0 | 48 | } |
tony63 | 2:75153c8d2ef0 | 49 | } |
tony63 | 2:75153c8d2ef0 | 50 | |
tony63 | 2:75153c8d2ef0 | 51 | //..............................INICIA EL PROGRAMA....................................................... |
tony63 | 2:75153c8d2ef0 | 52 | int main() |
tony63 | 2:75153c8d2ef0 | 53 | { |
tony63 | 2:75153c8d2ef0 | 54 | //...............PANTALLA INICIAL........................................... |
tony63 | 2:75153c8d2ef0 | 55 | inicio1: |
tony63 | 2:75153c8d2ef0 | 56 | button.fall(&flip); |
tony63 | 2:75153c8d2ef0 | 57 | IGBT1=0; //apaga el igbt de carga |
tony63 | 2:75153c8d2ef0 | 58 | lcd.cls(); |
tony63 | 2:75153c8d2ef0 | 59 | lcd.locate(3,0); //se posiciona en col 3 y fila 0 |
tony63 | 2:75153c8d2ef0 | 60 | lcd.printf("SPOT WELDER"); //primer mensaje |
tony63 | 2:75153c8d2ef0 | 61 | lcd.locate(3,1); //se posiciona en col 3 y fila 0 |
tony63 | 2:75153c8d2ef0 | 62 | lcd.printf("DUAL PULSE"); //primer mensaje |
tony63 | 2:75153c8d2ef0 | 63 | wait(3); //espera 3 seg |
tony63 | 2:75153c8d2ef0 | 64 | lcd.cls(); //borra pantalla |
tony63 | 2:75153c8d2ef0 | 65 | lcd.locate(0,0); //se posiciona en col 8 y fila 0 |
tony63 | 2:75153c8d2ef0 | 66 | lcd.printf("P1="); //se marca una variable |
tony63 | 2:75153c8d2ef0 | 67 | lcd.locate(8,0); //se posiciona 0,1 |
tony63 | 2:75153c8d2ef0 | 68 | lcd.printf("P2="); //se marca una variable |
tony63 | 2:75153c8d2ef0 | 69 | lcd.locate(0,1); //se posiciona en 8,1 |
tony63 | 2:75153c8d2ef0 | 70 | lcd.printf("Esp="); //se marca una variable |
tony63 | 2:75153c8d2ef0 | 71 | lcd.setCursor(TextLCD::CurOff_BlkOn); //se configura el cursor LCD parpadeante. |
tony63 | 2:75153c8d2ef0 | 72 | |
tony63 | 2:75153c8d2ef0 | 73 | //..............................FIN PANTALLA INICIAL..................................... |
tony63 | 2:75153c8d2ef0 | 74 | //.............programa ciclico.......................................................... |
tony63 | 2:75153c8d2ef0 | 75 | while(1){ |
tony63 | 2:75153c8d2ef0 | 76 | |
tony63 | 2:75153c8d2ef0 | 77 | if(i==0){ |
tony63 | 2:75153c8d2ef0 | 78 | lcd.locate(3,0); |
tony63 | 2:75153c8d2ef0 | 79 | lcd.printf(" "); |
tony63 | 2:75153c8d2ef0 | 80 | p1=wheel.getPulses(); |
tony63 | 2:75153c8d2ef0 | 81 | if(p1<0){ |
tony63 | 2:75153c8d2ef0 | 82 | p1=0; |
hudakz | 0:271d74b09d64 | 83 | } |
tony63 | 2:75153c8d2ef0 | 84 | lcd.locate(3,0); |
tony63 | 2:75153c8d2ef0 | 85 | lcd.printf("%d",p1); |
tony63 | 2:75153c8d2ef0 | 86 | wait_ms(60); |
hudakz | 0:271d74b09d64 | 87 | |
tony63 | 2:75153c8d2ef0 | 88 | } |
tony63 | 2:75153c8d2ef0 | 89 | if(i==1){ |
tony63 | 2:75153c8d2ef0 | 90 | lcd.locate(11,0); |
tony63 | 2:75153c8d2ef0 | 91 | lcd.printf(" "); |
tony63 | 2:75153c8d2ef0 | 92 | p2=wheel.getPulses(); |
tony63 | 2:75153c8d2ef0 | 93 | if(p2<0){ |
tony63 | 2:75153c8d2ef0 | 94 | p2=0; |
tony63 | 2:75153c8d2ef0 | 95 | } |
tony63 | 2:75153c8d2ef0 | 96 | lcd.locate(11,0); |
tony63 | 2:75153c8d2ef0 | 97 | lcd.printf("%d",p2); |
tony63 | 2:75153c8d2ef0 | 98 | wait_ms(60); |
tony63 | 2:75153c8d2ef0 | 99 | |
hudakz | 0:271d74b09d64 | 100 | |
tony63 | 2:75153c8d2ef0 | 101 | } |
tony63 | 2:75153c8d2ef0 | 102 | if(i==2){ |
tony63 | 2:75153c8d2ef0 | 103 | lcd.locate(4,1); |
tony63 | 2:75153c8d2ef0 | 104 | lcd.printf(" "); |
tony63 | 2:75153c8d2ef0 | 105 | espera=wheel.getPulses(); |
tony63 | 2:75153c8d2ef0 | 106 | if(espera<0){ |
tony63 | 2:75153c8d2ef0 | 107 | espera=0; |
tony63 | 2:75153c8d2ef0 | 108 | } |
tony63 | 2:75153c8d2ef0 | 109 | lcd.locate(4,1); |
tony63 | 2:75153c8d2ef0 | 110 | lcd.printf("%d",espera); |
tony63 | 2:75153c8d2ef0 | 111 | wait_ms(60); |
hudakz | 0:271d74b09d64 | 112 | |
tony63 | 2:75153c8d2ef0 | 113 | } |
tony63 | 2:75153c8d2ef0 | 114 | if(fire==0){ |
tony63 | 2:75153c8d2ef0 | 115 | weld(); |
tony63 | 2:75153c8d2ef0 | 116 | /* lcd.cls(); |
tony63 | 2:75153c8d2ef0 | 117 | lcd.printf("WELD-OK"); |
tony63 | 2:75153c8d2ef0 | 118 | wait(2); |
tony63 | 2:75153c8d2ef0 | 119 | goto inicio1; |
tony63 | 2:75153c8d2ef0 | 120 | */ |
tony63 | 2:75153c8d2ef0 | 121 | } |
tony63 | 2:75153c8d2ef0 | 122 | }//while |
tony63 | 2:75153c8d2ef0 | 123 | }//main |