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 or R.

This command has two forms:

I J Form

  • I specifies an X offset. J specifies a Y offset.
  • At least one of the I J parameters is required.
  • X and Y can be omitted to do a complete circle.
  • The given X Y is not error-checked. The arc ends based on the angle of the destination.
  • Mixing I or J with R will throw an error.

R Form

  • R specifies the radius. X or Y is required.
  • Omitting both X and Y will throw an error.
  • X or Y must differ from the current XY position.
  • Mixing R with I or J will throw an error.

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 Pause 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.

M0/M1 provides an interruptible “dwell” (Marlin 1.1.0 and up).

G4 with no arguments is effectively the same as M400.

Example

G4 P500 ; Dwell for 1/2 second

thinkyhead

G5 - Bézier cubic spline

1.1.0 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 parameters are required. I and J are required for the first G5 command in a series. For subsequent G5 commands, either both I and J must be specified, or neither. If I and J are unspecified, the starting direction of the 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).

See This interactive demo to understand how Bézier control points work.


Usage

G5 [E<pos>] [F<rate>] I<pos> J<pos> P<pos> Q<pos> X<pos> Y<pos>

Argument Description
[E<pos>]

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

[F<rate>]

The maximum feedrate of the move between the start and end point (in current units per second). This value applies to all subsequent moves.

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 end point to second control point

Q<pos>

Y incremental offset from end point to second 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 FWRETRACT

Retract the filament according to settings of M207.


Firmware retraction allows you to tune retraction at the machine level and can significantly reduce the size of G-code files.


Multiple consecutive G10 or G10 S1 commands without a corresponding G11 or G11 S1 will be ignored.


Performs two moves: a retract move at the retract feedrate/acceleration, and an optional Z lift at the maximum Z feedrate (travel acceleration).


Usage

G10 [S<flag>]

Argument Description
[S<flag>]

Use G10 S1 to do a swap retraction, before changing extruders. The subsequent G11 (after tool change) will do a swap recover. (Requires EXTRUDERS > 1)

Notes

Requires FWRETRACT.

See related codes G11, M207, M208, and M209.

Example

G10 ; retract

thinkyhead

G11 - Recover

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

Unretract (i.e., recover, prime) the filament according to settings of M208.


Multiple consecutive G11 or G11 S1 commands without a corresponding G10 or G10 S1 will be ignored.


Performs two moves: An optional Z lower at the maximum Z feedrate (travel acceleration), and a recovery move at the recover feedrate (retract acceleration).


Usage

G11

Notes

Requires FWRETRACT.

See related codes G10, M207, M208, and M209.

Example

G11 ; recover

MarlinFirmware

G12 - Clean the Nozzle

1.1.0 nozzle Perform the nozzle cleaning procedure. NOZZLE_CLEAN_FEATURE

{“Start the nozzle cleaning process. Three types of cleaning patterns are supported”=>”straight strokes, zigzags and circles. This feature requires a dedicated cleaning area on or outside the bed, but within reach of the nozzle. The patten may be repeated as many times as desired.”}


Usage

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

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

Pattern style selection

  • P0:

    Stroke straight back and forth

  • P1:

    Move in a zigzag pattern

  • P2:

    Move in a circular pattern

[R<radius>]

Radius of nozzle cleaning circle

[S<count>]

Number of repetitions of the pattern

[T<count>]

Number of triangles in the zigzag pattern

Notes

Default behavior is defined by NOZZLE_CLEAN_STROKES, NOZZLE_CLEAN_START_POINT, NOZZLE_CLEAN_END_POINT, NOZZLE_CLEAN_TRIANGLES, NOZZLE_CLEAN_CIRCLE_MIDDLE, NOZZLE_CLEAN_CIRCLE_RADIUS and NOZZLE_CLEAN_GOBACK.

With NOZZLE_CLEAN_GOBACK 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

To generate a 10mm radius circle which will be stroked one time use the following command.

G12 P2 S1 R10 ; 10mm circle

thinkyhead

G20 - Inch Units

1.1.0 units Set Units to Inches. INCH_MODE_SUPPORT

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


Usage

G20

Example

G20 ; set units to inches

thinkyhead

G21 - Millimeter Units

1.1.0 units Set Units to Millimeters. INCH_MODE_SUPPORT

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


Usage

G21

Example

G21 ; set units to millimeters

MarlinFirmware

G26 - Mesh Validation Pattern

1.1.0 calibration Test the mesh and adjust. HAS_MESH G26_MESH_VALIDATION

G26 Mesh Validation Pattern is designed to be used in conjunction with mesh-based leveling to test the accuracy of the probed mesh.

The G26 command prints a single-layer pattern over the entire print bed, giving a clear indication of how accurately every mesh point is defined. G26 can be used to determine which areas of the mesh are less-than-perfect and how much to adjust each mesh point.


Usage

G26 [B<temp>] [C<bool>] [D<bool>] [F<linear>] [H<linear>] [K<bool>] [L<linear>] [O<linear>] [P<linear>] [Q<float>] [R<int>] [S<float>] [U<linear>] [X<linear>] [Y<linear>]

Argument Description
[B<temp>]

Bed temperature (otherwise 60°C) to use for the test print.

[C<bool>]

Continue with the closest point (otherwise, don’t)

[D<bool>]

Disable leveling compensation (otherwise, enable)

[F<linear>]

Filament diameter (otherwise 1.75mm)

[H<linear>]

Hot end temperature (otherwise 205°C) to use for the test print.

[K<bool>]

Keep heaters on when done

[L<linear>]

Layer height to use for the test

[O<linear>]

Ooze amount (otherwise 0.3mm). Emitted at the start of the test.

[P<linear>]

Prime Length

[Q<float>]

Retraction multiplier (otherwise 1.0)

[R<int>]

Number of G26 Repetitions (otherwise 999)

[S<float>]

Nozzle size (otherwise 0.4mm)

[U<linear>]

Random deviation. (U with no value, 50).

[X<linear>]

X position (otherwise, current X position)

[Y<linear>]

Y position (otherwise, current Y position)

Notes

  • Before 1.1.6 requires UBL_G26_MESH_VALIDATION and AUTO_BED_LEVELING_UBL.
  • Since 1.1.7 requires G26_MESH_VALIDATION and HAS_MESH (AUTO_BED_LEVELING_UBL, MESH_BED_LEVELING, or AUTO_BED_LEVELING_BILINEAR).

MarlinFirmware

G27 - Park the nozzle

1.1.0 nozzle Move the nozzle to a predefined position. NOZZLE_PARK_FEATURE

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

calibration 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 [O] [R] [X] [Y] [Z]

Argument Description
[O]

Optional. If the position is known then exit without homing. (1.1.9)

[R]

Raise before homing distance (1.1.9)

[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

calibration Probe the bed and enable leveling compensation. AUTO_BED_LEVELING_(3POINT|LINEAR|BILINEAR)

ABL 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.

The printer must be homed with G28 before G29.


Automatic Probing

With an electronic probe Marlin can probe the entire bed in a matter of seconds —even before every print— with a single G29 command. Available parameters depend on the style of leveling. See parameter descriptions and examples below for details.


Manual Probing

Auto Bed Leveling now includes a PROBE_MANUALLY option for systems lacking a probe.

PROBE_MANUALLY adds these parameters to G29:

  • Q : Query leveling and G29 state
  • A : Abort current leveling procedure

To do manual probing simply repeat G29 until the procedure is complete.

The first G29 accepts the same parameters , shown in the Usage section below. The exact parameters available will depend on which style of bed leveling is enabled. (Note: UBL parameters are not covered on this page unless they coincide. See the G29 for UBL page for a full list of its options.)

Before probing the bed:

  1. Use G29 Q to get the current status. If G29 isn’t idle, abort with G29 A.
  2. Use M420 V to view leveling data. You can send M420 S1 to use the existing data.

To probe the bed using GCode:

  1. Use G29 to move to the first point for Z adjustment.
  2. Adjust Z so a piece of paper can just pass under the nozzle.
  3. Use G29 to save the Z value and move to the next point.
  4. Repeat steps 3-4 until completed.
  5. Use M500 to save the leveling data to EEPROM, if desired.

To probe the bed using your LCD controller: (Requires LCD_BED_LEVELING)

  1. Select the Level Bed sub-menu, then choose Level Bed (not Cancel).
  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.

Mesh Editing

AUTO_BED_LEVELING_BILINEAR adds these parameters to G29 for editing mesh points:

  • W Write a mesh point. (Ignored during leveling.)
  • I X index for mesh point
  • J Y index for mesh point
  • X logical X of mesh point
  • Y logical Y of mesh point
  • Z Z to store in mesh. If omitted, current raw Z.

Usage

G29 [A<bool>] [B<linear>] [C<bool>] [D<bool>] [E<bool>] [F<linear>] [J<bool>] [L<linear>] [O] [P<int>] [Q<bool>] [R<linear>] [S<rate>] [T<bool>] [V<0|1|2|3|4>] [W<bool>] [X<int/float>] [Y<int/float>] [Z<float>]

Argument Description
[A<bool>]

Abort leveling procedure in-progress (PROBE_MANUALLY)

[B<linear>]

Set the back limit of the probing grid (AUTO_BED_LEVELING_LINEAR, AUTO_BED_LEVELING_BILINEAR)

[C<bool>]

Create a fake grid for testing. (DEBUG_LEVELING_FEATURE)

[D<bool>]

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

[E<bool>]
  • By default G29 will engage the Z probe, test the bed, then disengage.
  • Include “E” to engage/disengage the Z probe for each sample.
  • There’s no extra effect if you have a fixed Z probe. (without PROBE_MANUALLY)
[F<linear>]

Set the front limit of the probing grid (AUTO_BED_LEVELING_LINEAR, AUTO_BED_LEVELING_BILINEAR)

[J<bool>]

(Without W) Jettison the leveling data stored in SRAM and turn off leveling compensation. Data in EEPROM is not affected.

[L<linear>]

Set the left limit of the probing grid (AUTO_BED_LEVELING_LINEAR, AUTO_BED_LEVELING_BILINEAR)

[O]

Optional. If leveling is already enabled then exit without leveling. (1.1.9)

[P<int>]

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

[Q<bool>]

Query the current leveling state (PROBE_MANUALLY, DEBUG_LEVELING_FEATURE)

[R<linear>]

Set the right limit of the probing grid (AUTO_BED_LEVELING_LINEAR, AUTO_BED_LEVELING_BILINEAR)

[S<rate>]

Set the XY travel speed between probe points (AUTO_BED_LEVELING_LINEAR, AUTO_BED_LEVELING_BILINEAR)

[T<bool>]

Generate a Bed Topology Report (AUTO_BED_LEVELING_LINEAR)

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

Set the verbose level

  • V2:

    Level 2 and up act like ‘T’

[W<bool>]

Write a mesh Z offset (AUTO_BED_LEVELING_BILINEAR). Requires X,Y or I,J to specify the point, and Z to specify the value.

[X<int/float>]
  • Override the X-size of the grid that will be probed (AUTO_BED_LEVELING_LINEAR).
  • Specify X when setting a mesh value (PROBE_MANUALLY).
[Y<int/float>]
  • Override the Y-size of the grid that will be probed (AUTO_BED_LEVELING_LINEAR).
  • Specify Y when setting a mesh value (AUTO_BED_LEVELING_LINEAR).
[Z<float>]

Specify the Z offset when setting a mesh value (AUTO_BED_LEVELING_BILINEAR).

Notes

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

Examples

Automatic Probing examples

G29 ; execute ABL

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

G29 P5 ; 5x5 matrix

Probe a 5x5 matrix. (AUTO_BED_LEVELING_LINEAR)

G29 X4 Y8 L50 R150 F50 B150 T V4

Probe a 4x8 matrix from X50 Y50 to X150 Y150, printing a full report. (AUTO_BED_LEVELING_LINEAR)

Manual Probing example

G29 V1 ;  Ready!  Go to Point 1, wait...
G29 V1 ; Store Z, go to Point 2, wait...
G29 V1 ; Store Z, go to Point 3, wait...
G29 V1 ; Store Z, go to Point 4, wait...
G29 V1 ; Store Z, go to Point 5, wait...
G29 V1 ; Store Z, go to Point 6, wait...
G29 V1 ; Store Z, go to Point 7, wait...
G29 V1 ; Store Z, go to Point 8, wait...
G29 V1 ; Store Z, go to Point 9, wait...
G29 V1 ; Store Z. Calculate matrix. Activate.

Each G29 command goes to the next step until the whole procedure is done. The V1 parameter provides a progress report.

thinkyhead

G29 - Mesh Bed Leveling

calibration Measure Z heights in a grid, enable leveling compensation MESH_BED_LEVELING

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. Comparable to using AUTO_BED_LEVELING_BILINEAR with PROBE_MANUALLY.

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.

To do 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.

To do LCD Bed Leveling with your controller: (Requires LCD_BED_LEVELING)

  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

Example

S0 produces a mesh report as follows:

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

MarlinFirmware

G29 - Unified Bed Leveling

calibration Probe the bed and enable leveling compensation. AUTO_BED_LEVELING_UBL

The Unified Bed Leveling System (UBL) provides a comprehensive set of resources to produce the best bed leveling results possible.


See the full Unified Bed Leveling documentation for more details. (Examples below.)


Usage

G29 [A<bool>] [B<bool>] [C<bool/float>] [D<bool>] [E<bool>] [F<linear>] [H<linear>] [I<int>] [J<int>] [K<index>] [L<index>] [P<0|1|2|3|4|5|6>] [Q<index>] [R<int>] [S<slot>] [T<0|1>] [U<bool>] [V<0|1|2|3|4>] [W<bool>] [X<linear>] [Y<linear>]

Argument Description
[A<bool>]

Activate Unified Bed Leveling (i.e., M420 S1)

[B<bool>]

Business Card mode (P2 only)

  • Use the ‘Business Card’ mode of the Manual Probe subsystem with P2.
  • In this mode of G29 P2, use a shim that the nozzle can grab onto as it is lowered. In principle, the nozzle-bed distance is the same when the same resistance is felt in the shim. You can omit the numerical value on first invocation of G29 P2 B to measure shim thickness. Subsequent use of B will apply the previously-measured thickness by default.
  • Note: A non-compressible Spark Gap feeler gauge is recommended over a business card.
[C<bool/float>]
  • G29 P1 C Continue: Continues the generation of a partially-constructed Mesh without invalidating previous measurements.
  • G29 P2 C Constant: specifies a Constant and tells the Manual Probe subsystem to use the current location in its search for the closest unmeasured Mesh Point.
  • G29 P3 C Constant: specifies the Constant for the fill. Otherwise, uses a “reasonable” value.
  • G29 Z C Current: Use the Current location (instead of bed center or nearest edge).
[D<bool>]

Disable Unified Bed Leveling (i.e., M420 S0).

[E<bool>]

Stow probe after probing Each point (P1 only).

[F<linear>]

Fade height. (UBL only! For others use M420 Z)

Fade the amount of Mesh Based Compensation over a specified height. At the specified height, no correction is applied and natural printer kenimatics take over. If no number is specified for the command, 10mm is assumed to be reasonable.

[H<linear>]

Height:

  • G29 P2 H: Height for Manual Probe raise (P2 only). Specify the Height to raise the nozzle after each manual probe of the bed. If omitted, the nozzle will raise by Z_CLEARANCE_BETWEEN_PROBES.
  • G29 P4 H : Offset above the mesh height to place the nozzle. If omitted, Z_CLEARANCE_BETWEEN_PROBES will be used.
[I<int>]

Invalidate a number of mesh points (default 1).

  • Invalidate Mesh Points near the given X Y (Default: nozzle position)
  • If no I value is given, only the point nearest to the given position is invalidated. Use T to produce a map afterward. This command is useful to invalidate a portion of the Mesh so it can be adjusted using other UBL tools. When attempting to invalidate an isolated bad mesh point, the T option shows the nozzle position in the Mesh with (#).
  • You can move the nozzle around and use this feature to select the center of the area (or cell) to invalidate.
[J<int>]

Grid (or 3-Point) leveling:

  • These options calculate a plane and adjust the existing mesh to the bed tilt.
  • If a value is provided, probe a grid with the given number of points, squared.
  • With no value, probe 3 points to find the plane of the bed.
[K<index>]

Kompare: Subtract (diff) the stored mesh with the given index from the current mesh. This operates on the mesh in-memory, so it will probably make the active mesh unsuitable for printing.

[L<index>]

Load a mesh. If no index is given, load the previously-activated mesh. The given mesh index will be used for subsequent Load and Store operations.

[P<0|1|2|3|4|5|6>]

Phase: The Phase commands are used for the bulk of the work to setup a Mesh. In general, you’ll start by initializing with a G29 P0 or a G29 P1 then do further refinement with additional Phases.

  • P0:

    Zero Mesh Data and turn off the Mesh Compensation System. This reverts the machine to the same state it was in before UBL Compensation was enabled. Setting the entire Mesh to Zero is a special case to allow a subsequent G or T leveling operation for backward-compatibility.

  • P1:

    Automatic Probing invalidates the mesh and continues automatic probing using the probe.

    • In most cases the probe can’t reach all areas that the nozzle can due to the offsets specified by X_PROBE_OFFSET_FROM_EXTRUDER and Y_PROBE_OFFSET_FROM_EXTRUDER. Deltabots can only probe within the area where DELTA_PROBEABLE_RADIUS and DELTA_PRINTABLE_RADIUS overlap.
    • Unreachable points can be filled in later with the P2 and P3 phases.
    • Use C to leave the previous mesh intact and automatically probe needed points. This allows you to invalidate parts of the mesh but still use Automatic Probing.
    • The X and Y parameters prioritize where to try and measure points. If omitted, the current probe position is used.
    • Use T (Topology) in this phase to report the probing results.
    • P1 will suspend mesh generation if the controller button is held down. Note that you may need to press and hold the switch for several seconds if moves are underway.
  • P2:

    Probe Areas of the mesh that can’t be automatically handled.

    • Use H to set the height between mesh points. If omitted, Z_CLEARANCE_BETWEEN_PROBES is used. Smaller values will be quicker. Move the nozzle down till it barely touches the bed. Make sure the nozzle is clean and unobstructed. Use caution and move slowly. This can damage your printer! (Uses SIZE_OF_LITTLE_RAISE mm if the nozzle is moving less than BIG_RAISE_NOT_NEEDED mm.)
    • The H value can be negative if the mesh dips in a large area. Press and hold the controller button to terminate the current Phase 2 command. You can then re-issue G29 P 2 with an H parameter more suitable for the area you’re manually probing. Note that the command tries to start in a corner of the bed where movement will be predictable. Override the distance calculation location with the X and Y parameters. You can print a mesh Map (G29 T) to see where the mesh is invalidated and where the nozzle needs to move to complete the command. Use C to indicate that the search should be based on the current position.
    • The B parameter for this command is described above. It places the manual probe subsystem into Business Card mode where the thickness of a business card is measured and then used to accurately set the nozzle height in all manual probing for the duration of the command. A Business card can be used, but you’ll get better results with a flexible Shim that doesn’t compress. This makes it easier to produce similar amounts of force and get more accurate measurements. Google if you’re not sure how to use a shim.
    • The T (Map) parameter helps track mesh building progress.
    • NOTE: P2 requires an LCD controller!
  • P3:

    Fill Unpopulated regions of the mesh with a fixed value (C) or use ‘smart fill’ to extrapolate from already probed points (no argument).

    • With a C constant, the closest invalid mesh points to the nozzle will be filled, and then a repeat count can also be specified with R.
    • Without C it does a Smart Fill, which scans the mesh from the edges inward looking for invalid mesh points. Adjacent points are used to determine the bed slope. If the bed is sloped upward from the invalid point, it takes the value of the nearest point. If sloped downward, it’s replaced by a value that puts all three points in a line. This version of G29 P3 is a quick, easy and (usually) safe way to populate unprobed mesh regions before continuing to G26 Mesh Validation Pattern. Note that this populates the mesh with unverified values. Pay attention and use caution.
  • P4:

    Fine Tune the Mesh. Generally used in the form G29 P4 Rnn Xxxx Yyyy.

    • This phase requires an LCD Panel. To fine-tune the mesh without a controller, use G42 and M421.
    • Phase 4 is meant to be used with G26 Mesh Validation to fine tune the mesh by direct editing of Mesh Points. Raise and lower points to fine tune the mesh until it gives consistently reliable adhesion.
    • P4 moves to the closest Mesh Point (and/or the given X Y), raises the nozzle above the mesh height by the given H offset (or default Z_CLEARANCE_BETWEEN_PROBES), and waits while the controller is used to adjust the nozzle height. On click the displayed height is saved in the mesh.
    • Start Phase 4 at a specific location with X and Y. Adjust a specific number of Mesh Points with the R (Repeat) parameter. (If R is left out, the whole matrix is assumed.) This command can be terminated early (e.g., after editing the area of interest) by pressing and holding the encoder button.
    • The general form is G29 P4 [R points] [X position] [Y position].
    • The H[offset] parameter is useful if a shim is used to fine-tune the mesh. For a 0.4mm shim the command would be G29 P4 H0.4`. The nozzle is moved to the shim height, you adjust height to the shim, and on click the height minus the shim thickness is saved in the mesh.
    • USE WITH CAUTION, as a bad mesh can cause the nozzle to crash into the bed!
  • P5:

    Find Mean Mesh Height and Standard Deviation.

    • Typically, it is easier to use and work with the Mesh if it is Mean-Adjusted. You can specify a C parameter to Correct the Mesh to a 0.00 Mean Height. With a C parameter this will automatically execute a G29 P6 C[mean height].
  • P6:

    Shift Mesh height by the C value.

    • The entire Mesh’s height is adjusted by the height specified by the C parameter. It’s useful to be able to adjust the height of a mesh. It can be used to compensate for a poorly-calibrated probe or other errors. Ideally, you should have the Mesh adjusted for a Mean Height of 0.00 and the Z-Probe measuring 0.0 at the Z homing position.
[Q<index>]

Test Pattern. Load the specified Test Pattern to check for correct operation. This command is intended for developers and is not required for everyday bed leveling.

[R<int>]

Repeat count. (Default GRID_MAX_POINTS_X * GRID_MAX_POINTS_Y).

  • P3 Example: G29 P3 R4 C0 will set the 4 points closest to the nozzle to 0.
  • P4 Example: G29 P4 R3 X80 Y80 will allow you to adjust the 3 points closest to X80 Y80.
  • This parameter does not apply to Phase 1! P1 will always attempt to probe the full grid.
[S<slot>]

Save the mesh to EEPROM in the given slot.

  • If no slot number is given, save to the last-activated slot.
  • Use S-1 for G-code output that can be used to restore the mesh anytime.
  • Note that this command also saves the current UBL state (enabled or disabled).
[T<0|1>]

Topology: Include a Topology Map in the output.

  • This parameter can be used alone (G29 T) or in combination with most of the other commands.
  • This option works with all Phase commands (e.g., G29 P4 R 5 T X 50 Y100 C-0.1 O)
  • A map type can also be specified:
    • T0: Human-readable (the default)
    • T1: Delimited. Suitable to paste into a spreadsheet to obtain a 3D graph of the mesh.
[U<bool>]

Unlevel: Probe the outer perimeter to assist bed tramming. (Use with G29 P1 O)

  • Only used with G29 P1 T U. This speeds up the probing of the edge of the bed. This option is useful when the entire bed doesn’t need to be probed because it will be physically adjusted (tramming).
[V<0|1|2|3|4>]

Verbosity Level (0-4)

[W<bool>]

What?: Display valuable UBL data.

[X<linear>]

X position for all phases and commands (Default: current X)

[Y<linear>]

Y position for all phases and commands (Default: current Y)

Notes

Requires AUTO_BED_LEVELING_UBL.

Release Notes:

  • It’s highly recommended to enable EEPROM. With EEPROM storage enabled, UBL is limited to 3-Point (G29 P0 T) and Grid (G29 P0 G) Leveling.

  • When you do a G28 and then a G29 P1 to automatically build your first mesh, you’ll notice that UBL probes increasingly far from the starting location. (The starting location defaults to the center of the bed.) Other grid leveling systems start in the corner and probe in a zigzag. UBL’s pattern is better for Delta machines, allowing for the center of the Mesh to be populated (and edited) more quickly. You can then do a small test print to check the mesh early in the process. You don’t need to populate the entire mesh to use it. You don’t want to spend a lot of time generating a mesh only to realize that the the resolution or M851 Z probe offset is off. UBL mesh generation gathers points closest the nozzle unless you specify an (X,Y) coordinate pair.

  • UBL requires a decent amount of EEPROM to store its mesh data. And it takes some effort to get this Mesh data correct for a given machine. To keep this data from being destroyed when the EEPROM version changes the Mesh data is stored at the high end of the EEPROM. (Happily, no developers seem to mind.)

  • This system is built around Edward Patel’s “Mesh Bed Leveling” system. A big “Thanks!” to him and to the creators of 3-Point and Grid Based leveling. Combining their contributions we now have the functionality and features of all three systems combined.

Examples

This is a minimal ‘quick-start’ sequence for set-up and initial probing of a UBL mesh on a machine that includes a display and z-probe

M502          ; Reset settings to configuration defaults...
M500          ; ...and Save to EEPROM. Use this on a new install.
M501          ; Read back in the saved EEPROM.  

M190 S65      ; Not required, but having the printer at temperature helps accuracy
M104 S210     ; Not required, but having the printer at temperature helps accuracy

G28           ; Home XYZ.
G29 P1        ; Do automated probing of the bed.
G29 P2 B T    ; Manual probing of locations. USUALLY NOT NEEDED!
G29 P3 T      ; Repeat until all mesh points are filled in.

G29 T         ; View the Z compensation values.
G29 S1        ; Save UBL mesh points to EEPROM.
G29 F 10.0    ; Set Fade Height for correction at 10.0 mm.
G29 A         ; Activate the UBL System.
M500          ; Save current setup. WARNING - UBL will be active at power up, before any G28.

Use G26 and G29 commands to fine-tune a measured mesh

G26 C P T3.0  ; Produce mesh validation pattern with primed nozzle.
    ; NOTE - PLA temperatures are assumed unless you specify - e.g. - B 105 H 225 for ABS Plastic
G29 P4 T      ; Move nozzle to 'bad' areas and fine tune the values if needed.
    ; Repeat G26 and G29 P4 T  commands as needed.
G29 S1        ; Save UBL mesh values to EEPROM.
M500          ; Resave UBL's state information.

Use 3-point probe to ‘tilt’ a stored mesh; e.g. in your startup script

G29 L1        ; Load the mesh stored in slot 1 (from G29 S1)
G29 J         ; No size specified on the J option tells G29 to probe the specified 3 points and tilt the mesh according to what it finds.

thinkyhead

G30 - Single Z-Probe

1.0.0-beta calibration Probe bed at current XY location HAS_BED_PROBE

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


Usage

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

Argument Description
[E<|>]

Engage the probe for each point.

[X<pos>]

X probe position

[Y<pos>]

Y probe position

thinkyhead

G31 - Dock Sled

1.0.0-beta planner Dock the Z probe sled. Z_PROBE_SLED

Dock the Z probe sled.


Usage

G31

Notes

Requires Z_PROBE_SLED.

Example

Dock the sled

G31

thinkyhead

G32 - Undock Sled

1.0.0-beta planner Undock the Z probe sled. Z_PROBE_SLED

Undock the Z probe sled.


Usage

G32

Example

Undock the sled

G32

LVD-AC thinkyhead

G33 - Delta Auto Calibration

1.1.0 calibration Calibrate various Delta parameters DELTA_AUTO_CALIBRATION

With the G33 command you can:

  • Probe a circular grid of points,
  • Calibrate Delta Height,
  • Calibrate endstops,
  • Calibrate Delta Radius, and
  • Calibrate Tower Angles.

Usage

G33 [C<>] [E<|>] [F<>] [P<-1|0|1|2|3|4-10>] [S<|>] [T<|>] [V<0|1|2|>]

Argument Description
[C<>]

If omitted iterations stop at best achievable precision; if set force iterations to stop at the set precision.

[E<|>]

Engage the probe for each point.

[F<>]

Force to run at least n iterations and take the best result.

[P<-1|0|1|2|3|4-10>]
  • P-1:

    Check the z-offset with a center probe and paper test.

  • P0:

    Normalize end-stops and tower angle corrections only (no probing).

  • P1:

    Probe center and set height only.

  • P2:

    Probe center and towers. Set height, endstops, and delta radius.

  • P3:

    Probe all positions - center, towers and opposite towers. Set all.

  • P4-10:

    Probe all positions with intermediate locations, averaging them.

[S<|>]

Setup mode - disables probe protection.

[T<|>]

Disable tower angle corrections calibration (P3-P7)

[V<0|1|2|>]

Set the verbose level

  • V0:

    Dry run, no calibration

  • V1:

    Report settings

  • V2:

    Report settings and probe results

Examples

Default (Verbose 1)

G33

> G33 Auto Calibrate
> Checking... AC
> .Height:295.00    Ex:+0.00  Ey:+0.00  Ez:+0.00    Radius:100.00
> .Tower angle :    Tx:+0.00  Ty:+0.00  Tz:+0.00
> Iteration : 01                                    std dev:2.665
> .Height:297.85    Ex:-0.18  Ey:-0.13  Ez:+0.00    Radius:100.68
> .Tower angle :    Tx:-0.05  Ty:+0.08  Tz:+0.00
> Iteration : 02                                    std dev:0.128
> .Height:297.77    Ex:-0.19  Ey:-0.09  Ez:+0.00    Radius:100.80
> .Tower angle :    Tx:-0.07  Ty:+0.15  Tz:+0.00
> Iteration : 03                                    std dev:0.025
> .Height:297.78    Ex:-0.17  Ey:-0.09  Ez:+0.00    Radius:100.78
> .Tower angle :    Tx:-0.09  Ty:+0.20  Tz:+0.00
> Iteration : 04                                    std dev:0.022
> .Height:297.80    Ex:-0.14  Ey:-0.07  Ez:+0.00    Radius:100.79
> .Tower angle :    Tx:-0.10  Ty:+0.22  Tz:+0.00
> Iteration : 05                                    std dev:0.019
> .Height:297.81    Ex:-0.13  Ey:-0.06  Ez:+0.00    Radius:100.80
> .Tower angle :    Tx:-0.10  Ty:+0.25  Tz:+0.00
> Calibration OK                                    rolling back.
> .Height:297.80    Ex:-0.14  Ey:-0.07  Ez:+0.00    Radius:100.79
> .Tower angle :    Tx:-0.10  Ty:+0.22  Tz:+0.00
> Save with M500 and/or copy to Configuration.h

Verbose 2

G33 V2

> G33 Auto Calibrate
> Checking... AC
> .Height:297.80    Ex:-0.14  Ey:-0.07  Ez:+0.00    Radius:100.79
> .Tower angle :    Tx:-0.10  Ty:+0.22  Tz:+0.00
> .      c:+0.01     x:+0.06   y:+0.04   z:+0.01
> .                 yz:-0.02  zx:-0.01  xy:+0.01
> Iteration : 01                                    std dev:0.028
> .Height:297.81    Ex:-0.10  Ey:-0.04  Ez:+0.00    Radius:100.81
> .Tower angle :    Tx:-0.10  Ty:+0.24  Tz:+0.00
> .      c:-0.03     x:-0.01   y:-0.02   z:-0.03
> .                 yz:-0.05  zx:-0.05  xy:-0.06
> Calibration OK                                    rolling back.
> .Height:297.80    Ex:-0.14  Ey:-0.07  Ez:+0.00    Radius:100.79
> .Tower angle :    Tx:-0.10  Ty:+0.22  Tz:+0.00
> Save with M500 and/or copy to Configuration.h

Using V0 for Dry Run with no calibration.

G33 V0

> G33 Auto Calibrate
> Checking... AC (DRY-RUN)
> .Height:295.00    Ex:+0.00  Ey:+0.00  Ez:+0.00    Radius:100.00
> .Tower angle :    Tx:+0.00  Ty:+0.00  Tz:+0.00
> .      c:-2.86     x:-2.68   y:-2.62   z:-2.56
> .                 yz:-2.55  zx:-2.61  xy:-2.78
> End DRY-RUN                                       std dev:2.668

Using the T flag for no tower angles.

G33 T

> G33 Auto Calibrate
> Checking... AC
> .Height:297.79    Ex:-0.13  Ey:-0.06  Ez:+0.00    Radius:100.83
> Iteration : 01                                    std dev:0.024
> .Height:297.82    Ex:-0.09  Ey:-0.05  Ez:+0.00    Radius:100.82
> Calibration OK                                    rolling back.
> .Height:297.79    Ex:-0.13  Ey:-0.06  Ez:+0.00    Radius:100.83
> Save with M500 and/or copy to Configuration.h

Use a single point (P1) to check the height.

G33 P1

> G33 Auto Calibrate
> Checking... AC
> .Height:297.79
> Calibration OK
> .Height:297.80
> Save with M500 and/or copy to Configuration.h

thinkyhead

G38.2, G38.3 - Probe target

1.1.0 calibration Probe towards a workpiece and stop on contact. G38_PROBE_TARGET

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.

ManuelMcLure

G42 - Move to mesh coordinate

1.1.2 calibration Move to a specific point in the leveling mesh HAS_MESH

The G42 command moves the nozzle to the location corresponding to a specific coordinate in the bed leveling mesh. It operates similarly to the G0 and G1 commands except that the provided coordinates are a mesh row and column instead of an absolute or relative position on the bed.

The G42 command will determine the bed position that corresponds to the provided mesh row and column and move the nozzle to that position.


Usage

G42 [F<rate>] [I<pos>] [J<pos>]

Argument Description
[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.

[I<pos>]

The column of the mesh coordinate

[J<pos>]

The row of the mesh coordinate

Examples

Move to various points on a 9x9 mesh

G42 I0 J0	; front left corner
G42 I4 J4	; center
G42 I4 J8	; back center
G42 I8 J8	; back right

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 [P<ms>] [S<sec>] [string]

Argument Description
[P<ms>]

Expire time, in milliseconds

[S<sec>]

Expire time, in seconds

[string]

An optional message to display on the LCD

Notes

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

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

M3 - Spindle CW / Laser On

1.1.2 control Set the spindle CW speed or laser power SPINDLE_LASER_ENABLE

Wait for moves to complete, then set the spindle speed (clockwise) or laser power.


Usage

M3 [S<power>]

Argument Description
[S<power>]

Spindle speed or laser power

Examples

Set spindle rotation clockwise at 50%

M3 S128

Turn on the laser at full power

M3

thinkyhead

M4 - Spindle CCW / Laser On

1.1.2 control Set the spindle CCW speed or laser power SPINDLE_LASER_ENABLE

Wait for moves to complete, then set the spindle speed (counter-clockwise) or laser power.


Usage

M4 [S<power>]

Argument Description
[S<power>]

Spindle speed or laser power

Examples

Set spindle rotation counter-clockwise at 50%

M4 S128

Turn on the laser at full power

M4

thinkyhead

M5 - Spindle / Laser Off

1.1.2 control Turn off spindle or laser SPINDLE_LASER_ENABLE

Wait for moves to complete, then turn off the spindle / laser power and PWM.


Usage

M5

Examples

Turn off the spindle or laser

M5

thinkyhead

M17 - Enable Steppers

control Power on all steppers

Enable power on all stepper motors.


Usage

M17

Examples

Enable power on all stepper motors

M17

thinkyhead

M18, M84 - Disable steppers

control Disable steppers (same as M84).

This command can be used to set the stepper inactivity timeout (S) or to disable one or more steppers (X,Y,Z,E).

If a timeout is given with S, this command just sets the stepper inactivity timeout.

If no steppers are specified, this command disables all steppers immediately.

If one or more axes are specified, this command disables the specified steppers immediately.


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

Examples

Set the stepper inactivity timeout to 1 minute

M18 S60

Disable all steppers immediately

M18

Disable Z and E steppers immediately

M18 Z E

thinkyhead

M20 - List SD Card

sdcard List the contents of the SD Card. SDSUPPORT

List the entire contents of the SD card to serial output in the more compact DOS 8.3 format.

Marlin 1.1.0 includes file sizes in the output.


Usage

M20

Notes

Requires SDSUPPORT

thinkyhead

M21 - Init SD card

sdcard Attempt to detect an SD card in the slot. SDSUPPORT

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 SDSUPPORT

If Marlin gets confused about the state of the SD card, this command can be used to simulate an ejection of the SD card.

Re-insert the SD card or use M21 to enable the SD card following M22.


Usage

M22

Notes

Requires SDSUPPORT

thinkyhead

M23 - Select SD file

sdcard Select an SD file to be executed SDSUPPORT

Usage

M23 filename

Argument Description
filename

The filename of the file to open.

Notes

Requires SDSUPPORT

thinkyhead

M24 - Start or Resume SD print

sdcard Start or resume a file selected with `M23` SDSUPPORT

Start an SD print or resume the paused SD print. If PARK_HEAD_ON_PAUSE is enabled, unpark the nozzle.

If POWER_LOSS_RECOVERY is enabled M24 accepts parameters which allow resuming the print from a specific point in the file. These parameters are usually only used in this scenario.


Usage

M24 [S<pos>] [T<time>]

Argument Description
[S<pos>]

Position in file to resume from (requires POWER_LOSS_RECOVERY)

[T<time>]

Elapsed time since start of print (requires POWER_LOSS_RECOVERY)

Notes

Requires SDSUPPORT

thinkyhead

M25 - Pause SD print

sdcard Pause printing from the SD card SDSUPPORT

Pause the SD print in progress. If PARK_HEAD_ON_PAUSE is enabled, park the nozzle.


Usage

M25

Notes

Requires SDSUPPORT

thinkyhead

M26 - Set SD position

sdcard Set the SD read position SDSUPPORT

Set the next read position in the open SD file.


Usage

M26 [S<pos>]

Argument Description
[S<pos>]

Next file read position to set

Notes

Requires SDSUPPORT

thinkyhead TheSFReader

M27 - Report SD print status

sdcard Print SD progress to serial SDSUPPORT

With no parameter, report the current SD read position in the form “SD printing byte 123/12345.” If no file is open the response is “Not SD printing.”


With ‘S', set the SD status auto-report interval. (Requires `AUTO_REPORT_SD_STATUS`)


With ‘C’, get the currently open file’s name (and long filename if possible). Print “(no file)” if no file is open.


Usage

M27 [C] [S<seconds>]

Argument Description
[C]

Report the filename and long filename of the current file.

[S<seconds>]

Interval between auto-reports. S0 to disable.

Notes

Requires SDSUPPORT

Examples

Report current SD status

M27 S4

Report SD status every 4 seconds

M27 S4

Stop reporting SD status

M27 S0

Report currently open filename

M27 C

thinkyhead

M28 - Start SD write

sdcard Start writing to a file on the SD card SDSUPPORT

This command starts a file write. All commands received by Marlin are written to the file and are not executed until M29 closes the file.


Usage

M28

Notes

Requires SDSUPPORT

To write commands to a file while also printing, use M928

thinkyhead

M29 - Stop SD write

sdcard Stop writing the file, end logging. SDSUPPORT

Stop writing to a file that was begun with M28 or M928. Logging is disabled.


Usage

M29

Notes

Requires SDSUPPORT

thinkyhead

M30 - Delete SD file

sdcard Delete a specified file from SD.

Usage

M30 filename

Argument Description
filename

The filename of the file to delete.

Notes

Requires SDSUPPORT

Example

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. SDSUPPORT

The M32 command exists to allow G-code to load other G-code files and run them as sub-programs. This can be useful to change the start / end gcode for a batch of files without having to edit them all.


For legacy reasons M32 uses ‘!’ (and ‘#’) to delimit the filepath parameter. The filepath must be the last parameter.


Usage

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

Argument Description
[P<flag>]

Sub-Program flag

[S<filepos>]

Starting file offset

Notes

Requires SDSUPPORT

This is a seldom-used beta feature that 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

1.0.2 sdcard Convert a short pathname to a long pathname. SDSUPPORT LONG_FILENAME_HOST_SUPPORT

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

1.1.0 sdcard Set SDCard file sorting options. SDSUPPORT SDCARD_SORT_ALPHA

Marlin now contains support for SDCard alphabetical file sorting in the LCD menus. This feature uses free SRAM to create a sorting index for up to the first 256 files in the current folder, and (if you have lots of SRAM) 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

  • F-1:

    Folders before files

  • F0:

    No folder sorting

  • F1:

    Folders after files

[S<bool>]

Sorting on/off

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. (LED_PIN if omitted)

S<int>

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

thinkyhead

M43 T - Toggle Details (Debug Pins)

debug Get information about pins. PINS_DEBUGGING

The M43 T command toggles one or more pins.


Usage

M43 T [I<bool>] [L<pin>] [R<count>] [S<pin>] [W<time>]

Argument Description
[I<bool>]

Flag to ignore Marlin’s pin protection. Use with caution!!!!

[L<pin>]

End Pin number. If not given, will default to last pin defined for this board

[R<count>]

Repeat pulses on each pin this number of times before continuing to next pin. If not given will default to 1.

[S<pin>]

Start Pin number. If not given, will default to 0

[W<time>]

Wait time (in milliseconds) transitions. If not given will default to 500.

Notes

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

Examples

Toggle pins 3-6 five times with 1 second low and 1 second high pulses but only if the pin isn’t in the protected list.

M43 T S3 L6 R5 W1000

thinkyhead

M43 - Debug Pins

debug Get information about pins. PINS_DEBUGGING

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 I to report the values on pins that are protected. Use W to watch the specified pin, or all pins. Use the E option to monitor endstops. Use S option to test a BLTouch type servo probe. Use T option to toggle pins.


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>] [I] [P<pin>] [S] [T] [W]

Argument Description
[E<bool>]

Watch endstops

[I]

Ignore protection when reporting values

[P<pin>]

Digital Pin Number

[S]

Test BLTouch type servo probes. Use P to specify servo index (0-3). Defaults to 0 if P omitted

[T]

Toggle pins - see M43 T for options

[W]

Watch pins

Notes

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

Examples

Get a report on all pins

M43

Get a report on all pins, ignore pin protection list when displaying values

M43 I

Watch pin 56 for changes

M43 P56 W

Start watching endstops

M43 E1

Toggle pins 3-6 five times with 1 second low and 1 second high pulses but only if the pin isn’t in the protected list.

M43 T S3 L6 R5 W1000

Test probe controlled by servo index 2.

M43 S P2

thinkyhead

M48 - Probe Accuracy Test

calibration Measure Z Probe repeatability. Z_MIN_PROBE_REPEATABILITY_TEST

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>] [S<0|1>] [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

[S<0|1>]

Star/Schizoid probe. By default this will do 7 points. Override with L.

  • S0:

    Circular pattern

  • S1:

    Star-like pattern

[V<level>]

Verbose Level

[X<pos>]

X Position

[Y<pos>]

Y Position

Notes

Requires Z_MIN_PROBE_REPEATABILITY_TEST.

MarlinFirmware

M73 - Set Print Progress

1.1.7 lcd Set current print progress percentage for LCD. LCD_SET_PROGRESS_MANUALLY

Set current print progress percentage for LCD.


Usage

M73 P<percent>

Argument Description
P<percent>

Current print progress percentage

Examples

Set print progress to 25%

M73 P25

thinkyhead

M75 - Start Print Job

printjob Start the print job timer.

Start the print job timer.


Usage

M75

Example

Start the print job timer

M75

thinkyhead

M76 - Pause Print Job

printjob Pause the print job timer.

Pause the print job timer.


Usage

M76

Example

Pause the print job timer

M76

thinkyhead

M77 - Stop Print Job

printjob Stop the print job timer.

Stop the print job timer.


Usage

M77

Example

Stop the print job timer

M77

thinkyhead

M78 - Print Job Stats

printjob Print statistics about print jobs. PRINTCOUNTER

Usage

M78

thinkyhead

M80 - Power On

control Turn on the power supply. POWER_SUPPLY>0

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


Usage

M80 [S]

Argument Description
[S]

Report Power Supply state

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. POWER_SUPPLY>0

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 the 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.

Example

Set E steps for a new extruder

M92 E688.4

thinkyhead

M100 - Free Memory

debug Description Here M100_FREE_MEMORY_WATCHER

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>] [T<index>]

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.

[T<index>]

Hotend index. If omitted, the currently active hotend will be used.

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

Set target temperature for the active hotend

M104 S185

Set target temperature for E1

M104 T1 S205

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.


Usage

M105 [T<index>]

Argument Description
[T<index>]

Hotend index

Notes

Some hosts may hide the reply from M105.

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 to receive temperatures.

Examples

Get a temperature report

M105

thinkyhead

M106 - Set Fan Speed

thermal Turn on the fan and set its speed EXTRA_FAN_SPEED

Turn on one of the fans and set its speed. If no fan index is given, the print cooling fan is selected. The fan speed applies to the next block added to the planner, so it will not take effect until previous moves in the planner are done. Under manual control with an idle machine, M106 will change the fan speed immediately.


Usage

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

Argument Description
[P<index>]

Fan index

[S<speed>]

Speed

[T<secondary>]

Secondary speed. Added in Marlin 1.1.7. (Requires EXTRA_FAN_SPEED)

  • M106 P<fan> T3-255 sets a secondary speed for <fan>.’
  • M106 P<fan> T2 uses the set secondary speed.’
  • M106 P<fan> T1 restores the previous fan 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.

Example

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 M109 waits only when heating. If the temperature is set with R then M109 will also wait for the temperature to go down.


Usage

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

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.

[T<index>]

Hotend index. If omitted, the currently active hotend will be used.

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, preventing remote shutdown. However, if EMERGENCY_PARSER is enabled, a host can send M108 to break out of the wait loop.

To set the hot end temperature and proceed without waiting, use M104.

Examples

Set target temperature and wait (if heating up)

M109 S180

Set target temperature, wait even if cooling

M109 R120

Set target temperature for E1 and wait (if heating up)

M109 T1 R205

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:

Mask Name Description
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.)
64 Reserved Reserved for future usage
128 Reserved Reserved for future usage

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

Enable everything except dry-run mode

M111 S247 ; 255 - 8

Disable previously set extra debugging output.

M111 S0

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. HOST_KEEPALIVE_FEATURE

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. If M114_DETAIL is enabled the D parameter will provide more details such as leveling information and kinematics.


Usage

M114 [D<|>]

Argument Description
[D<|>]

Detailed information (requires M114_DETAIL)

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, 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. ULTRA_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

M118 - Serial print

hosts Send text to serial

Send a message to the connected host for display in the host console or to perform a host action.


Usage

M118 [A1] [E1] [string]

Argument Description
[A1]

Prepend // to denote a comment or action command. Hosts like OctoPrint can interpret such commands to perform special actions. See your host’s documentation.

[E1]

Prepend echo: to the message. Some hosts will display echo messages differently when preceded by echo:.

[string]

Message string. If omitted, a blank line will be sent.

Notes

The E and A parameters must precede the message.

Examples

Echo “Yello World!” in the console

M118 E1 Yello World!

Tell OctoPrint to cancel the print job

M118 A1 action:cancel

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 and filament runout sensors are also reported with this command.


Usage

M119

Notes

The BLTOUCH probe only sends a brief pulse, so “TRIGGERED” indicates the probe is in error state.

Similarly, Trinamic’s Sensorless Homing only sends a short pulse, so for these “TRIGGERED” is unusual.

Example

Get all endstop states

> M119
Reporting endstop status
x_min: open
y_min: open
z_min: TRIGGERED
z_probe: open
filament: open

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

mbuc

M122 - TMC Debugging

1.1.7 debug Get TMC Debug Info HAVE_TMC2130|HAVE_TMC2208 TMC_DEBUG

When sent without a parameter, returns a table of current register settings for any Trinamic TMC2130 or TMC2208 stepper motor drivers. Sending the command with the S parameter and a following boolean will respectively enable or disable reporting the debugging information on a continous basis.


Usage

M122 [S]

Argument Description
[S]

Flag to enable/disable continuous reporting of debugging information.

Notes

Need to have TMC_DEBUG enabled in Configuration_adv.h.

Examples

Enabling debugging output:

M122 S1

Example Output:

SENDING:M122
X	Y
Enabled		false	false
Set current	850	850
RMS current	826	826
MAX current	1165	1165
Run current	26/31	26/31
Hold current	13/31	13/31
CS actual		13/31	13/31
PWM scale	41	41
vsense		1=.18	1=.18
stealthChop	true	true
msteps		16	16
tstep		1048575	1048575
pwm
threshold		0	0
[mm/s]		-	-
OT prewarn	false	false
OT prewarn has
been triggered	false	false
off time		5	5
blank time	24	24
hysterisis
-end		2	2
-start		3	3
Stallguard thrs	0	0
DRVSTATUS	X	Y
stallguard
sg_result		0	0
fsactive
stst		X	X
olb
ola
s2gb
s2ga
otpw
ot
'Driver registers:'
	X = 0x80:0D:00:00
	Y = 0x80:0D:00:00

thinkyhead

M125 - Park Head

nozzle Save current position and move to filament change position. PARK_HEAD_ON_PAUSE

Save the current nozzle position and move to the configured park position.


Usage

M125 [L<linear>] [X<linear>] [Y<linear>] [Z<linear>]

Argument Description
[L<linear>]

Retract length (otherwise FILAMENT_CHANGE_RETRACT_LENGTH)

[X<linear>]

X position to park at (otherwise FILAMENT_CHANGE_X_POS)

[Y<linear>]

Y position to park at (otherwise FILAMENT_CHANGE_Y_POS)

[Z<linear>]

Z raise before park (otherwise FILAMENT_CHANGE_Z_ADD)

Notes

Requires PARK_HEAD_ON_PAUSE.

Examples

Retract 2cm of filament and park the nozzle

M125 L20 ; park and retract

thinkyhead

M126 - Baricuda 1 Open

baricuda Open the valve for Baricuda 1. BARICUDA

Open the valve for Baricuda paste extruder 1.


Usage

M126 [S<pressure>]

Argument Description
[S<pressure>]

Valve pressure

Notes

Requires BARICUDA.

Examples

M126 ; open valve 1

thinkyhead

M127 - Baricuda 1 Close

baricuda Close the valve for Baricuda 1. BARICUDA

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. BARICUDA

Open the valve for Baricuda paste extruder 2.


Usage

M128 [S<pressure>]

Argument Description
[S<pressure>]

Valve pressure

Notes

Requires BARICUDA.

Examples

M128 ; open valve 2

thinkyhead

M129 - Baricuda 2 Close

baricuda Close the valve for Baricuda 2. BARICUDA

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. NEWPANEL

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(W) Color

lcd Set the color of the RGB(W) LED, backlight, or LED strip. BLINKM|RGB_LED|RGBW_LED|NEOPIXEL_LED|PCA9632

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


Usage

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

Argument Description
[B<intensity>]

Blue component from 0 to 255

[P<intensity>]

Brightness from 0 to 255 (NEOPIXEL_LED only)

[R<intensity>]

Red component from 0 to 255

[U<intensity>]

Green component from 0 to 255

[W<intensity>]

White component from 0 to 255 (RGBW_LED or NEOPIXEL_LED only)

Notes

Requires BLINKM, RGB_LED, RGBW_LED, NEOPIXEL_LED or PCA9632.

thinkyhead

M155 - Temperature Auto-Report

hosts Auto-report temperatures to host periodically. AUTO_REPORT_TEMPERATURES EXTENDED_CAPABILITIES_REPORT

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. S0 to disable.

Notes

Requires AUTO_REPORT_TEMPERATURES in Configuration_adv.h.

Also enable EXTENDED_CAPABILITIES_REPORT to notify hosts about this capability.

Examples

Report temperatures every 4 seconds

M155 S4

Stop reporting temperatures

M155 S0

thinkyhead

M163 - Set Mix Factor

mixing Set a single mix factor for a mixing extruder. 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. MIXING_EXTRUDER MIXING_VIRTUAL_TOOLS

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. MIXING_EXTRUDER DIRECT_MIXING_IN_G1

Set the mix all at once. Any factors left out are set to 0.0. This is based on a reference implementation by Pìa Taubert.


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>] [T<index>]

Argument Description
[D<diameter>]

Filament diameter

[T<index>]

Extruder index. If omitted, the currently active extruder will be used.

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<units/s>] [T<index>] [X<units/s>] [Y<units/s>] [Z<units/s>]

Argument Description
[E<units/s>]

E axis max feedrate

[T<index>]

Target extruder (Requires DISTINCT_E_FACTORS)

[X<units/s>]

X axis max feedrate

[Y<units/s>]

Y axis max feedrate

[Z<units/s>]

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 X100 Y100

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>] [J<deviation>] [S<units/s>] [T<units/s>] [X<jerk>] [Y<jerk>] [Z<jerk>]

Argument Description
[B<µs>]

Minimum segment time (µs)

[E<jerk>]

E max jerk (units/s)

[J<deviation>]

Junction deviation (requires JUNCTION_DEVIATION)

[S<units/s>]

Minimum feedrate for print moves (units/s)

[T<units/s>]

Minimum feedrate for travel moves (units/s)

[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 T40 ; Travel feedrate = 40mm/s

thinkyhead

M206 - Set Home Offsets

planner Description Here HAS_HOME_OFFSET

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 [P<offset>] [T<offset>] [X<offset>] [Y<offset>] [Z<offset>]

Argument Description
[P<offset>]

SCARA Psi offset (Requires MORGAN_SCARA)

[T<offset>]

SCARA Theta offset (Requires MORGAN_SCARA)

[X<offset>]

X home offset

[Y<offset>]

Y home offset

[Z<offset>]

Z home offset

Notes

  • This command isn’t available on DELTA. (For delta use M665 H.)
  • This GCode can be disabled with NO_WORKSPACE_OFFSETS to optimize movement.
  • 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. FWRETRACT

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.

See related codes G10, G11, M208, and M209.

thinkyhead

M208 - Set Firmware Recovery

planner Set values for firmware-based retract recovery. FWRETRACT

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


Usage

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

Argument Description
[F<feedrate>]

Recover feedrate (units/min)

[R<feedrate>]

Recover swap feedrate (units/min)

[S<length>]

Recover length

[W<length>]

Recover swap length (multi-extruder)

Notes

Requires FWRETRACT.

See related codes G10, G11, M207, and M209.

thinkyhead

M209 - Set Auto Retract

planner Enable / disable auto-retraction. FWRETRACT

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

Requires FWRETRACT.

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.

See related codes G10, G11, M207, and M208.

thinkyhead

M211 - Software Endstops

planner Set and/or get the software endstops state (MIN|MAX)_SOFTWARE_ENDSTOPS

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). EXTRUDERS>1

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_NOZZLE.

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_NOZZLE.
  • 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 in all (X, Y, Z, and E) axes.


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. CHDK|PHOTOGRAPH_PIN

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. HAS_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. EXPERIMENTAL_I2CBUS

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. EXPERIMENTAL_I2CBUS

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. NUM_SERVOS>0

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

M290 - Babystep

1.1.7 calibration Babystep one or more axes BABYSTEPPING

Apply babysteps to one or more axes using current units. Offsets applied with M290 aren’t added to the current coordinates, but are intended for making small adjustments, especially in the Z axis, at the start of a print.


Note that when BABYSTEP_ZPROBE_OFFSET is enabled, M290 also modifies the Probe Z Offset (with no immediate effects). The new Z offset applies to successive probing operations, and can be saved with M500. This behavior is means to coincide with the LCD Menu replacing “Z Babystepping” with “Babystep Z Probe Offset.” To avoid this side-effect, use M290 P0 or leave BABYSTEP_ZPROBE_OFFSET disabled.


Usage

M290 [P<bool>] [S<pos>] [X<pos>] [Y<pos>] [Z<pos>]

Argument Description
[P<bool>]

Use P0 to leave the Probe Z Offset unaffected. (Requires BABYSTEP_ZPROBE_OFFSET)

[S<pos>]

Alias for Z

[X<pos>]

A distance on the X axis

[Y<pos>]

A distance on the Y axis

[Z<pos>]

A distance on the Z axis

Notes

Requires BABYSTEP_XY for babystepping on the XY axes.

Example

Babystep the Z axis by 0.25mm (in mm units mode)

M290 Z0.25 ; move up 0.25mm on the Z axis

thinkyhead

M300 - Play Tone

lcd Play a single tone, buzz, or beep. SPEAKER

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. PIDTEMP

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. PREVENT_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. PIDTEMP|PIDTEMPBED

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. PIDTEMPBED

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.

thinkyhead

M350 - Set micro-stepping

control Set micro-stepping for drivers that support it HAS_MICROSTEPS

If your board has digital micro-stepping pins (X_MS1, Y_MS1, etc.), use this command to set the micro-steps.


Usage

M350 [B<1|2|4|8|16>] [E<1|2|4|8|16>] [S<1|2|4|8|16>] [X<1|2|4|8|16>] [Y<1|2|4|8|16>] [Z<1|2|4|8|16>]

Argument Description
[B<1|2|4|8|16>]

Set micro-stepping for the 5th stepper driver.

[E<1|2|4|8|16>]

Set micro-stepping for the E0 stepper driver.

[S<1|2|4|8|16>]

Set micro-stepping for all 5 stepper drivers.

[X<1|2|4|8|16>]

Set micro-stepping for the X stepper driver.

[Y<1|2|4|8|16>]

Set micro-stepping for the Y stepper driver.

[Z<1|2|4|8|16>]

Set micro-stepping for the Z stepper driver.

thinkyhead

M351 - Set Microstep Pins

control Directly set the micro-stepping pins HAS_MICROSTEPS

If your board has digital micro-stepping pins (X_MS1, Y_MS1, etc.), use this command to set the micro-steps.


Usage

M351 [B<0|1>] [E<0|1>] S<1|2> [X<0|1>] [Y<0|1>] [Z<0|1>]

Argument Description
[B<0|1>]

Set the MS1/2 pin for the 5th stepper driver.

[E<0|1>]

Set the MS1/2 pin for the E stepper driver.

S<1|2>

Select the pin to set for all specified axes.

  • S1:

    Select pin MS1 for all axes being set.

  • S2:

    Select pin MS2 for all axes being set.

[X<0|1>]

Set the MS1/2 pin for the X stepper driver.

[Y<0|1>]

Set the MS1/2 pin for the Y stepper driver.

[Z<0|1>]

Set the MS1/2 pin for the Z stepper driver.

Examples

Set the X_MS1 pin and clear the E0_MS1 pin

M351 S1 X1 E0

thinkyhead

M355 - Case Light Control

control Turn the case light on or off, set brightness CASE_LIGHT_PIN

Set the case light power state and/or brightness.


Usage

M355 [P<byte>] [S<bool>]

Argument Description
[P<byte>]

Set the brightness factor from 0 to 255.

[S<bool>]

Turn the case light on or off.

Notes

Requires a CASE_LIGHT_PIN to control the on/off or PWM state of the case light. The pin will need to be a 12V MOSFET pin with PWM control, or a signal pin connected to a MOSFET or relay to control the higher current required for the light.

Example

Turn the case light on at half brightness

M355 S1 P128

thinkyhead

M360 - SCARA Theta A

control Move to Theta A MORGAN_SCARA

Move the nozzle to SCARA calibration position Theta 0 (A0 B120) for calibration of “zero degrees.”


Usage

M360

thinkyhead

M361 - SCARA Theta-B

control Move to Theta-B MORGAN_SCARA

Move the nozzle to SCARA Theta-B calibration position Theta 90 (A90 B130) for calibration of “90 degrees steps-per-degree.”


Usage

M361

thinkyhead

M362 - SCARA Psi-A

control Move to Psi-A MORGAN_SCARA

Move the nozzle to SCARA Psi-A calibration position Psi 0 (A60 B180) for calibration of “zero degrees.”


Usage

M362

thinkyhead

M363 - SCARA Psi-B

control Move to Psi-B MORGAN_SCARA

Move the nozzle to SCARA Psi-B calibration position Psi 90 (A50 B90) for calibration of “90 degrees steps-per-degree.”


Usage

M363

thinkyhead

M364 - SCARA Psi-C

control Move to Psi-C MORGAN_SCARA

Move the nozzle to SCARA Psi-C calibration position Theta-Psi 90 (A45 B135) for calibration of “90 degrees to Theta.”


Usage

M364

thinkyhead

M380 - Activate Solenoid

none Activate EXT_SOLENOID

Activate the solenoid on the active extruder.


Usage

M380

Example

M381 ; Deactivate all solenoids
T0   ; Extruder 0
M380 ; Activate the E0 solenoid

thinkyhead

M381 - Deactivate Solenoids

none Deactivate all extruder solenoids EXT_SOLENOID

Deactivate all solenoids on all extruders.


Usage

M381

Example

M381 ; Deactivate all solenoids

thinkyhead

M400 - Finish Moves

planner Wait for all moves to finish

This command causes all GCode processing to pause and wait in a loop until all moves in the planner are completed.


Usage

M400

Example

Wait for moves to finish before turning off the spindle

M400
M5    ; Without M400 this happens too soon

thinkyhead

M401 - Deploy Probe

calibration Deploy the bed probe HAS_BED_PROBE

Deploy the bed probe. The Z axis may raise up to make room for the probe to deploy.


Usage

M401

Notes

Requires some kind of bed probe. This command has no visible effect for probes that don’t move. They are just activated.

Examples

Deploy the probe

M401

thinkyhead

M402 - Stow Probe

calibration Stow the bed probe HAS_BED_PROBE

Stow the bed probe. The Z axis may raise up to make room for the probe to stow.


Usage

M402

Notes

Requires some kind of bed probe. This command has no visible effect for probes that don’t move. They are just deactivated.

Examples

Stow the probe

M402

thinkyhead

M404 - Set Filament Diameter

control Set the nominal diameter for filament width sensor auto-flow FILAMENT_WIDTH_SENSOR

Report or set the nominal filament width, such as 1.75 or 3.00.

This value is used to determine the percentage difference when auto-adjusting flow in response to the measured filament width, and should match the value used for filament width in your slicer settings.


Usage

M404 [W<linear>]

Argument Description
[W<linear>]

The new nominal width value

Notes

Requires FILAMENT_WIDTH_SENSOR.

Examples

Set the diameter to 1.75mm

M404 W1.75

Get the current width

M404
> Filament dia (nominal mm): 1.75

thinkyhead

M405 - Filament Width Sensor On

control Enable filament width sensor flow control FILAMENT_WIDTH_SENSOR

Turn on the filament width sensor and start using it to do flow control. Initially, the filament between the sensor and the hot-end will be treated as the nominal width.


Usage

M405 [D<cm>]

Argument Description
[D<cm>]

Distance from measurement point to hot end. If not given, the previous value will be used. The default startup value is set by MEASUREMENT_DELAY_CM.

Notes

Requires FILAMENT_WIDTH_SENSOR.

Example

Start measuring filament width, adjusting flow

M405

thinkyhead

M406 - Filament Width Sensor Off

control Disable filament width sensor flow control FILAMENT_WIDTH_SENSOR

Turn off the filament width sensor and stop using it to do flow control.


Usage

M406

Notes

Requires FILAMENT_WIDTH_SENSOR.

Example

Stop measuring filament width

M406

thinkyhead

M407 - Filament Width

control Report the measured filament width FILAMENT_WIDTH_SENSOR

Report the current measured filament width to the host.


Usage

M407

Notes

Requires FILAMENT_WIDTH_SENSOR.

Example

Get the current measured filament width

M407
> Filament dia (measured mm): 1.768

thinkyhead

M410 - Quickstop

planner Stop all steppers instantly

Stop all steppers instantly. Since there will be no deceleration, steppers are expected to be out of position after this command.


Usage

M410

Notes

This command is intended only for emergency situations.

If EMERGENCY_PARSER is not enabled, this will be delayed.

Example

Stop all steppers now.

M410

thinkyhead

M420 - Bed Leveling State

planner Get and/or set bed leveling state and fade height AUTO_BED_LEVELING_(3POINT|LINEAR|BILINEAR|UBL)|MESH_BED_LEVELING

Get and/or set the enabled state of bed leveling compensation, plus Z fade height.


This command has been extended with L to load a mesh for Unified Bed Leveling.


Usage

M420 [C<bool>] [L<int>] [S<bool>] [T<0|1|4>] [V<bool>] [Z<linear>]

Argument Description
[C<bool>]

Center the mesh on the mean of the lowest and highest points

[L<int>]

Load mesh from EEPROM index (Requires AUTO_BED_LEVELING_UBL and EEPROM_SETTINGS)

[S<bool>]

Enabled state

[T<0|1|4>]

Format to print the mesh data

  • T0:

    Human readable

  • T1:

    CSV

  • T4:

    Compact

[V<bool>]

Verbose: Print the stored mesh / matrix data

[Z<linear>]

Leveling fade Z height (Requires ENABLE_LEVELING_FADE_HEIGHT)

Notes

The “current position” may change in response to M420 Sn.

thinkyhead

M421 - Set Mesh Value

planner Set a single mesh Z height AUTO_BED_LEVELING_(BILINEAR|UBL)|MESH_BED_LEVELING

This command is used to set a single Z value for a mesh point in the stored bed leveling data.


Allowed forms are M421 In Jn Zn, M421 Xn Yn Zn (MESH_BED_LEVELING only) or M421 C Zn (AUTO_BED_LEVELING_UBL only).


Usage

M421 [C<bool>] [I<int>] [J<int>] [N<bool>] [Q<linear>] [X<linear>] [Y<linear>] [Z<linear>]

Argument Description
[C<bool>]

Set the mesh point closest to the current nozzle position (requires AUTO_BED_LEVELING_UBL)

[I<int>]

X index into the mesh array

[J<int>]

Y index into the mesh array

[N<bool>]

Set the mesh point to undefined (requires AUTO_BED_LEVELING_UBL)

[Q<linear>]

A value to add to the existing Z value

[X<linear>]

X position (which should be very close to a grid line) (requires MESH_BED_LEVELING)

[Y<linear>]

Y position (which should be very close to a grid line) (requires MESH_BED_LEVELING)

[Z<linear>]

The new Z value to set

Examples

Set the Z height in the middle of a 5x5 grid

M421 I2 J2 Z-0.05

Set the same Z height using XY

M421 X100 Y100 Z-0.05

Adjust the mesh point by -0.01

M421 I2 J2 Q-0.01

thinkyhead

M428 - Home Offsets Here

planner Set home offsets based on current position HAS_HOME_OFFSET

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 must be within 2cm from 0 or an endstop.
  • 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

  • Only the Z offset can be altered on DELTA.
  • This GCode can be disabled with NO_WORKSPACE_OFFSETS to optimize movement.
  • 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. EEPROM_SETTINGS

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. EEPROM_SETTINGS

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 M500.


Usage

M502

Notes

This command can be used even if EEPROM_SETTINGS is disabled.

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.

ManuelMcLure

M504 - Validate EEPROM contents

eeprom Validate the contents of the EEPROM. EEPROM_SETTINGS

Validate the contents of the EEPROM.


Usage

M504

Notes

Requires EEPROM_SETTINGS.

Examples

Validate EEPROM contents.

M504

thinkyhead

M540 - Endstops Abort SD

sdcard Abort SD printing when an endstop is triggered. SDSUPPORT ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED

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 filament Automatically change filament ADVANCED_PAUSE_FEATURE

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 [B<beeps>] [E<pos>] [L<pos>] [T<index>] [U<pos>] [X<pos>] [Y<pos>] [Z<pos>]

Argument Description
[B<beeps>]

Number of beeps to alert user of filament change (default FILAMENT_CHANGE_ALERT_BEEPS)

[E<pos>]

Retract before moving to change position (negative, default PAUSE_PARK_RETRACT_LENGTH)

[L<pos>]

Load length, longer for bowden (negative)

[T<index>]

Target extruder

[U<pos>]

Amount of retraction for unload (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

Requires ADVANCED_PAUSE_FEATURE.

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

ManuelMcLure

M603 - Configure Filament Change

1.1.0 filament Configure automatic filament change parameters ADVANCED_PAUSE_FEATURE

The M603 command configures automatic filament change parameters.


Usage

M603 [L<pos>] [T<index>] [U<pos>]

Argument Description
[L<pos>]

Load length, longer for bowden (negative)

[T<index>]

Target extruder

[U<pos>]

Amount of retraction for unload (negative)

Notes

Requires ADVANCED_PAUSE_FEATURE.

Examples

Configure load and unload lengths for automatic filament change

M603 U120 L125

thinkyhead

M605 - Dual Nozzle Mode

control Set the behavior mode for dual nozzles DUAL_NOZZLE_DUPLICATION_MODE|DUAL_X_CARRIAGE

This command behaves differently for DUAL_X_CARRIAGE vs. DUAL_NOZZLE_DUPLICATION_MODE


For DUAL_NOZZLE_DUPLICATION_MODE the S2 parameter enables duplication mode. Any other value disables it.


For DUAL_X_CARRIAGE, this command sets the Dual X mode. See the description of S below.


Usage

M605 [R<temp>] S<0|1|2> [X<linear>]

Argument Description
[R<temp>]

Temperature difference to apply to E1. (Requires DUAL_X_CARRIAGE)

S<0|1|2>

Select the pin to set for all specified axes.

  • S0:

    Full control mode. Both carriages are free to move, constrained by safe distance. (Requires DUAL_X_CARRIAGE)

  • S1:

    Auto-park mode. One carriage parks while the other moves. (Requires DUAL_X_CARRIAGE)

  • S2:

    Duplication mode. Carriages and extruders move in unison.

[X<linear>]

X distance between dual X carriages. (Requires DUAL_X_CARRIAGE)

ManuelMcLure

M665 - SCARA Configuration

none Set SCARA geometry values MORGAN_SCARA|MAKERARM_SCARA

Configure SCARA geometry values


Usage

M665 [A<theta-pi-offset>] [B<theta-offset>] [P<theta-pi-offset>] [S<segments-per-second>] [T<theta-offset>] [X<theta-pi-offset>] [Y<theta-offset>]

Argument Description
[A<theta-pi-offset>]

Theta-Psi offset, alias for P

[B<theta-offset>]

Theta offset, alias for T

[P<theta-pi-offset>]

Theta-Psi offset, added to the shoulder (A/X) angle

[S<segments-per-second>]

Segments per second

[T<theta-offset>]

Theta offset, added to the elbow (B/Y) angle

[X<theta-pi-offset>]

Theta-Psi offset, alias for P

[Y<theta-offset>]

Theta offset, alias for T

thinkyhead

M665 - Delta Configuration

none Set delta geometry values DELTA

Delta machines are very fast and accurate when tuned. The first key is to make sure all your dimensions are set correctly. Even small errors in these values can lead to curved movements and failed prints. To ensure the best delta experience, use this command in conjunction with G33 to get these dimensions set perfectly before beginning to print.


Usage

M665 [B<linear>] [H<linear>] [L<linear>] [R<linear>] [S<float>] [X<float>] [Y<float>] [Z<float>]

Argument Description
[B<linear>]

Delta calibration radius

[H<linear>]

Delta height

[L<linear>]

Diagonal rod

[R<linear>]

Delta radius

[S<float>]

Segments per second

[X<float>]

Alpha (Tower 1) angle trim

[Y<float>]

Beta (Tower 2) angle trim

[Z<float>]

Gamma (Tower 3) angle trim

ManuelMcLure

M666 - Set dual endstop offsets

calibration Set dual endstop offsets (X|Y|Z)_DUAL_ENDSTOPS

The M666 command allows adjusting the offsets for dual endstops


Usage

M666 [X<adj>] [Y<adj>] [Z<adj>]

Argument Description
[X<adj>]

Offset for the X axis endstops

[Y<adj>]

Offset for the Y axis endstops

[Z<adj>]

Offset for the Z axis endstops

ManuelMcLure

M666 - Set Delta endstop adjustments

calibration Set Delta endstop adjustments DELTA

The M666 command allows adjusting the endstops on a Delta printer.


Usage

M666 [X<adj>] [Y<adj>] [Z<adj>]

Argument Description
[X<adj>]

Adjustment for the X actuator endstop

[Y<adj>]

Adjustment for the Y actuator endstop

[Z<adj>]

Adjustment for the Z actuator endstop

thinkyhead

M851 - Z Probe Offset

none Set the Z probe Z offset from nozzle HAS_BED_PROBE

Set the vertical distance from the nozzle to the Z probe trigger-point.


The easiest way to get the value is to:

  • Home the Z axis.
  • Raise Z and deploy the probe.
  • Move Z down slowly until the probe triggers.
  • Take the current Z value and negate it. (5.2 => -5.2)
  • Set with M851 Z-5.2 and #define Z_PROBE_OFFSET_FROM_EXTRUDER -5.2.

Usage

M851 Z<linear>

Argument Description
Z<linear>

Z probe Z offset

Notes

The default (factory) value is set by Z_PROBE_OFFSET_FROM_EXTRUDER.

Examples

Set a reasonable offset for an inductive probe

M851 Z-2.0

A probe that is triggered by the nozzle itself

M851 Z1.2

HekTron802

M852 - Bed Skew Compensation

calibration Misalignment in the XYZ axes.

Bed Skew Compensation corrects for misalignment in the XY, XZ, and ZY axes through the use of correction factors.


Usage

M852 [I] [J] [K] [S]

Argument Description
[I]

Skew correction factor for XY axis.

[J]

Skew correction factor for XZ axis

[K]

Skew correction factor for YZ axis

[S]

Alias for I when only XY skew correction is enabled

Notes

Correction factors have a range of -1 to 1.

See Bed Skew Compensation section in the configuration file for more information on calculating the correction factors.

thinkyhead

M900 - Linear Advance Factor

control Get and set Linear Advance K value LIN_ADVANCE

Get and/or set the Linear Advance K factor.


Usage

M900 [K<float>]

Argument Description
[K<float>]

Advance K factor. Unchanged if omitted. Set this value higher for more flexible filament or a longer filament path.

Notes

See Linear Advance for details on how to determine the K factor.

Example

Set the K factor

M900 K0.18

Fetch the K factor

M900

thinkyhead

M906 - TMC Motor Current

none Set the motor current (in milliamps) HAVE_TMC2130

Set the current for a stepper motor in milliamps units.


Usage

M906 [E<mA>] [I<index>] [T<index>] [X<mA>] [Y<mA>] [Z<mA>]

Argument Description
[E<mA>]

Current for the E0 stepper

[I<index>]

(>=1.1.9) Index for dual steppers. Use I1 for X2, Y2, and/or Z2.

[T<index>]

(>=1.1.9) Index (tool) number for the E axis. If not specified, the E0 extruder.

[X<mA>]

Current for the X stepper

[Y<mA>]

Current for the Y stepper

[Z<mA>]

Current for the Z stepper

Examples

Set the XYZ motor currents to 5mA

M906 X5 Y5 Z5

Set the E1 motor current to 10mA

M906 T1 E10

Set the X2 motor current to 5mA

M906 I1 X5

thinkyhead

M907 - Set Motor Current

control Set motor current via digital trimpot DIGIPOTSS_PIN|HAS_MOTOR_CURRENT_PWM|DIGIPOT_I2C|DAC_STEPPER_CURRENT

Set digital trimpot motor current using axis codes X, Y, Z, E, plus B and S. The unit used for current depends on the type of stepper driver.


Usage

M907 [B<current>] [C<current>] [D<current>] [E<current>] [S<current>] [X<current>] [Y<current>] [Z<current>]

Argument Description
[B<current>]

Current for the E1 stepper (Requires DIGIPOTSS_PIN or DIGIPOT_I2C)

[C<current>]

Current for the E2 stepper (Requires DIGIPOT_I2C)

[D<current>]

Current for the E3 stepper (Requires DIGIPOT_I2C)

[E<current>]

Current for the E0 stepper

[S<current>]

Set this current on all steppers (Requires DIGIPOTSS_PIN or DAC_STEPPER_CURRENT)

[X<current>]

Current for the X stepper (and the Y stepper with MOTOR_CURRENT_PWM_XY)

[Y<current>]

Current for the Y stepper (Use X with MOTOR_CURRENT_PWM_XY)

[Z<current>]

Current for the Z stepper

thinkyhead

M908 - Set Trimpot Pins

control Set a digital trimpot directly DAC_STEPPER_CURRENT|DIGIPOTSS_PIN

Set the digital trimpot current directly by address/channel/pin index. DAC_STEPPER_CURRENT pertains to the MCP4728.


Usage

M908 P<address> S<current>

Argument Description
P<address>

Pin (i.e., Address, Channel)

S<current>

Current value

Notes

Requires DAC_STEPPER_CURRENT or DIGIPOTSS_PIN.

thinkyhead

M909 - DAC Print Values

control Report DAC current values to host DAC_STEPPER_CURRENT

Print the DAC stepper current values in the format “% (Amps)”.


Usage

M909

Notes

Requires DAC_STEPPER_CURRENT.

Examples

M909

thinkyhead

M910 - Commit DAC to EEPROM

control Commit digipot/DAC value to external EEPROM DAC_STEPPER_CURRENT

Commit digipot/DAC value to external EEPROM via I2C.


Usage

M910

Notes

Requires DAC_STEPPER_CURRENT.

thinkyhead

M911 - TMC OT Pre-Warn Condition

control Driver overtemperature pre-warn condition HAVE_TMC2130

Report the TMC stepper driver overtemperature pre-warn condition to the host.


Usage

M911

thinkyhead

M912 - Clear TMC OT Pre-Warn

control Clear overtemperature pre-warn condition flag HAVE_TMC2130

Clear the stepper driver overtemperature pre-warn condition flag.


Usage

M912 [E<-|0-4>] [I<0|1|2>] [X] [Y] [Z]

Argument Description
[E<-|0-4>]

Clear all or one E stepper driver Over Temperature Pre-warn flag.

  • E-:

    All E.

  • E0-4:

    E index.

[I<0|1|2>]

Stepper number to set. If omitted, all specified axes.

  • I0:

    Both.

  • I1:

    Base (X, Y, Z) steppers.

  • I2:

    Second (X2, Y2, Z2) steppers.

[X]

Clear X and/or X2 stepper driver Over Temperature Pre-warn flag.

[Y]

Clear Y and/or Y2 stepper driver Over Temperature Pre-warn flag.

[Z]

Clear Z and/or Z2 stepper driver Over Temperature Pre-warn flag.

Notes

Requires one or more TMC stepper drivers.

Examples

M912     ; clear all
M912 X   ; clear X and X2
M912 X1  ; clear X1 only
M912 X2  ; clear X2 only
M912 X E ; clear X, X2, and all E
M912 E1  ; clear E1 only

mbuc

M913 - Set Hybrid Threshold Speed

control TMC driver switching to spreadCycle HAVE_TMC2130 or HAVE_TMC2208 HYBRID_THRESHOLD

When HYBRID_THRESHOLD is enabled, the TMC driver is switched from the quieter StealthChop to spreadCycle when the feed rate for a given stepper motor is over its _HYBRID_THRESHOLD.


Individual Threshold Values

  • X_HYBRID_THRESHOLD
  • X2_HYBRID_THRESHOLD
  • Y_HYBRID_THRESHOLD
  • Y2_HYBRID_THRESHOLD
  • Z_HYBRID_THRESHOLD
  • Z2_HYBRID_THRESHOLD
  • E0_HYBRID_THRESHOLD
  • E1_HYBRID_THRESHOLD
  • E2_HYBRID_THRESHOLD
  • E3_HYBRID_THRESHOLD
  • E4_HYBRID_THRESHOLD

Usage

M913 [E] [I<index>] [T<index>] [X] [Y] [Z]

Argument Description
[E]

Set E0_HYBRID_THRESHOLD and E1_HYBRID_THRESHOLD and E2_HYBRID_THRESHOLD and E3_HYBRID_THRESHOLD to the provided value.

[I<index>]

(>=1.1.9) Index for dual steppers. Use I1 for X2, Y2, and/or Z2.

[T<index>]

(>=1.1.9) Index (tool) number for the E axis. If not specified, the E0 extruder.

[X]

Set X_HYBRID_THRESHOLD and X2_HYBRID_THRESHOLD to the provided value.

[Y]

Set Y_HYBRID_THRESHOLD and Y2_HYBRID_THRESHOLD to the provided value.

[Z]

Set Z_HYBRID_THRESHOLD and Z2_HYBRID_THRESHOLD to the provided value.

Notes

At least one parameter must be used.

Setting X, Y, Z, or E will set the hybrid threshold for all motors that fall under that category that have the _IS_TRINAMIC flag set. See examples below.

Examples

In this case, assume that X_IS_TRINAMIC and X2_IS_TRINAMIC are both enabled in Configuration_adv.h.

M913 X100

Both X_HYBRID_THRESHOLD and X2_HYBRID_THRESHOLD are set to 100.

In this case, assume that X_IS_TRINAMIC, X2_IS_TRINAMIC, Y_IS_TRINAMIC, E0_IS_TRINAMIC, and E2_IS_TRINAMIC are enabled in Configuration_adv.h.

M913 X100 Y120 E30

X_HYBRID_THRESHOLD and X2_HYBRID_THRESHOLD are set to 100. Y_HYBRID_THRESHOLD is set to 120. E0__HYBRID_THRESHOLD and E2_HYBRID_THRESHOLD are both set to 30. E1_HYBRID_THRESHOLD is not changed since the E0_IS_TRINAMIC flag is not set.

thinkyhead mbuc

M914 - TMC Bump Sensitivity

control Set sensorless homing sensitivity HAVE_TMC2130 SENSORLESS_HOMING

Some TMC stepper drivers can detect when they bump into something that causes them to stop moving. This feature is so sensitive that it can actually take the place of traditional endstops. Use this command to set the bump sensitivity for the X, Y, and Z stepper drivers.


Usage

M914 [I<index>] [X<int>] [Y<int>] [Z<int>]

Argument Description
[I<index>]

(>=1.1.9) Index for dual steppers. Use I1 for X2, Y2, and/or Z2.

[X<int>]

Sensitivity of the X stepper driver. A value from -64 to +63.

[Y<int>]

Sensitivity of the Y stepper driver. A value from -64 to +63.

[Z<int>]

Sensitivity of the Z stepper driver. A value from -64 to +63.

Notes

Set SENSORLESS_HOMING in Configuration_adv.h to enable this feature.

This feature is currently only compatible with the TMC2130.

This works best with the *_HOME_BUMP_MM options set to 0.

Higher values = Lower sensitivity.

thinkyhead

M915 - TMC Z axis calibration

control Align ends of the Z axis and test torque HAVE_TMC2130 TMC_Z_CALIBRATION

The command aims to align the ends of the X gantry (for a Průša i3-style printer). Here’s a video demonstration.

Using the given current, Marlin will move the Z axis (at homing speed) to the top plus a given extra distance. Since this intentionally stalls the Z steppers, you should use the minimum current required to move the axis.

Z is then re-homed to correct the position.


Usage

M915 [S<mA>] [Z<linear>]

Argument Description
[S<mA>]

Current value to use for the raise move. (Default: CALIBRATION_CURRENT)

[Z<linear>]

Extra distance past Z_MAX_POS to move the Z axis. (Default: CALIBRATION_EXTRA_HEIGHT)

Notes

Requires TMC_Z_CALIBRATION and at least one TMC driver for Z axis.

If Z_DUAL_STEPPER_DRIVERS is used, both should be TMC drivers.

Example

Set the current to 300mA and press the steppers against the top for an extra 5mm.

G21 ; Units to mm
M915 S300 Z5

thinkyhead

M928 - Start SD Logging

sdcard Log serial input to an SD file

Use this command to start logging all console and host input to an SD file while still operating the machine.


Usage

M928 filename

Argument Description
filename

File name of log file

Notes

Stop logging with M29.

Examples

Start logging to log.txt

M928 log.txt

thinkyhead

M999 - STOP Restart

control Return the machine to Running state

If a STOP occurs you can use M999 to restart the “stopped” machine after resolving the issue.

Marlin will call STOP if any error occurs that would make continuing the current process problematic. For example, if the probe fails to deploy, it will abort probing and STOP. Note that this disables all heaters.


Usage

M999 S<bool>

Argument Description
S<bool>

Resume without flushing the command buffer. The default behaviour is to flush the serial buffer and request a resend to the host starting on the last N line received.

Examples

Restart the machine

M999