Duet3D Logo Duet3D
    • Tags
    • Documentation
    • Order
    • Register
    • Login

    Can you set external triggers to toggle gcode?

    Scheduled Pinned Locked Moved
    Duet Hardware and wiring
    4
    13
    1.4k
    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.
    • Mangy_Dogundefined
      Mangy_Dog
      last edited by

      So I have my printers lighting setup on Fan channel 1 (0 being primary fan)

      Now I would like to set a momentary button to turn the leds on or off. Or even if possible several stages of brightness.

      In c it would be something as simple as changing the state of a boolean light!=light;

      But is it possible to make a trigger do a if statement? If fan1==0 ; fan1=1;... type thing? Or toggle a boolean?

      Can complex scripts be stored in the .g config or trigger.g files?

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

        https://duet3d.dozuki.com/Wiki/Gcode#Section_M581_Configure_external_trigger

        You may be able to work out something with this.

        The conditional scripting you describe isn't currently possible, but is being worked on.

        Z-Bot CoreXY Build | Thingiverse Profile

        1 Reply Last reply Reply Quote 0
        • Mangy_Dogundefined
          Mangy_Dog
          last edited by

          Yeah I've been reading that already. That's fine for setting a state with a single button... Like an end atop or emergency stop. But I would like the ability to cycle through two states or more.

          Is there any kind of expression system that can be used?

          1 Reply Last reply Reply Quote 0
          • frank26080115undefined
            frank26080115
            last edited by

            I have a dynamic button on my Duet, for one example, when a print starts, it is configured for trigger6

            trigger6 contains a command for pause

            pause contains a command to reconfigure the button for trigger7

            trigger7 contains a command for resume

            resume contains a command to reconfigure the button for trigger6

            etc etc

            should be easy to do it for LED stuff

            1 Reply Last reply Reply Quote 1
            • Mangy_Dogundefined
              Mangy_Dog
              last edited by

              Actually that sounds reasonable.... Thanks 🙂

              1 Reply Last reply Reply Quote 0
              • Mangy_Dogundefined
                Mangy_Dog
                last edited by

                Ok having a problem...

                At the end of my config file I have

                M106 P1 S1 ;Turns lights full bright
                M581 T2 E3 S0 ;Light switch

                trigger2.g
                M106 P1 S0.66 ;Turns lights 1/3down
                M581 T3 E3 S0 ;preps next trigger

                trigger3.g
                M106 P1 S0.33 ;Turns lights 2/3down
                M581 T4 E3 S0 ;preps next trigger

                trigger4.g
                M106 P1 S0.0 ;Turns lights off
                M581 T5 E3 S0 ;preps next trigger

                trigger5.g
                M106 P1 S1 ;Turns lights Full on
                M581 T2 E3 S0 ;preps next trigger

                The lights will cycle down once and back to full bright as the button is pressed. But trigger5, the prep next trigger doesnt seem to work.

                So i press the button from fresh restart, turns down 1/3 press again turns down another 1/3 press once more turns off, press again and turns on full bright, but pressing again does nothing. The lights would briefly flash off but isnt cycling down again.

                Am i missing something?

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

                  When you create a new trigger to do something different next time the button is pressed, you should cancel the old one unless you want both trigger files to be run.

                  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

                  Mangy_Dogundefined 1 Reply Last reply Reply Quote 0
                  • Mangy_Dogundefined
                    Mangy_Dog @dc42
                    last edited by

                    @dc42 Oh how do you cancel the old one?
                    I had assuming the new trigger declaration would over write the old one...

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

                      @mangy_dog said in Can you set external triggers to toggle gcode?:

                      @dc42 Oh how do you cancel the old one?
                      I had assuming the new trigger declaration would over write the old one...

                      Read the documentation for M581 on the GCodes wiki page.

                      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
                      • Mangy_Dogundefined
                        Mangy_Dog
                        last edited by

                        I have read the docs and maybe I'm blind I can't see anything about canceling the previous trigger?

                        1 Reply Last reply Reply Quote 0
                        • frank26080115undefined
                          frank26080115
                          last edited by

                          use S-1 to disable a trigger file

                          1 Reply Last reply Reply Quote 1
                          • Mangy_Dogundefined
                            Mangy_Dog
                            last edited by

                            Thanks
                            s-1 wasnt listed on the doku gcode wiki... the reprap gcode wiki did mention it but as a delete all triggers option...

                            Anyway its sorted now thanks 🙂

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

                              @mangy_dog said in Can you set external triggers to toggle gcode?:

                              Thanks
                              s-1 wasnt listed on the doku gcode wiki... the reprap gcode wiki did mention it but as a delete all triggers option...

                              Anyway its sorted now thanks 🙂

                              From the doku wiki:

                              Using S-1 with no X Y Z or E parameters sets the trigger back to ignoring all inputs.

                              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
                              • First post
                                Last post
                              Unless otherwise noted, all forum content is licensed under CC-BY-SA