So i have build a machine that is controlled by an Arduino Mega. It has an XY table that is run by two stepper motors. These two steppers need a seperat controller to run fast enough, so i have flashed a Arduino Uno with GRBL and connected the GRBL arduino to the Arduino mega thorugh the mega’s serial1 port.
Using the SerialPassthrough (on the mega) i can communicate with the GRBL arduino. Everything works.
I can now write a code that controls the machine and if i need to move the steppers i send something like “x1000 y500” thorugh the serial1 and it moves to these positions. So far so good.
My problem is, how do i check when the position has been reached? GRBL only sends a ok command, when the position is received, not when it have arrived at that position.
I can send a “?” while is is running and then it returns the actual position (at the time requested) in this string:
(When i send the ? in the above example we were a X159.100 Y32.844)
Is the best approach to disect this string and retrieve the current position and then compare this to the commanded position? Am i missing an easier way? If this indeed the right way, how do i disect this string most efficiently?