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

    mod function doesn't work with variable or constant name

    Scheduled Pinned Locked Moved
    Gcode meta commands
    2
    4
    202
    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.
    • MathVundefined
      MathV
      last edited by

      Hi everybody,

      I am using the mod(,) function in a while loop and I noticed that the function doesn't work with the contstant "iterations" in it.
      Here is my while loop:

      while iterations < 1000
        if mod(iterations, 50) = 0
          M117 "mod function OK!"
        G4 P100
        continue
      

      The evaluation of mod(140,50) returns the proper value.
      If I create a global variable [name], set it to 140 (and check the assignment with M117) and evaluate mod(global.[name],50), it doesn't return any value.

      Is there somehing I missed?

      Thanks in advance.

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

        @mathv it works OK for me, running in standalone mode, if I replace the M117 line with an echo command.

        It is a feature of DWC that if you send the same M117 message two or more times in succession, you only see the first one. So it also works for me if I replace the M117 line with this:

            M117 {"mod function OK! "^iterations}
        

        because then the message is different each time.

        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

        MathVundefined 1 Reply Last reply Reply Quote 0
        • MathVundefined
          MathV @dc42
          last edited by

          @dc42 , Thanks for your feedback.
          I got this error message when I run it:
          Error: Failed to read code from macro test: Failed to evaluate "mod(iterations, 50) = 0": expected ','
          I am sure it is a very obvious mistake from me, but I can't find it.

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

            @mathv are you running RRF in CNC mode? If so, see my response to https://forum.duet3d.com/topic/24519/rrf3-3-meta-functions-don-t-work-when-in-cnc-mode.

            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