Skip to content
Dan Royer edited this page Jul 22, 2020 · 7 revisions

What is GCODE and why should I care?

GCODE is the language that a Sixi robot understands. It is a text-based human readable format to simplify testing and understanding. if you know your GCODE then you can make a Sixi robot do whatever you want.

When your robot can talk to RO and your robot arm model is in RO then RO can do all the path planning and record/playback stuff for you.

What is the syntax?

[line number]command[options][checksum]

Sections in square brackets [] are optional.

All commands must end with a newline (\n)

The Arduino MEGA 2560 brain imposes a limit of 64 characters on any message. With line number and checksum I recommend you keep your message under 50 characters.

line number

format: "Nw " where N is the literal letter N and w is a whole number. By default line numbers start at zero (N0). Line numbers must be followed by at least one space. If the wrong line number is received a "BADLINENUM w" error occurs, where w is the line number expected. Commands with no line number cannot generate a BADLINENUM error or a BADCHECKSUM error.

command

Format "Aw" where A is a single letter and w is a whole number. Each line must have one command, or nothing will happen. Some commands may have options. See the comprehensive list further down for more specific details.

checksum

Format "w" where * is the literal '' character and w is a whole number. w is calculated by XORing all the characters in the string up to (but not including) the *, including the line number. The checksum is verified by the robot. if the verification fails the command is rejected. If the verification fails and a line number is given the robot generates a "BADCHECKSUM w" error, where w is the line number that failed. Commands with no line number cannot generate a BADLINENUM error or a BADCHECKSUM error.

What are the available commands?

The most up to date info can always be found in the firmware parser.h file.

w means whole number. b means binary (1 or 0). d means potentially decimal number

M110 [Nw]

Set and report line number. If no number given, report only.

M111 [Sw]

Sets flags to n. If no number given, report only.

Combine any valid flags: 1 (echo)

M112

Emergency stop. Set all PIDS to zero.

M114

Report current target position, max feedrate, and max acceleration.

M206 [Xd] [Yd] [Zd] [Ud] [Vd] [Wd]

Set and report home offsets. If no number given, report only.

M306 L(0...5) [Pd] [Id] [Dd]

Adjust PID and report new values. If no number given, report only. L is the joint number where L0 is X L5 is W.

M428

Set home position to the current raw angle values. As soon as this executes the robot will believe the joint angles are X0 Y-90 Z0 U0 V0 W0.

M500

Save home offsets.

M501 Load home offsets.

M502

Reset the home offsets to zero.

M503

Report the home offsets.

D17

Report adjusted sensor values.

D18

Copy sensor values to motor step positions. Deprecated?

D19 [Pb]

Set and report continuous D17 reporting.

D20

Turn off position error.

D21 [Pb]

Set and report limit checking.

D22

Save all PID values to EEPROM.

D50 [Sb]

Set and report strict mode. When strict mode is on all commands MUST have a checksum.

G0 [Xd] [Yd] [Zd] [Ud] [Vd] [Wd] Set the target adjusted joint angles to the values provided. If a value is not given, the target angle for that joint does not change. If any part of the requested destination is outside of range a "LIMIT MIN/MAX [joint number]" for each part will be displayed and no action will be taken.

G28

Go to home position

G90

Set absolute mode

G91

Set relative mode