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

    Using variables as GCode argument keys

    Scheduled Pinned Locked Moved
    Gcode meta commands
    3
    9
    680
    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.
    • pfnundefined
      pfn
      last edited by pfn

      Hi,

      I'm trying to write some gcode expressions like so:

      G1 {global.extruder_axis}2
      G1 {global.extruder_axis ^ "2"}
      G1 {"E2", "F600"}
      M92 {global.extruder_axis ^ global.extruder_steps}

      But all of these result in no action occurring, it seems that the gcode parser ignores the argument keys that evaluate as a result of the expression. (Basically, it's like G1 without arguments, or M92 without arguments).

      I have a workaround, but I really don't like it, is there something that can be done to support the above use-case? @dc42 thoughts?

      echo >"tmp.g" "G1 " ^ global.extruder_axis ^ 2
      M98 P"tmp.g"
      M400
      M30 "sys/tmp.g"
      
      fcwiltundefined T3P3Tonyundefined 2 Replies Last reply Reply Quote 0
      • pfnundefined
        pfn
        last edited by pfn

        This post is deleted!
        1 Reply Last reply Reply Quote 0
        • fcwiltundefined
          fcwilt @pfn
          last edited by

          @pfn

          Another work-around would be to pass a parameter with the desired axis and use that value in a series of IF statements.

          Frederick

          Printers: a E3D MS/TC setup and a RatRig Hybrid. Using Duet 3 hardware running 3.4.6

          pfnundefined 1 Reply Last reply Reply Quote 0
          • pfnundefined
            pfn @fcwilt
            last edited by

            @fcwilt said in Using variables as GCode argument keys:

            @pfn

            Another work-around would be to pass a parameter with the desired axis and use that value in a series of IF statements.

            Frederick

            This approach wouldn't work as there would be any axis, not XYZE. It could be any if UVWABCD and I don't want to repeat the same line of code for each with only the single letter changed.

            fcwiltundefined 1 Reply Last reply Reply Quote 0
            • fcwiltundefined
              fcwilt @pfn
              last edited by

              @pfn said in Using variables as GCode argument keys:

              This approach wouldn't work as there would be any axis, not XYZE. It could be any if UVWABCD and I don't want to repeat the same line of code for each with only the single letter changed.

              Well it would work but if you don't care for it that is entirely up to you.

              Frederick

              Printers: a E3D MS/TC setup and a RatRig Hybrid. Using Duet 3 hardware running 3.4.6

              pfnundefined 1 Reply Last reply Reply Quote 0
              • pfnundefined
                pfn @fcwilt
                last edited by

                @fcwilt it's not a scalable solution

                T3P3Tonyundefined 1 Reply Last reply Reply Quote 0
                • T3P3Tonyundefined
                  T3P3Tony administrators @pfn
                  last edited by T3P3Tony

                  @pfn said in Using variables as GCode argument keys:

                  G1 {global.extruder_axis}2

                  this is invalid, should be G1 {global.extruder_axis}^2

                  @pfn said in Using variables as GCode argument keys:

                  G1 {"E2", "F600"}

                  This should be G1 {"E2"^" "^"F600"}

                  However I have confirmed the core issue in tests, you cannot pass string arguments within gcode meta commands in the way you are trying to do. This impacts situations like this:

                  M92 {global.extruder_axis}^100
                  as well as the combinations you have used above.

                  however
                  M92 E{global.extruder_steps}
                  Should work.

                  Will flag this to @dc42.

                  www.duet3d.com

                  1 Reply Last reply Reply Quote 1
                  • T3P3Tonyundefined
                    T3P3Tony administrators @pfn
                    last edited by

                    @pfn we have updated the documentation to make this clear. :

                    https://duet3d.dozuki.com/Wiki/GCode_Meta_Commands?#Section_Use_of_expressions_within_GCode_commands

                    And I will move this discussion to the firmware wishlist category.

                    www.duet3d.com

                    T3P3Tonyundefined 1 Reply Last reply Reply Quote 1
                    • T3P3Tonyundefined
                      T3P3Tony administrators @T3P3Tony
                      last edited by

                      @T3P3Tony leaving this here if it comes up in searches. There is a feature request for this here:

                      https://github.com/Duet3D/RepRapFirmware/issues/708

                      Related to this request:
                      https://forum.duet3d.com/topic/35660/passing-axis-letters-as-macro-parameters-to-m98

                      T3P3 created this issue in Duet3D/RepRapFirmware

                      open allow expressions to be used as a substitution for any part of a gcode string #708

                      www.duet3d.com

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