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

    Passing Axis Letters As Macro Parameters to M98

    Scheduled Pinned Locked Moved
    Gcode meta commands
    2
    3
    151
    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.
    • davidjryanundefined
      davidjryan
      last edited by davidjryan

      I have a non-3D printer, 13 axes CNC (M453) system.

      Is it possible to send an axis letter as a macro parameter through M98 and then use it in a G1 (or any) command?

      Say I want to have a single macro that will move any of my axes 5mm in the positive or negative direction. I want to use param.X and param.Y to signify axis letter and direction, respectively.

      Basic G-Code for forward and reverse (what I am trying to achieve through the macro):

      G91 G1 X5 F2000
      or
      G91 G1 X-5 F2000
      based on desired axis and direction, X could be Y, W, A, B, C, D, etc...
      

      I'd like to do this:

      M98 P"jog-axis.g" X"X" Y"Pos"
      

      or

      M98 P"jog-axis.g" X"X" Y"Neg"
      

      Contents of jog_axis.g:

      echo {param.X} ^ "  " ^ {param.Y}    ;just to confirm the macro inputs
      if {param.Y} = "Pos"
          echo "Positive"  ;confirm param.Y was interpreted correctly
          G91 G1 {param.X}5.0 F2000
      elif {param.Y} = "Neg"
          echo "Negative"  ;confirm param.Y was interpreted correctly
          G91 G1 {param.X}-5.0 F2000
      

      The jog_axis.g functon runs but the axis does not move and the console reports:

      Error: in file jog_axis.g line 12: Illegal parameter letter '-'
      

      So, it's interpreting the param.Y value and executing the correct condition. It's just not interpreting param.X as the axis letter for the G1 command and then, subsequently, the '-' in -5 is interpreted as a character/parameter out of place.

      If I put the 5.0 and -5.0 in {}, I can get the Error to go away but the axis still does not move.

      Am I doing anything wrong or am I trying to use a feature that does not currently exist?

      My alternative is to write 13(x2) conditionals for all of my axes. Not the end of the world but I thought passing the axis letter would be more elegant; 6 lines of code vs. 78.

      T3P3Tonyundefined 1 Reply Last reply Reply Quote 0
      • T3P3Tonyundefined T3P3Tony referenced this topic
      • T3P3Tonyundefined
        T3P3Tony administrators @davidjryan
        last edited by

        @davidjryan this is not currently possible. It has been requested in the past and we have a feature request outstanding:

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

        @davidjryan said in Passing Axis Letters As Macro Parameters to M98:

        My alternative is to write 13(x2) conditionals for all of my axes. Not the end of the world but I thought passing the axis letter would be more elegant; 6 lines of code vs. 78.

        Unfortunately this work around is how you need to do it for now.

        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

        davidjryanundefined 1 Reply Last reply Reply Quote 0
        • davidjryanundefined
          davidjryan @T3P3Tony
          last edited by

          @T3P3Tony Thanks, Tony!
          I have the longer form implemented and all works well.

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