External Triggers
-
@deltacon said in External Triggers:
Nice idea, and good write-up!
Actually I believe the confirmation DWC asks for when "ATX Off" is issued, can be disabled in the DWC settings. I don't have it at hand though...Yes that can be disabled now.
-
@hayseed_byte, is there a new URL to your write up? I'm looking to use external push button switches to help with common tasks.
Thanks!
-
The text can be salvaged from the Wayback Machine -- maybe it's worth adding an equivalent as a guide to the official wiki?
-
Your link does not work, it says "404 page not found".
-
I have extracted the text from the Wayback Machine. Here is it is.
===
External Control Panel for Duet Wifi
Clinton Thomas November 13, 2018 BlogControl Panel
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.Image
The wiring looks complicated but it’s not so bad. On each switch, one terminal is wired to common (gnd) and the other is wired to a certain pin on the expansion header. My board is mounted upside-down just to make it super confusing for everyone.Here are the pins I used.
Pin 4 = E2_STOP
Pin 9 = E3_STOP
Pin 14 = E4_STOP
Pin 19 = E5_STOP
Pin 26 = E6_STOP
Pin 44 = RESET
Expansion Header
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: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 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.
So, in order to get buttons for pause, home, ATX on, and disable steppers, I had to add the following to my config file:; 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
Originally, I planned to have a button for HALT (RRF calls it “Emergency Stop” but that’s not what it does, in my opinion) and ATX Off. Duet Web Control asks for confirmation when those commands are sent. As a result, it’s not currently possible to execute them via external triggers.For the rest, I had to add macro trigger files. Which are just text files containing the respective commands saved as trigger#.gcode.
;tigger2.g
M80 ; ATX ON
;trigger3.g
M400 ; Finish Current Moves
M18 ; Disable Steppers
M300 S300 P1000 ; Play a beep sound at 300Hz for 1000milliseconds
;trigger4.g
M400 ; Finish current moves
G28 ; Home all axes
M300 S300 P1000 ; Play a beep sound at 300Hz for 1000milliseconds -
@dc42 is there a way to do conditional logic in macros? Something like this sudocode:
resume.g // resume method after filament runout // maintain sub state for what action to perform next on same macro call int globalSubState; // initial state after runout detected if (state == "paused" && globalSubState < 1 && e0_temp > 210) { // execute whatever macro sets tool to active temperature execcmd "G1 E-100 F1800"; // retract all filament left from runout globalSubState = 1; // set flag for next execution of macro } // remaining filament has been removed and new filament has been hand loaded // go to just above where the last print position was and extrude 10mm to prime, but do not start printing yet else if (globalSubState == 1) { execcmd "G1 R1 X0 Y0 Z5 F6000 ; go to 5mm above position of the last print move"; execcmd "G1 R1 X0 Y0 ; go back to the last print move"; execcmd "M83 ; relative extruder moves"; execcmd "G1 E10 F3600 ; extrude 10mm of filament"; globalSubState = 2; // set flag for next execution of macro } // resume print else { state == "printing"; // unpause the print and resume printing continueprint; }
Or is there another way to do this with multiple macros that you can call, but all off the same trigger? I doubt it, but it doesn't hurt to ask i hope lol
-
Conditionals and variables have been announced for RRF 3
-
@oliof said in External Triggers:
Conditionals and variables have been announced for RRF 3
And partly implemented already; but not really usable before the object model had been completed so that you can access the variables to need.
-
Woah...Didn't realize this was getting any attention. I've been playing around with my website since it wasn't getting any traffic and managed to break it. I'll get it back up as soon as I can.
Here are some pictures of my control panel if anyone is interested.
-
I fixed the link, though now the url is https://www.wildbot3d.xyz/contol-panel/. So the article is back up if anyone wants to check it out in the future.
-
@hayseed_byte would you consider adding the gist of it to the wiki for posterity?
-
@phaedrux said in External Triggers:
@hayseed_byte would you consider adding the gist of it to the wiki for posterity?
I'd be happy to.
-
One thing I'd like to link to an external button is the "Print Another" thing but I'm guessing that's a function of the DWC and not the firmware? Print Another is amazingly useful. I have a few printers that don't have Duet controllers (yet) and I really miss that feature.
-
Remind me to add the name of the last file printed to the RRF3 object model. Then it will be possible to write a macro that reprints the last file printed.
-
@dc42 said in External Triggers:
Remind me to add the name of the last file printed to the RRF3 object model. Then it will be possible to write a macro that reprints the last file printed.
Wow..that would be great. Thank you! I might go ahead and order a fourth duet.
-
@phaedrux I added it to the wiki. I'm not much of a writer but all the information is there, I think.
https://duet3d.dozuki.com/Wiki/Using_M581_-_External_Triggers_and_Building_a_Control_Panel -
@dc42 said in External 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)
@hayseed_byteHey there,
trying to connect some external triggers like in the guide mentioned above.
I had the emergency trigger working (T0) but it seems to cause some weird behavior after resetting...
seems kinda "stuck" - screen freezes and no control with buttons. it comes back to normal after unplugging the external triggers. am I missing something with the way its connected? some resistors maybe?Also, after T0 is engaged I get a "firmware restart" option - a 2nd reset basically, why is that ? a bit redundant, no? anyway to avoid that and have the system restart only once after hitting the emergency button ?
thanks a bunch !
-
@Ringo1508 I thought about that too and I am trying to store the information that the axes have been homed by disabling a trigger in the homing macro. The trigger pin is allways low. When the print starts it checks for the trigger and is supposed to execute the homing macro if it is still active. The problem now is that the homing sequence is not run properly. It seams called from the gcode file it interferes with the code generated by the slicer. I still do not really understand what priority the trigger code has.
@dc42 Could you explain how a trigger behaves during a running print and how I could achieve what I am trying to do?
-
@CJ-BRAVO I was never able to get an emergency stop button to work. The Duets ask for confirmation for emergency stop which sort of defeats the purpose. If I understand you correctly, your 2nd reset might have something to do with switch bounce so you might look into delay/debounce settings.
-
@hayseed_byte said in External Triggers:
The Duets ask for confirmation for emergency stop
I assure you, they don't! They stop immediately, then if the stop wasn't followed by a reset, Duet Web Control asks you if you want to reset.