arret_urgence.ino
Machine safety basics: a normally-closed contact on IN1 cuts the relays the moment the loop opens, the fault latches, and nothing restarts without a manual reset on IN2. The guard loop is supervised continuously.
Hardware
An STMicroelectronics Opta PLC (real-time STM32H747 + secure i.MX RT1052 companion) programmed with the Arduino PLC environment, 24 V DIN-rail supply. NC mushroom emergency button wired into the safety loop on IN1, reset pushbutton on IN2.
Wiring
E-stop loop: 24 V → NC button → IN1; both buttons in series. 0 V to COM. Verify loop continuity before commissioning.
How it works
A healthy loop holds IN1 high; any opening (press, cut wire) triggers latched total shutdown. Reset requires the loop closed again + reset press.
Running it
Install the Arduino PLC boards manager, select “Opta PLC”, wire USB/DFU and upload. The sketch runs on the real-time STM32H747 side.
Variants
Add relay arc-welding check via auxiliary contacts, or log E-stop events to 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 ...
}