Use "Expr.txt" to monitor input pin.
Then in global loop trigger e-stop is machine is running and input is triggered and in #OnStart event return NAN to abort,
Hello,
I am currently designing a safety enclosure for a small CNC machine that needs to have one main feature: if the doors are open, the user shouldn't be able to start a G-code or turn on the spindle. The machine should also go into E-stop mode if the door is opened during a job. I would like nonetheless the machine to be able to perform certain actions when the doors are open for ergonomic reasons, i.e. manual jog allowed, or using a tool measure length probe.
I have two ideas in mind, both with advantages and drawbacks:
1. Place a switch on the door frame, wired in series with the main e-stop switch. The advantage is that it will be reliable and work for the scenarios mentioned above, except that I won't be able to control the machine manually with an open door.
2. Place a reed switch or a sensor on the door frame, wired to an input of the Mk3/4 controller. I modified the OnStart and M3 scripts to check the state of that pin before starting a job or turning on the spindle and it works well, but the issue here is: how to stop the program while it's running if the door is suddenly opened?
Lastly, am I missing another possibility to achieve this?
If someone already tried something similar or has ideas to give me, I'd greatly appreciate it!
Similar Threads:
Use "Expr.txt" to monitor input pin.
Then in global loop trigger e-stop is machine is running and input is triggered and in #OnStart event return NAN to abort,
Nice, thanks a lot for the fast and helpful reply!
Another question though: how can I force the e-stop when the input changes? I mean with which syntax? I saw the variable _hw_estop in the documentation but it's read-only.
Ok so I solved it by using: exec(cmd('Machine.Emergency_Stop'))
One last thing, could you show me what is the syntax to return a Nan value from the script? I couldn't find it in the documentation.
Here is one solution using Expr.txt:
In main loop, if machine is moving (_hw_stop==0) and inpit 7 is triggered and(_hw_input,64) we execute two things - print alarm and cmd for estopCode:if(_hw_stop==0 && and(_hw_input,64), exec(print('Alarm!!!'), cmd('Machine.Emergency_Stop'))); #OnStart if(and(_hw_input,64), exec(print('Alarm!!!'), nan()));
On on start event we check if input 7 is triggered. We also print alarm but we return nan and start is aborted if it is.