Door interlock to trigger a pause

Hi all, I’ve built an MPCNC with a rambo board and sending gcode via Repetier. I’m looking for a way to trigger a pause command, either in marlin or repetier if a carve is running and the enclosure door is opened. I’d like to specifically avoid a solution that simply cuts power to the board, as I don’t want to have to rehome it every time the door is opened while simply setting up a carve. Ideally if the MPCNC isn’t running, the door interlock should have no effect.

I’ve got some magnetic contact switches that simply show continuity when the contacts are within an inch of each other. Is there a pin I can connect to that would send some kind of pause or stop command?

This is a place where switching to grbl makes more sense. They have door triggers, and an “alarm” state. IIRC, if the door is opened, it goes into alarm, and you have to clear the alarm to continue. I am not sure if it would work more like a pause or an estop though.

1 Like

Wonder if you could make it work like a filament runout sensor? Not sure if marlin can do that.

That is an interesting idea. Does it pause all motion when the filament sensor triggers? Or just extrusion?

It would be funny to get all the filament sensor configuration parameters renamed to filament or door sensor.

All motion obviously. What good would it do to keep moving the XYZ axis if no filament? :smiley:

Well, travel moves don’t use the filament, so it is possible. I haven’t used a filament feature myself.

This could probably work, but I’m not well versed enough in Marlin to figure out how to do it. Triggering the filament sensor runs an M412 command to enable the runout state, followed by an M600 command to perform the advanced pause functions for changing out the filament. I would need to branch it somewhere in there, probably the runout.cpp file to perform the pause and resume functions and bypass all the filament parts.

I duet, it pauses the print and moves the hot end off the print area. Keeps it from drooling on your print. I changed the code to turn off the hot end, but keep the build plate running. Had a filament runout overnight and it heat creeped enough to jam. Had to take the thing apart while it was paused!

Does filament runout pause after it depletes the planner queue? There should be a little filament available and prints tend not to have long moves, so I would guess it depletes the planner queue (on Marlin anyway).

On a CNC there could be some very long-duration moves queued up. You would have the same problem if Octoprint for example detected an external event and paused: it might be a while before the queue is depleted and the pause actually happened.

A low-level “hard-pause” that froze the motion (acceleration be damned) based on the state of a pin seems like it would be plausible. I don’t know if such a thing exists but I have never heard of anything like that mentioned in Marlin, so I doubt it. It would probably be the easiest way to get this feature in Marlin, but probably more difficult than switching to another controller like LinuxCNC which I am guessing would already have something like that.

1 Like

This is what M410 Quickstop does. The docs do warn that steppers can lose steps.

In the code I could see that it clears the planner buffer. I don’t know if Marlin can remember where it left off exactly, but it’s unlikely.

So it’s more like an emergency stop / kill that keeps the steppers enabled.

So I decided to solve this problem a different way. I was already using a 12v relay connected to FAN2 to signal the spindle to turn on and off. These relays require two inputs to trigger: a 12v source to power the relay and a 12v or -12v signal to trigger the switch. I tapped the FAN2 connection to provide power to this second relay, and used the door switches with a pull up resistor to 12v as the trigger signal. On the load side I connected the 120v line input to the NC connectors and put the whole thing in series with the manual emergency stop.

The result of this is when the spindle isn’t running (FAN2 is 0v) I can open the doors with no effect because the emergency relay isn’t energized. When I start a carve, FAN2 puts the relay into “ready” mode. If the doors open the relay trips and the whole thing shuts down. Since the relay is wired to be NC, the loss of power disables it, and power is immediately restored. I do have to rehome everything, but it’s a small price to pay for an event that I don’t expect to be very frequent.