Duet3D Logo

    Duet3D

    • Register
    • Login
    • Search
    • Categories
    • Tags
    • Documentation
    • Order

    External Triggers

    Duet Hardware and wiring
    12
    28
    2290
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • hayseed_byte
      hayseed_byte last edited by hayseed_byte

      I did a little write-up on adding pushbutton switches to control my Duet Wifi. I thought it might be helpful if anyone else decides to mess around with external triggers with the Duet.

      https://www.wildbot3d.xyz/contol-panel/

      https://wildbot.me/wildbot
      Gcode Definitions for VSCode extension: https://github.com/hayseedbyte/rrf-gcode-definitions

      1 Reply Last reply Reply Quote 5
      • DeltaCon
        DeltaCon last edited by DeltaCon

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

        If you think trial and error is dangerous, try routine. That's even more so!

        timcurtis67 1 Reply Last reply Reply Quote 0
        • Cata
          Cata last edited by

          Nice job. Thanks

          1 Reply Last reply Reply Quote 0
          • timcurtis67
            timcurtis67 @DeltaCon last edited by

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

            1 Reply Last reply Reply Quote 0
            • Ringo1508
              Ringo1508 last edited by

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

              1 Reply Last reply Reply Quote 0
              • oliof
                oliof last edited by

                The text can be salvaged from the Wayback Machine -- maybe it's worth adding an equivalent as a guide to the official wiki?

                <>Creality CR-20 IDEX Duet3 mini 5+<>RatRig V-Minion SKR RRF 1.1<>

                1 Reply Last reply Reply Quote 1
                • chas2706
                  chas2706 last edited by

                  @hayseed_byte

                  Your link does not work, it says "404 page not found".

                  1 Reply Last reply Reply Quote 0
                  • dc42
                    dc42 administrators last edited by dc42

                    I have extracted the text from the Wayback Machine. Here is it is.

                    ===

                    External Control Panel for Duet Wifi
                    Clinton Thomas November 13, 2018 Blog

                    Control 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

                    Duet WiFi hardware designer and firmware engineer
                    Please do not ask me for Duet support via PM or email, use the forum
                    http://www.escher3d.com, https://miscsolutions.wordpress.com

                    1 Reply Last reply Reply Quote 0
                    • Ringo1508
                      Ringo1508 last edited by Ringo1508

                      @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

                      TC 1 Reply Last reply Reply Quote 0
                      • oliof
                        oliof last edited by

                        Conditionals and variables have been announced for RRF 3

                        <>Creality CR-20 IDEX Duet3 mini 5+<>RatRig V-Minion SKR RRF 1.1<>

                        dc42 1 Reply Last reply Reply Quote 0
                        • dc42
                          dc42 administrators @oliof last edited by

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

                          Duet WiFi hardware designer and firmware engineer
                          Please do not ask me for Duet support via PM or email, use the forum
                          http://www.escher3d.com, https://miscsolutions.wordpress.com

                          1 Reply Last reply Reply Quote 1
                          • hayseed_byte
                            hayseed_byte last edited by hayseed_byte

                            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.

                            https://wildbot.me/wildbot
                            Gcode Definitions for VSCode extension: https://github.com/hayseedbyte/rrf-gcode-definitions

                            1 Reply Last reply Reply Quote 2
                            • hayseed_byte
                              hayseed_byte last edited by

                              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.

                              https://wildbot.me/wildbot
                              Gcode Definitions for VSCode extension: https://github.com/hayseedbyte/rrf-gcode-definitions

                              Phaedrux 1 Reply Last reply Reply Quote 1
                              • Phaedrux
                                Phaedrux Moderator @hayseed_byte last edited by

                                @hayseed_byte would you consider adding the gist of it to the wiki for posterity?

                                Z-Bot CoreXY Build | Thingiverse Profile

                                hayseed_byte 1 Reply Last reply Reply Quote 1
                                • hayseed_byte
                                  hayseed_byte last edited by

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

                                  https://wildbot.me/wildbot
                                  Gcode Definitions for VSCode extension: https://github.com/hayseedbyte/rrf-gcode-definitions

                                  1 Reply Last reply Reply Quote 2
                                  • hayseed_byte
                                    hayseed_byte last edited by

                                    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.

                                    https://wildbot.me/wildbot
                                    Gcode Definitions for VSCode extension: https://github.com/hayseedbyte/rrf-gcode-definitions

                                    1 Reply Last reply Reply Quote 0
                                    • dc42
                                      dc42 administrators last edited by

                                      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.

                                      Duet WiFi hardware designer and firmware engineer
                                      Please do not ask me for Duet support via PM or email, use the forum
                                      http://www.escher3d.com, https://miscsolutions.wordpress.com

                                      Eduma 1 Reply Last reply Reply Quote 0
                                      • hayseed_byte
                                        hayseed_byte last edited by

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

                                        https://wildbot.me/wildbot
                                        Gcode Definitions for VSCode extension: https://github.com/hayseedbyte/rrf-gcode-definitions

                                        1 Reply Last reply Reply Quote 0
                                        • hayseed_byte
                                          hayseed_byte @Phaedrux last edited by

                                          @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

                                          https://wildbot.me/wildbot
                                          Gcode Definitions for VSCode extension: https://github.com/hayseedbyte/rrf-gcode-definitions

                                          1 Reply Last reply Reply Quote 1
                                          • CJ.BRAVO
                                            CJ.BRAVO last edited by CJ.BRAVO

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

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

                                            hayseed_byte 1 Reply Last reply Reply Quote 0
                                            • TC
                                              TC @Ringo1508 last edited by

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

                                              1 Reply Last reply Reply Quote 0
                                              • hayseed_byte
                                                hayseed_byte @CJ.BRAVO last edited by

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

                                                https://wildbot.me/wildbot
                                                Gcode Definitions for VSCode extension: https://github.com/hayseedbyte/rrf-gcode-definitions

                                                dc42 Phaedrux 2 Replies Last reply Reply Quote 0
                                                • dc42
                                                  dc42 administrators @hayseed_byte last edited by

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

                                                  Duet WiFi hardware designer and firmware engineer
                                                  Please do not ask me for Duet support via PM or email, use the forum
                                                  http://www.escher3d.com, https://miscsolutions.wordpress.com

                                                  1 Reply Last reply Reply Quote 0
                                                  • Phaedrux
                                                    Phaedrux Moderator @hayseed_byte last edited by

                                                    @hayseed_byte said in External Triggers:

                                                    The Duets ask for confirmation for emergency stop

                                                    It asks for confirmation of a cancel, but not the stop.

                                                    Z-Bot CoreXY Build | Thingiverse Profile

                                                    1 Reply Last reply Reply Quote 0
                                                    • CJ.BRAVO
                                                      CJ.BRAVO last edited by

                                                      @dc42

                                                      Any way to have the duet to reset automatically without asking for confirmation?

                                                      Also any thoughts regarding the "freeze" situation I encounter while triggering other commands ?

                                                      1 Reply Last reply Reply Quote 0
                                                      • First post
                                                        Last post
                                                      Unless otherwise noted, all forum content is licensed under CC-BY-SA