Skip to main content
WARNING! From February 2022, these pages are no longer maintained.
Please see the current Duet3D documentation at https://docs.duet3d.com/
Help
/

Site Navigation

Your Account

Choose Language

Revision to Using M581 - External Triggers and Building a Control Panel

Clinton Thomas

+[summary_image|1702]
+[title|Using M581 - External Triggers and Building a Control Panel]
+
+[toc]
+
+[summary]This is how I configured my Duet 2 Wifi to respond to pushbuttons in a control panel.[/summary]
+
+
+
+== Introduction ==
+
+The DuetWifi is hands down the best controller on the market. The only downside is that it doesn’t come with a display/control panel and it’s only compatible with the PanelDue displays. I’ve recently purchased a 5″ PanelDue but for a long time adjusting the Wildbot was troublesome. It involved a lot of walking from my computer to my printer and back. I used triggers and external buttons to solve this problem.
+
+== Required Hardware ==
+
+* Some kind of Pushbutton or switch (I used Idec and Allen-Bradley brand pushbuttons with Normally Open contact blocks)
+* Dupont connectors
+* Wire
+
+== Wiring ==
+
+You want to connect one side of your switch to gnd or the negative coming from your power supply. The other side of the switch will go to a pin on the expansion header. The best way I found to do this is to use Dupont connectors.
+
+{table
+| [image|1703]
+| [image|1704|align=center]
+}
+
+If you look closely you'll see that I used 2P Dupont connectors but one of the pins has a wire going to it. This is because 1P connectors kept falling off so I put a wire in one side of a 2P connector with just an empty pin in the other side.
+
+[br]
+I used the following pins:
+
+* Pin 4 = E2_STOP
+* Pin 9 = E3_STOP
+* Pin 14 = E4_STOP
+* Pin 19 = E5_STOP
+* Pin 26 = E6_STOP
+* Pin 44 = RESET
+
+== Configuring the Firmware ==
+
+Pin 44 forces a reset when shorted to ground so that button was easy enough. For the rest, I had to make changes to the config file. I found the following digging around RepRap.org:
+
+[code]
+M581: Configure external trigger
+Parameters
+ Tnn Logical trigger number to associate the endstop input(s) with, from zero up to a firmware-specific maximum (e.g. 9 for RepRapFirmware)
+ X, Y, Z, E Selects endstop input(s) to monitor
+ P Reserved, may be used in the future to allow general I/O pins to cause triggers
+ S Whether trigger occurs on a rising edge of that input (S1, default), falling edge (S0), or ignores that input (S-1). By default, all triggers ignore all inputs.
+ C Condition: whether to trigger at any time (C0, default) or only when printing a file from SD card (C1)
+
+In RepRapFirmware, trigger number 0 causes an emergency stop as if
+ M112 had been received. Trigger number 1 causes the print to be paused as if M25 had been received. Any trigger number # greater then 1 causes the macro file sys/trigger#.g to be executed.
+[/code]
+
+So, in order to get buttons for pause, home, ATX on, and disable steppers, I had to add the following to my config file:
+
+[code]
+; Input/Output
+M581 E2 S1 T1 C1 ; Pause - PIN4
+M581 E5 S1 T3 C0 ; Disable Steppers - PIN19 - trigger3.g
+M581 E4 S1 T4 C0 ; Home All - PIN14 - trigger4.g
+M581 E3 S1 T2 C0 ; ATX On - PIN9 - trigger2.g
+[/code]
+
+Finally, I had to add macro trigger files. Which are just text files containing the respective commands saved as trigger#.gcode.
+
+[code]
+;tigger2.g
+M80 ; ATX ON
+[/code]
+
+[code]
+;trigger3.g
+M400 ; Finish Current Moves
+M18 ; Disable Steppers
+[/code]
+
+[code]
+;trigger4.g
+M400 ; Finish current moves
+G28 ; Home all axes
+[/code]