Cómo restablecer un PLC mediante Ethernet

24 de diciembre de 2018 por
Cómo restablecer un PLC mediante Ethernet
Alejandro Jabalquinto

Introducción

En este post, se verá cómo configurar el Ethernet para permitir al usuario enviar un reinicio a través de Ethernet, en lugar de pulsar el botón manualmente.


Requisitos

Ethernet or 20 I/Os PLC:      Ethernet PLC             20 I/Os PLC     

Placas de Industrial Shields:  Placas de Industrial Shields:  


Descripción

Esta configuración es útil para subir un sketch usando el escudo Ethernet en lugar del USB. Típicamente la carga se hace vía USB, en este caso, el IDE de Arduino envía una orden al escudo de Arduino para reiniciarlo. Cuando es vía Ethernet esto no es posible por defecto. Es decir, hay que enviar una orden que el escudo Ethernet acepte para resetearlo. Por eso hay que configurarlo. 

Esta configuración se realiza mediante el propio software del sketch. Esto significa que en el sketch hay que añadir alguna configuración que diga que cuando se hable con el PLC vía Ethernet usando un determinado puerto, se reinicie automáticamente.


Ejemplo

Veamos cómo se realiza esta configuración en el software:

#include <avr/wdt.h>                                              //library to enable the remote reset
#include <Ethernet2.h>                                            //library to configure the Ethernet Shield

uint8_t mac[] = {0xde, 0xad, 0xbe, 0xef, 0xfe, 0xed};             //mac name
uint8_t ip[] = {192, 168, 1, 211};                                //ip name

EthernetServer server(2000);                                      //port for the communication

void setup() {
    wdt_disable();                                               //disabled remote reset in the setup
    Serial.begin(9600L); 
    Serial.println("remote-reset started");
    Ethernet.begin(mac, ip);                                     //configure the ethernet shield with mac,ip name
    server.begin();                                              //enable the server communication
}

void loop() {
    wdt_reset();                                                 //reset the library to prepare the remote reset
    EthernetClient client = server.available();                  //looks if there is something on port 2000
    
    if (client) {
        wdt_enable(WDTO_4S);                                     //force the reset
        while (true);
   }
   //Code for the Arduino 
}

Usando este sketch vamos a configurar el shield para darle un nombre y poder hablar con el PLC usando Ethernet. Ahora el PLC es capaz de reiniciarse al enviar un solo carácter ("a") después de establecer la conexión usando la IP 192.168.1.211 y el puerto 2000. 

Keep in mind the reset itself will be done after the current loop is finished, so in large programs the reset may no be done instantly and may take a while.

Buscar en nuestro blog

Cómo restablecer un PLC mediante Ethernet
Alejandro Jabalquinto 24 de diciembre de 2018
Compartir

¿Estás buscando tu Controlador Lógico Programable ideal?

Echa un vistazo a esta comparativa de producto de varios controladores industriales basados en Arduino.

Comparamos entradas, salidas, comunicaciones y otras especificaciones con las de los equipos de otras marcas destacadas.


Industrial PLC comparison >>>