thinkyhead

G0, G1 - Linear Move

1.0.0-beta planner Add a straight line movement to the planner

The G0 and G1 commands add a linear move to the queue to be performed after all previous moves are completed. These commands yield control back to the command parser as soon as the move is queued, but they may delay the command parser while awaiting a slot in the queue.

A linear move traces a straight line from one point to another, ensuring that the specified axes will arrive simultaneously at the given coordinates (by linear interpolation). The speed may change over time following an acceleration curve, according to the acceleration and jerk settings of the given axes.

A command like G1 F1000 sets the feedrate for all subsequent moves.

Marlin treats G0 (rapid linear movement) as an alias to G1 (rapid movement).

By convention, most G-Code generators use G0 for non-extrusion movements (those without the E axis) and G1 for moves that include extrusion. This is meant to allow a kinematic system to, optionally, do a more rapid uninterpolated movement requiring much less calculation.

Usage

G0 [E<pos>] [F<rate>] [X<pos>] [Y<pos>] [Z<pos>]

Argument Description
[E<pos>]

The length of filament to feed into the extruder between the start and end point

[F<rate>]

The maximum movement rate of the move between the start and end point. The feedrate set here applies to subsequent moves that omit this parameter.

[X<pos>]

A coordinate on the X axis

[Y<pos>]

A coordinate on the Y axis

[Z<pos>]

A coordinate on the Z axis

Notes

  • Coordinates are given in millimeters by default. Units may be set to inches by G20.
  • In Relative Mode (G91) all coordinates are interpreted as relative, adding onto the previous position.
  • A single linear move may generate several smaller moves due to kinematics and bed leveling compensation.
  • Developers, keep using G0 for non-print moves. It makes G-Code more adaptable to lasers, engravers, etc.
  • In a future version of Marlin, G0 will do rapid movement, optionally, on SCARA machines.

Examples

The most basic move sets a feedrate and moves the tool to the given position.

G0 X12   ; move to 12mm on the X axis
G0 F1500 ; set the feedrate to 1500mm/minute
G1 X90.6 Y13.8 ; move to 90.6mm on the X axis and 13.8mm on the Y axis

There are some caveats related with feedrates. Consider the following:

G1 F1500 ; set the feedrate to 1500mm/minute
G92 E0
G1 X50 Y25.3 E22.4 ; move while extruding

In the above example the feedrate is set to 1500mm/minute, then the tool is moved 50mm on the X axis and 25.3mm on the Y axis while extruding 22.4mm of filament between the two points.

G1 F1500
G92 E0
G1 X50 Y25.3 E22.4 F3000

However, in the above example, we set a feedrate of 1500 mm/minute on line 1 then do the move described above, accelerating to a feedrate of 3000 mm/minute (if possible). The extrusion will accelerate along with the X and Y movement, so everything stays synchronized.


thinkyhead

G2, G3 - Controlled Arc Move

1.0.0-beta planner Add an arc movement to the planner

G2 adds a clockwise arc move to the planner; G3 adds a counter-clockwise arc. An arc move starts at the current position and ends at the given XYZ, pivoting around a center-point offset given by I and J. Arc moves actually generate several short straight-line moves, the length of which are determined by the configuration option MM_PER_ARC_SEGMENT (default 1mm). Any change in the Z position is linearly interpolated over the whole arc.

Usage

G2 [E<pos>] [F<rate>] I<offset> J<offset> R<radius> [X<pos>] [Y<pos>] [Z<pos>]

Argument Description
[E<pos>]

The amount to extrude between the start point and end point

[F<rate>]

The maximum rate of the move between the start and end point

I<offset>

An offset from the current X position to use as the arc center

J<offset>

An offset from the current Y position to use as the arc center

R<radius>

A radius from the current XY position to use as the arc center

[X<pos>]

A coordinate on the X axis

[Y<pos>]

A coordinate on the Y axis

[Z<pos>]

A coordinate on the Z axis

Examples

Move in a clockwise arc from the current position to (125, 32) with the center offset from the current position by (10.5, 10.5).

G2 X125 Y32 I10.5 J10.5

Move in a counter-clockwise arc from the current position to (125, 32) with the center offset from the current position by (10.5, 10.5).

G3 X125 Y32 I10.5 J10.5

Move in a complete clockwise circle with the center offset from the current position by 20, 20.

G2 I20 J20

thinkyhead

G4 - Dwell

1.0.0-beta planner Add a pause to the planner.

Dwell pauses the command queue and waits for a period of time.

Usage

G4 [P<time in ms>] [S<time in sec>]

Argument Description
[P<time in ms>]

Amount of time to dwell

[S<time in sec>]

Amount of time to dwell

Notes

If both S and P are included, S takes precedence.

G4 with no arguments is effectively the same as M400.

Examples

G4 P500 ; Dwell for 1/2 second

MarlinFirmware

G5 - Bézier cubic spline

1.1.0-RC7 planner Cubic B-spline with XYZE destination and IJPQ offsets

G5 creates a cubic B-spline in the XY plane with the X and Y axes only. P and Q must both be specified for every G5 command. For the first G5 command in a series of G5 commands, I and J must both be specified. For subsequent G5 commands, either both I and J must be specified, or neither. If I and J are unspecified, the starting direction of this cubic will automatically match the ending direction of the previous cubic (as if I and J are the negation of the previous P and Q).

Usage

G5 I<pos> J<pos> P<pos> Q<pos> X<pos> Y<pos>

Argument Description
I<pos>

X incremental offset from start point to first control point

J<pos>

Y incremental offset from start point to first control point

P<pos>

X incremental offset from start point to first control point

Q<pos>

Y incremental offset from start point to first control point

X<pos>

A coordinate on the X axis

Y<pos>

A coordinate on the Y axis

Notes

It is an error if an axis other than X or Y is specified.

Examples

For example, to program a curvy N shape:

G0 X0 Y0
G5 I0 J3 P0 Q-3 X1 Y1

A second curvy N that attaches smoothly to this one can now be made without specifying I and J:

G5 P0 Q-3 X2 Y2

thinkyhead

G10 - Retract

1.0.0-beta planner Retract the filament

Retract the filament according to settings of M207.

Usage

G10

Notes

Requires FWRETRACT.

Examples

G10 ; retract

thinkyhead

G11 - Recover

1.0.0-beta planner Recover the filament with firmware-based retract.

Unretracts the filament according to settings of M208.

Usage

G11

Notes

Requires FWRETRACT.

Examples

G11 ; recover

MarlinFirmware

G12 - Clean the Nozzle

1.1.0-RC7 nozzle Perform the nozzle cleaning procedure.

{“Start the nozzle cleaning process. Two types of cleaning patterns are supported”=>”stroke-based and zigzag-based. This feature requires a dedicated cleaning area on or outside the bed, but within reach of the nozzle.”}

Usage

G12 [P<0|1>] [S<count>] [T<count>]

Argument Description
[P<0|1>]

Pattern style selection

[S<count>]

Number of strokes (i.e. back-and-forth movements)

[T<count>]

Number of repetitions

Notes

Default behavior is defined by NOZZLE_CLEAN_STROKES, NOZZLE_CLEAN_START_POINT, NOZZLE_CLEAN_END_POINT and NOZZLE_CLEAN_PARK.

With NOZZLE_CLEAN_PARK enabled, the nozzle automatically returns to the XYZ position before G12.

Examples

The most basic example is to use the command without any arguments, this will default to a stroke based pattern which will be stroked NOZZLE_CLEAN_STROKES times.

G12 ; stroke pattern (default)

To generate a three triangle zig-zag pattern which will be stroked one time use the following command.

G12 P1 S1 T3 ; zig-zag pattern with 3 triangles

thinkyhead

G20 - Inch Units

1.1.0-RC7 units Set Units to Inches.

Set units to inches. In this mode, all positions, offsets, rates, accelerations, etc., specified in G-Code parameters are interpreted as inches.

Usage

G20

Examples

G20 ; set units to inches

thinkyhead

G21 - Millimeter Units

1.1.0-RC7 units Set Units to Millimeters.

Set units to millimeters. In this mode, all positions, offsets, rates, accelerations, etc., specified in GCode parameters are interpreted as millimeters.

Usage

G21

Examples

G21 ; set units to millimeters

MarlinFirmware

G27 - Park the nozzle

1.1.0-RC7 nozzle Move the nozzle to a predefined position.

Park the nozzle at a predefined XYZ position.

Usage

G27 [P<0|1|2>]

Argument Description
[P<0|1|2>]

Z axis action

P0:

If current Z-pos is lower than Z-park then the nozzle will be raised to reach Z-park height

P1:

No matter the current Z-pos, the nozzle will be raised/lowered to reach Z-park height

P2:

The nozzle height will be raised by Z-park amount but never going over the machine’s limit of Z_MAX_POS

Notes

Requires NOZZLE_PARK_FEATURE.

The park position is defined by NOZZLE_PARK_POINT.

Examples

The most basic example is to use the command without any arguments, this will default to a move the the parking position and raising the Z-pos if lower than the default Z-park position.

G27 ; raise Z if lower

This one is useful to be used on the end-script of a print, it will raise the Z-pos by Z-park.

G27 P2 ; always raise Z

thinkyhead

G28 - Auto Home

1.0.0-beta planner Auto home one or more axes.

Auto-home one or more axes, moving them towards their endstops until triggered. Each axis is backed off and re-bumped according to the [XYZ]_HOME_BUMP_MM and HOMING_BUMP_DIVISOR settings.

Usage

G28 [X] [Y] [Z]

Argument Description
[X]

Flag to go back to the X axis origin

[Y]

Flag to go back to the Y axis origin

[Z]

A coordinate on the Z axis

Notes

Homing is required before G29, M48, and some other procedures.

If homing is needed the LCD will blink the X Y Z indicators.

Examples

The most-used form of this command is to home all axes:

G28 ; Go to origin on all axes

With no arguments to G28, Marlin homes according to the Z_SAFE_HOMING, QUICK_HOME and HOME_Y_BEFORE_X settings.

G28 X Z ; Home the X and Z axes

thinkyhead

G29 - Automatic Bed Leveling

1.0.0-beta planner Probes the bed at 3 or more points

Probes the bed at 3 or more points and enables bed leveling compensation. The exact procedure and method depends on the type of bed leveling chosen in Configuration.h:

  • AUTO_BED_LEVELING_3POINT probes 3 points and uses a matrix to compensate for bed tilt.
  • AUTO_BED_LEVELING_LINEAR also uses a tilt matrix but probes a grid and applies “least-squares.”
  • AUTO_BED_LEVELING_BILINEAR probes a grid and produces a mesh to adjust Z across the bed.
  • There is also a manual MESH_BED_LEVELING option for setups without a probe.

The printer must be homed with G28 before G29.

Usage

G29 [B<pos>] [D<flag>] [F<pos>] [L<pos>] [P<int>] [R<pos>] [S<rate>] [T<flag>] [V<1|2|3|4>] [X<int>] [Y<int>]

Argument Description
[B<pos>]

Set the back limit of the probing grid

[D<flag>]

Dry-Run mode. Just probe the grid but don’t update the bed leveling data

[F<pos>]

Set the front limit of the probing grid

[L<pos>]

Set the left limit of the probing grid

[P<int>]

Set the size of the grid that will be probed (P x P points)

[R<pos>]

Set the right limit of the probing grid

[S<rate>]

Set the XY travel speed between probe points

[T<flag>]

Generate a Bed Topology Report

[V<1|2|3|4>]

Set the verbose level

[X<int>]

Override the X-size of the grid that will be probed

[Y<int>]

Override the Y-size of the grid that will be probed

Notes

Any arguments left out of G29 will use the default values set in Configuration.h.

Examples

G29 is most commonly used without any arguments. This uses the parameters set in Configuration.h.

G29 ; execute ABL

Probe a 5x5 matrix:

G29 P5 ; 5x5 matrix

Probe a 4x8 matrix from X50 Y50 to X150 Y150, printing a full report:

G29 X4 Y8 L50 R150 F50 B150 T V4

thinkyhead

G29 - Manual Bed Leveling

1.0.0-beta planner Probes a grid and produces a mesh

With Mesh Bed Leveling (MBL) you can interactively measure a grid of Z heights without a bed probe. The only tool required is a piece of paper or a feeler gauge. MBL uses the mesh to compensate for variations in height across the bed.

This feature is enabled with the MESH_BED_LEVELING option in Configuration.h. Users with a probe should enable one of the AUTO_BED_LEVELING_* options instead.

The procedure for Mesh Bed Leveling from your host software:

  1. Use G29 S0 to get the current status and mesh. If there’s an existing mesh, you can send M420 S1 to use it.
  2. Use G29 S1 to move to the first point for Z adjustment.
  3. Adjust Z so a piece of paper can just pass under the nozzle.
  4. Use G29 S2 to save the Z value and move to the next point.
  5. Repeat steps 3-4 until completed.
  6. Use M500 to save the mesh to EEPROM, if desired.

The procedure for Manual Bed Leveling from your LCD controller:

  1. Select Level Bed then choose Level Bed (not Cancel) in the sub-menu.
  2. Wait for Homing XYZ to complete.
  3. When Click to Begin appears, press the controller button to move to the first point.
  4. Use the controller wheel to adjust Z so that a piece of paper can just pass under the nozzle.
  5. Press the controller button to save the Z value and move to the next point.
  6. Repeat steps 4-5 until completed.
  7. Use Control > Store memory to save the mesh to EEPROM, if desired.

Usage

G29 S<0|1|2|3|4|5>

Argument Description
S<0|1|2|3|4|5>

S0:

Produce a mesh report (see example 1)

S1:

Start probing mesh points

S2:

Probe the next mesh point

S3:

Manually modify a single point

S4:

Set Z-Offset, positive away from bed, negative closer to bed.

S5:

Reset and disable mesh

Examples

S0 produces a mesh report as follows:

+----> X-axis  1-n
|
|
v Y-axis  1-n

thinkyhead

G30 - Single Z-Probe

1.0.0-beta calibration Probe bed at current XY location

Do a single Z probe at a specified position. By default probe in the current position.

Usage

G30 [X<pos>] [Y<pos>]

Argument Description
[X<pos>]

X probe position

[Y<pos>]

Y probe position


thinkyhead

G31 - Dock Sled

1.0.0-beta planner Dock the Z probe sled.

Dock the Z probe sled.

Usage

G31

Notes

Requires Z_PROBE_SLED.

Examples

Dock the sled.

G31

thinkyhead

G32 - Undock Sled

1.0.0-beta planner Undock the Z probe sled.

Undock the Z probe sled.

Usage

G32

Examples

Undock the sled.

G32

thinkyhead

G38.2, G38.3 - Probe target

1.1.0 calibration Probe towards a workpiece and stop on contact.

The Probe Target commands are used to probe towards a workpiece and determine its precise position. The Z endstop doubles as the probe for these commands. You might, for example, use a grounded metal workpiece, with a metal probe spliced into the Z endstop circuit.

  • G38.2 probes towards a target and stops on contact, signaling an error if it reaches the target position without triggering the Z endstop.
  • G38.3 probes towards a target and stops on contact. No error is given if it fails to trigger the Z endstop.

These commands use the current homing feedrate, by default.

Usage

G38.2 [F<rate>] [X<pos>] [Y<pos>] [Z<pos>]

Argument Description
[F<rate>]

Feedrate for the move

[X<pos>]

Target X

[Y<pos>]

Target Y

[Z<pos>]

Target Z

Notes

These commands require G38_PROBE_TARGET.


thinkyhead

G90 - Absolute Positioning

1.0.0-beta units Use absolute positions.

In absolute mode all coordinates given in G-Code are interpreted as positions in the logical coordinate space. This includes the extruder position unless overridden by M83.

Usage

G90

Notes

Absolute positioning is the default.


thinkyhead

G91 - Relative Positioning

1.0.0-beta units Use relative positions.

Set relative position mode. In this mode all coordinates are interpreted as relative to the last position. This includes the extruder position unless overridden by M82.

Usage

G91

thinkyhead

G92 - Set Position

1.0.0-beta planner Set the current position of one or more axes.

Set the current position to the values specified. In Marlin 1.1.0 and up, the software endstops are adjusted to preserve the physical movement limits. Thus you could use G92 to set the middle of the bed to 0,0 and then run .gcode that was sliced for a Deltabot.

Usage

G92 [E<pos>] [X<pos>] [Y<pos>] [Z<pos>]

Argument Description
[E<pos>]

New extruder position

[X<pos>]

New X axis position

[Y<pos>]

New Y axis position

[Z<pos>]

New Z axis position

Notes

In earlier versions of Marlin G92 doesn’t update the software endstops, so it was unsupported to set coordinates outside these boundaries. In Marlin 1.1.0 and up, the physical boundaries are maintained. This means you can no longer use G92 to move below the bed, for example.

Examples

Specify that the nozzle’s current X position is 10 and the current extruder position is 90.

G92 X10 E90

Specify that the nozzle’s current XYZ position is 0, 0, 0.

G92 X0 Y0 Z0

thinkyhead

M0, M1 - Unconditional stop

1.0.0-beta planner Stop and wait for user.

The M0 and M1 commands pause after the last movement and wait for the user to continue.

Usage

M0

Notes

Without an LCD controller or EMERGENCY_PARSER this command is ignored.

With EMERGENCY_PARSER enabled the M108 command can be used to continue.

Examples

Stop and wait

M0

Display a message, stop, and wait

M0 Click to continue

thinkyhead

M17 - Enable Steppers

control Enable/Power all stepper motors.

Usage

M17

thinkyhead

M18, M84 - Disable steppers

control Disable all steppers (same as M84).

Usage

M18 [E<flag>] [S<seconds>] [X<flag>] [Y<flag>] [Z<flag>]

Argument Description
[E<flag>]

E Disable

[S<seconds>]

Inactivity Timeout. If none specified, disable now.

[X<flag>]

X Disable

[Y<flag>]

Y Disable

[Z<flag>]

Z Disable


thinkyhead

M20 - List SD Card

sdcard List the contents of the SD Card.

Usage

M20

Notes

Requires SDSUPPORT


thinkyhead

M21 - Init SD card

sdcard Attempt to detect an SD card in the slot.

Use this command if the SD card isn’t detected automatically.

Usage

M21

Notes

Requires SDSUPPORT


thinkyhead

M22 - Release SD card

sdcard Simulate ejection of the SD card

Use M21 to enable the SD card after M22.

Usage

M22

Notes

Requires SDSUPPORT


thinkyhead

M23 - Select SD file

sdcard Select an SD file to be executed

Usage

M23

Notes

Requires SDSUPPORT


thinkyhead

M24 - Start or Resume SD print

sdcard Start or resume a file selected with `M23`

Usage

M24

Notes

Requires SDSUPPORT


thinkyhead

M25 - Pause SD print

sdcard Pause printing from the SD card

Usage

M25

Notes

Requires SDSUPPORT


thinkyhead

M26 - Set SD position

sdcard Set the read position in the selected SD file

Usage

M26

Notes

Requires SDSUPPORT


thinkyhead

M27 - Report SD print status

sdcard Print SD status and position to serial

Usage

M27

Notes

Requires SDSUPPORT


thinkyhead

M28 - Start SD write

sdcard Start writing to a file on the SD card

Usage

M28

Notes

Requires SDSUPPORT


thinkyhead

M29 - Stop SD write

sdcard Stop writing to the file begun with `M28`.

Usage

M29

Notes

Requires SDSUPPORT


thinkyhead

M30 - Delete SD file

sdcard Delete a specified file from SD.

Usage

M30

Notes

Requires SDSUPPORT

Examples

Delete the file “/path/to/file.gco”

M30 /path/to/file.gco

thinkyhead

M31 - Print time

printjob Report the current print time.

This command reports the time elapsed since the start of the current print job to the host. When printing from SD card, the print job timer starts as soon as SD printing starts.

If PRINTJOB_TIMER_AUTOSTART is enabled then the first M109 or M190 command received from the host will also start the print job timer.

For manual control from the host, use M75, M76, and M77 to start, pause, and stop the print job timer.

Usage

M31

thinkyhead

M32 - Select and Start

sdcard Begin an SD print from a file.

The M32 command exists to allow G-Code to load other G-Code files and run them as sub-programs.

For legacy reasons in M32 uses the ‘!’ character to start the filename (which must also be the last command parameter).

Usage

M32 [P<flag>] [S<filepos>]

Argument Description
[P<flag>]

Sub-Program flag

[S<filepos>]

Starting file offset

Notes

Requires SDSUPPORT

Beta level and little-used feature. Needs more testing and use cases.

Examples

Select and start a file at offset 5022.

M32 S5022 !/boats/sailboat.gco

Select and start a file from within G-Code.

M32 P !/models/lgbust.gco#

The # suffix is needed when using P to “stop buffer pre-reading” so no commands after M32 will go into the buffer until after it returns.


thinkyhead

M33 - Get Long Path

sdcard Convert a short pathname to a long pathname.

Usage

M33 path

Argument Description
path

DOS 8.3 path to a file or folder

Notes

Requires SDSUPPORT and LONG_FILENAME_HOST_SUPPORT

Examples

Get the long path for a file

M33 funstuff/mask.gco

Output

FunStuff/Mask.gcode

thinkyhead

M34 - SDCard Sorting

sdcard Set SDCard file sorting options.

One of Marlin’s branches contains experimental support for SDCard file sorting in the LCD menus. This feature uses free SRAM to create a sorting index for the first 256 files in each folder, and can optionally cache file listings for a more responsive UI. Buffering only occurs during file browsing. Otherwise the SRAM is freed.

Usage

M34 [F<-1|0|1>] [S<bool>]

Argument Description
[F<-1|0|1>]

Folder Sorting

[S<bool>]

Enable Flag

Notes

Requires SDSUPPORT and SDCARD_SORT_ALPHA


thinkyhead

M42 - Set Pin State

control Set an analog or digital pin to a specified state.

For custom hardware not officially supported in Marlin, you can often just connect up an unused pin and use M42 to control it.

Usage

M42 P<int> S<int>

Argument Description
P<int>

A digital pin number (even for analog pins) to write to

S<int>

The state to set. PWM-able pins may be set from 0-255.


thinkyhead

M43 - Debug Pins

debug Get information about pins.

When setting up or debugging a machine it’s useful to know how pins are assigned to functions by the firmware, and to be able to find pins for use with new functions. M43 provides these tools. M43 by itself reports all pin assignments. Use P to specify a single pin. Use W to watch the specified pin, or all pins. Use the E option to monitor endstops.

The W watch mode option continues looping, blocking all further commands, until the board is reset. If EMERGENCY_PARSER is enabled, M108 may also be used to exit the watch loop without needing to reset the board.

Usage

M43 [E<bool>] [P<pin>] [W<bool>]

Argument Description
[E<bool>]

Watch endstops

[P<pin>]

Digital Pin Number

[W<bool>]

Watch pins

Notes

Requires PINS_DEBUGGING. This feature should be disabled for production use.

Examples

Get a report on all pins

M43

Watch pin 56 for changes

M43 P56 W

Start watching endstops

M43 E

thinkyhead

M48 - Probe Accuracy Test

calibration Measure Z Probe repeatability.

Probes come in many flavors and as such have varying levels of accuracy, reliability, and repeatability, depending on several factors. This command tests the probe for accuracy and produces a standard deviation based on two or more probes of the same XY position.

Usage

M48 [E<engage>] [L<legs>] [P<count>] [V<level>] [X<pos>] [Y<pos>]

Argument Description
[E<engage>]

Engage for each probe

[L<legs>]

Number of legs to probe

[P<count>]

Number of probes to do

[V<level>]

Verbose Level

[X<pos>]

X Position

[Y<pos>]

Y Position

Notes

Requires Z_MIN_PROBE_REPEATABILITY_TEST.


thinkyhead

M75 - Start Print Job

printjob Start the print job timer.

Start the print job timer.

Usage

M75

Examples

Start the print job timer

M75

thinkyhead

M76 - Pause Print Job

printjob Pause the print job timer.

Pause the print job timer.

Usage

M76

Examples

Pause the print job timer

M76

thinkyhead

M77 - Stop Print Job

printjob Stop the print job timer.

Stop the print job timer.

Usage

M77

Examples

Stop the print job timer

M77

thinkyhead

M78 - Print Job Stats

printjob Print statistics about print jobs.

Usage

M78

thinkyhead

M80 - Power On

control Turn on the power supply.

Turn on the high-voltage power supply. Requires a board that’s powered from USB or another 5V source.

Usage

M80

Notes

Requires POWER_SUPPLY and a digital pin connected to the PSU’s enable pin.


thinkyhead

M81 - Power Off

control Turn off the power supply.

Turn off the high-voltage power supply. If the board is not powered from another source, this may also shut down the electronics.

Usage

M81

Notes

Requires POWER_SUPPLY and a digital pin connected to the PSU’s enable pin.


thinkyhead

M82 - E Absolute

units Set E to absolute positioning.

This command is used to override G91 and put the E axis into absolute mode independent of the other axes.

Usage

M82

thinkyhead

M83 - E Relative

units Set E to relative positioning.

This command is used to override G90 and put the E axis into relative mode independent of the other axes.

Usage

M83

thinkyhead

M85 - Inactivity Shutdown

control Set the inactivity timeout.

Use this command to set a maximum period of time for the machine to be inactive (with no moves). If the machine is idle for longer than the set period, the firmware will shut everything down and halt the machine.

Usage

M85 S<seconds>

Argument Description
S<seconds>

Max inactive seconds


thinkyhead

M92 - Set Axis Steps-per-unit

planner Set the number of steps-per-mm or steps-per-inch.

Use M92 to set the steps-per-unit for one or more axes. This setting affects how many steps will be done for each unit of movement. Units will be in steps/mm unless inch mode is set with G20 (which requires INCH_MODE_SUPPORT).

Usage

M92 [E<steps>] [T<index>] [X<steps>] [Y<steps>] [Z<steps>]

Argument Description
[E<steps>]

E steps per unit

[T<index>]

Target extruder (Requires DISTINCT_E_FACTORS)

[X<steps>]

X steps per unit

[Y<steps>]

Y steps per unit

[Z<steps>]

Z steps per unit

Notes

Get current steps-per-unit settings with M503.

With EEPROM_SETTINGS enabled:

  • This setting for all axes is saved with M500 and loaded with M501.
  • M502 resets steps-per-unit for all axes to the values from DEFAULT_AXIS_STEPS_PER_UNIT.

Examples

Set E steps for a new extruder

M92 E688.4

thinkyhead

M100 - Free Memory

debug Description Here

Use M100 for development purposes to observe how much memory (particularly stack) is being used by code. Proper AVR code should avoid use of new, malloc, etc., and instead use either pre-allocated static variables or stack.

Usage

M100 [C<n>] [D] [F] [I]

Argument Description
[C<n>]

Corrupt ‘n’ locations in the free memory pool and report the locations of the corruption. This is useful to check the correctness of the M100 D and M100 F commands.

[D]

Dump the free memory block from __brkval to the stack pointer.

[F]

Return the number of free bytes in the memory pool along with other vital statistics that define the memory pool.

[I]

Initialize the free memory pool so it can be watched and print vital statistics that define the free memory pool.

Notes

Requires M100_FREE_MEMORY_WATCHER.


thinkyhead

M104 - Set Hotend Temperature

thermal Set a new target hot end temperature.

Set a new target hot end temperature and continue without waiting. The firmware will continue to try to reach and hold the temperature in the background.

Use M109 to wait for the hot end to reach the target temperature.

Usage

M104 [B<temp>] [F<flag>] [S<temp>]

Argument Description
[B<temp>]

AUTOTEMP: The max auto-temperature.

[F<flag>]

AUTOTEMP: Autotemp flag. Omit to disable autotemp.

[S<temp>]

Target temperature.
AUTOTEMP: the min auto-temperature.

Notes

  • With PRINTJOB_TIMER_AUTOSTART this command will stop the print job timer if the temperature is set at or below half of EXTRUDE_MINTEMP.

Examples

Simple set target temperature

M104 S180

AUTOTEMP: Set autotemp range

M104 F S180 B190

AUTOTEMP: Disable autotemp

M104

thinkyhead

M105 - Report Temperatures

thermal Send a temperature report to the host.

Request a temperature report to be sent to the host at some point in the future. Some hosts may hide the reply from M105.

Usage

M105 [T<index>]

Argument Description
[T<index>]

Hotend index

Notes

A better way for hosts to get regular temperature updates is to use M155 (requires AUTO_REPORT_TEMPERATURES and EXTENDED_CAPABILITIES_REPORT). Hosts then no longer need to run an extra process or use up slots in the command buffer.

Examples

Get a temperature report

M105

thinkyhead

M106 - Set Fan Speed

thermal Turn on the fan and set its speed

Turn on one of the fans and set its speed. If no fan index is given, the print cooling fan.

Usage

M106 [P<index>] [S<speed>]

Argument Description
[P<index>]

Fan index

[S<speed>]

Speed

Notes

M106 with no speed sets the fan to full speed.

Turn off fans with M107.


thinkyhead

M107 - Fan Off

thermal Turn off a fan

Turn off one of the fans. If no fan index is given, the print cooling fan.

Usage

M107 [P<index>]

Argument Description
[P<index>]

Fan index

Notes

Turn on fans with M106.


thinkyhead

M108 - Break and Continue

control Break out of the current waiting loop

The M108 command requires EMERGENCY_PARSER for full effectiveness. (Otherwise a full queue blocks the parser.)

Some G-Code commands cause Marlin to go into a closed loop, waiting indefinitely for a certain state or event. For example, M109 waits for the target temperature to be reached, and M0 waits for an LCD click.

  • In the case of M109, the M108 command stops waiting for the target temperature and continues processing G-Code. This may result in “cold extrude” messages. For a full stop use M112.
  • In the case of M0 the M108 command acts like the LCD button, breaking out of M0 and continuing to process the G-Code queue.

Usage

M108

Notes

With both EMERGENCY_PARSER and HOST_KEEPALIVE_FEATURE enabled, hosts will be able to prompt for continuation or cancellation, confirming with M108 and cancelling with M112.

Examples

Use M108 as a “Continue” button in your host software.

M0 You're up, mate ; in your G-Code file
M108               ; as your "Continue" button

thinkyhead

M109 - Wait for Hotend Temperature

thermal Wait for the hot end to reach its target.

This command optionally sets a new target hot end temperature and waits for the target temperature to be reached before proceeding. If the temperature is set with S then it waits only when heating.

Usage

M109 [B<temp>] [F<flag>] [R<temp>] [S<temp>]

Argument Description
[B<temp>]

With AUTOTEMP, the max auto-temperature.

[F<flag>]

Autotemp flag. Omit to disable autotemp.

[R<temp>]

Target temperature (wait for cooling or heating).

[S<temp>]

Target temperature (wait only when heating). Also AUTOTEMP: The min auto-temperature.

Notes

With PRINTJOB_TIMER_AUTOSTART this command will start the print job if heating, and stop the print job timer if the temperature is set at or below half of EXTRUDE_MINTEMP.

This command (and M190) can block new commands from the host. To break out of wait for temperature using M108 from the host, enable EMERGENCY_PARSER.

Use M104 to set the hot end temperature and proceed without waiting.

Examples

Set target temperature and wait (if heating)

M109 S180

Set target temperature, wait even if cooling

M109 R120

AUTOTEMP: Set autotemp range, wait for temp

M109 F S180 B190

AUTOTEMP: Disable autotemp, wait for temp

M109

thinkyhead

M110 - Set Line Number

hosts Set the current line number.

Hosts can use M110 to set the current line number in a print job. Each line number sent by a host must be one higher than the previous line number, or the firmware will ignore the line and send an error requesting a resend of the missing line. This is one technique Marlin uses to keep in sync with hosts.

Usage

M110 N<line>

Argument Description
N<line>

Line number

Notes

All these are valid: N100 M110, M110 N100, N101 M110 N100.


thinkyhead

M111 - Debug Level

hosts Report and optionally set the debug flags.

Marlin has several debug bits that can be set, in combination, to help configure, troubleshoot, and debug the firmware. Add up the debug bits you need:

  • 1 ECHO - Echo all commands sent to the parser.
  • 2 INFO - Print extra informational messages.
  • 4 ERRORS - Print extra error messages.
  • 8 DRYRUN - Don’t extrude, don’t save leveling data, etc.
  • 16 COMMUNICATION - Not currently used.
  • 32 LEVELING - Detailed messages for homing, probing, and leveling. (Requires DEBUG_LEVELING_FEATURE.)

Usage

M111 [S<flags>]

Argument Description
[S<flags>]

Debug flag bits

Examples

Enable extra messages

M111 S38 ; LEVELING, ERRORS, INFO

Enable dry-run mode

M111 S8

thinkyhead

M112 - Emergency Stop

safety Shut everything down and halt the machine.

Used for emergency stopping, M112 shuts down the machine, turns off all the steppers and heaters, and if possible, turns off the power supply. A reset is required to return to operational mode.

Usage

M112

Notes

M112 is the fastest way to shut down the machine using a host, but it may need to wait for a space to open up in the command queue. Enable EMERGENCY_PARSER for an instantaneous M112 command.

Examples

Shut down now!

M112

thinkyhead

M113 - Host Keepalive

hosts Get or set the host keepalive interval.

During some lengthy processes, such as G29, Marlin may appear to the host to have “gone away.” The “host keepalive” feature will send messages to the host when Marlin is busy or waiting for user response so the host won’t try to reconnect.

Usage

M113 [S<seconds>]

Argument Description
[S<seconds>]

Keepalive interval (0-60)

Notes

Requires HOST_KEEPALIVE_FEATURE.


thinkyhead

M114 - Get Current Position

hosts Report the current tool position to the host.

Get the current position of the active nozzle. Includes stepper values.

Usage

M114

Notes

Hosts should respond to the output of M114 by updating their current position.

Examples

Get the current position

M114

thinkyhead

M115 - Firmware Info

hosts Print the firmware info and capabilities.

This command causes Marlin to output a string like this:

FIRMWARE_NAME:Marlin 1.1.0 (Github) SOURCE_CODE_URL:https://github.com/MarlinFirmware/Marlin PROTOCOL_VERSION:1.0 MACHINE_TYPE:RepRap EXTRUDER_COUNT:1 UUID:cede2a2f-41a2-4748-9b12-c55c62f367ff

When EXTENDED_CAPABILITIES_REPORT is enabled, then Marlin also reports its capabilities:

Cap:EEPROM:1
Cap:AUTOREPORT_TEMP:1
Cap:PROGRESS:0
Cap:AUTOLEVEL:1
Cap:Z_PROBE:1
Cap:SOFTWARE_POWER:0
Cap:TOGGLE_LIGHTS:0
Cap:EMERGENCY_PARSER:1

Hosts use this information to improve interoperability, so it’s a good feature to enable.

Usage

M115

thinkyhead

M117 - Set LCD Message

lcd Set the message line on the LCD.

Set the status line message on the LCD.

Usage

M117 [string]

Argument Description
[string]

LCD status message

Notes

Requires an LCD controller.

The message should appear immediately, but it will depend on LCD settings.

Examples

Set the message to “Yello World!”

M117 Yello World!

thinkyhead

M119 - Endstop States

debug Report endstop and probe states to the host.

Use this command to get the current state of all endstops, useful for setup and troubleshooting. Endstops are reported as either “open” or “TRIGGERED”.

The state of the Z probe is also reported.

Usage

M119

Examples

Get all endstop states

M119

thinkyhead

M120 - Enable Endstops

control Enable endstops and keep them enabled when not homing.

Enable endstops.

Usage

M120

Notes

After this command endstops will be kept enabled when not homing. This may have side-effects if using ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED.

Examples

Enable endstops

M120

thinkyhead

M121 - Disable Endstops

control Disable endstops and keep them enabled when not homing.

Disable endstops.

Usage

M121

Notes

After this command endstops will be kept disabled when not homing. This may have side-effects if using ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED.

Examples

Disable endstops

M121

thinkyhead

M122 - TMC2130 Status

debug Report status for all TMC2130 steppers.

Report TMC2130 status.

Usage

M122

Notes

Requries HAVE_TMC2130DRIVER.

Examples

Get the status of all TMC2130 steppers

M122

thinkyhead

M126 - Baricuda 1 Open

baricuda Open the valve for Baricuda 1.

Open the valve for Baricuda paste extruder 1.

Usage

M126

Notes

Requires BARICUDA.

Examples

M126 ; open valve 1

thinkyhead

M127 - Baricuda 1 Close

baricuda Close the valve for Baricuda 1.

Close the valve for Baricuda paste extruder 1.

Usage

M127

Notes

Requires BARICUDA.

Examples

M127 ; close valve 1

thinkyhead

M128 - Baricuda 2 Open

baricuda Open the valve for Baricuda 2.

Open the valve for Baricuda paste extruder 2.

Usage

M128

Notes

Requires BARICUDA.

Examples

M128 ; open valve 2

thinkyhead

M129 - Baricuda 2 Close

baricuda Close the valve for Baricuda 2.

Close the valve for Baricuda paste extruder 2.

Usage

M129

Notes

Requires BARICUDA.

Examples

M129 ; close valve 2

thinkyhead

M140 - Set Bed Temperature

thermal Set a new target bed temperature.

Set a new target heated bed temperature and continue without waiting. The firmware will continue to try to reach and hold the temperature in the background.

Use M190 to wait for the bed to reach the target temperature.

Usage

M140 [S<temp>]

Argument Description
[S<temp>]

Target temperature.
AUTOTEMP: the min auto-temperature.

Examples

Simple set target temperature

M140 S80

thinkyhead

M145 - Set Material Preset

lcd Set material presets in the LCD menu.

Set the preheating presets for materials in the LCD menu.

Usage

M145 [B<temp>] [F<speed>] [H<temp>] [S<index>]

Argument Description
[B<temp>]

Bed temperature

[F<speed>]

Fan speed

[H<temp>]

Hotend temperature

[S<index>]

Material index

Notes

Requires an LCD controller.

View the current settings with M503.

If EEPROM_SETTINGS is enabled, these settings are saved with M500, loaded with M501, and reset with M502.

Examples

Set heatup presets for material 1

M145 S0 H190 B70 F50

thinkyhead

M149 - Set Temperature Units

units Set temperature units to Celsius, Fahrenheit, or Kelvin.

Set temperature units to Celsius, Fahrenheit, or Kelvin. Celsius is the default.

Usage

M149 [C] [F] [K]

Argument Description
[C]

Celsius

[F]

Fahrenheit

[K]

Kelvin


thinkyhead

M150 - Set RGB Color

lcd Set the color of the RGB LED, backlight, or LED strip.

If you have an RGB light, either as part of a controller or installed separately, the M150 command can be used to set its color.

Usage

M150 [B<intensity>] [R<intensity>] [U<intensity>]

Argument Description
[B<intensity>]

Blue component from 0 to 255

[R<intensity>]

Red component from 0 to 255

[U<intensity>]

Green component from 0 to 255

Notes

Requires BLINKM or RGB_LED.


thinkyhead

M155 - Temperature Auto-Report

hosts Auto-report temperatures to host periodically.

It can be useful for host software to track temperatures, display and graph them over time, but polling with M105 is less than optimal. With M155 hosts simply set an interval and Marlin will keep sending data automatically. This method is preferred over polling with M105.

Usage

M155 [S<seconds>]

Argument Description
[S<seconds>]

Interval in seconds between auto-reports

Notes

Requires AUTO_REPORT_TEMPERATURES in Configuration_adv.h.

Also enable EXTENDED_CAPABILITIES_REPORT to notify hosts about this capability.


thinkyhead

M163 - Set Mix Factor

mixing Set a single mix factor for a mixing extruder.

Set a single mix factor from 0 to 1. (The mix will be “normalized” by M164 before saving.)

Usage

M163 [P<factor>] [S<index>]

Argument Description
[P<factor>]

Mix factor

[S<index>]

Component index

Notes

Requires MIXING_EXTRUDER.

Examples

Save a 60/40 mix as tool index 5:

M163 S0 P0.6
M163 S1 P0.4
M164 S5

Save a 3/5 mix as tool index 4:

M163 S0 P3
M163 S1 P5
M164 S4

thinkyhead

M164 - Save Mix

mixing Save the current mix as a virtual tool.

Usage

M164 S<index>

Argument Description
S<index>

Tool index (0 if none)

Notes

Requires MIXING_EXTRUDER and MIXING_VIRTUAL_TOOLS.

Examples

Save a 60/40 mix as tool index 5:

M163 S0 P0.6
M163 S1 P0.4
M164 S5

Save a 3/5 mix as tool index 4:

M163 S0 P3
M163 S1 P5
M164 S4

thinkyhead

M165 - Set Mix

mixing Set all mix factors for the mixing extruder.

Set the mix all at once. Any factors left out are set to 0.0.

Usage

M165 [A<factor>] [B<factor>] [C<factor>] [D<factor>] [H<factor>] [I<factor>]

Argument Description
[A<factor>]

Mix factor 1

[B<factor>]

Mix factor 2

[C<factor>]

Mix factor 3

[D<factor>]

Mix factor 4

[H<factor>]

Mix factor 5

[I<factor>]

Mix factor 6

Notes

Requires MIXING_EXTRUDER and DIRECT_MIXING_IN_G1.

Examples

Set a colorful mix

M165 A0.2 B0.4 C0.3 D0.1

thinkyhead

M190 - Wait for Bed Temperature

thermal Wait for the bed to reach target temperature.

This command optionally sets a new target bed temperature and waits for the target temperature to be reached before proceeding. If the temperature is set with S then it waits only when heating.

Usage

M190 [R<temp>] [S<temp>]

Argument Description
[R<temp>]

Target temperature (wait for cooling or heating).

[S<temp>]

Target temperature (wait only when heating). Also AUTOTEMP: The min auto-temperature.

Notes

This command (and M109) can block new commands from the host. To break out of wait for temperature using M108 from the host, enable EMERGENCY_PARSER.

Use M140 to set the bed temperature and proceed without waiting.

Examples

Set target bed temperature and wait (if heating)

M190 S80

Set target bed temperature, wait even if cooling

M190 R40

thinkyhead

M200 - Set Filament Diameter

planner Set the diameter for volumetric extrusion.

Set the filament’s current diameter and enable volumetric extrusion.

In volumetric extrusion mode the E axis specifies cubic mm instead of linear mm, and the firmware calculates how much length to extrude for the given volume based on the filament diameter.

Usage

M200 [D<diameter>]

Argument Description
[D<diameter>]

Filament diameter

Examples

A common diameter close to 3mm:

M200 D2.85

Turn off volumetric extrusion

M200 D0
M200 D  ; also works

thinkyhead

M201 - Set Print Max Acceleration

planner Set maximum acceleration for print moves one or more axes.

Set the max acceleration for one or more axes (in current units-per-second squared).

Usage

M201 [E<accel>] [T<index>] [X<accel>] [Y<accel>] [Z<accel>]

Argument Description
[E<accel>]

E axis max acceleration

[T<index>]

Target extruder (Requires DISTINCT_E_FACTORS)

[X<accel>]

X axis max acceleration

[Y<accel>]

Y axis max acceleration

[Z<accel>]

Z axis max acceleration

Notes

View the current setting with M503.

If EEPROM_SETTINGS is enabled, these are saved with M500, loaded with M501, and reset with M502.

Examples

Set max acceleration lower so it sounds like a robot:

M201 X50 Y50

thinkyhead

M203 - Set Max Feedrate

planner Set maximum feedrate for one or more axes.

Set the max feedrate for one or more axes (in current units-per-second).

Usage

M203 [E<accel>] [T<index>] [X<accel>] [Y<accel>] [Z<accel>]

Argument Description
[E<accel>]

E axis max feedrate

[T<index>]

Target extruder (Requires DISTINCT_E_FACTORS)

[X<accel>]

X axis max feedrate

[Y<accel>]

Y axis max feedrate

[Z<accel>]

Z axis max feedrate

Notes

View the current setting with M503.

If EEPROM_SETTINGS is enabled, these are saved with M500, loaded with M501, and reset with M502.

Examples

Set max feedrate for XY to 100mm/s:

M203 X6000 Y6000

thinkyhead

M204 - Set Starting Acceleration

planner Set the starting acceleration for moves by type.

Set the preferred starting acceleration for moves of different types.

Usage

M204 [P<accel>] [R<accel>] [T<accel>]

Argument Description
[P<accel>]

Printing acceleration

[R<accel>]

Retract acceleration

[T<accel>]

Travel acceleration

Notes

View the current setting with M503.

If EEPROM_SETTINGS is enabled, these are saved with M500, loaded with M501, and reset with M502.


thinkyhead

M205 - Set Advanced Settings

planner Set some advanced settings related to movement.

Set various motion settings. See parameters for details.

Usage

M205 [B<µs>] [E<jerk>] [S<feedrate>] [T<feedrate>] [X<jerk>] [Y<jerk>] [Z<jerk>]

Argument Description
[B<µs>]

Minimum segment time (µs)

[E<jerk>]

E max jerk (units/s)

[S<feedrate>]

Minimum feedrate for print moves (units/min)

[T<feedrate>]

Minimum feedrate for travel moves (units/min)

[X<jerk>]

X max jerk (units/s)

[Y<jerk>]

Y max jerk (units/s)

[Z<jerk>]

Z max jerk (units/s)

Notes

View the current setting with M503.

If EEPROM_SETTINGS is enabled, these are saved with M500, loaded with M501, and reset with M502.

Examples

Set some advanced settings.

M205 T2400

thinkyhead

M206 - Set Home Offsets

planner Description Here

Use M206 to apply a persistent offset to the native home position and coordinate space. This effectively shifts the coordinate space in the negative direction. See examples below.

  • The current position is adjusted to align to the new home offset values.
  • The home offset is persistent — added to the current position until changed.
  • Some uses include fine adjustment of Z position (without moving endstops) and shifting the coordinate space to print on a different part of the bed.

Usage

M206 [X<offset>] [Y<offset>] [Z<offset>]

Argument Description
[X<offset>]

X home offset

[Y<offset>]

Y home offset

[Z<offset>]

Z home offset

Notes

  • Changing the home offsets will not invalidate bed leveling or other saved data.
  • View the current offsets with M503.
  • If EEPROM_SETTINGS is enabled, the home offsets are saved with M500, loaded with M501, and reset with M502.
  • M428 sets home offsets so the current position aligns to the native home position.

Examples

Raise Z up a little bit on the first layer:

M206 Z-0.2

Shift the print area 10mm to the left:

M206 X10

thinkyhead

M207 - Set Firmware Retraction

planner Set options for firmware-based retraction.

Set lengths, feedrate, and Z lift for firmware-based retraction. See parameters below.

Usage

M207 [F<feedrate>] [S<length>] [W<length>] [Z<length>]

Argument Description
[F<feedrate>]

Retract feedrate (units/min)

[S<length>]

Retract length

[W<length>]

Retract swap length (multi-extruder)

[Z<length>]

Z lift on retraction

Notes

Requires FWRETRACT.


thinkyhead

M208 - Set Firmware Recovery

planner Set values for firmware-based retract recovery.

Set lengths and feedrate for firmware-based retract recovery. The new values will apply to all subsequent G11

Usage

M208 [F<feedrate>] [S<length>] [W<length>]

Argument Description
[F<feedrate>]

Recover feedrate (units/min)

[S<length>]

Recover length

[W<length>]

Recover swap length (multi-extruder)

Notes

Requires FWRETRACT.


thinkyhead

M209 - Set Auto Retract

planner Enable / disable auto-retraction.

Enable or disable automatic retraction. This option is meant to help slicers that don’t support G10/G11. But it can be used to override retraction in any GCode.

When auto-retract is enabled, all reversed E-only moves are treated as retraction. (Recover moves are also automatically overridden.) When disabled, E retraction derives from G-Code.

Usage

M209 S<flag>

Argument Description
S<flag>

Set Auto-Retract on/off

Notes

Most slicers today can generate G10/G11. But this option is useful for older G-Code.

Though not currently very popular, both volumetric extrusion and firmware-based retraction (and/or M209) make G-Code more immune to changes from one machine to another, and permit changing the hardware without needing to re-slice.


thinkyhead

M211 - Software Endstops

planner Set and/or get the software endstops state.

Optionally enable/disable software endstops, then report the current state.

With software endstops enabled, moves will be clipped to the physical boundaries from [XYZ]_MIN_POS to [XYZ]_MAX_POS.

Usage

M211 [S<flag>]

Argument Description
[S<flag>]

Software endstops state

Notes

Requires either min_software_endstops or max_software_endstops for the enable option.


thinkyhead

M218 - Set Hotend Offset

calibration Set the offset of a hotend (from hotend 0).

To keep nozzles aligned to the work area between tool-changes, the firmware needs to know how they relate to each other.

Usage

M218 [T<index>] [X<offset>] [Y<offset>] [Z<offset>]

Argument Description
[T<index>]

Hotend index. Active extruder by default.

[X<offset>]

Hotend X offset

[Y<offset>]

Hotend Y offset

[Z<offset>]

Hotend Z offset. Requires DUAL_X_CARRIAGE or SWITCHING_EXTRUDER.

Notes

  • Requires 2 or more nozzles.
  • The default hotend offsets are set with HOTEND_OFFSET_[XYZ].
  • Z hotend offset only available with DUAL_X_CARRIAGE or SWITCHING_EXTRUDER.
  • View current hotend offsets with M503.
  • If EEPROM_SETTINGS is enabled, these offsets are saved with M500, loaded with M501, and reset with M502.

thinkyhead

M220 - Set Feedrate Percentage

planner Set the global feedrate percentage.

Set the feedrate percentage, which applies to all G-Code-based moves.

Usage

M220 S<percent>

Argument Description
S<percent>

Feedrate percentage


thinkyhead

M221 - Set Flow Percentage

planner Set the flow percentage, which applies to all E moves.

Set the flow percentage, which applies to all E moves added to the planner.

Usage

M221 S<percent> [T<index>]

Argument Description
S<percent>

Feedrate percentage

[T<index>]

Target extruder (requires multi-extruder). Default is the active extruder.

Examples

Set the flow rate to 150%.

M221 S150

thinkyhead

M226 - Wait for Pin State

control Wait for a pin to have a given state.

Wait for a pin to have a certain value or state.

Usage

M226 P<pin> [S<state>]

Argument Description
P<pin>

Pin number

[S<state>]

State 0 or 1. Default -1 for inverted.


thinkyhead

M240 - Trigger Camera

extras Trigger camera snapshot or recording.

Trigger the photograph pin to take a snapshot or toggle recording.

Usage

M240

Notes

Requires CHDK or PHOTOGRAPH_PIN. See this article for more info.


thinkyhead

M250 - LCD Contrast

lcd Set and/or get the LCD contrast.

Set and/or get the LCD contrast. The value is constrained based on the LCD.

Usage

M250 [C<contrast>]

Argument Description
[C<contrast>]

Contrast value

Notes

Requires an LCD controller with software-controlled contrast.


thinkyhead

M260 - I2C Send

i2c Send data to the I2C bus.

Utility to send data over the I2C bus.

Usage

M260 [A<addr>] [B<byte>] [R<flag>] [S<flag>]

Argument Description
[A<addr>]

The bus address to send to

[B<byte>]

The byte to add to the buffer

[R<flag>]

Reset and rewind the I2C buffer

[S<flag>]

Send flag. Flush the buffer to the bus.

Notes

Requires EXPERIMENTAL_I2CBUS.

Examples

Send “Marlin” to the slave device with address 0x63 (99)

M260 A99  ; Target slave address
M260 B77  ; M
M260 B97  ; a
M260 B114 ; r
M260 B108 ; l
M260 B105 ; i
M260 B110 ; n
M260 S1   ; Send the current buffer

Request 6 bytes from slave device with address 0x63 (99)

M261 A99 B5
i2c-reply: from:99 bytes:5 data:hello

thinkyhead

M261 - I2C Request

i2c Request and echo bytes from the I2C bus.

Request bytes from the I2C bus and echo them to the host. To find out how to do more useful things with I2C see the I2C master / slave article.

Usage

M261 A<addr> B<count>

Argument Description
A<addr>

The bus address to request bytes from

B<count>

The number of bytes to request

Notes

Requires EXPERIMENTAL_I2CBUS.


thinkyhead

M280 - Servo Position

servos Set or get a servo position.

Set or get the position of a servo.

Usage

M280 P<index> S<pos>

Argument Description
P<index>

Servo index to set or get

S<pos>

Servo position to set. Omit to read the current position.

Notes

Requires NUM_SERVOS of 1 or more.


thinkyhead

M300 - Play Tone

lcd Play a single tone, buzz, or beep.

Add a tone to the tone queue.

Usage

M300 [P<ms>] [S<Hz>]

Argument Description
[P<ms>]

Duration (1s)

[S<Hz>]

Frequency (260Hz)

Notes

Requires SPEAKER to play tones (not just beeps).

In Marlin 1.0.2, playing tones block the command queue. Marlin 1.1.0 uses a tone queue and background tone player to keep the command buffer from being blocked by playing tones.

Examples

Play a tune.

M300 S440 P200
M300 S660 P250
M300 S880 P300

thinkyhead

M301 - Set Hotend PID

thermal Set PID values for a hotend.

Set the values that control the PID loop for a hotend.

Usage

M301 [C<value>] [D<value>] [E<index>] [I<value>] [L<value>] [P<value>]

Argument Description
[C<value>]

C term (requires PID_EXTRUSION_SCALING)

[D<value>]

Derivative value

[E<index>]

Extruder index to set. Default 0.

[I<value>]

Integral value

[L<value>]

Extrusion scaling queue length (requires PID_EXTRUSION_SCALING)

[P<value>]

Proportional value

Notes

Requires PIDTEMP.

View current PID values with M503.

If EEPROM_SETTINGS is enabled, all hotend PID values are saved with M500, loaded with M501, and reset with M502.


thinkyhead

M302 - Cold Extrude

thermal Set minimum extrusion temperature, allow cold extrusion.

Set the minimum extrusion temperature, potentially allowing E movement at temperatures below the melting point of the material.

Usage

M302 [P<flag>] [S<temp>]

Argument Description
[P<flag>]

Flag to allow extrusion at any temperature

[S<temp>]

Minimum temperature for safe extrusion

Notes

Requires PREVENT_COLD_EXTRUSION.

Examples

Some common uses…

M302         ; report current cold extrusion state
M302 P0      ; enable cold extrusion checking
M302 P1      ; disable cold extrusion checking
M302 S0      ; always allow extrusion (disable checking)
M302 S170    ; only allow extrusion above 170
M302 S170 P1 ; set min extrude temp to 170 but leave disabled

thinkyhead

M303 - PID autotune

thermal Auto-tune the PID system to find stable values.

This command initiates a process of heating and cooling to determine the proper PID values for the specified hotend or the heated bed.

Usage

M303 C<count> [E<index>] S<temp> U<flag>

Argument Description
C<count>

Cycles. Default 5.

[E<index>]

Hotend index (-1 for heated bed). Default 0.

S<temp>

Target temperature

U<flag>

Use PID result. (Otherwise just print it out.)

Notes

Requires PIDTEMP or PIDTEMPBED.

View current PID values with M503.

If EEPROM_SETTINGS is enabled, all PID values are saved with M500, loaded with M501, and reset with M502.


thinkyhead

M304 - Set Bed PID

thermal Set PID values for the heated bed.

Set the values that control the PID loop for the heated bed.

Usage

M304 [D<value>] [I<value>] [P<value>]

Argument Description
[D<value>]

Derivative value

[I<value>]

Integral value

[P<value>]

Proportional value

Notes

Requires PIDTEMPBED.

View current bed PID values with M503.

If EEPROM_SETTINGS is enabled, bed PID values are saved with M500, loaded with M501, and reset with M502.


MarlinFirmware

M350 - Coming Soon

none Description Here

Usage

M350

MarlinFirmware

M351 - Coming Soon

none Description Here

Usage

M351

MarlinFirmware

M355 - Coming Soon

none Description Here

Usage

M355

MarlinFirmware

M360 - Coming Soon

none Description Here

Usage

M360

MarlinFirmware

M361 - Coming Soon

none Description Here

Usage

M361

MarlinFirmware

M362 - Coming Soon

none Description Here

Usage

M362

MarlinFirmware

M363 - Coming Soon

none Description Here

Usage

M363

MarlinFirmware

M364 - Coming Soon

none Description Here

Usage

M364

MarlinFirmware

M380 - Coming Soon

none Description Here

Usage

M380

MarlinFirmware

M381 - Coming Soon

none Description Here

Usage

M381

MarlinFirmware

M400 - Coming Soon

none Description Here

Usage

M400

MarlinFirmware

M401 - Coming Soon

none Description Here

Usage

M401

MarlinFirmware

M402 - Coming Soon

none Description Here

Usage

M402

MarlinFirmware

M404 - Coming Soon

none Description Here

Usage

M404

MarlinFirmware

M405 - Coming Soon

none Description Here

Usage

M405

MarlinFirmware

M406 - Coming Soon

none Description Here

Usage

M406

MarlinFirmware

M407 - Coming Soon

none Description Here

Usage

M407

MarlinFirmware

M410 - Coming Soon

none Description Here

Usage

M410

MarlinFirmware

M420 - Coming Soon

none Description Here

Usage

M420

MarlinFirmware

M421 - Coming Soon

none Description Here

Usage

M421

thinkyhead

M428 - Here is Home

planner Set home offsets based on current position.

Use M428 to set a persistent offset to the native home position and coordinate space by assigning the current position as the native home position. See the example below.

  • The current position is set to the native home position.
  • Any previous position shift from G92 is cleared.
  • The home offset is persistent — added to the current position until changed.
  • Some uses include fine adjustment of Z position (without moving endstops) and shifting the coordinate space to print on a different part of the bed.

Usage

M428

Notes

  • Changing the home offsets will not invalidate bed leveling or other saved data.
  • If EEPROM_SETTINGS is enabled, the home offsets are saved with M500, loaded with M501, and reset with M502.
  • Use M206 to set the home offsets directly.

Examples

What was X=10 becomes X=0. So the X home offset becomes -10.

G1 X10
M428

thinkyhead

M500 - Save Settings

eeprom Save settings to EEPROM.

Save all configurable settings to EEPROM.

Usage

M500

Notes

Requires EEPROM_SETTINGS.

Since Marlin 1.1.0 only changed bytes are written to prolong EEPROM life.

Examples

Save settings

M500

thinkyhead

M501 - Restore Settings

eeprom Restore settings from EEPROM.

Load all saved settings from EEPROM.

Usage

M501

Notes

Requires EEPROM_SETTINGS.

Examples

Restore all settings.

M501

thinkyhead

M502 - Factory Reset

eeprom Restore all settings to factory defaults.

Reset all configurable settings to their factory defaults.

To also reset settings in EEPROM, follow with M502.

Usage

M502

Notes

Requires EEPROM_SETTINGS.

Examples

Reset settings and save them to EEPROM

M502 ; reset!
M500 ; saved!!

thinkyhead

M503 - Report Settings

eeprom Report all settings that may be saved to EEPROM.

Print a concise report of all current settings (in SRAM) to the host console.

Usage

M503 [S<flag>]

Argument Description
[S<flag>]

Detailed output flag. (true if omitted.)

Notes

Does not require EEPROM_SETTINGS.


thinkyhead

M540 - Endstops Abort SD

sdcard Abort SD printing when an endstop is triggered.

Set whether SD printing should abort in the event of any endstop being triggered. This provides a fast way to abort a print in the event of mechanical failure such as loose couplings, lost steps, diverted axes, binding, etc., which lead to axes being very far out of position.

Usage

M540 S<flag>

Argument Description
S<flag>

Whether (1) or not (0) to abort SD printing on endstop hit.

Notes

Requires SDSUPPORT and ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED.

Use ENDSTOPS_ALWAYS_ON_DEFAULT or M120 to ensure that endstops are enabled.


clexpert petrzjunior thinkyhead

M600 - Filament Change

1.1.0-RC7 filament Automatically change filament

The M600 command initiates the filament change procedure. The basic procedure will move the print head away from the print, eject the filament, wait for new filament to be inserted and the user to confirm, load and prime the filament, and continue with the print. M600 may be initiated automatically if a filament runout sensor is installed.

Usage

M600 [E<pos>] [L<pos>] [X<pos>] [Y<pos>] [Z<pos>]

Argument Description
[E<pos>]

Retract before moving to change position (negative)

[L<pos>]

Load/unload lenght, longer for bowden (negative)

[X<pos>]

X position for filament change

[Y<pos>]

Y position for filament change

[Z<pos>]

Z relative lift for filament change position

Notes

The settings for this command can be found in Configuration.h. At this time M600 requires an LCD controller.

Examples

With no parameters M600 uses the settings in Configuration.h.

M600 ; execute filament change

To set the change position:

M600 X10 Y15 Z5 ; Do filament change at X:10, Y:15 and Z:+5 from current

MarlinFirmware

M605 - Coming Soon

none Description Here

Usage

M605

MarlinFirmware

M665 - Coming Soon

none Description Here

Usage

M665

MarlinFirmware

M666 - Coming Soon

none Description Here

Usage

M666

MarlinFirmware

M851 - Coming Soon

none Description Here

Usage

M851

MarlinFirmware

M907 - Coming Soon

none Description Here

Usage

M907

MarlinFirmware

M908 - Coming Soon

none Description Here

Usage

M908

MarlinFirmware

M909 - Coming Soon

none Description Here

Usage

M909

MarlinFirmware

M910 - Coming Soon

none Description Here

Usage

M910

MarlinFirmware

M928 - Coming Soon

none Description Here

Usage

M928

MarlinFirmware

M999 - Coming Soon

none Description Here

Usage

M999