arret_urgence.ino
La base de la seguridad de máquina: un contacto de cierre negativo (NC) en IN1 corta los relés en cuanto se abre el lazo, el estado queda memorizado y nada arranca sin rearme manual en IN2. El cable de guarda se supervisa constantemente.
Hardware
Una Opta PLC de STMicroelectronics (STM32H747 en tiempo real + coprocesador seguro i.MX RT1052) programada con el entorno Arduino PLC, alimentada a 24 V DIN. Botón de seta NC cableado en el lazo de seguridad sobre IN1, botón de rearme RAZ sobre IN2.
Cableado
Lazo AU: 24 V → botón NC → IN1; los dos botones en serie. 0 V a COM. Verificar continuidad del lazo antes de poner en servicio.
Funcionamiento
El lazo sano mantiene IN1 a 1; cualquier apertura (pulso, cable cortado) dispara la corte total memorizada. El rearme exige lazo rehecho + pulso RAZ.
Ejecución
Instala el gestor de placas Arduino PLC, selecciona «Opta PLC», conecta USB/DFU y vuelca el programa. El sketch corre por el STM32H747 en tiempo real.
Variantes
Añadir un contacto auxiliar de control de arco en los relés (detección de soldadura) o registrar los eventos AU en EEPROM/SD.
arret_urgence.ino
// Opta PLC : arrêt d'urgence sur contact NF (IN1), mémorisé, réarmement manuel.
// Règle : contact NF actif = 24 V présent ; perte du 24 V = défaut = arrêt.
#include "PLCContainer.h"
PLCContainer PLC;
bool defautAU = false; // état mémorisé de l'arrêt d'urgence
unsigned long tNF = 0; // anti-rebond du contact NF
bool nfStable = true;
void setup() {
Serial.begin(115200);
PLC.begin();
PLC.DigitalIn.setMode(OPTA_IN_1, PLCDigitalIn::PULL_UP); // boucle AU
PLC.DigitalIn.setMode(OPTA_IN_2, PLCDigitalIn::PULL_UP); // réarmement
Serial.println("Arret d'urgence actif (NF sur IN1, RAZ sur IN2)");
}
void coupure_totale() {
PLC.Relay[0].off();
PLC.Relay[1].off();
defautAU = true;
PLC.LedRgb.set(255, 0, 0); // rouge = AU mémorisé
Serial.println(">>> ARRET D'URGENCE — tout est coupé");
}
void loop() {
bool nf = PLC.DigitalIn.read(OPTA_IN_1); // true = boucle saine
if (nf != nfStable && millis() - tNF > 50) { nfStable = nf; tNF = millis(); }
if (!nfStable) coupure_totale(); // boucle ouverte -> coupure
if (defautAU) {
// Réarmement : boucle refaite ET bouton RAZ enfoncé (IN2, actif à 0)
if (nfStable && !PLC.DigitalIn.read(OPTA_IN_2)) {
defautAU = false;
PLC.LedRgb.set(0, 255, 0);
Serial.println("RAZ effectuee : redemarrage machine autorise");
}
return; // verrou : rien ne redémarre seul
}
PLC.LedRgb.set(0, 0, 255); // bleu = machine armée
// ... ici la logique machine normale, avec relais commandés par cycle ...
}