thinkyhead

G0, G1 - Linear Move

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

Description

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.

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.

For Cartesians and Deltas the G0 (rapid linear movement) command is (and must be) a direct alias for G1 (rapid movement). On SCARA machines G0 does a fast non-linear move. Marlin 2.0 introduces an option to maintain a separate default feedrate for G0. Note: Slicers tend to override firmware feedrates!

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 to the planner due to kinematics and bed leveling compensation. Printing performance can be tuned by adjusting segments-per-second.

Developer Notes

  • Developers: Keep using G0 for non-print moves. It makes G-code more adaptable to lasers, engravers, etc.

Usage

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

Parameters

[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

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

Description

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>]

Parameters

[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

Description

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

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.

Usage

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

Parameters

[P<time in ms>]

Amount of time to dwell

[S<time in sec>]

Amount of time to dwell

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

Description

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.

Notes

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

Usage

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

Parameters

[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

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

Description

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

Notes

Requires FWRETRACT.

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

Usage

G10 [S<flag>]

Parameters

[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)

Example

G10 ; retract 

thinkyhead

G11 - Recover

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

Description

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

Notes

Requires FWRETRACT.

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

Usage

G11

Example

G11 ; recover 

MarlinFirmware

G12 - Clean the Nozzle

1.1.0 nozzle Perform the nozzle cleaning procedure. NOZZLE_CLEAN_FEATURE

Description

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 pattern may be repeated as many times as desired.

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.

Usage

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

Parameters

[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

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

Description

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

Description

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

Description

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.

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

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>]

Parameters

[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)

MarlinFirmware

G27 - Park toolhead

1.1.0 nozzle Park the toolhead NOZZLE_PARK_FEATURE

Description

Park the nozzle at a predefined XYZ position.

Notes

Requires NOZZLE_PARK_FEATURE.

The park position is defined by NOZZLE_PARK_POINT.

Usage

G27 [P<0|1|2>]

Parameters

[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

Examples

The most basic example is to use the command without any arguments, which raises Z by the default distance and moves to the parking position.

G27 ; Raise Z if lower 

This one is useful as an end script, simply raising Z and parking.

G27 P2 ; Always raise Z 

thinkyhead

G28 - Auto Home

calibration Auto home one or more axes.

Description

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.

Notes

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

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

G28 disables bed leveling. Follow with M420 S to turn leveling on, or use RESTORE_LEVELING_AFTER_G28 to automatically keep leveling on after G28.

Usage

G28 [O] [R] [X] [Y] [Z]

Parameters

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

Flag to go back to the Z axis origin

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 - Bed Leveling (Automatic)

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

Description

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.

Notes

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

G28 disables bed leveling. Follow with M420 S to turn leveling on, or use RESTORE_LEVELING_AFTER_G28 to automatically keep leveling on after G28.

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>]

Parameters

[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).

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 - Bed Leveling (Manual)

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

Description

Mesh Bed Leveling (MBL) allows interactively measuring a Z height mesh 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.

Mesh Bed Leveling from the host:

  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.

Mesh Bed Leveling using an LCD 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.

Notes

Requires the MESH_BED_LEVELING option in Configuration.h.

Similar to AUTO_BED_LEVELING_BILINEAR with PROBE_MANUALLY but uses less SRAM.

For automatic probe-based leveling enable one of the AUTO_BED_LEVELING_* options instead.

G28 disables bed leveling. Follow with M420 S to turn leveling on, or use RESTORE_LEVELING_AFTER_G28 to automatically keep leveling on after G28.

Usage

G29 [I<index>] [J<index>] S<0|1|2|3|4|5> [X<count>] [Y<count>] [Z<linear>]

Parameters

[I<index>]

(Marlin 2.x) With S3, the (0…n-1) X index of the mesh value to modify.

[J<index>]

(Marlin 2.x) With S3, the (0…n-1) Y index of the mesh value to modify.

S<0|1|2|3|4|5>
  • S0:

    Produce a mesh report (see examples below).

  • S1:

    Start probing mesh points.

  • S2:

    Probe the next mesh point.

  • S3:

    Manually modify a single point with X Y Z parameters. (See also M421.)

  • S4:

    Set a global Z offset. Positive values are away from the bed; negative values are closer.

  • S5:

    Reset and disable mesh.

[X<count>]

(Marlin 1.x) With S3, the (1…n) X count of the mesh value to modify.

[Y<count>]

(Marlin 1.x) With S3, the (1…n) Y count of the mesh value to modify.

[Z<linear>]

With S3, the new mesh Z value.

Examples

S0 mesh report:

> S0
Num X,Y: 3,3
Z offset: 0
Measured points:
       0      1       2
0 +0.011 -0.020  -0.026
1 +0.017 +0.002  -0.019
2 +0.022 -0.030  -0.013
 

(Marlin 1.x) Modify some mesh points and view the new mesh:

> S3 X3 Y3 Z0.042
> S3 X2 Y2 Z-0.666
> S0
Num X,Y: 3,3
Z offset: 0
Measured points:
       0      1       2
0 +0.011 -0.020  -0.026
1 +0.017 -0.666  -0.019
2 +0.022 -0.030  +0.042
 

(Marlin 2.x) Modify some mesh points and view the new mesh:

> S3 I2 J2 Z0.042
> S3 I1 J1 Z-0.666
> S0
3x3 mesh. Z offset: 0
Measured points:
       0      1       2
0 +0.011 -0.020  -0.026
1 +0.017 -0.666  -0.019
2 +0.022 -0.030  +0.042
 

MarlinFirmware

G29 - Bed Leveling (Unified)

calibration Probe the bed and enable leveling compensation. AUTO_BED_LEVELING_UBL

Description

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

Notes

Requires AUTO_BED_LEVELING_UBL.

G28 disables bed leveling. Follow with M420 S to turn leveling on, or use RESTORE_LEVELING_AFTER_G28 to automatically keep leveling on after G28.

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.

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>]

Parameters

[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)

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

Description

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

Usage

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

Parameters

[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

Description

Dock the Z probe sled.

Notes

Requires Z_PROBE_SLED.

Usage

G31

Example

Dock the sled

G31 

thinkyhead

G32 - Undock Sled

1.0.0-beta planner Undock the Z probe sled. Z_PROBE_SLED

Description

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

Description

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<0|1|2|3|4-10>] [T<|>] [V<0|1|2|>]

Parameters

[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<0|1|2|3|4-10>]
  • 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.

[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

Description

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.

Notes

These commands require G38_PROBE_TARGET.

Usage

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

Parameters

[F<rate>]

Feedrate for the move

[X<pos>]

Target X

[Y<pos>]

Target Y

[Z<pos>]

Target Z

ManuelMcLure

G42 - Move to mesh coordinate

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

Description

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>]

Parameters

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

Description

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.

Notes

Absolute positioning is the default.

Usage

G90

thinkyhead

G91 - Relative Positioning

1.0.0-beta units Use relative positions.

Description

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.

Description

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.

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.

Usage

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

Parameters

[E<pos>]

New extruder position

[X<pos>]

New X axis position

[Y<pos>]

New Y axis position

[Z<pos>]

New Z axis position

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 

mteixeira

G425 - Perform auto-calibration

calibration Uses a calibration cube, washer or bolt for automatic calibration CALIBRATION_GCODE

Description

This command performs an automatic calibration of backlash, positional errors, and nozzle offset by touching the nozzle on the sides of a bed-mounted, electrically-conductive object (e.g., a cube, washer or bolt).

This command measures backlash but doesn’t enable backlash correction. Use M425 to enable backlash correction.

Notes

Requires CALIBRATION_GCODE and the following parameters:

  • CALIBRATION_MEASUREMENT_RESOLUTION determines the increments taken in mm when performing measurements
  • CALIBRATION_FEEDRATE_SLOW, CALIBRATION_FEEDRATE_FAST and CALIBRATION_FEEDRATE_TRAVEL determine the speed of motion during the calibration.
  • CALIBRATION_NOZZLE_TIP_HEIGHT and CALIBRATION_NOZZLE_OUTER_DIAMETER refer to the conical part of the nozzle tip
  • CALIBRATION_REPORTING enables G425 V for reporting of measurements
  • CALIBRATION_OBJECT_CENTER and CALIBRATION_OBJECT_DIMENSIONS define the true location and dimensions of a cube/bolt/washer mounted on the bed.
  • CALIBRATION_MEASURE_RIGHT, CALIBRATION_MEASURE_FRONT, CALIBRATION_MEASURE_LEFT and CALIBRATION_MEASURE_BACK define the usable touch points. Comment out any sides which are unreachable by the probe. For best results, all four sides should be reachable.
  • CALIBRATION_PIN, CALIBRATION_PIN_INVERTING, CALIBRATION_PIN_PULLDOWN and CALIBRATION_PIN_PULLUP configure the pin used for calibration. For example, if the nozzle is grounded, the calibation cube would be connected to a digital input pin with a pull-up enabled.

Usage

G425 [B] [T<index>] [U<linear>] [V]

Parameters

[B]

Perform calibration of backlash only.

[T<index>]

Perform calibration of toolhead only.

[U<linear>]

Uncertainty, how far to start probe away from the cube (mm)

[V]

Probe cube and print position, error, backlash and hotend offset. (Requires CALIBRATION_REPORTING)

Examples

Check the positional accuracy before calibration (requires CALIBRATION_REPORTING)

T1                  ; Switch to second nozzle 
G425 V              ; Showing positional report for T1 
T0                  ; Switch to second nozzle 
G425 V              ; Showing positional report for T0 

Performs automatic calibration.

G425                ; Perform full calibration sequence 
M425 F1 S0          ; Enable backlash compensation at 100% 

Check the positional accuracy after calibration (requires CALIBRATION_REPORTING)

T1                  ; Switch to second nozzle 
G425 V              ; Validate by showing report for T1 
T0                  ; Switch to second nozzle 
G425 V              ; Validate by showing report for T0 

thinkyhead

M0, M1 - Unconditional stop

1.0.0-beta planner Stop and wait for user.

Description

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

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.

Usage

M0 [P<ms>] [S<sec>] [string]

Parameters

[P<ms>]

Expire time, in milliseconds

[S<sec>]

Expire time, in seconds

[string]

An optional message to display on the LCD

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

Description

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

Usage

M3 [S<power>]

Parameters

[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

Description

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

Usage

M4 [S<power>]

Parameters

[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

Description

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

Description

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

Description

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>]

Parameters

[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

Description

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.

Notes

Requires SDSUPPORT

Usage

M20

thinkyhead

M21 - Init SD card

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

Description

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

Notes

Requires SDSUPPORT

Usage

M21

thinkyhead

M22 - Release SD card

sdcard Simulate ejection of the SD card SDSUPPORT

Description

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.

Notes

Requires SDSUPPORT

Usage

M22

thinkyhead

M23 - Select SD file

sdcard Select an SD file to be executed SDSUPPORT

Description

Notes

Requires SDSUPPORT

Usage

M23 filename

Parameters

filename

The filename of the file to open.

Examples

Select a file and start it

M23 /musicg~1/shav~1.gco 
M24 

thinkyhead

M24 - Start or Resume SD print

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

Description

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.

Notes

Requires SDSUPPORT

Since Marlin 2.0.0, SD printing can be aborted with M524.

Usage

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

Parameters

[S<pos>]

Position in file to resume from (requires POWER_LOSS_RECOVERY)

[T<time>]

Elapsed time since start of print (requires POWER_LOSS_RECOVERY)

thinkyhead

M25 - Pause SD print

sdcard Pause printing from the SD card SDSUPPORT

Description

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

Notes

Requires SDSUPPORT

Usage

M25

thinkyhead

M26 - Set SD position

sdcard Set the SD read position SDSUPPORT

Description

Set the next read position in the open SD file.

Notes

Requires SDSUPPORT

Usage

M26 [S<pos>]

Parameters

[S<pos>]

Next file read position to set

thinkyhead TheSFReader

M27 - Report SD print status

sdcard Print SD progress to serial SDSUPPORT

Description

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.

Notes

Requires SDSUPPORT

Usage

M27 [C] [S<seconds>]

Parameters

[C]

Report the filename and long filename of the current file.

[S<seconds>]

Interval between auto-reports. S0 to disable.

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

Description

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.

Notes

Requires SDSUPPORT

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

Usage

M28 filename

Parameters

filename

File name to write

Example

Start writing to file.txt

M28 file.txt 

thinkyhead

M29 - Stop SD write

sdcard Stop writing the file, end logging. SDSUPPORT

Description

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

Notes

Requires SDSUPPORT

Usage

M29

thinkyhead

M30 - Delete SD file

sdcard Delete a specified file from SD.

Description

Notes

Requires SDSUPPORT

Usage

M30 filename

Parameters

filename

The filename of the file to delete.

Example

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

M30 /path/to/file.gco 

thinkyhead

M31 - Print time

printjob Report the current print time.

Description

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

Description

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.

Notes

Requires SDSUPPORT

This is a seldom-used beta feature that needs more testing and use-cases.

Usage

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

Parameters

[P<flag>]

Sub-Program flag

[S<filepos>]

Starting file offset

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

Description

Notes

Requires SDSUPPORT and LONG_FILENAME_HOST_SUPPORT

Usage

M33 path

Parameters

path

DOS 8.3 path to a file or folder

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

Description

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.

Notes

Requires SDSUPPORT and SDCARD_SORT_ALPHA.

Usage

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

Parameters

[F<-1|0|1>]

Folder Sorting

  • F-1:

    Folders before files

  • F0:

    No folder sorting

  • F1:

    Folders after files

[S<bool>]

Sorting on/off

thinkyhead

M42 - Set Pin State

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

Description

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>

Parameters

[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 Pins

debug Get information about pins. PINS_DEBUGGING

Description

The M43 T command toggles one or more pins.

Notes

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

See M43 for other pins debug options.

Usage

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

Parameters

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

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

Description

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.

See M43 T for Pins Debugging toggle options.

Notes

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

Usage

M43 [E<bool>] [I] [P<pin>] [S] [T] [W]

Parameters

[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

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

Description

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.

Notes

Requires Z_MIN_PROBE_REPEATABILITY_TEST.

Usage

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

Parameters

[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

MarlinFirmware

M73 - Set Print Progress

1.1.7 lcd Set current print progress percentage for LCD. LCD_SET_PROGRESS_MANUALLY

Description

Set current print progress percentage for LCD.

Usage

M73 P<percent>

Parameters

P<percent>

Current print progress percentage

Examples

Set print progress to 25%

M73 P25 

thinkyhead

M75 - Start Print Job Timer

printjob Start the print job timer.

Description

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.

Description

Pause the print job timer.

Usage

M76

Example

Pause the print job timer

M76 

thinkyhead

M77 - Stop Print Job Timer

printjob Stop the print job timer.

Description

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

Description

Usage

M78

thinkyhead

M80 - Power On

control Turn on the power supply. POWER_SUPPLY>0

Description

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

Notes

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

Usage

M80 [S]

Parameters

[S]

Report Power Supply state

thinkyhead

M81 - Power Off

control Turn off the power supply. POWER_SUPPLY>0

Description

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

Notes

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

Usage

M81

thinkyhead

M82 - E Absolute

units Set E to absolute positioning.

Description

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.

Description

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.

Description

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>

Parameters

S<seconds>

Max inactive seconds

thinkyhead

M92 - Set Axis Steps-per-unit

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

Description

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

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.

Usage

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

Parameters

[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

Example

Set E steps for a new extruder

M92 E688.4 

thinkyhead

M100 - Free Memory

debug Description Here M100_FREE_MEMORY_WATCHER

Description

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.

Notes

Requires M100_FREE_MEMORY_WATCHER.

Usage

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

Parameters

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

thinkyhead

M104 - Set Hotend Temperature

thermal Set a new target hot end temperature.

Description

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.

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.

Usage

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

Parameters

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

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.

Description

Request a temperature report to be sent to the host at some point in the future.

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.

Usage

M105 [T<index>]

Parameters

[T<index>]

Hotend index

Examples

Get a temperature report

M105 

thinkyhead

M106 - Set Fan Speed

thermal Turn on the fan and set its speed EXTRA_FAN_SPEED

Description

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.

Notes

M106 with no speed sets the fan to full speed.

Turn off fans with M107.

Usage

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

Parameters

[P<index>]

Fan index

[S<speed>]

Speed, from 0 to 255. S255 provides 100% duty cycle; S128 produces 50%.

[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.’

Example

Turn on the fan at 200/255 DC

M106 S200 

thinkyhead

M107 - Fan Off

thermal Turn off a fan

Description

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

Notes

Turn on fans with M106.

Usage

M107 [P<index>]

Parameters

[P<index>]

Fan index

thinkyhead

M108 - Break and Continue

control Break out of the current waiting loop

Description

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.

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.

Usage

M108

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.

Description

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.

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.

Usage

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

Parameters

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

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.

Description

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.

Notes

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

Usage

M110 N<line>

Parameters

N<line>

Line number

thinkyhead

M111 - Debug Level

hosts Report and optionally set the debug flags.

Description

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>]

Parameters

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

Description

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.

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.

Usage

M112

Examples

Shut down now!

M112 

thinkyhead

M113 - Host Keepalive

hosts Get or set the host keepalive interval. HOST_KEEPALIVE_FEATURE

Description

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.

Notes

Requires HOST_KEEPALIVE_FEATURE.

Usage

M113 [S<seconds>]

Parameters

[S<seconds>]

Keepalive interval (0-60)

thinkyhead

M114 - Get Current Position

hosts Report the current tool position to the host.

Description

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.

Notes

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

Usage

M114 [D<|>]

Parameters

[D<|>]

Detailed information (requires M114_DETAIL)

Examples

Get the current position

M114 

thinkyhead

M115 - Firmware Info

hosts Print the firmware info and capabilities.

Description

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

Description

Set the status line message on the LCD.

Notes

Requires an LCD controller.

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

Usage

M117 [string]

Parameters

[string]

LCD status message

Examples

Set the message to “Yello World!”

M117 Yello World! 

thinkyhead

M118 - Serial print

hosts Send text to serial

Description

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

Notes

The E and A parameters must precede the message.

Usage

M118 [A1] [E1] [string]

Parameters

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

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.

Description

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.

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.

Usage

M119

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.

Description

Enable endstops.

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.

Usage

M120

Examples

Enable endstops

M120 

thinkyhead

M121 - Disable Endstops

control Disable endstops and keep them enabled when not homing.

Description

Disable endstops.

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.

Usage

M121

Examples

Disable endstops

M121 

mbuc

M122 - TMC Debugging

1.1.7 debug Get TMC Debug Info TMC2130 TMC2208

Description

Do a communication check for configured TMC drivers.

With no parameters, this command returns the current settings for all installed Trinamic TMC2130 and TMC2208 stepper motor drivers. The S[0|1] parameter enables/disables continuous debugging output.

Notes

TMC_DEBUG is no longer needed in Marlin 2.0.x, but enabling it produces an extended report.

Responses of all LOW (00:00:00:00) or all HIGH (FF:FF:FF:FF) are signs of a communication problem.
See TMC Troubleshooting for further information.

Usage

M122 [E] [S] [V] [X] [Y] [Z]

Parameters

[E]

Target E driver(s) only.

[S]

Flag to enable/disable continuous debug reporting.

[V]

Report raw register data. Refer to the datasheet to decypher.

[X]

Target X driver(s) only.

[Y]

Target Y driver(s) only.

[Z]

Target Z driver(s) only.

Examples

Get all TMC2130 and TMC2208 states

> 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

Description

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

Notes

Requires PARK_HEAD_ON_PAUSE.

Usage

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

Parameters

[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)

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

Description

Open the valve for Baricuda paste extruder 1.

Notes

Requires BARICUDA.

Usage

M126 [S<pressure>]

Parameters

[S<pressure>]

Valve pressure

Examples

M126 ; open valve 1 

thinkyhead

M127 - Baricuda 1 Close

baricuda Close the valve for Baricuda 1. BARICUDA

Description

Close the valve for Baricuda paste extruder 1.

Notes

Requires BARICUDA.

Usage

M127

Examples

M127 ; close valve 1 

thinkyhead

M128 - Baricuda 2 Open

baricuda Open the valve for Baricuda 2. BARICUDA

Description

Open the valve for Baricuda paste extruder 2.

Notes

Requires BARICUDA.

Usage

M128 [S<pressure>]

Parameters

[S<pressure>]

Valve pressure

Examples

M128 ; open valve 2 

thinkyhead

M129 - Baricuda 2 Close

baricuda Close the valve for Baricuda 2. BARICUDA

Description

Close the valve for Baricuda paste extruder 2.

Notes

Requires BARICUDA.

Usage

M129

Examples

M129 ; close valve 2 

thinkyhead

M140 - Set Bed Temperature

thermal Set a new target bed temperature.

Description

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>]

Parameters

[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

Description

Set the preheating presets for materials in the LCD menu.

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.

Usage

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

Parameters

[B<temp>]

Bed temperature

[F<speed>]

Fan speed

[H<temp>]

Hotend temperature

[S<index>]

Material index

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.

Description

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

Usage

M149 [C] [F] [K]

Parameters

[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

Description

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.

Notes

Requires BLINKM, RGB_LED, RGBW_LED, NEOPIXEL_LED or PCA9632.

Usage

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

Parameters

[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)

thinkyhead

M155 - Temperature Auto-Report

hosts Auto-report temperatures to host periodically. AUTO_REPORT_TEMPERATURES EXTENDED_CAPABILITIES_REPORT

Description

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.

Notes

Requires AUTO_REPORT_TEMPERATURES in Configuration_adv.h.

Also enable EXTENDED_CAPABILITIES_REPORT to notify hosts about this capability.

Usage

M155 [S<seconds>]

Parameters

[S<seconds>]

Interval in seconds between auto-reports. S0 to disable.

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

Description

Set a single mix factor (in proportion to the sum total of all mix factors). The mix must be committed to a virtual tool by M164 before it takes effect.

Notes

Requires MIXING_EXTRUDER.

Usage

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

Parameters

[P<factor>]

Mix factor

[S<index>]

Component index

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

Description

Notes

Requires MIXING_EXTRUDER and MIXING_VIRTUAL_TOOLS.

Usage

M164 S<index>

Parameters

S<index>

Tool index (active virtual tool if omitted)

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

Description

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

Notes

Requires MIXING_EXTRUDER and DIRECT_MIXING_IN_G1.

Usage

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

Parameters

[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

Examples

Set a colorful mix

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

thinkyhead

M166 - Gradient Mix

2.0.0 mixing Set a Gradient Mix MIXING_EXTRUDER GRADIENT_MIX

Description

Use M166 to set a gradient that will be automatically updated as the Z position changes during a print. The gradient smoothly transitions from one virtual tool to another between the given starting and ending Z heights. Below the starting height the starting virtual tool fully applies, and above the ending height the ending virtual tool fully applies.

Notes

Requires MIXING_EXTRUDER and GRADIENT_MIX.

Usage

M166 A<linear> I<index> J<index> [S<enable>] [T<index>] Z<linear>

Parameters

A<linear>

Starting Z Height. (Use Z to set the Ending Z Height.)

I<index>

Starting Virtual Tool. The Gradient begins with this tool-mix. Below the Starting Z Height the Starting Virtual Tool fully applies.

J<index>

Ending Virtual Tool. The Gradient transitions to this tool-mix as Z approaches the Ending Z Height. Above the Ending Z Height the Ending Virtual Tool fully applies.

[S<enable>]

Enable / disable the gradient in manual mode. When using the tool index alias, tool-change commands determine whether or not the gradient is enabled.

[T<index>]

A tool index to reassign to the gradient. If no index is given, cancel the tool assignment.

Z<linear>

Ending Z Height. (Use A to set the Starting Z Height.)

Examples

Gradient for a tall vase

M166 A0 Z250 I0 J1 S1 

In this example no tool index is assigned to the Gradient. So the Gradient is enabled using M166 S1 and disabled with M166 S0.

Gradient as a Virtual Tool

M166 A0 Z250 I0 J1 T3 
T3 

In this example the Gradient has been given a tool alias of 3. So the Gradient is selected with T3, and all other Tn commands will select a static mix.

To use the static mix stored in T0…

M166 T 
T0 

thinkyhead

M190 - Wait for Bed Temperature

thermal Wait for the bed to reach target temperature.

Description

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.

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.

Usage

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

Parameters

[R<temp>]

Target temperature (wait for cooling or heating).

[S<temp>]

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

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.

Description

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>]

Parameters

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

Description

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

Notes

View the current setting with M503.

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

Usage

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

Parameters

[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

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.

Description

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

Notes

View the current setting with M503.

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

Usage

M203 [E<units/s>] [T<index>] [X<units/s>] [Y<units/s>] [Z<units/s>]

Parameters

[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

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.

Description

Set the preferred starting acceleration for moves of different types.

Notes

View the current setting with M503.

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

Usage

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

Parameters

[P<accel>]

Printing acceleration. Used for moves that include extrusion (i.e., which employ the current tool).

[R<accel>]

Retract acceleration. Used for extruder retraction moves.

[T<accel>]

Travel acceleration. Used for moves that include no extrusion.

thinkyhead

M205 - Set Advanced Settings

planner Set some advanced settings related to movement.

Description

Set various motion settings. See parameters for details.

Notes

View the current setting with M503.

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

Usage

M205 [B<µs>] [E<jerk>] [J<deviation>] [S<units/s>] [T<units/s>] [X<jerk>] [Y<jerk>] [Z<jerk>]

Parameters

[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)

Examples

Set some advanced settings.

M205 T40 ; Travel feedrate = 40mm/s 

thinkyhead

M206 - Set Home Offsets

planner Description Here HAS_HOME_OFFSET

Description

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.

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.

Usage

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

Parameters

[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

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

Description

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

Notes

Requires FWRETRACT.

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

Usage

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

Parameters

[F<feedrate>]

Retract feedrate (units/min)

[S<length>]

Retract length

[W<length>]

Retract swap length (multi-extruder)

[Z<length>]

Z lift on retraction

thinkyhead

M208 - Firmware Recover

planner Firmware-retraction recover settings. FWRETRACT

Description

Use M208 to set the feedrates and additional lengths for firmware-based retract recovery. The lengths set by M208 are applied in addition to the lengths set by M207 when un-retracting (aka “recovering”) the filament. The new values will apply to all subsequent G11 commands.

The “swap” values apply to firmware-based recover moves after a tool-change.

Notes

Requires FWRETRACT.

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

Usage

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

Parameters

[F<feedrate>]

Recover feedrate (units/min)

[R<feedrate>]

Swap recover feedrate (units/min)

[S<length>]

Additional recover length. Can be negative to reduce recover length.

[W<length>]

Additional recover swap length. Can be negative to reduce the length.

Examples

Set recover extra length to 0.2mm and recover feedrate to 10mm/s

M208 S0.2 F600 

Set a retract length of 2mm and total recover length of 2.5mm

M207 S2.0  ; 2.0mm retract 
M208 S0.5  ; 2.0mm + 0.5mm recover 

thinkyhead

M209 - Set Auto Retract

planner Enable / disable auto-retraction. FWRETRACT

Description

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.

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.

Usage

M209 S<flag>

Parameters

S<flag>

Set Auto-Retract on/off

thinkyhead

M211 - Software Endstops

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

Description

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.

Notes

Requires either MIN_SOFTWARE_ENDSTOPS or MAX_SOFTWARE_ENDSTOPS for the enable option.

Usage

M211 [S<flag>]

Parameters

[S<flag>]

Software endstops state

thinkyhead

M217 - Filament swap parameters

2.0.0 calibration Set length and speed for filament swapping EXTRUDERS > 1

Description

When changing tools on some setups, one filament may be retracted before the other is primed. This command sets the length and feedrates used for the filament swap retract and prime.

If no parameters are given this command reports the current filament swap parameters.

Notes

These values are stored in EEPROM.

Usage

M217 [P<feedrate>] [R<feedrate>] [S<linear>] [X<linear>] [Y<linear>] [Z<feedrate>]

Parameters

[P<feedrate>]

Prime feedrate

[R<feedrate>]

Retract feedrate

[S<linear>]

Swap length

[X<linear>]

Park X position. Requires SINGLENOZZLE_SWAP_PARK.

[Y<linear>]

Park Y position. Requires SINGLENOZZLE_SWAP_PARK.

[Z<feedrate>]

Z Raise.

thinkyhead

M218 - Set Hotend Offset

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

Description

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

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.

Usage

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

Parameters

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

thinkyhead

M220 - Set Feedrate Percentage

planner Set the global feedrate percentage.

Description

Set the feedrate percentage, which applies to all G-code-based moves in all (X, Y, Z, and E) axes.

Usage

M220 S<percent>

Parameters

S<percent>

Feedrate percentage

thinkyhead

M221 - Set Flow Percentage

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

Description

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

Usage

M221 S<percent> [T<index>]

Parameters

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.

Description

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

Usage

M226 P<pin> [S<state>]

Parameters

P<pin>

Pin number

[S<state>]

State 0 or 1. Default -1 for inverted.

thinkyhead

M240 - Trigger Camera

extras Trigger a camera shutter PHOTO_GCODE

Description

Trigger a camera shutter using a digital pin or by bumping a physical switch.

Notes

CHDK_PIN or PHOTOGRAPH_PIN is required prior to Marlin 2.0.0.

To use the CHDK_PIN or PHOTOGRAPH_PIN option with a digital camera see this article.

To use an endstop or contact switch as a shutter switch for your smartphone’s camera, see this video.

Usage

M240 [A<offset>] [B<offset>] [D<ms>] [F<feedrate>] [I<pos>] [J<pos>] [P<ms>] [R<length>] [S<feedrate>] [X<pos>] [Y<pos>] [Z<length>]

Parameters

[A<offset>]

Offset to the X return position. (Requires PHOTO_POSITION)

[B<offset>]

Offset to the Y return position. (Requires PHOTO_POSITION)

[D<ms>]

Duration to hold down the shutter switch. (Requires PHOTO_SWITCH_POSITION and PHOTO_SWITCH_MS)

[F<feedrate>]

Feedrate for the main photo moves. If omitted, the homing feedrate will be used. (Requires PHOTO_POSITION)

[I<pos>]

Shutter switch X position. If omitted, the photo move X position applies. (Requires PHOTO_SWITCH_POSITION)

[J<pos>]

Shutter switch Y position. If omitted, the photo move Y position applies. (Requires PHOTO_SWITCH_POSITION)

[P<ms>]

Delay after pressing the shutter switch. (Requires PHOTO_SWITCH_POSITION and PHOTO_SWITCH_MS)

[R<length>]

Retract/recover length. (Requires PHOTO_POSITION)

[S<feedrate>]

Retract/recover feedrate. (Requires PHOTO_POSITION)

[X<pos>]

Main photo move X position. (Requires PHOTO_POSITION)

[Y<pos>]

Main photo move Y position. (Requires PHOTO_POSITION)

[Z<length>]

Main photo move Z raise. (Requires PHOTO_POSITION)

Related Media

thinkyhead

M250 - LCD Contrast

lcd Set and/or get the LCD contrast. HAS_LCD_CONTRAST

Description

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

Notes

Requires an LCD controller with software-controlled contrast.

Usage

M250 [C<contrast>]

Parameters

[C<contrast>]

Contrast value

thinkyhead

M260 - I2C Send

i2c Send data to the I2C bus. EXPERIMENTAL_I2CBUS

Description

Utility to send data over the I2C bus.

Notes

Requires EXPERIMENTAL_I2CBUS.

Usage

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

Parameters

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

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

Description

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.

Notes

Requires EXPERIMENTAL_I2CBUS.

Usage

M261 A<addr> B<count>

Parameters

A<addr>

The bus address to request bytes from

B<count>

The number of bytes to request

thinkyhead

M280 - Servo Position

servos Set or get a servo position. NUM_SERVOS>0

Description

Set or get the position of a servo.

Notes

Requires NUM_SERVOS of 1 or more.

Usage

M280 P<index> S<pos>

Parameters

P<index>

Servo index to set or get

S<pos>

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

thinkyhead

M290 - Babystep

1.1.7 calibration Babystep one or more axes BABYSTEPPING

Description

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.

Notes

Requires BABYSTEP_XY for babystepping on the XY axes.

Usage

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

Parameters

[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

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

Description

Add a tone to the tone queue.

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.

Usage

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

Parameters

[P<ms>]

Duration (1s)

[S<Hz>]

Frequency (260Hz)

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

Description

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

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.

Usage

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

Parameters

[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

thinkyhead

M302 - Cold Extrude

thermal Set minimum extrusion temperature, allow cold extrusion. PREVENT_COLD_EXTRUSION

Description

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

Notes

Requires PREVENT_COLD_EXTRUSION.

Usage

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

Parameters

[P<flag>]

Flag to allow extrusion at any temperature

[S<temp>]

Minimum temperature for safe 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

Description

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

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.

Usage

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

Parameters

C<count>

Cycles. At least 3 cycles are required. 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.)

thinkyhead

M304 - Set Bed PID

thermal Set PID values for the heated bed. PIDTEMPBED

Description

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

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.

Usage

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

Parameters

[D<value>]

Derivative value

[I<value>]

Integral value

[P<value>]

Proportional value

thinkyhead

M350 - Set micro-stepping

control Set micro-stepping for drivers that support it HAS_MICROSTEPS

Description

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>]

Parameters

[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

Description

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>]

Parameters

[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

Description

Set the case light power state and/or brightness.

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.

Usage

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

Parameters

[P<byte>]

Set the brightness factor from 0 to 255.

[S<bool>]

Turn the case light on or off.

Example

Turn the case light on at half brightness

M355 S1 P128 

thinkyhead

M360 - SCARA Theta A

control Move to Theta A MORGAN_SCARA

Description

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

Description

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

Description

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

Description

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

Description

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

Description

Activate the solenoid on the active extruder.

Usage

M380 [S<index>]

Parameters

[S<index>]

Solenoid index (Requires MANUAL_SOLENOID_CONTROL)

Example

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

thinkyhead

M381 - Deactivate Solenoids

none Deactivate all extruder solenoids EXT_SOLENOID

Description

Deactivate all solenoids on all extruders.

Usage

M381 [S<index>]

Parameters

[S<index>]

Solenoid index (Requires MANUAL_SOLENOID_CONTROL)

Examples

M381 ; Deactivate all solenoids 
M381 S1 ; Deactivate solenoid 1 

thinkyhead

M400 - Finish Moves

planner Wait for all moves to finish

Description

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

Description

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

Notes

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

Usage

M401

Examples

Deploy the probe

M401 

thinkyhead

M402 - Stow Probe

calibration Stow the bed probe HAS_BED_PROBE

Description

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

Notes

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

Usage

M402

Examples

Stow the probe

M402 

revilor

M403 - MMU2 Filament Type

control Set filament type for Multi-Material Unit 2.0 PRUSA_MMU2

Description

Set the filament type for a Prusa MMU2 (or compatible) material slot.

Notes

Requires a Prusa Multi-Material Unit v2.0.

Requires PRUSA_MMU2

Usage

M403 E<index> F<0|1|2>

Parameters

E<index>

The MMU2 slot [0..4] to set the material type for

F<0|1|2>

The filament type.

  • F0:

    Default (PLA, PETG, …)

  • F1:

    Flexible filament

  • F2:

    PVA

Examples

Set slot 0 to flexible

M403 E0 F1 

Set slot 3 to PVA

M403 E3 F2 

thinkyhead

M404 - Set Filament Diameter

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

Description

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.

Notes

Requires FILAMENT_WIDTH_SENSOR.

Usage

M404 [W<linear>]

Parameters

[W<linear>]

The new nominal width value

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

Description

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.

Notes

Requires FILAMENT_WIDTH_SENSOR.

Usage

M405 [D<cm>]

Parameters

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

Example

Start measuring filament width, adjusting flow

M405 

thinkyhead

M406 - Filament Width Sensor Off

control Disable filament width sensor flow control FILAMENT_WIDTH_SENSOR

Description

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

Notes

Requires FILAMENT_WIDTH_SENSOR.

Usage

M406

Example

Stop measuring filament width

M406 

thinkyhead

M407 - Filament Width

control Report the measured filament width FILAMENT_WIDTH_SENSOR

Description

Report the current measured filament width to the host.

Notes

Requires FILAMENT_WIDTH_SENSOR.

Usage

M407

Example

Get the current measured filament width

M407 
> Filament dia (measured mm): 1.768 

thinkyhead

M410 - Quickstop

planner Stop all steppers instantly

Description

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

Notes

This command is intended only for emergency situations.

If EMERGENCY_PARSER is not enabled, this will be delayed.

Usage

M410

Example

Stop all steppers now.

M410 

thinkyhead

M412 - Filament Runout

2.0.0 control Enable / disable filament runout detection FILAMENT_RUNOUT_SENSOR

Description

Enable or disable filament runout detection. When filament sensors are enabled, Marlin will respond to a filament runout by running the configured G-code (usually M600 Filament Change). When filament runout detection is disabled, Marlin will take no action for filament runout.

Notes

Requires FILAMENT_RUNOUT_SENSOR.

Usage

M412 [S<bool>]

Parameters

[S<bool>]

Flag to enable or disable Filament Runout Detection. If omitted, the current enabled state will be reported.

Examples

Enable filament runout detection

M412 S1 

Disable filament runout detection

M412 S0 

Report filament runout state

M412
Filament runout ON
 

thinkyhead

M413 - Power-loss Recovery

2.0.0 control Enable / disable power-loss recovery POWER_LOSS_RECOVERY

Description

Enable or disable the Power-loss Recovery feature. When this feature is enabled, the state of the current print job (SD card only) will be saved to a file on the SD card. If the machine crashes or a power outage occurs, the firmware will present an option to Resume the interrupted print job. In Marlin 2.0 the POWER_LOSS_RECOVERY option must be enabled.

This feature operates without a power-loss detection circuit by writing to the recovery file periodically (e.g., once per layer), or if a POWER_LOSS_PIN is configured then it will write the recovery info only when a power-loss is detected. The latter option is preferred, since constant writing to the SD card can shorten its life, and the print will be resumed where it was interrupted rather than repeating the last layer. (Future implementations may allow use of the EEPROM or the on-board SD card.)

Notes

Requires POWER_LOSS_RECOVERY and an LCD controller.

Usage

M413 [S<bool>]

Parameters

[S<bool>]

Flag to enable or disable Power-loss Recovery. If omitted, the current enabled state will be reported.

Examples

Enable power-loss recovery

M413 S1 

Disable power-loss recovery

M413 S0 

Report power-loss recovery state

M413
Power-loss recovery ON
 

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

Description

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.

Notes

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

G28 disables bed leveling. Follow with M420 S to turn leveling on, or use RESTORE_LEVELING_AFTER_G28 to automatically keep leveling on after G28.

Usage

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

Parameters

[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)

thinkyhead

M421 - Set Mesh Value

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

Description

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>]

Parameters

[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 

mteixeira

M425 - Backlash compensation

calibration Enable and tune backlash compensation BACKLASH_COMPENSATION BACKLASH_GCODE

Description

Backlash compensation works by adding extra steps to one or more segments whenever a motor reverses direction.

By default, steps will be added to the first segment after a direction change, this gives the best dimensional accuracy but may cause marks to appear in the print. Smoothing spreads those extra steps multiple consecutive segments to prevent blemishes in the print, at the expense of dimensional accuracy.

Backlash compensation can be configured at both compile-time and run-time. Enable ‘BACKLASH_GCODE’ for run-time configuration, which enables M425 as well as a “Backlash” menu in the LCD.

Backlash can be automatically measured on all axes with G425 or on Z only with G29 when MEASURE_BACKLASH_WHEN_PROBING is enabled.

Notes

Requires BACKLASH_COMPENSATION, BACKLASH_GCODE and the following parameters:

  • BACKLASH_DISTANCE_MM specifies the default backlash on the X, Y and Z axis.
  • BACKLASH_CORRECTION specifies the default backlash correction (0.0 = 0%, 1.0 = 100%)
  • BACKLASH_SMOOTHING_MM enables backlash smoothing over a specified distance.
  • BACKLASH_GCODE enables M425 for run-time tuning of backlash.
  • MEASURE_BACKLASH_WHEN_PROBING turns on Z backlash measurement when probing (G29).
  • Use BACKLASH_MEASUREMENT_LIMIT, BACKLASH_MEASUREMENT_RESOLUTION and BACKLASH_MEASUREMENT_FEEDRATE configure G29 measurement.

Usage

M425 [F<value>] [S<linear>] [X<linear>] [Y<linear>] [Z<linear>] [Z]

Parameters

[F<value>]

Enable or disables backlash correction, or sets an intermediate fade-out (0.0 = none to 1.0 = 100%)

[S<linear>]

Distance over which backlash correction is spread

[X<linear>]

Set the backlash distance on X (mm; 0 to disable)

[Y<linear>]

Set the backlash distance on Y (mm; 0 to disable)

[Z<linear>]

Set the backlash distance on Z (mm; 0 to disable)

[Z]

When MEASURE_BACKLASH_WHEN_PROBING is enabled, copies the measured backlash into the backlash distance.

Examples

Manually configure backlash compensation

M425 X0.1 Y0.2 Z0.3 ; Set backlash to specific values for all axis 
M425 F1             ; Enable backlash compensation at 100% 

Use smoothing for best print surface quality

M425 F1 S3 

Use no smoothing for best dimensional accuracy

M425 F1 S0 

Automatically measure X, Y, and Z backlash using G425

G425                ; Perform a full calibration 
M425 F1             ; Use full measured value of backlash on X, Y and Z 

G425 automatically loads the measured backlash into the backlash distance, but will not enable backlash compensation.

To automatically measure Z backlash when probing with MEASURE_BACKLASH_WHEN_PROBING:

G29                 ; Perform probe and measure backlash on Z 
M425 F1 Z           ; Use full measured value of backlash on Z 

MEASURE_BACKLASH_WHEN_PROBING measures backlash, but does not update the configured backlash distance. The measured value should be activated by using the Z argument without a value. This differs from the behavior of G425.

Report the current backlash configuration

M425 

thinkyhead

M428 - Home Offsets Here

planner Set home offsets based on current position HAS_HOME_OFFSET

Description

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.

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.

Usage

M428

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

Description

Save all configurable settings to EEPROM.

Notes

Requires EEPROM_SETTINGS.

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

Usage

M500

Examples

Save settings

M500 

thinkyhead

M501 - Restore Settings

eeprom Restore settings from EEPROM. EEPROM_SETTINGS

Description

Load all saved settings from EEPROM.

Notes

Requires EEPROM_SETTINGS.

Usage

M501

Examples

Restore all settings.

M501 

thinkyhead

M502 - Factory Reset

eeprom Restore all settings to factory defaults.

Description

Reset all configurable settings to their factory defaults.

To also reset settings in EEPROM, follow with M500.

Notes

This command can be used even if EEPROM_SETTINGS is disabled.

Usage

M502

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.

Description

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

Notes

Does not require EEPROM_SETTINGS.

Usage

M503 [S<flag>]

Parameters

[S<flag>]

Detailed output flag. (true if omitted.)

ManuelMcLure

M504 - Validate EEPROM contents

eeprom Validate the contents of the EEPROM. EEPROM_SETTINGS

Description

Validate the contents of the EEPROM.

Notes

Requires EEPROM_SETTINGS.

Usage

M504

Examples

Validate EEPROM contents.

M504 

thinkyhead

M524 - Abort SD print

2.0.0 sdcard Abort an SD print started with `M24` SDSUPPORT

Description

Abort an SD print in progress and turn off all heaters.

Notes

Requires SDSUPPORT

Usage

M524

Examples

Abort an SD print

M524 

thinkyhead

M540 - Endstops Abort SD

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

Description

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.

Notes

Requires SDSUPPORT and ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED.

Use ENDSTOPS_ALWAYS_ON_DEFAULT or M120 to ensure that endstops are enabled.

Usage

M540 S<flag>

Parameters

S<flag>

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

teemuatlut

M569 - Set TMC stepping mode

2.0.0 none Toggle stealthChop TMC2130 TMC2208

Description

Toggle between stealthChop and spreadCycle on supporting TMC drivers.

Notes

Requires at least one stealthChop capable TMC driver, such as TMC2130 or TMC2208.

Usage

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

Parameters

[E]

Stepping mode for the E0 stepper

[I<index>]

Index for dual steppers. Use I1 for X2, Y2, and/or Z2.

[T<index>]

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

[X]

Stepping mode for the X stepper

[Y]

Stepping mode for the Y stepper

[Z]

Stepping mode for the Z stepper

Examples

Enable stealthChop on Z and E

M569 S1 Z E 

Disable stealthChop (use spreadCycle) on X and Y

M569 S0 X Y 

Enable stealthChop on X2 and E1

M569 S1 I1 X T1 E 

Report driver modes

M569 

clexpert petrzjunior thinkyhead

M600 - Filament Change

1.1.0 filament Automatically change filament ADVANCED_PAUSE_FEATURE

Description

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.

Notes

Requires ADVANCED_PAUSE_FEATURE.

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

Usage

M600 [B<beeps>] [E<pos>] [L<pos>] [T<index>] [U<pos>] [X<pos>] [Y<pos>] [Z<pos>]

Parameters

[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

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

Description

The M603 command configures automatic filament change parameters.

Notes

Requires ADVANCED_PAUSE_FEATURE.

Usage

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

Parameters

[L<pos>]

Load length, longer for bowden (negative)

[T<index>]

Target extruder

[U<pos>]

Amount of retraction for unload (negative)

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

Description

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>]

Parameters

[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

Description

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>]

Parameters

[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

Description

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>]

Parameters

[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

Description

The M666 command allows adjusting the offsets for dual endstops

Usage

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

Parameters

[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

Description

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

Usage

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

Parameters

[X<adj>]

Adjustment for the X actuator endstop

[Y<adj>]

Adjustment for the Y actuator endstop

[Z<adj>]

Adjustment for the Z actuator endstop

revilor

M701 - Load filament

control Load filament NOZZLE_PARK_FEATURE ADVANCED_PAUSE_FEATURE FILAMENT_LOAD_UNLOAD_GCODES

Description

Load filament into the active extruder. By default this will use the configured ADVANCED_PAUSE_FEATURE settings.

Notes

Enabled using FILAMENT_LOAD_UNLOAD_GCODES

Usage

M701 L<distance> [T<extruder>] [Z<distance>]

Parameters

L<distance>

Extrude distance for insertion (positive value) (manual reload)

[T<extruder>]

Optional extruder index. Current extruder if omitted.

[Z<distance>]

Move the Z axis by this distance

Examples

Load filament into the active extruder

M701 

revilor

M702 - Unload filament

control Unload filament NOZZLE_PARK_FEATURE ADVANCED_PAUSE_FEATURE FILAMENT_LOAD_UNLOAD_GCODES

Description

Unload filament. By default this command will use the configured ADVANCED_PAUSE_FEATURE settings.

Notes

Enabled using FILAMENT_LOAD_UNLOAD_GCODES

Usage

M702 [T<extruder>] U<distance> [Z<distance>]

Parameters

[T<extruder>]

Optional extruder number. If omitted, current extruder (or ALL extruders with FILAMENT_UNLOAD_ALL_EXTRUDERS).

U<distance>

Retract distance for removal (manual reload)

[Z<distance>]

Move the Z axis by this distance

Example

Unload filament from current extruder

M702 

thinkyhead

M7219 - MAX7219 Control

debug Control Max7219 Segmented LEDs MAX7219_DEBUG

Description

Set the state of one or more Max7219 matrix displays or 7-segment digital displays.

Notes

Requires MAX7219_DEBUG.

Usage

M7219 [C<column>] [F] [I] [P] [R<row>] [V<bits>] [X<index>] [Y<index>]

Parameters

[C<column>]

Set the column specified by C to bit pattern V.

[F]

Fill the matrix by turning on all LEDs.

[I]

Initialize (clear) all matrixes.

[P]

Print the LED array state for debugging.

[R<row>]

Set the row specified by R to bit pattern V.

[V<bits>]

Value to apply when using the C, R, or X/Y parameters.

[X<index>]

Set a matrix LED at the given X position to the V value. If no V is given, toggle the LED state.

[Y<index>]

Set a matrix LED at the given Y position to the V value. If no V is given, toggle the LED state.

Related Media

thinkyhead

M851 - Z Probe Offset

none Set the Z probe Z offset from nozzle HAS_BED_PROBE

Description

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.

Notes

The default (factory) value is set by Z_PROBE_OFFSET_FROM_EXTRUDER.

Usage

M851 Z<linear>

Parameters

Z<linear>

Z probe Z offset

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.

Description

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

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.

Usage

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

Parameters

[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

thinkyhead

M900 - Linear Advance Factor

control Get and set Linear Advance K value LIN_ADVANCE

Description

Get and/or set the Linear Advance K factor.

Notes

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

Usage

M900 [K<kfactor>] [L<kfactor>] [S<slot>] [T<index>]

Parameters

[K<kfactor>]

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

With EXTRA_LIN_ADVANCE_K this sets the primary K factor. Note that this factor may be inactive and won’t take effect until the next M900 S0.

[L<kfactor>]

Set the second K factor for the specified extruder. Requires EXTRA_LIN_ADVANCE_K. Note that this factor may be inactive and won’t take effect until the next M900 S1.

[S<slot>]

Select slot and -if changing slots- sideline the current value and reinstate the last-set or last-sidelined value.

[T<index>]

Extruder to which K, L, and S will apply.

Examples

Fetch the K factor

M900 

Set the K factor

M900 K0.18 

(EXTRA_LIN_ADVANCE_K) Set second K factor for T2, then activate it.

M900 T2 L0.9 
M900 T2 S1 

thinkyhead

M906 - TMC Motor Current

none Set the motor current (in milliamps) TMC2130 TMC2208 TMC2660

Description

Set the current for a stepper motor in milliamps units.

Notes

Requires one or more TMC stepper drivers.

Usage

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

Parameters

[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

Description

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>]

Parameters

[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

Description

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

Notes

Requires DAC_STEPPER_CURRENT or DIGIPOTSS_PIN.

Usage

M908 P<address> S<current>

Parameters

P<address>

Pin (i.e., Address, Channel)

S<current>

Current value

thinkyhead

M909 - DAC Print Values

control Report DAC current values to host DAC_STEPPER_CURRENT

Description

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

Notes

Requires DAC_STEPPER_CURRENT.

Usage

M909

Examples

M909 

thinkyhead

M910 - Commit DAC to EEPROM

control Commit digipot/DAC value to external EEPROM DAC_STEPPER_CURRENT

Description

Commit digipot/DAC value to external EEPROM via I2C.

Notes

Requires DAC_STEPPER_CURRENT.

Usage

M910

thinkyhead

M911 - TMC OT Pre-Warn Condition

control Driver overtemperature pre-warn condition TMC2130 TMC2208 TMC2660 MONITOR_DRIVER_STATUS

Description

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

Notes

Requires one or more TMC stepper drivers.

Usage

M911

thinkyhead

M912 - Clear TMC OT Pre-Warn

control Clear overtemperature pre-warn condition flag TMC2130 TMC2208 TMC2660 MONITOR_DRIVER_STATUS

Description

Clear the stepper driver overtemperature pre-warn condition flag.

Notes

Requires one or more TMC stepper drivers.

Usage

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

Parameters

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

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

Description

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

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.

Usage

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

Parameters

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

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 TMC2130 SENSORLESS_HOMING

Description

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.

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.

Usage

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

Parameters

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

thinkyhead

M915 - TMC Z axis calibration

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

Description

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.

Notes

This command is deprecated. Use Z_STEPPER_AUTO_ALIGN instead.

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.

Usage

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

Parameters

[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)

Example

Set a 300mA current and press the gantry against the top for 5 extra mm.

G21 ; Units to mm 
M915 S300 Z5 

thinkyhead

M928 - Start SD Logging

sdcard Log serial input to an SD file

Description

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

Notes

Stop logging with M29.

Usage

M928 filename

Parameters

filename

File name of log file

Examples

Start logging to log.txt

M928 log.txt 

thinkyhead

M999 - STOP Restart

control Return the machine to Running state

Description

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>

Parameters

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