You are on page 1of 17

Micro-controlador para mquina HENGRUN

Empresa: Grupo Pico (Plastillant)



Antecedentes.
La mquina HR-1600 present una falla despus de un apagn en la zona. Esta falla consisti en perder toda la
calibracin en transductores, zonas de calefaccin, etc. Despus de haber visitado la empresa para hacer dichos ajustes
se not que el transductor de botador presentaba problemas (la calibracin).
Cuando finalmente pudo calibrarse dicho transductor, la mquina presentaba la alarma open_spend al momento de
tratar de mover el botador en manual. Esta alarma se muestra en la pantalla incluso cuando la funcin botador est
desactivada.
Se hizo el intento de correr la mquina bajo ciclo semi o automtico para descartar que realmente existiera un problema
con la funcin de botador. En el primer intento de hacer esta prueba (correr en semi auto) la mquina mostr otra
alarma: Servo drive failure!
Esto denota un dao severo en el sistema de control de la mquina, pues sta no cuenta con servo drive (variador de
frecuencia), sino que es una mquina hidrulica convencional.
Cabe mencionar que tanto Hengrun, como las compaas que le maquilaban los controles electrnicos, quebraron. Por
ende, no se cuenta ni con soporte ni con refacciones. De alguna manera se consigui una tarjeta de entradas y salidas
original de la mquina y se reemplaz por la otra. Este reemplazo corrigi la alarma Servo drive failure!,pero no as con
el problema del botador.
Con esa tarjeta nueva, la mquina ya poda trabajar en semi y/o auto, con un par de detalles:
1. Era necesario abrir y cerrar ambas puertas (operador y no operador) para iniciar el ciclo
2. En ambos modos, al finalizar el ciclo, la alarma open_spend siempre aparece, inhibiendo la repeticin del ciclo
3. La funcin botador sigue sin funcionar en modo manual
Dado todo lo anterior, se decidi hacer un programa para cargarlo en un micro-controlador, pues representa un gasto
menor que reemplazar todo el control por otra marca que ofrezca soporte. Este controlador debera ser capaz de
engaar a la mquina con una serie de rutinas que simulen las funciones de botador y aires, adems de la apertura y
cierre de las puertas (para lograr un verdadero ciclo automtico).
El mismo deber estar interconectado con el control original de la mquina, de manera que el controlador gobernar en
ciertas funciones a la misma. Todo esto sin comprometer ni pasar por alto la seguridad propia de la mquina.
El sistema est diseado para mover en manual el botador y los aires, adems de simular la apertura y cierre de las
puertas en ciclo automtico junto con las funciones antes mencionadas. La ejecucin del programa depende de ciertas
seales, como la de apertura de prensa completada.
En los siguientes apartados se muestran los diagramas de conexiones, diagramas electrnicos, y en anexo, el cdigo del
programa. Para este proyecto, el sistema est basado en open source, utilizando una placa Arduino Mega 2560.

Instalacin
Para instalar este sistema se necesita lo siguiente:
Lnea de 24V y G24 (alimentacin de relays)
Lnea de 12V y G12 (alimentacin de placa arduino)
Lneas de las vlvulas
Tornillos de sujecin

1. Identificar en la mquina las salidas originales del botador y de los soplados
2. Verificar si esas salidas se tratan de un +24 de un G24 (son +24)
3. Retirar esta conexin de la tarjeta y mandarla a las clemas del nuevo control (ver diagramas)
4. Mandar al nuevo control una lnea proveniente de una fuente de 24V, segn el resultado del paso 2
5. Identificar en la botonera original de la mquina los pines del modo manual y del modo automtico
6. Soldar en esos pines 2 cables de 2 hilos (1 para cada botn) y sacar esa lnea hacia el nuevo control
7. Hacer las conexiones y probar su correcto funcionamiento
8. Si las pruebas resultan exitosas, retirar las tarjetas del panel original de control y hacer las 5 perforaciones para
sujetar el nuevo gabinete y para pasar los cables.
9. Volver a instalar las tarjetas del gabinete original de control
10. Hacer una ltima prueba final

Diagramas:
Conexiones en clema (INTERNAS)

1. +12V
2. G12
3. COM 24 (vlvulas)
4. CH1 - NA
5. CH2 - NA
6. CH3 - NA
7. CH4 - NA
8. CH8 - NC
9. CH8 - COM
10. CH7 - NC
11. CH7 - COM
12. CH6 - NA
13. CH6 - COM
14. CH5 - NA
15. CH5 - COM
16. RELAY 24V INTERNO (+)
17. RELAY 24V INTERNO (-)
Conexiones en clema (EXTERNAS)

1. +12V
2. G12
3. COM 24 (vlvulas)
4. SEAL AVANC. BOT.
5. SEAL RET. BOT.
6. SEAL AIRE 1
7. SEAL AIRE 2
8. CABLE PTA DEL 1
9. CABLE PTA DEL 2
10. CABLE PTA TRAS 1
11. CABLE PTA TRAS 2
12. CABLE BOTON MANUAL 1
13. CABLE BOTON MANUAL 2
14. CABLE BOTON AUTO 1
15. CABLE BOTON AUTO 2
16. LIMIT SWITCH APERTURA PRENSA
17. G24

Diagramas electrnicos
SELECTORES DE FUNCIN

POTENCIMETROS

LEDS

TECLADO

MDULO DE RELAYS

CONEXIN DEL FIN DE APERTURA DE MOLDE


CDIGO DEL PROGRAMA

#include "Timer.h"
#include <Keypad.h>

const byte ROWS = 4; // Four rows
const byte COLS = 4; // Three columns
// Define the Keymap
char keys[ROWS][COLS] = {
{
'1','2','3','A' }
,
{
'4','5','6','B' }
,
{
'7','8','9','C' }
,
{
'#','0','*','D' }
};
// Connect keypad ROW0, ROW1, ROW2 and ROW3 to these Arduino pins.
byte rowPins[ROWS] = {
21,20,19,18};
// Connect keypad COL0, COL1 and COL2 to these Arduino pins.
byte colPins[COLS] = {
17,16,15,14};

// Create the Keypad
Keypad kpd = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

// entradas dig

#define ej_sw 13 //INTERRUPT DE PALANCA
#define blw1_sw 12 //INTERRUPT DE PALANCA
#define blw2_sw 11 //INTERRUPT DE PALANCA
#define cl_bwd_end 10 //micro de la mquina

// salidas dig
#define o_ej_fw 45 // RELE CH1
#define o_ej_bw 43 //RELE CH2
#define o_blw1 41 //RELE CH3
#define o_blw2 39 //RELE CH4
#define md_rst_m 37 // CH5 reset MANUAL en control de la mquina //RELE
#define md_rst_a 35 // CH6 reset AUTO en control de la mquina //RELE
#define fd_rst 33 // CH7 reset de puerta delantera //RELE
#define bd_rst 31 // CH8 reset de puerta trasera //RELE
#define man_led 6 //led de modo manual
#define semi_led 5 //led de modo semi
#define aut_led 4 // led de modo auto
#define ej_led 7 //led botador
#define blw1_led 8 //led soplado 1
#define blw2_led 9 //led soplado 2


//entradas analog
#define ej_pot 2
#define blw1_pot 1
#define blw2_pot 0

//variables de funcin
boolean man=LOW;
boolean semi=LOW;
boolean aut=LOW;
int ej_tm=0;
int blw1_tm=0;
int blw2_tm=0;
int cycl_semi=0;
int cycl_aut=0;
boolean ej_fw=LOW;
boolean ej_bw=LOW;
boolean blw1=LOW;
boolean blw2=LOW;
int ej;


// Timers
Timer timer;
//Timer timer2;
Timer eject;
Timer blow1;
Timer blow2;


//variables para reset de timer
int ef; //idem
int eb; //idem
int t_semi; //idem
int t_aut; //idem
int t_aut2; //idem
int b1; //idem
int b2; //idem

//variables flag auto
boolean aux_e;
boolean aux_b1;
boolean aux_b2;


void setup(){

//entradas dig
pinMode(ej_sw,INPUT); // funcin botado
pinMode(blw1_sw,INPUT); // funcin soplado 1
pinMode(blw2_sw,INPUT); // funcin soplado 2
pinMode(cl_bwd_end,INPUT); // fin de apertura de prensa
//salidas dig
pinMode(o_ej_fw,OUTPUT); // avance bot
pinMode(o_ej_bw,OUTPUT); // retroceso bot
pinMode(o_blw1,OUTPUT); // soplado 1
pinMode(o_blw2,OUTPUT); // soplado 2
pinMode(md_rst_m,OUTPUT); // reset MANUAL en control de la mquina
pinMode(md_rst_a,OUTPUT); // reset AUTO en control de la mquina
pinMode(fd_rst,OUTPUT); // reset puerta delantera
pinMode(bd_rst,OUTPUT); // reset puerta delantera
pinMode(o_ej_fw,OUTPUT); // reset puerta trasera
pinMode(man_led,OUTPUT); // led manual
pinMode(semi_led,OUTPUT); // led semi
pinMode(aut_led,OUTPUT); // led auto
pinMode(ej_led,OUTPUT); // led ej
pinMode(blw1_led,OUTPUT); // led blw1
pinMode(blw2_led,OUTPUT); // led blw2


//entradas analog ??????????? --RESUELTO- NO SE NECESITAN ESTAS LINEAS DE CODIGO
//pinMode(ej_pot,INPUT); // temp de bot
//pinMode(blw1_pot,INPUT); // temp sop1
//pinMode(blw2_pot,INPUT); // temp sop2

digitalWrite(o_ej_fw,LOW); // avance bot
digitalWrite(o_ej_bw,LOW); // retroceso bot
digitalWrite(o_blw1,LOW); // soplado 1
digitalWrite(o_blw2,LOW); // soplado 2
digitalWrite(md_rst_m,LOW); // reset MANUAL en control de la mquina
digitalWrite(md_rst_a,LOW); // reset AUTO en control de la mquina
digitalWrite(fd_rst,LOW); // reset puerta delantera
digitalWrite(bd_rst,LOW); // reset puerta trasera
digitalWrite(man_led,LOW);
digitalWrite(semi_led,LOW);
digitalWrite(aut_led,LOW);
digitalWrite(ej_led,LOW); //led botador
digitalWrite(blw1_led,LOW); //led soplado 1
digitalWrite(blw2_led, LOW); //led soplado 2

kpd.addEventListener(keypadEvent); //add an event listener for this keypad

aux_e=LOW;
aux_b2=LOW;
aux_b1=LOW;


Serial.begin(9600);
}// FIN DEL SETUP

char key;
boolean clampState;

void loop()
{
//leyendo el status de la prensa
key = kpd.getKey();
clampState = digitalRead(cl_bwd_end);
timer.update();
//timer2.update();
eject.update();
blow1.update();
blow2.update();

if(digitalRead(ej_sw) == LOW)
{
digitalWrite(ej_led,HIGH); //led botador
}
else
{
digitalWrite(ej_led,LOW);
aux_e=HIGH;
}

if(digitalRead(blw1_sw) == LOW)
{
digitalWrite(blw1_led,HIGH);
}
else
{
digitalWrite(blw1_led,LOW);
aux_b1=HIGH;
}

if(digitalRead(blw2_sw) == LOW)
{
digitalWrite(blw2_led, HIGH); //led soplado 2
}
else
{
digitalWrite(blw2_led, LOW);
aux_b2=HIGH;
}

// if (digitalRead(cl_bwd_end)==LOW)
{
//leyendo potencimetros (TIEMPOS)

ej_tm=analogRead(ej_pot)*2;
blw1_tm=analogRead(blw1_pot)*2;
blw2_tm= analogRead(blw2_pot)*2;

//lectura de las palancas

//modo manual

//para encender el relay es HIGH
if ( (man == HIGH) && (clampState == LOW))
{
switch(key)
{
case '4': // retroceso de botador
digitalWrite(o_ej_bw,HIGH);
delay(ej_tm);
digitalWrite(o_ej_bw,LOW);
break;
case '5': //avance de botador
digitalWrite(o_ej_fw,HIGH);
delay(ej_tm);
digitalWrite(o_ej_fw,LOW);
break;
case '#': //soplado 1
digitalWrite(o_blw1,HIGH);
delay(blw1_tm);
digitalWrite(o_blw1,LOW);
break;
case '0': //soplado 2
digitalWrite(o_blw2,HIGH);
delay(blw2_tm);
digitalWrite(o_blw2,LOW);
break;
}

}//fin manual

//modo semi

if((digitalRead(ej_sw) == LOW) || (digitalRead(blw1_sw) == LOW) || (digitalRead(blw2_sw) == LOW))
{

if(semi==HIGH)
{

if( (cycl_semi==1) && (clampState == LOW))
{ //funciones al ciclo
//botado
if(digitalRead(ej_sw)==LOW)
{
if(ej==1)
{
ef=eject.pulse(o_ej_fw,ej_tm,HIGH);
eject.after(ej_tm,ejf_reset);
ej=2;
}
if((ej==2))
{
eb=eject.pulse(o_ej_bw,ej_tm,LOW);
}
}

//soplado 1
if(digitalRead(blw1_sw)==LOW)
{
b1=blow1.pulse(o_blw1,blw1_tm,HIGH);
blow1.after(blw1_tm,blow1_reset);
}

//soplado2
if(digitalRead(blw2_sw)==LOW)
{
b2=blow2.pulse(o_blw2,blw2_tm,HIGH);
blow2.after(blw2_tm,blow2_reset);
}

cycl_semi=3; //reset

} // fin de funciones de ciclo

if((cycl_semi==0) && (clampState == LOW))
{
digitalWrite(md_rst_m,HIGH);
delay(150);
digitalWrite(md_rst_m,LOW); //manual --mquina
digitalWrite(md_rst_a,HIGH);
delay(150);
digitalWrite(md_rst_a,LOW); //auto mquina
digitalWrite(fd_rst,HIGH);
delay(150); //abrir pta delant
digitalWrite(bd_rst,HIGH);
delay(150);
digitalWrite(bd_rst,LOW);
delay(150); // abrir-cerrar pta tras
digitalWrite(fd_rst,LOW);
delay(150); //cerrar pta delant
cycl_semi=2;
t_semi=timer.after(2000,rst_semi);
}
}

}//fin semi

//modo auto


if((digitalRead(ej_sw) == LOW) || (digitalRead(blw1_sw) == LOW) || (digitalRead(blw2_sw) == LOW))
{

if(aut==HIGH)
{

if((aux_b1 == HIGH) && (aux_b2 == HIGH) && (aux_e == HIGH))
{
timer.after(500, rst_aut2);
}

if( (cycl_aut==1) && (clampState == LOW))
{ //funciones al ciclo
//botado
if(digitalRead(ej_sw)==LOW)
{

if(ej==1)
{
ef=eject.pulse(o_ej_fw,ej_tm,HIGH);
eject.after(ej_tm,ejf_reset);
ej=2;
}
if((ej==2))
{
eb=eject.pulse(o_ej_bw,ej_tm,LOW);
eject.after((ej_tm)*2,ejb_reset);
}

}

//soplado 1
if(digitalRead(blw1_sw)==LOW)
{
b1=blow1.pulse(o_blw1,blw1_tm,HIGH);
blow1.after(blw1_tm,blow1_reset);
}

//soplado2
if(digitalRead(blw2_sw)==LOW)
{
b2=blow2.pulse(o_blw2,blw2_tm,HIGH);
blow2.after(blw2_tm,blow2_reset);
}

// t_aut2=timer.after(6000,rst_aut2);
cycl_aut = 1000;

// timer.after(2000, rst_aut2);

} // fin de funciones de ciclo

if((cycl_aut==0) && (clampState == LOW))
{
digitalWrite(md_rst_m,HIGH);
delay(150);
digitalWrite(md_rst_m,LOW); //manual --mquina
digitalWrite(md_rst_a,HIGH);
delay(150);
digitalWrite(md_rst_a,LOW); //auto mquina
digitalWrite(fd_rst,HIGH);
delay(150); //abrir pta delant
digitalWrite(bd_rst,HIGH);
delay(150);
digitalWrite(bd_rst,LOW);
delay(150); // abrir-cerrar pta tras
digitalWrite(fd_rst,LOW);
delay(150); //cerrar pta delant
cycl_aut=2;
//cycl_semi=1;
t_aut=timer.after(3000,rst_aut);
}


}//fin auto
}

} //fin del if

Serial.print(b1);

}


void rst_aut2()
{
if((aux_b1 == HIGH) && (aux_b2 == HIGH) && (aux_e == HIGH))
{
cycl_aut=0;
aux_b1=LOW;
aux_b2=LOW;
aux_e=LOW;
}
}

void rst_aut()
{
cycl_aut=1;
ej=1;
aux_b1=LOW;
aux_b2=LOW;
aux_e=LOW;
}


void rst_semi()
{
cycl_semi=1;
ej=1;
}


void ejf_reset()
{
eject.stop(ef);
ej=2;
}


void ejb_reset()
{

eject.stop(ef);
aux_e=HIGH;
}


void blow1_reset()
{

blow1.stop(b1);
aux_b1=HIGH;
}

void blow2_reset()
{
blow2.stop(b2);
aux_b2=HIGH;
}



//take care of some special events
void keypadEvent(KeypadEvent key)
{
switch (kpd.getState())
{

case PRESSED:
switch (key)
{
case 'A':
semi=LOW;
aut=LOW;
man=HIGH;

timer.stop(t_semi);
timer.stop(t_aut2);
timer.stop(t_aut);
eject.stop(eb);
eject.stop(ef);
blow1.stop(b1);
blow2.stop(b2);

aux_e=LOW;
aux_b1=LOW;
aux_b2=LOW;

cycl_semi=0;
cycl_aut=0;



digitalWrite(semi_led,LOW);
digitalWrite(aut_led,LOW);
digitalWrite(man_led,HIGH);

digitalWrite(o_ej_fw,LOW); // avance bot
digitalWrite(o_ej_bw,LOW); // retroceso bot
digitalWrite(o_blw1,LOW); // soplado 1
digitalWrite(o_blw2,LOW); // soplado 2
digitalWrite(md_rst_m,HIGH); // reset MANUAL en control de la mquina
delay(150);
digitalWrite(md_rst_m,LOW); // reset MANUAL en control de la mquina

//eject.stop(ej);
break;
case 'B':
man=LOW;
aut=LOW;
semi=HIGH;

digitalWrite(man_led,LOW);
digitalWrite(aut_led,LOW);
digitalWrite(semi_led,HIGH);

timer.stop(t_aut2);
timer.stop(t_aut);

//para cuando se quiere cambiar de auto a semi sin estropear nada

if((cycl_aut!=0))
{
cycl_semi=1;
cycl_aut=0;
}
else
{
cycl_semi=0;
}

ej=1;

/*
if((cycl_semi==3) && (cycl_aut!=0))
cycl_semi=0;
*/
break;

case 'C':
man=LOW;
semi=LOW;
aut=HIGH;

digitalWrite(semi_led,LOW);
digitalWrite(man_led,LOW);
digitalWrite(aut_led,HIGH);

timer.stop(t_semi);

//para cuando se quiere cambiar de semi a auto sin estropear nada

if((cycl_semi!=0))
{
cycl_aut=1;
cycl_semi=0;
}
else
cycl_aut=0;

//cycl_aut = 0;

aux_b1=LOW;
aux_b2=LOW;
aux_e=LOW;

break;
}
break;

case RELEASED:
switch (key)
{
case 'A':

break;
case 'B':


break;
case 'C':

break;
}
break;
}
}

You might also like