Asking machine about motion status

If you send G1 or any other motion commands those are buffered for good reasons.
I'm doing a pick and place machine with 2 board setup and need to know if the machine has reached it's target position before issuing a depending command to the other board.
Is there any way to ask the machine for the size of the motion buffer, or wait until everything before had been processed?


  • M400 waits until end of all moves so you know it is at destination position. 
  • Oh - that's something I should have found myself.
    It is so obvious, at least in the sourcecode.

  • I had to use two M400 to get this working.
    The reason is that the first M400 sends the ok before it waits.
    So in respect of the gcode stream itself it works, but the client still has no idea if the target position is reached.
    It is the second M400 (or any other command), which returns its ok after the first M400 finished and I assume this only works because GCODE_BUFFER_SIZE is set to 1.
    For me the workaround is good enough, but I'm not sure if this is intended.
    Reading the sourcecode it might be difficult to change.

  • "ok" is just a signal that a command was successfully received. The action can be any time after the ok, that is correct. Is is not that hard tochange though. Remove it in gcode.cpp and add it in the command loop in commands.cpp. Just make sure to only move the good "ok" and not the resend bound "ok" in gcode.cpp.
Sign In or Register to comment.