What the button should do
Note that a true "emergency" stop should cut the power, external from any electronic and firmware control - the big red button illustrated for example
Cut all power
The most definite way to stop a robot is to cut all power to it. Yanking the plug out of the wall works, as does a circuit breaker that's easy to flip by hand, or an https://en.wikipedia.org/wiki/Residual-c... whose test button is easy to press. This will cut all power regardless of any component failure aboard the Duet or robot. Of course it requires a physical action to reset.
Cut the 12/24V supply
If your power supply supports the PS_ON pin of the Duet, then executing the G-code M112 will cancel all executing G-code and shut down the 12/24V circuit. Even if you don't support PS_ON, it still commands all heaters and motors to shut down.
Note that this will make your "always-on" fans turn off even though your hot end may be hot, and it also leaves the head wherever it was when you stopped the machine. The former might produce a hot end jam, and the latter might heat the bed. Also, if your axes are smooth enough, turning off the stepper motors entirely may allow the machine to fall. On the other hand, one of the ways for the MOSFETs controlling the heaters to fail is for them to fail shorted, so that the heaters are on 100% regardless of what the MCU commands; shutting off the 12/24V supply will shut them off in spite of this.
Just stop doing what you're doing
If the machine's misbehaviour is mild, you may want to stop what it's doing but not shut everything down. You can write your own G-code macro for what should happen in this case, for example, turn off all heaters and home the head. At the moment, there is no way to make this interrupt actions in progress (including "wait for heater to reach temperature").
Making a button do what you want
The Duet firmware allows you to associate a state change on any endstop with a "trigger", a user-definable action, with the M581 G-code. Trigger 0 does an emergency stop (like M112), Trigger 1 pauses the print, and any higher number n executes the file triggern.g. So you can arrange for a physical button to execute any command by connecting it to the pins of an unused endstop. Note that in addition to the five endstop connectors on the board (X, Y, Z, E0, E1) there are five more pins on the extension connector that can be used in this way.
Note that triggers only fire on a transition off -> on; you can use M582 to make the trigger fire if the button is already pressed. You can use M574 to select whether the button is normally open or closed.
The easiest way to implement an external reset/emergency stop, is to configure it as an External Trigger (Gcode dictionary)
The forced emergency stop using the easiest method is (inside your config.g file):
M581 T0 E1 S1
Newer versions of the firmware (3.01RC2+) require pin definition before M581:
M950 J1 C"e1stop"
M581 P1 T0 C0
The parameters:
T0 = emergency stop on trigger; T1 = pause print; T{N} = runs the macro "sys/trigger{N}.g" (useful if you want to do things in a specific order, before pausing or sending the emergency stop).
X, Y, Z, E0, E1 = select the endstop pin to monitor for trigger; typically one would use E0 or E1.
S1 or S0 = sets it as raising edge (S1) or falling edge (S0). Set this based on your switch type (NO or NC); typically one would use a NC switch to GND as this will cause a trigger if the switch is removed (providing a safe fallback).
C0 or C1 = when it may trigger: C0 is anytime; C1 is only during a print.
If the switch is reliable and works as expected, you can add Gcode dictionary for it inside your config.g - useful if you need the button to be reset before the Duet can restart (useful if using the PS_ON features).
You can use any free endstop connector on the Duet. If you don't have a DueX board connected to the expansion connector, you can use any of the five En_STOP pins (n = 2-6). They are labelled on the underside of the Duet.
Software resets
Pressing the "Emergency Stop" switch within Duet Web Control or sending M112 also reset the board. this can be useful however are not a direct substitute for a hardwired emergency stop that cuts the power.
Image from https://www.flickr.com/photos/dumbledad/...
7 Comments
Looking at it again, It looks like I need to add M581 T0 E1 S1 to the config.g file. I assume at the end? I also assume E1 is extruder 1 end stop connection and S1 indicates the switch is NO. There is no C0 or C1 parameter so I assume it defaults to C0 and can be triggered anytime. If I want to use PS_ON I am not sure what the correct parameter is to substitue for E1 to assign PS_ON to the command. Please let me know if I understand this right and what to use for PS_ON if you know it. Thanks
James A Doglio - Reply
Hi James, please use the forum for questions (forum.duet3d.com)
Tony -
If I use the PS_ON trigger do I need to connect the stop switch to PS_On and ground? Then, do I need to add the M112 command to Config.g? Does it need other parameters to assign it to the switch? Thanks
James A Doglio - Reply
DWC after reset may show you window offering to “confirm firmware reset” if this is the case increase “Reconnect Delay on Halt:” parameter in DWC. in my case 20 sec worked fine.
philip - Reply
some other useful notes:
@dc42
Q: DWC "Emergency stop button" behaviour.... is it equivalent to hardware reset pin 44 on expansion 50 pin slot? if not - what is the difference
A:No, it is a software reset, however it works very quickly - assuming that you have network connection of course.
Q: which pins out this 50 can be used for M581 ? reading wiring diagram did not help.
A:You can use any free endstop connector on the Duet. If you don't have a DueX board connected to the expansion connector, you can use any of the five En_STOP pins (n = 2-6). They are labelled on the underside of the Duet.
philip - Reply