Reporting position during moves?
-
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.
-
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.
-
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.
-
@JuKu we may support a more fine-grained reporting of machine position in RRF 3.5 or 3.6.