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

    Reporting position during moves?

    Scheduled Pinned Locked Moved
    Gcode meta commands
    4
    4
    252
    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.
    • JuKuundefined
      JuKu
      last edited by

      Disclaimer: I just started learning, and this is my very first attempt to do anything with meta commands. Please feel free to correct and tell better ways to something.

      I wanted to get position reports to my user interface during machine moves.
      In my config.c I have:

      ; Variables for daemon.g
      global Xposition = move.axes[0].machinePosition
      global Yposition = move.axes[1].machinePosition
      global Zposition = move.axes[2].machinePosition
      global Aposition = move.axes[4].machinePosition
      

      My daemon.g is

      ; daemon.g
      var report = 0
      if global.Xposition != move.axes[0].machinePosition
      	set var.report = 1
      	set global.Xposition = move.axes[0].machinePosition
      if global.Yposition != move.axes[1].machinePosition
      	set var.report = 1
      	set global.Xposition = move.axes[1].machinePosition
      if var.report == 1
      	echo "test X: ",global.Xposition," Y:", global.Yposition
      G4 P250  ; 250 ms delay
      

      Issue 1: move.axes[0].machinePosition doesn't seem to work. Even if I do regular move from the console and say "echo move.axes[0].machinePosition", I get the start position each time, until the move ends.

      issue 2: I asked for 250ms max. delay, but the daemon runs in 10s intervals (not shown, but I put an echo command in the start of the file, and the console shows a message every ten seconds.

      dc42undefined 1 Reply Last reply Reply Quote 0
      • mikeabuilderundefined
        mikeabuilder
        last edited by mikeabuilder

        First - Kudos for diving into metal commands. Loads of fun and useful things you can do.

        In answer to your questions - Please read the short section on daemon.g on this page: https://docs.duet3d.com/en/User_manual/Tuning/Macros. It says that if you want to loop faster than once every 10 seconds, you need to run your own loop inside daemon.g.

        Daemon.g shares compute resources with getting your moves completed, so making a compute intensive daemon.g can impact your "real" work.

        Regarding reading the object model, I think (one of the Duet sw folks may correct me here) that the values in it are only updated at the end of a move and not mid-move. The object model is a list of values held in memory and when you set a variable to the value in the object model, you are just grabbing that value. It's theoretically possible for the fw to update the object model after every motor step is sent to the motor, but I think this would probably take up a lot of CPU time, and writing the memory might not be fast enough.

        Hope this helps.

        1 Reply Last reply Reply Quote 0
        • achrnundefined
          achrn
          last edited by achrn

          As I understand it:

          machinePosition is the end position from the last completed move, so it will always be the start of the current move.

          userPosition is the position in user coordinates (the ones specified in GCode) at the end of the last GCode movement command that has been completely or partially queued for execution. Therefore, it is the starting position for the next GCode movement command that will be added to the queue. Thus, if you want to queue some commands that depend upon position, you should be using userPosition, becaues that's what the position will be when the machine starts processing that command.

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

            @JuKu we may support a more fine-grained reporting of machine position in RRF 3.5 or 3.6.

            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 1
            • First post
              Last post
            Unless otherwise noted, all forum content is licensed under CC-BY-SA