G-Code Detailed Reference

G commands

G0/G1 - Linear Move

Performs a linear move between two points at a certain speed while extruding material.

Parameters

G1 [Xnnn] [Ynnn] [Znnn] [Ennn] [Fnnn]

[Xnnn] where nnn is a co-ordinate point on the X axis.

[Ynnn] where nnn is a co-ordinate point on the Y axis.

[Znnn] where nnn is a co-ordinate point on the Z axis.

[Ennn] where nnn is a value in mm determining how many mm of filament to extrude during the movement.

[Fnnn] where nnn is the speed of movement in mm/min.

Examples

G1 X50.2 Y10.7 E2.6 F1800 move to XY co-ordinate (50.2,10.7) in a straight line at 1800mm/min velocity while extruding 2.6mm of filament.


G4 - Dwell

Makes a pause for a specified period in second or in millisecond before executing next GCode.

The pause can be stopped using M410.

Parameters

G4 [Snnn] [Pnnn]

[Snnn] where nnn is the number of seconds to wait. [Pnnn] where nnn is the number of milliseconds to wait.

Examples

G4 S60 waits for a minute before executing next GCode.


G28 - Home Axes

Homes a specified axes or all axes. Specifying no parameter homes all axes.

Parameters

G28 [X] [Y] [Z]

Examples

G28 X Y Homes X and Y axes.

G28 Home all axes.


G29 - Auto Bed Leveling

Initiates auto bed leveling with the nozzle probe. Requires G28 beforehand, if not homed then it is homed automatically. This will probe the bed with a multi-point grid, then move the active tool to the front-middle of the bed.

After the probing process is complete, you should always verify that the nozzle is not making firm contact with the bed or depressing the probe mechanism. Adjustments should be made using M290.

All parameters are optional.

The probing grid limits the range from 0mm to 450mm but the bed can be smaller. Be careful not to probe outside the bed area, you could damage your toolhead.

Parameters

G29 [D] [Snnn] [Fnnn] [Bnnn] [Lnnn] [Rnnn] [Tnnn] [Xnnn] [Ynnn]

[D] Dry-run mode. Evaluates the bed topology and does not apply or alter the bed level data. Useful to check the topology after a first run of G29.

[Snnn] Set nnn as the XY travel speed between probe points in mm/min. Default to 30000.

[Fnnn] Set nnn as the front limit of the probing grid in mm. Defaults to 35. Limited to [0, 420]. Must be less than [Bnnn].

[Bnnn] Set nnn as the back limit of the probing grid in mm. Defaults to 415. Limited to [30, 450]. Must be greater than [Fnnn].

[Lnnn] Set nnn as the left limit of the probing grid in mm. Defaults to 35. Limited to [0, 420]. Must be less than [Rnnn].

[Rnnn] Set nnn as the right limit of the probing grid in mm. Defaults to 415. Limited to [30, 450]. Must be greater than [Lnnn].

[Tnnn] Set nnn as the maximum toolhead temperature to probe in Celsius. Defaults to 200.

[Xnnn] Set nnn as the number of probe points in X. Defaults to 8. Limited to [3, 10].

[Ynnn] Set nnn as the number of probe points in Y. Defaults to 8. Limited to [3, 10].


G90 - Absolute Positioning

Sets G-code interpretation to absolute position mode where positions are given as absolute values in co-ordinate space.

Parameters

G90

G91 - Relative Positioning

Sets G-code interpretation to relative position mode where the next position is calculated relative to the last known position in co-ordinate space.

Parameters

G91

G92 - Set Position

Manually sets the current position to the values specified by this command. Homing (G28) and probing (G29) will invalidate any set values.

Parameters

G92 [Ennn]

[Ennn] where nnn is the extruder position, in mm.

Examples

G92 E0 sets the current known position to E=0 regardless of the actual physical location of the extruder position.


T0/T1 - Select Active Toolhead

Changes the active toolhead. This will move the initial toolhead back to its parked position, and enable the new toolhead mesh and Z offset.

Parameters

[Tx]

[Tx] where x is an index between 0 or 1 corresponding to the desired tool.

Examples

T1 changes the active toolhead to T1 (right extruder). If the active toolhead is already T1, does nothing.


M commands

M0 - Pause

Pauses the printer once all previously queued movement commands have completed.

Parameters

M0 [Snnn]

[Snnn] where nnn denotes the pause time length in seconds.

Examples

M0 causes the printer to pause and wait until an M108 command is sent to resume printing.

M0 S5 causes the printer to pause for 5 seconds and then resume printing.


M82 - Set E to Absolute

Overrides G91 to set just the extruder into absolute co-ordinates mode. If used, ensure that it is disabled after use to avoid unintended retractions.

Parameters

M82

Examples

G91 ;sets all axes to relative mode
M82 ;sets E to absolute mode, all other axes remain in relative mode

M83 - Set E to Relative

Overrides G90 to set just the extruder into relative co-ordinates mode.

Parameters

M83

Examples

G90 ;sets all axes to absolute mode
M83 ;sets E to relative mode, all other axes remain in absolute mode

M104 - Set Hot End/Chamber Temperature

Sets the hot end/chamber target temperature and continues to the next command.

Parameters

M104 [Tx] [Snnn]

[Tx] where x is 0 (T0), 1 (T1), or 2 (Chamber Heater)

[Snnn] where nnn is the target temperature in °C.

Examples

M104 T1 S250 Set T1 to 250°C

M104 T2 S120 Set chamber temperature to 120°C


M106 - Set Fan Speeds

Turns on and set fan speeds via PWM.

Parameters

M106 [Px] [Snnn]

[Px] where x is an index of 0, 1, or 2. The M2 only has a chamber fan, accessible as index 2.

[Snnn] where nnn is a value between 0-255 for PWM.

Examples

M106 P2 S255 turn chamber heater fan on to full power.


M108 - Resume

Continues after a pause (M0) command. Can also override the waiting period for M109 and M190.

Parameters

M108

Examples

M0 ;pauses print job
M108 ;resumes print job

M109 - Set Hot End/Chamber Temperature and Wait

Sets the hot end/chamber target temperature and waits until target temperature is reached before continuing to the next command.

Parameters

M109 [Tx] [Snnn] [Rnnn]

[Tx] where x is 0 (T0), 1 (T1), or 2 (Chamber Heater)

[Snnn] where nnn is the target temperature in °C. Waits only when heating.

[Rnnn] where nnn is the target temperature in °C. Waits when heating and cooling.

Examples

M109 T1 S250 Set T1 to 250°C and completes its execution only when the temperature is at least at 250.

M109 T2 S120 Set chamber temperature to 120°C and completes its execution only when the temperature is at 120.


M114 - Get Current Position

Reports the current position of the active toolhead.

Parameters

M114 [D]

[D] Detailed mode. Shows detailed position information.

Examples

M114 reports axes co-ordinates of the current active toolhead.


M115 - Get Firmware Information

Reports the current firmware information.

Parameters

M115

Examples

M115 returns a string with information on current firmware.


M119 - Endstop Status

Reports the current status of all endstops and probes - either open or triggered.

Parameters

M119

Examples

M119 returns set of strings reporting on Xmin, Xmax, Y1, Y2, Z1, Z2, Probe.


M140 - Set Bed Temperature

Sets the bed temperature and continues the next command in the buffer.

Parameters

M140 [Snnn]

[Snnn] where nnn is the desired target temperature in °C.

Examples

M140 S150 sets the bed target to 150°C


M190 - Set Bed Temperature and Wait

Sets the bed temperature and waits for target to be reached before continuing to the next command in the buffer.

Parameters

M190 [Snnn]

[Snnn] where nnn is the target temperature in °C. Waits only when heating. [Rnnn] where nnn is the target temperature in °C. Waits when heating and cooling.

Examples

M190 S150 sets the bed target to 150°C and completes its execution only when the temperature is at least at 150°C. M190 R120 sets the chamber temperature to 120°C and completes its execution only when the temperature is at 120°C.


M218 - Set Toolhead Offsets

Adjusts the dual extruder offset calibration, if only T1 is provided echo current offset.

Parameters

M218 T1 [Xnnn] [Ynnn]

[Xnnn] where nnn is the X offset of T1 relative to T0 in mm. Default is 615.

[Ynnn] where nnn is the Y offset of T1 relative to T0 in mm. Default is 0.

Examples

M218 T1 X605 Y-0.2 compensates for T1 that prints 10mm too far to the left and 0.2mm too close towards the front of the bed.


M220 - Movement Feedrate Percentage Override

During a print, overrides the XYZ axes movement speed by a percentage value.

Parameters

M220 [Snnn]

[Snnn] where nnn is a percentage value applied on the feedrate that decreases print speed or increases print speed upto the maximum feedrate of the printer.

Examples

M220 S125 increases print speed by 25%. M220 S10 decreases print speed by 10 times.


M221 - Extrusion Flowrate Percentage Override

During a print, overrides the extruder flowrate by a percentage value.

Parameters

M221 [Tx] [Snnn]

[Tx] where x is the optional extruder number. Current extruder if omitted. [Snnn] where nnn is a percentage value between 0-200%

Examples

M221 S95 decreases material flow rate by 5%. M221 S110 increases material flow rate by 10%.


M290 - Z Offset Adjustment

Allows for micro-adjustments of toolhead Z offset position. This should be used to calibrate the tool position after probing the bed and is equivalent to “touching off” in machining processes.

Parameters

M290 [Znnn]

[Znnn] where nnn is a value in mm to shift the toolhead location by in the Z axis. If a value of 0 or no Z is provided then the current Z offset is output.

Examples

M290 Z-0.1 decreases the nozzle-to-bed distance by 0.1mm.


M301 - Set Hotend and Chamber PID

Sets PID values for the hot ends and chamber heater. Obtain PID values from M303 and set them using this command. Save with M500.

Parameters

M301 [Ex] [Pnnn] [Innn] [Dnnn]

[Ex] where x is an index of -1 (Bed), 0 (T0), 1 (T1), or 2 (chamber heater)

[Pnnn] where nnn is the proportional term of the PID.

[Innn] where nnn is the integral term of the PID.

[Dnnn] where nnn is the derivative term of the PID.

Examples

M301 E0 P15 I1 D50 sets the T0 PID to 15, 1, 50.


M303 - PID Autotune

Automatically determines the appropriate PID values using the Ziegler-Nichols tuning method. Optionally, automatically applies PID values without the use of M301.

Parameters

M303 [Cnnn] [Ex] [Snnn] [U]

[Cnn] where nnn is an integer value denoting the number of heating/cooling cycles

[Ex] where x is an index of -1 (Bed), 0 (T0), 1 (T1), or 2 (Chamber)

[Snnn] where nnn is the set point around which to perform the tuning.

[U] optional - automatically applies the PID values to the heater indexed by [Ex]. Save with M500.

Examples

M303 C5 E0 S300 U run PID tuning on T0 around 300°C cycling 5 times and apply PID values immediately.


M420 - Bed Leveling Configuration Management

Enable/disable bed leveling, set the Z fade height, and/or, print leveling information.

Parameters

M420 [Sx] [Znnn] [V]

[Sx] where x is set to 1 to apply bed leveling and set to 0 to disable bed leveling. [Znnn] where nnn is an integer value denoting the Z fade height value (0 or none to disable Z fade height). [V] verbose - print the leveling grid information including results of the last execution of G29 for both toolheads

Examples

M420 S0 disable bed leveling.


M500 - Save to EEPROM

Saves configuration to EEPROM (programmable read-only memory)

Parameters

M500

M501 - Restore from EEPROM

Restores configuration previously stored in EEPROM. If you need reset them after you changed them temporarily.

Parameters

M501

M502 - Reset EEPROM

Clears EEPROM and restores default values from the firmware, i.e., reverts to the default “factory settings”. You still need to store them in EEPROM afterwards if you want to (M500).

Parameters

M502

M503 - Reports Current Configuration

Reports the current configuration, i.e., not necessarily the one stored in EEPROM. To report the configuration stored in EEPROM, make sure you issus a ‘M501’ before.

Parameters

M503

Last modified: November 15, 2019