Gcode Reference Guide

Here is a comprehensive list of all the gcode understood by the Makelangelo firmware.  Please use this guide to create your own gcode generator, to understand the gcode created by Makelangelo software, or to build machines that comply with the format.

Gcode commands should be common to most CNC machines and follow the same format as 3D printers, mills, lathes, and others.  For a more complete reference, please visit https://en.wikipedia.org/wiki/G-code.  Wherever possible we have tried to match the format.

Command structure

All commands are on separate lines (one command per line).  All lines end with a newline (\n). A return (\r) is not required.  Blank lines are ignored.
Any text after a ; is ignored. This gives you room to add comments inside a list of gcode commands.  Commands can be preceeded by a line number:

N[n] command;[checksum]

where [n] is some number >= 0 and checksum is a non-printable character (the XOR sum of all previous characters in the command, not including line number and semi-colon ‘;’ ).  Every correctly parsed command with a line number will increment the expected line number.

M Commands

M6 T[n]
Change to tool number [n].

M17
Engage (turn on) all motors. They will actively resist being moved and will obey commands.

M18
Disengage (turn off) all motors. They will not resist being moved and will ignore commands.

M20
List files on SD card (if any) to the serial connection.

M42 P[n1] S[n2]
Change digital pin number [n1] to state [n2] (0 for low voltage, 1 for high voltage)

M100
Print help message to the serial connection.

M101 A[n1] T[n2] B[n3]
Change software limits for axis [n1] to max/top [n2] and minimum/bottom [n3].  These limits are in millimeters.

M102
Print machine axis limits to the serial connection.

M110 N[n]
Change the next expected line number to number [n]. This means that the N[n] can appear twice on a single line with different values. The firmware should treat the first N as the current line number and the second N as the desired line number.

M114
Report the current state of the machine to the serial connection. This includes where it believes it is positioned, the feed rate, the acceleration, and possibly other values.

M117 [string]
Display messsage [string] on the LCD panel.

M226 P[n1] S[n2]
Wait for digital pin number [n1] to be in state [n2] (0 for off, 1 for on).
If P is not included, the default is the LCD button pin.
If S is not included, the default is off (0).

M300 P[n1] S[n2]
Play frequency [n2] for [n1] milliseconds through the LCD speaker.
If P is not included, the default is 250 (1/4s).
If S is not included, the default is 60 (a C note).
Some buzzers cannot play different frequencies.

G commands

G0 X[n1] Y[n2] Z[n3] U[n4] V[n5] W[n6] A[n7] F[n8]
G1 X[n1] Y[n2] Z[n3] U[n4] V[n5] W[n6] A[n7] F[n8]
Move the machine in a straight line to (X,Y,Z,U,V,W) at feedrate F and acceleration A.  All values are millimetres, except F and A which are in motor steps per second.  If any of these parameters are not included, the current value is used.

G2 X[n1] Y[n2] I[n3] J[n4] A[n5] F[n6]
G3 X[n1] Y[n2] I[n3] J[n4] A[n5] F[n6]
Move the machine in an an arc around a circle in the XY plane. The arc begins at the current position. The arc ends at (n1,n2).  The center of the circle of the arc is (n3,n4).  G2 is for clockwise arcs.  G3 is for counter-clockwise arcs.  If any of these values are not included, the value is unchanged.  I and J default to X and Y, respectively.

G4 P[n1] S[n2]
Dwell (wait) for n1 seconds and n2 milliseconds.

G28
Find home. This is different for each machine design. In general this means that the machine moves until it activates sensors to confirm its position. Many machines will refuse other G commands until G28 is completed. G28 is not run automatically when the robot turns for human safety.

G54 X[n1] Y[n2] Z[n3] U[n4] V[n5] W[n6]
Adjust tool offset for tool 0. This way the position the machine will report is the same as the position at the tip of the tool.

G55-G59
Adjust tool offset for tools 1-5. See G54 for more information.

G90
Absolute movement mode. All movement position values are relative to the machine’s frame of reference.

G91
Relative movement mode. All movement position values are relative to the current position.

G92 X[n1] Y[n2] Z[n3] U[n4] V[n5] W[n6]
Adjust the machine’s internal position value.

Non-standard Gcode Commands

The following commands are unique to Makelangelo firmware.  They will not appear in other machines.

UID [n]
Set the robot’s unique id number to [n].

D0 L[n1] R[n2] U[n3] V[n4] W[n5] T[n6]
Jog motors. Each letter represents a different motor. each [n] is a number of steps to move. the number of steps can be negative for a reverse jog. Not all machines have one motor per axis.

D4 [string]
Begin processing the file on the SD card called [string].

D5
Report firmware version number.

D6 X[n1] Y[n2] Z[n3] U[n4] V[n5] W[n6]
Set home position for each axis. When G28 completes the machine will teleport (G92) to this position.

D7 [Lnnn] [Rnnn]
Adjust Makelangelo calibration values for the length of left and right belts. Default is 1011mm.

D8
Report Makelangelo calibration values for left and right belts

D9
Save Makelangelo calibration values for left and right belts.

D10
Print hardware version number to the serial connection.

D11
Set up all default values for the Makelangelo 5.

D12
Assume the robot is as machine reference (absolute) position 0 on each axis. Move towards home switches and measure the distance. Then adjust D6 based on the measured distance.

D13
Adjust the pen angle on the Makelangelo. This is the same as a jog command. it is always absolute position in degrees.

D14
Report the machine style (kinematic model) to the serial connection.