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

    Modifying a global variable while running

    Scheduled Pinned Locked Moved
    Gcode meta commands
    6
    10
    445
    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.
    • audryhomeundefined
      audryhome
      last edited by

      I wrote a macro to cool down parts after print, using the fan and the XY part trace to scan the entire printed area of the bed until head temperature reach an acceptable value. The idea is to accelerate part cool down, thus reducing wait time.

      However, this process should be interrupted manually if the cooled part is easily removed from bed without damaging it.

      I run a macro to do this, however I would like to interrupt the macro by setting a flag from command line, something like set global.part_cool = false. Macro does something like
      "while (global.part_cool and temperature> something)
      scan_the_bed
      "

      Using G4 P100 in the loop doesn't solve the problem, since G4 does wait, but don't allow me to send command to set a global variable until macro end, which is precisely what I want to avoid.

      Using daemon.g won't solve the problem, since it will execute a set of commands the same way, only at regular intervals.

      Question: Is there a command/trick that would allow this, other than wiring a hardware button somewhere and using it as a trigger?

      Many thanks for help

      cosmowaveundefined 1 Reply Last reply Reply Quote 0
      • cosmowaveundefined
        cosmowave @audryhome
        last edited by

        @audryhome
        that should be possible with daemon.g

        in daemon.g something like:

        if global.part_cool =true
        ....your code
        

        And additionally a macro for toggle the variable:

        if global.part_cool = false
            global.part_cool = true
        else global.part_cool=false
        

        To toggle the variable you can also use the BtnCmd PlugIn for direct access to the object model. But then only in DWC and not on the panel if you have one.

        Note: this code is untested and only for demonstration.

        Mankati FSXT+, DeltaTowerV2, E3D MS/TC

        audryhomeundefined 1 Reply Last reply Reply Quote 0
        • audryhomeundefined
          audryhome @cosmowave
          last edited by

          @cosmowave Thanks for the tip, but I cannot wait 10 Sec between action not put a loop inside the daemon.g code, since my code is scanning a a certain rate to cool down, and I need also to deactivate the daemon.g from the outside => more global variables..... Since this 10 sec is hard coded, I'm stuck....

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

            @audryhome you can use a loop containing a G4 command in the daemon.g file.

            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

            audryhomeundefined 1 Reply Last reply Reply Quote 0
            • audryhomeundefined
              audryhome @dc42
              last edited by

              @dc42 Yes, but it will fire only at 10 sec interval, plus the G4 parameter, plus more, which is far too long.
              I understand the reason why you stretched this delay, but in my case, I just scan the print area with the fan running at100%, nothing to do with print quality. BTW it cools the part, dual extruders and bed 40% quicker on my bigbox.

              For instance, a G4 S4 will end up with 4 +10 minimal delay. Since I cannot change the 10 sec delay, it is useless. Would need as low as 100 ms to be workable for my use case.

              BUT it works when I use the DWC console (set global.cool_part=false) while printing through Octoprint on a RPI 4. There is hope there, except I have to switch from Octoprint to DWC, what I try to avoid.
              I don't dislike DWC, but I use mainly the PanelDue rather than the web interface once launched the print through OCTOAPP on mobile, and setting up a global variable through the panel is not very easy and I don't see how I can do it through octoapp.

              Maybe I miss something on panel due ( custom button with a meta command on main page possible? )

              Many thanks

              jay_s_ukundefined Sindariusundefined 2 Replies Last reply Reply Quote 0
              • jay_s_ukundefined
                jay_s_uk @audryhome
                last edited by

                @audryhome i believe if you add a loop it runs continuously and isn't subject to the 10 second delay

                Owns various duet boards and is the main wiki maintainer for the Teamgloomy LPC/STM32 port of RRF. Assume I'm running whatever the latest beta/stable build is

                dc42undefined 1 Reply Last reply Reply Quote 1
                • Sindariusundefined
                  Sindarius @audryhome
                  last edited by

                  This post is deleted!
                  1 Reply Last reply Reply Quote 0
                  • dc42undefined
                    dc42 administrators @jay_s_uk
                    last edited by

                    @jay_s_uk said in Modifying a global variable while running:

                    @audryhome i believe if you add a loop it runs continuously and isn't subject to the 10 second delay

                    Correct. The 10 second delay occurs when RRF reaches the end of daemon.g or daemon.g aborts, before RRF tries to open and start daemon.g again.

                    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
                    • audryhomeundefined
                      audryhome
                      last edited by

                      @dc42 So I solved the problem by putting a simple macro that shows up on Panel Due main page.
                      This toggles the variable that control the cooling. Then I can modify it while a macro is running in a loop.

                      Regarding daemon.g, I think user should have control on the 10 sec delay. I understand the reason why this is done that way, but this greatly limit the usability of this interesing functionality.

                      Many thanks again for help

                      OwenDundefined 1 Reply Last reply Reply Quote 0
                      • OwenDundefined
                        OwenD @audryhome
                        last edited by OwenD

                        @audryhome said in Modifying a global variable while running:

                        Regarding daemon.g, I think user should have control on the 10 sec delay. I understand the reason why this is done that way, but this greatly limit the usability of this interesing functionality.

                        Actually you have failed to understand the advice you were given.

                        If you put an infinite loop in your daemon.g, it does not run every 10 seconds.

                        ; daemon.g
                        while true
                           echo state.time
                           G4 S1
                        

                        Would do everything in that loop once a second (plus the time to carry out the commands within the loop)

                        As the macro remains open, RRF won't open it again.
                        The reason it was changed to 10 seconds was because every time it's opened it must be read from the SD card, which impacts on other processes.

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