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

    How can I read the machine position for conditionals?

    Scheduled Pinned Locked Moved
    CNC
    3
    4
    215
    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.
    • TQKez 0undefined
      TQKez 0
      last edited by

      E.g there are lots of relative moves on the z axis that are there to move the head out of the way in the homing code. But being a CNC, the z position is often already near max.

      How could I say e.g (pseudo code)

      if ("z axis position" < 50) {
      ...do the relative z move up
      } else {
      ...do nothing.
      }

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

        @tqkez-0
        Something like this will do it

        if {(move.axes[2].machinePosition) < (move.axes[2].max - 10)} ; check if there's sufficient space to raise head
        	M291 P{"Raising head to...  Z" ^ (move.axes[2].machinePosition+5)}  R"Raising head" S0 T2
        	G91 ; relative positioning
        	G1 Z5 F120 ; move Z up a bit
        	G90 ;absolute positioning
        
        TQKez 0undefined 1 Reply Last reply Reply Quote 1
        • TQKez 0undefined
          TQKez 0 @OwenD
          last edited by

          @owend said in How can I read the machine position for conditionals?:

          @tqkez-0
          Something like this will do it

          if {(move.axes[2].machinePosition) < (move.axes[2].max - 10)} ; check if there's sufficient space to raise head
          	M291 P{"Raising head to...  Z" ^ (move.axes[2].machinePosition+5)}  R"Raising head" S0 T2
          	G91 ; relative positioning
          	G1 Z5 F120 ; move Z up a bit
          	G90 ;absolute positioning
          

          Perfect thanks!

          I've trying to find the list of variables that can be accessed, but i can only seem to find info in the docs about creating custom variables. Is there a list somewhere?

          HebigTundefined 1 Reply Last reply Reply Quote 0
          • HebigTundefined
            HebigT @TQKez 0
            last edited by HebigT

            @tqkez-0

            Check out the object model. https://duet3d.dozuki.com/Wiki/Object_Model_of_RepRapFirmware

            DuetWebControl also includes an object model plugin (at least newer versions do). Run that and you should be able to access the position for each axis and reference it using variations of @TQKez-0's example.

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