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

    How do I trigger a macro during Certain Machine operations

    Scheduled Pinned Locked Moved
    Duet Web Control
    4
    10
    502
    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.
    • wkellyoundefined
      wkellyo
      last edited by

      I have Neopixel Bed lighting that can be controlled using macros. I have one macro that is run when I home the machine since It triggers when clicking the Home All button in DWC which runs the "homeall.g" file in the video you can see the lights turn green.

      But... How can I trigger from other actions such as when a print starts, ends, pauses, etc. when there isn't a file I can place code in calling the macro? There are some files that can work but what about when the filament sensor detects an out of filament condition what could be used to trigger a macro for that? Any help and Ideas with this would be greatly appreciated.

      1 Reply Last reply Reply Quote 0
      • Danalundefined
        Danal
        last edited by

        Most of those have Macros. For example, begin.g when a print starts, pause.g when filiment out (although, there are several possible reasons for a pause, so there may be a better way).

        As for those that don't, you can put the same commands you'd have in the macro directly in the G-Code.

        The above covers a lot of ground. If you have an example of something else, post it, and we'll see if there is an easy way.

        Delta / Kossel printer fanatic

        1 Reply Last reply Reply Quote 0
        • wkellyoundefined
          wkellyo
          last edited by

          Thanks Danal for the positive comments! As the video shows, the lights change to green when the printer is "calibrating" such as homing or bed leveling and after it's done, another GCode dims the lights back to an "Idle" color. I have GCode in the homeall.g file. I also have matching code in the Homez.g, homex.g and homey.g files. My bed lights run from a small arduino connected to a GPIO pin on the DUEX5 board and I'm using M42 to send commands to change the color.
          Is it as simple as knowing which file is called during each operation? You mention a begin.g file, I don't have one with that name. Is there a Duet docs link that might explain more about all the various files I could make use of?

          Here are some other examples I would like to change color with:
          When a print starts, which file could the GCode/macro be called from? I don't have a begin.g file....
          When a print ends, my gcode would be called from stop.g?
          When a print pauses, my gcode would be called from pause.g?
          When a print resumes, my gcode would be called from resume.g?

          Maybe I was simply over analyzing this. I have about 5 colors I'd like to trigger depending on the printer's status.

          1 Reply Last reply Reply Quote 0
          • Danalundefined
            Danal
            last edited by Danal

            Macro Names. I believe this is the whole list:

            bed.g
            pause.g
            resume.g
            cancel.g
            start.g
            stop.g
            sleep.g
            config-override.g
            deployprobe.g
            retractprobe.g
            heightmap.csv
            load.g
            config.g
            unload.g
            resurrect.g
            resurrect-prologue.g
            filament-change.g

            You can search the various documents for the nuances of each.

            P.S. I said "begin.g", it is really 'start.g', and if you don't have one, create it (in 0:/sys/)

            Delta / Kossel printer fanatic

            Phaedruxundefined 1 Reply Last reply Reply Quote 1
            • mrehorstdmdundefined
              mrehorstdmd
              last edited by

              You could put custom gcode in the slicer for the start and end of prints, and if there's anything you want to do at layer change.

              https://drmrehorst.blogspot.com/

              1 Reply Last reply Reply Quote 0
              • wkellyoundefined
                wkellyo
                last edited by

                Thanks so much Danal, that's quite a list of possible macros. This should definitely help me out. mrehorstdmd thanks for the tip about using the slicer I may try that as well but I was hoping to keep the printer and the light changes to itself so I don't have to do custom programming in the slicer. Its definitely an option though! Thanks!

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

                  @Danal said in How do I trigger a macro during Certain Machine operations:

                  heightmap.csv

                  I dunno if I'd consider this one a macro. It's also system created, so if you added anything to it I'm not sure how well it would be parsed afterwards and it would be overwritten next time you ran G29. 😉

                  Z-Bot CoreXY Build | Thingiverse Profile

                  Danalundefined 1 Reply Last reply Reply Quote 0
                  • wkellyoundefined
                    wkellyo
                    last edited by

                    Yes, I recognized that one as well. I make use of the mesh bed compensation and each time I run it, a new heightmap.csv file is created. Thanks!

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

                      @Phaedrux said in How do I trigger a macro during Certain Machine operations:

                      @Danal said in How do I trigger a macro during Certain Machine operations:

                      heightmap.csv

                      I dunno if I'd consider this one a macro. It's also system created, so if you added anything to it I'm not sure how well it would be parsed afterwards and it would be overwritten next time you ran G29. 😉

                      Good point. That list was derived from regex applied to a module in RRF source. Should have taken that one out by hand.

                      Delta / Kossel printer fanatic

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

                        I doubted that you'd typed those all by hand. Well done.

                        Z-Bot CoreXY Build | Thingiverse Profile

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