I am making a little machine that interprets g-code and moves some steppers around appropriately. I am using an arduino as the brains on the machine side and sending commands to it from some software I am also building.

If it receives a command to move the steppers, lets say, a thousand steps how does the computer know when its done moving and ready to receive another command?

Once the arduino receives a command, "L101G01X9Y10" for example, should it respond with any sort of code to say "Ok I got it, give me another command"?

NOTE: I am not looking for a custom solution in this case. I am trying to establish what the standard protocol is


2 Answers 2


After each line of Gcode sent from the host to the controller, all the RepRap G-code interpreters (typically) respond with a line that starts with "ok" and ends with a newline. Most of the time it's just those 3 bytes -- "ok\n" -- but occasionally there's some debugging information at the end of the line.

Have you considered maybe starting with one of the RepRap Gcode interpreters that run on an Arduino, and tweaking it to meet your needs, rather than starting from scratch?

Most of those RepRap interpreters work exactly like Michael Pruitt pointed out -- they have an internal buffer that can hold several lines of Gcode. The interpreter holds off on sending the "ok" reply until there is enough room in that buffer for the next line of Gcode. When there is plenty of space in the buffer, the interpreter may immediately send "ok" in response to several G1 codes, buffering them all up, sending those OKs long before it actually executes any of those commands.

I hear there are a variety of other methods to tell the drip-feeder software on the host end that the machine is ready for the next line of Gcode: dnc4U mentions "XON/XOFF, RTS/CTS Haas Xmodem and Heidenhain Blockwise handshaking protocols".

I wish there was a single standard protocol, or some way to automatically detect which standard protocol today's machine is using.


See: http://en.wikipedia.org/wiki/G-code G-code is a one way protocol; I think echoing of interpreted commands is very common. Otherwise the DNC terminal would be blank.

Traditionally, the target machine will halt and display and alarm to the operator (a person) if an error occurs.

I doesn't matter if the interpreter has processed the command. What does matter is if the communications buffer has room for more data.

The machine will use Hardware or software flow control of the communications link to prevent the sending computer from overflowing the buffer. The specific implementation is related to what kind of link you are using.

See: http://en.wikipedia.org/wiki/Flow_control

If you plan on using something fancier than a terminal program, you can send what ever you want back. I don't know if there are any standards. Don't confuse it with systems that do the interpolation on the PC, such as Mach 3 (http://www.machsupport.com/).


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.