I am programming a whole process that coordinates the movement of different motors, pneumatic cylinders, etc., and I have an emergency stop button to stop the process externally if necessary.
I am using CONTROLLINO MEGA. My question is: how should I program so that when I press the emergency button the code that controls all the movements stops completely? (and make everything remain stopped)
What do you mean? I have an external physical button to wire to one of the CONTROLLINO pins . Of course I know that, but I want to know what should I program after wiring everything.
What bluejets means is that it is an uphill battle to get a regulatory agency to accept a software Emergency Stop. For obvious reasons: if your software crashes or is otherwise badly written (both the cases where you're most likely to need the E-Stop), how can you guarantee that the button will be acted on properly?
Standard behavior is to provide E-Stop by disabling power. Secondary problem is making sure that with power off, the system is actually safe. e.g., make sure that shutting off an actuator in mid-stroke doesn't cause a 10-ton weight to come down on someone's head.
Add a relay controlled by the E-stop. Take a contact closure off of that relay to one of the controller inputs to sense if the E-stop has been activated. As others have noted, the hardware E-stop circuit is the primary means of cutting electrical power to the machine, not the secondary means