Skip to main content

Site Navigation

Your Account

Choose Language

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 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)

The forced emergency stop using the easiest method is (inside your config.g file):

M581 T0 E1 S1

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 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


It is a topic about connecting Emergency Stop but there is no information where to connect it and how to config

Piotr Kojder - Reply

Its there, you can wire it to 1. cut the main power supply, 2. Cut the 24/11v power supply, 3. Use an end stop pin for the mushroom and in the program, you can assign feature to that.

Wiring an emergency stop for main power cut off is on google. It can also be used for the 24/12V case also.

Ádám Horváth -

some other useful notes:


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.


philip - 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

Add Comment

View Statistics:

Past 24 Hours: 5

Past 7 Days: 65

Past 30 Days: 274

All Time: 5,545