Copy-paste from doxygen documentation "/Firmware/doc/html/group__GCodes.html" (JIRA manages to retain formatting to some extent):

The description is only for Prusa Research specific G Codes. The rest can be found on http://marlinfw.org/meta/gcode/


-----------------------------------------------------------------------------------------------------------------------------------------------------------------------

G-Code List

This is a list of currently implemented G Codes in Prusa firmware (dynamically generated from doxygen).

They are shown in order of appearance in the code. There are reasons why some G Codes aren't in numerical order.

Special internal commands

These are used by internal functions to process certain actions in the right order. Some of these are also usable by the user. They are processed early as the commands are complex (strings). These are only available on the MK3(S) as these require TMC2130 drivers:

  • CRASH DETECTED
  • CRASH RECOVER
  • CRASH_CANCEL
  • TMC_SET_WAVE
  • TMC_SET_STEP
  • TMC_SET_CHOP

PRUSA - Internal command set G98: Activate farm mode - Notes

Set of internal PRUSA commands

Usage

PRUSA [ PRN | FAN | thx | uvlo | MMURES | RESET | fv | M28 | SN | Fir | Rev | Lang | Lz | FR ]

Parameters

  • PRN - Prints revision of the printer
  • FAN - Prints fan details
  • thx
  • uvlo
  • MMURES - Reset MMU
  • RESET - (Careful!)
  • fv - ?
  • M28
  • SN
  • Fir - Prints firmware version
  • Rev- Prints filament size, elelectronics, nozzle type
  • Lang - Reset the language
  • Lz
  • FR - Full factory reset
  • nozzle set <diameter> - set nozzle diameter (farm mode only), e.g. PRUSA nozzle set 0.4
  • nozzle D<diameter> - check the nozzle diameter (farm mode only), works like M862.1 P, e.g. PRUSA nozzle D0.4
  • nozzle - prints nozzle diameter (farm mode only), works like M862.1 P, e.g. PRUSA nozzle

G Codes

G0, G1 - Coordinated movement X Y Z E G0 & G1: Move

In Prusa Firmware G0 and G1 are the same.

Usage

  G0 [ X | Y | Z | E | F | S ]
  G1 [ X | Y | Z | E | F | S ]

Parameters

  • X - The position to move to on the X axis
  • Y - The position to move to on the Y axis
  • Z - The position to move to on the Z axis
  • E - The amount to extrude between the starting point and ending point
  • F - The feedrate per minute of the move between the starting point and ending point (if supplied)

G2, G3 - Controlled Arc Move G2 & G3: Controlled Arc Move

These commands don't propperly work with MBL enabled. The compensation only happens at the end of the move, so avoid long arcs.

Usage

  G2 [ X | Y | I | E | F ] (Clockwise Arc)
  G3 [ X | Y | I | E | F ] (Counter-Clockwise Arc)

Parameters

  • X - The position to move to on the X axis
  • Y - The position to move to on the Y axis
  • 'Z' - The position to move to on the Z axis
  • I - The point in X space from the current X position to maintain a constant distance from
  • J - The point in Y space from the current Y position to maintain a constant distance from
  • E - The amount to extrude between the starting point and ending point
  • F - The feedrate per minute of the move between the starting point and ending point (if supplied)

G4 - Dwell G4: Dwell

Pause the machine for a period of time.

Usage

G4 [ P | S ]

Parameters

  • P - Time to wait, in milliseconds
  • S - Time to wait, in seconds

G10 - Retract G10: Retract

Retracts filament according to settings of M207

G11 - Retract recover G11: Unretract

Unretracts/recovers filament according to settings of M208

G21 - Sets Units to Millimters G21: Set Units to Millimeters

Units are in millimeters. Prusa doesn't support inches.

G28 - Home all Axes one at a time G28: Move to Origin (Home)

Using G28 without any parameters will perfom homing of all axes AND mesh bed leveling, while G28 W will just home all axes (no mesh bed leveling).

Usage

 G28 [ X | Y | Z | W | C ]

Parameters

  • 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
  • W - Suppress mesh bed leveling if X, Y or Z are not provided
  • C - Calibrate X and Y origin (home) - Only on MK3/s

G29 - Detailed Z-Probe G29: Detailed Z-Probe

In Prusa Firmware this G-code is deactivated by default, must be turned on in the source code.

See G81

G30 - Single Z Probe G30: Single Z-Probe

In Prusa Firmware this G-code is deactivated by default, must be turned on in the source code.

G31 - Dock the sled G31: Dock Z Probe sled

In Prusa Firmware this G-code is deactivated by default, must be turned on in the source code.

G32 - Undock the sled G32: Undock Z Probe sled

In Prusa Firmware this G-code is deactivated by default, must be turned on in the source code.

G30 - Single Z Probe G30: Single Z-Probe

Sensor must be over the bed. The maximum travel distance before an error is triggered is 10mm.

G75 - Print temperature interpolation G75: Print temperature interpolation

Show/print PINDA temperature interpolating.

G76 - PINDA probe temperature calibration G76: PINDA probe temperature calibration

This G-code is used to calibrate the temperature drift of the PINDA (inductive Sensor).

The PINDAv2 sensor has a built-in thermistor which has the advantage that the calibration can be done once for all materials.

The Original i3 Prusa MK2/s uses PINDAv1 and this calibration improves the temperature drift, but not as good as the PINDAv2.

superPINDA sensor has internal temperature compensation and no thermistor output. There is no point of doing temperature calibration in such case. If PINDA_THERMISTOR and SUPERPINDA_SUPPORT is defined during compilation, calibration is skipped with serial message "No PINDA thermistor". This can be caused also if PINDA thermistor connection is broken or PINDA temperature is lower than PINDA_MINTEMP.

Example


G76

echo PINDA probe calibration start
echo start temperature: 35.0°
echo ...
echo PINDA temperature -- Z shift (mm): 0.---

G80 - Mesh-based Z probe G80: Mesh-based Z probe

Default 3x3 grid can be changed on MK2.5/s and MK3/s to 7x7 grid.

Usage

  G80 [ N | R | V | L | R | F | B ]

Parameters

  • N - Number of mesh points on x axis. Default is 3. Valid values are 3 and 7.
  • R - Probe retries. Default 3 max. 10
  • V - Verbosity level 1=low, 10=mid, 20=high. It only can be used if the firmware has been compiled with SUPPORT_VERBOSITY active.

Using the following parameters enables additional "manual" bed leveling correction. Valid values are -100 microns to 100 microns.

Additional Parameters

  • L - Left Bed Level correct value in um.
  • R - Right Bed Level correct value in um.
  • F - Front Bed Level correct value in um.
  • B - Back Bed Level correct value in um.

G81 - Mesh bed leveling status G81: Mesh bed leveling status

Prints mesh bed leveling status and bed profile if activated.

G82: Single Z probe at current location - Not active G82: Single Z probe at current location

WARNING! USE WITH CAUTION! If you'll try to probe where is no leveling pad, nasty things can happen! In Prusa Firmware this G-code is deactivated by default, must be turned on in the source code.

G83: Babystep in Z and store to EEPROM - Not active G83: Babystep in Z and store to EEPROM

In Prusa Firmware this G-code is deactivated by default, must be turned on in the source code.

G84: UNDO Babystep Z (move Z axis back) - Not active G84: UNDO Babystep Z (move Z axis back)

In Prusa Firmware this G-code is deactivated by default, must be turned on in the source code.

G85: Pick best babystep - Not active G85: Pick best babystep

In Prusa Firmware this G-code is deactivated by default, must be turned on in the source code.

G86 - Disable babystep correction after home G86: Disable babystep correction after home

This G-code will be performed at the start of a calibration script. (Prusa3D specific)

G87 - Enable babystep correction after home G87: Enable babystep correction after home

This G-code will be performed at the end of a calibration script. (Prusa3D specific)

G88 - Reserved G88: Reserved

Currently has no effect.

G90 - Switch off relative mode G90: Set to Absolute Positioning

All coordinates from now on are absolute relative to the origin of the machine. E axis is left intact.

G91 - Switch on relative mode G91: Set to Relative Positioning

All coordinates from now on are relative to the last position. E axis is left intact.

G92 - Set position G92: Set Position

It is used for setting the current position of each axis. The parameters are always absolute to the origin. If a parameter is omitted, that axis will not be affected. If X, Y, or Z axis are specified, the move afterwards might stutter because of Mesh Bed Leveling. E axis is not affected if the target position is 0 (G92 E0). A G92 without coordinates will reset all axes to zero on some firmware. This is not the case for Prusa-Firmware!

Usage

  G92 [ X | Y | Z | E ]

Parameters

  • X - new X axis position
  • Y - new Y axis position
  • Z - new Z axis position
  • E - new extruder position

G98 - Activate farm mode G98: Activate farm mode

Enable Prusa-specific Farm functions and g-code. See Internal Prusa commands.

G99 - Deactivate farm mode G99: Deactivate farm mode

Disables Prusa-specific Farm functions and g-code.

End of G-Codes


M Commands

M0, M1 - Stop the printer M0: Stop or Unconditional stop

Usage

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

Parameters

  • P<ms> - Expire time, in milliseconds
  • S<sec> - Expire time, in seconds
  • string - Must for M1 and optional for M0 message to display on the LCD

M17 - Enable all axes M17: Enable/Power all stepper motors

M20 - SD Card file list M20: List SD card

Usage

M20 [ L | T ]

Parameters

  • T - Report timestamps as well. The value is one uint32_t encoded as hex. Requires host software parsing (Cap:EXTENDED_M20).
  • L - Reports long filenames instead of just short filenames. Requires host software parsing (Cap:EXTENDED_M20).

M21 - Init SD card M21: Initialize SD card

M22 - Release SD card M22: Release SD card

M23 - Select file M23: Select SD file

Usage

M23 [filename]

M24 - Start SD print M24: Start/resume SD print

M26 - Set SD index M26: Set SD position

Set position in SD card file to index in bytes. This command is expected to be called after M23 and before M24. Otherwise effect of this command is undefined.

Usage

  M26 [ S ]

Parameters

  • S - Index in bytes

M27 - Get SD status M27: Report SD print status

Usage

  M27 [ P ]

Parameters

  • P - Show full SFN path instead of LFN only.

M28 - Start SD write M28: Begin write to SD card

M29 - Stop SD write M29: Stop writing to SD card

Stops writing to the SD file signaling the end of the uploaded file. It is processed very early and it's not written to the card.

M30 - Delete file M30: Delete a file on the SD card

Usage

M30 [filename]

M32 - Select file and start SD print M32: Select file and start SD print

Todo:What are the parameters P and S for in M32?

M928 - Start SD logging M928: Start SD logging

Usage

M928 [filename]

M31 - Report current print time M31: Output time since last M109 or SD card start to serial

M42 - Set pin state M42: Switch I/O pin

Usage

M42 [ P | S ]

Parameters

  • P - Pin number.
  • S - Pin value. If the pin is analog, values are from 0 to 255. If the pin is digital, values are from 0 to 1.

M44 - Reset the bed skew and offset calibration M44: Reset the bed skew and offset calibration

M45 - Bed skew and offset with manual Z up M45: Bed skew and offset with manual Z up

Usage

M45 [ V ]

Parameters

  • V - Verbosity level 1, 10 and 20 (low, mid, high). Only when SUPPORT_VERBOSITY is defined. Optional.
  • Z - If it is provided, only Z calibration will run. Otherwise full calibration is executed.

M46 - Show the assigned IP address M46: Show the assigned IP address.

M47 - Show end stops dialog on the display M47: Show end stops dialog on the display

M48 - Z-Probe repeatability measurement function M48: Measure Z-Probe repeatability

This function assumes the bed has been homed. Specifically, that a G28 command as been issued prior to invoking the M48 Z-Probe repeatability measurement function. Any information generated by a prior G29 Bed leveling command will be lost and needs to be regenerated.

The number of samples will default to 10 if not specified. You can use upper or lower case letters for any of the options EXCEPT n. n must be in lower case because Marlin uses a capital N for its communication protocol and will get horribly confused if you send it a capital N.

Todo:Why would you check for both uppercase and lowercase? Seems wasteful.

Usage

M48 [ n | X | Y | V | L ]

Parameters

  • n - Number of samples. Valid values 4-50
  • X - X position for samples
  • Y - Y position for samples
  • V - Verbose level. Valid values 1-4
  • L - Legs of movementprior to doing probe. Valid values 1-15

M73 - Set/get print progress M73: Set/Get build percentage

Usage

M73 [ P | R | Q | S | C | D ]

Parameters

  • P - Percent in normal mode
  • R - Time remaining in normal mode
  • Q - Percent in silent mode
  • S - Time in silent mode
  • C - Time to change/pause/user interaction in normal mode
  • D - Time to change/pause/user interaction in silent mode

M104 - Set hotend temperature M104: Set Extruder Temperature

Usage

M104 [ S ]

Parameters

  • S - Target temperature

M112 - Emergency stop M112: Full (Emergency) Stop

It is processed much earlier as to bypass the cmdqueue.

M140 - Set bed temperature M140: Set Bed Temperature (Fast)

Usage

M140 [ S ]

Parameters

  • S - Target temperature

M105 - Report temperatures M105: Get Extruder Temperature

Prints temperatures:

  • T: - Hotend (actual / target)
  • B: - Bed (actual / target)
  • Tx: - x Tool (actual / target)
  • @: - Hotend power
  • B@: - Bed power
  • P: - PINDAv2 actual (only MK2.5/s and MK3/s)
  • A: - Ambient actual (only MK3/s)

Example:

ok T:20.2 /0.0 B:19.1 /0.0 T0:20.2 /0.0 @:0 B@:0 P:19.8 A:26.4

M155 - Automatically send status M155: Automatically send temperatures

Usage

M155 [ S ] [ C ]

Parameters

  • S - Set autoreporting interval in seconds. 0 to disable. Maximum: 255
  • C - Activate auto-report function (bit mask). Default is temperature.
    bit 0 = Auto-report temperatures
    bit 1 = Auto-report fans
    bit 2 = Auto-report position
    bit 3 = free
    bit 4 = free
    bit 5 = free
    bit 6 = free
    bit 7 = free
    

M109 - Wait for extruder temperature M109: Set Extruder Temperature and Wait

Usage

M104 [ B | R | S ]

Parameters (not mandatory)

  • S - Set extruder temperature
  • R - Set extruder temperature
  • B - Set max. extruder temperature, while S is min. temperature. Not active in default, only if AUTOTEMP is defined in source code.

Parameters S and R are treated identically. Command always waits for both cool down and heat up. If no parameters are supplied waits for previously set extruder temperature.

M190 - Wait for bed temperature M190: Wait for bed temperature to reach target temp

Usage

M190 [ R | S ]

Parameters (not mandatory)

  • S - Set extruder temperature and wait for heating
  • R - Set extruder temperature and wait for heating or cooling

If no parameter is supplied, waits for heating or cooling to previously set temperature.

M106 - Set fan speed M106: Fan On

Usage

M106 [ S ]

Parameters

  • S - Specifies the duty cycle of the print fan. Allowed values are 0-255. If it's omitted, a value of 255 is used.

M107 - Fan off M107: Fan Off

M80 - Turn on the Power Supply M80: ATX Power On

Only works if the firmware is compiled with PS_ON_PIN defined.

M81 - Turn off Power Supply M81: ATX Power Off

Only works if the firmware is compiled with PS_ON_PIN defined.

M82 - Set E axis to absolute mode M82: Set extruder to absolute mode

Makes the extruder interpret extrusion as absolute positions.

M83 - Set E axis to relative mode M83: Set extruder to relative mode

Makes the extruder interpret extrusion values as relative positions.

M84 - Disable steppers M84: Stop idle hold

This command can be used to set the stepper inactivity timeout (S) or to disable steppers (X,Y,Z,E) This command can be used without any additional parameters. In that case all steppers are disabled.

The file completeness check uses this parameter to detect an incomplete file. It has to be present at the end of a file with no parameters.

M84 [ S | X | Y | Z | E ]
  • S - Seconds
  • X - X axis
  • Y - Y axis
  • Z - Z axis
  • E - Extruder

M18 - Disable steppers M18: Disable all stepper motors

Equal to M84 (compatibility)

M85 - Set max inactive time M85: Set Inactivity Shutdown Timer

Usage

M85 [ S ]

Parameters

  • S - specifies the time in seconds. If a value of 0 is specified, the timer is disabled.

M86 - Set safety timer expiration time M86: Set Safety Timer expiration time

When safety timer expires, heatbed and nozzle target temperatures are set to zero.

Usage

M86 [ S ]

Parameters

  • S - specifies the time in seconds. If a value of 0 is specified, the timer is disabled.

M92 Set Axis steps-per-unit M92: Set axis_steps_per_unit

Allows programming of steps per unit (usually mm) for motor drives. These values are reset to firmware defaults on power on, unless saved to EEPROM if available (M500 in Marlin)

Usage

M92 [ X | Y | Z | E ]

Parameters

  • X - Steps per mm for the X drive
  • Y - Steps per mm for the Y drive
  • Z - Steps per mm for the Z drive
  • E - Steps per mm for the extruder drive

M110 - Set Line number M110: Set Current Line Number

Sets the line number in G-code

Usage

M110 [ N ]

Parameters

  • N - Line number

M113 - Get or set host keep-alive interval M113: Host Keepalive

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 (or disconnect).

Usage

M113 [ S ]

Parameters

  • S - Seconds. Default is 2 seconds between "busy" messages

M115 - Firmware info M115: Get Firmware Version and Capabilities

Print the firmware info and capabilities Without any arguments, prints Prusa firmware version number, machine type, extruder count and UUID. M115 U Checks the firmware version provided. If the firmware version provided by the U code is higher than the currently running firmware, it will pause the print for 30s and ask the user to upgrade the firmware.

Examples:

M115 results:

FIRMWARE_NAME:Prusa-Firmware 3.8.1 based on Marlin FIRMWARE_URL:https://github.com/prusa3d/Prusa-Firmware PROTOCOL_VERSION:1.0 MACHINE_TYPE:Prusa i3 MK3S EXTRUDER_COUNT:1 UUID:00000000-0000-0000-0000-000000000000

M115 V results:

3.8.1

M115 U3.8.2-RC1 results on LCD display for 30s or user interaction:

New firmware version available: 3.8.2-RC1 Please upgrade.

Usage

M115 [ V | U ]

Parameters

  • V - Report current installed firmware version
  • U - Firmware version provided by G-code to be compared to current one.

M114 - Get current position M114: Get Current Position

M117 - Display Message M117: Display Message

M118 - Serial print M118: Serial print

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.

M120 - Enable endstops M120: Enable endstop detection

M121 - Disable endstops M121: Disable endstop detection

M119 - Get endstop states M119: Get Endstop Status

Returns the current state of the configured X, Y, Z endstops. Takes into account any 'inverted endstop' settings, so one can confirm that the machine is interpreting the endstops correctly.

Todo:update for all axes, use for loop

M123 - Tachometer value M123: Tachometer value

This command is used to report fan speeds and fan pwm values.

Usage

  M123
  • E0: - Hotend fan speed in RPM
  • PRN1: - Part cooling fans speed in RPM
  • E0@: - Hotend fan PWM value
  • PRN1@: -Part cooling fan PWM value

Example:

E0:3240 RPM PRN1:4560 RPM E0@:255 PRN1@:255

M150 - Set RGB(W) Color M150: Set LED color

In Prusa Firmware this G-code is deactivated by default, must be turned on in the source code by defining BLINKM and its dependencies.

Usage

M150 [ R | U | B ]

Parameters

  • R - Red color value
  • U - Green color value. It is NOT G!
  • B - Blue color value

M200 - Set filament diameter M200: Set filament diameter

Usage

M200 [ D | T ]

Parameters

  • D - Diameter in mm
  • T - Number of extruder (MMUs)

M201 - Set Print Max Acceleration M201: Set max printing acceleration

For each axis individually.

Usage

M201 [ X | Y | Z | E ]

Parameters
  • X - Acceleration for X axis in units/s^2
  • Y - Acceleration for Y axis in units/s^2
  • Z - Acceleration for Z axis in units/s^2
  • E - Acceleration for the active or specified extruder in units/s^2

M203 - Set Max Feedrate M203: Set maximum feedrate

For each axis individually.

Usage

M203 [ X | Y | Z | E ]

Parameters
  • X - Maximum feedrate for X axis
  • Y - Maximum feedrate for Y axis
  • Z - Maximum feedrate for Z axis
  • E - Maximum feedrate for extruder drives

M204 - Acceleration settings M204: Set default acceleration

Old format:

Usage
M204 [ S | T ]
Parameters
  • S - normal moves
  • T - filmanent only moves

New format:

Usage
M204 [ P | R | T ]
Parameters
  • P - printing moves
  • R - filmanent only moves
  • T - travel moves (as of now T is ignored)

M205 - Set advanced settings M205: Advanced settings

Set some advanced settings related to movement.

Usage

M205 [ S | T | B | X | Y | Z | E ]

Parameters

  • S - Minimum feedrate for print moves (unit/s)
  • T - Minimum feedrate for travel moves (units/s)
  • B - Minimum segment time (us)
  • X - Maximum X jerk (units/s)
  • Y - Maximum Y jerk (units/s)
  • Z - Maximum Z jerk (units/s)
  • E - Maximum E jerk (units/s)

M206 - Set additional homing offsets M206: Offset axes

Usage

M206 [ X | Y | Z ]

Parameters

  • X - X axis offset
  • Y - Y axis offset
  • Z - Z axis offset

M207 - Set firmware retraction M207: Set retract length

Usage

M207 [ S | F | Z ]

Parameters

  • S - positive length to retract, in mm
  • F - retraction feedrate, in mm/min
  • Z - additional zlift/hop

M208 - Set retract recover length M208: Set unretract length

Usage

M208 [ S | F ]

Parameters

  • S - positive length surplus to the M207 Snnn, in mm
  • F - feedrate, in mm/sec

M209 - Enable/disable automatict retract M209: Enable automatic retract

This boolean value S 1=true or 0=false enables automatic retract detect if the slicer did not support G10/G11: every normal extrude-only move will be classified as retract depending on the direction.

Usage

M209 [ S ]

Parameters

  • S - 1=true or 0=false

M214 - Set Arc configuration values (Use M500 to store in eeprom) M214: Set Arc configuration values

Usage

M214 [P] [S] [N] [R] [F]

Parameters

  • P - A float representing the max and default millimeters per arc segment. Must be greater than 0.
  • S - A float representing the minimum allowable millimeters per arc segment. Set to 0 to disable
  • N - An int representing the number of arcs to draw before correcting the small angle approximation. Set to 0 to disable.
  • R - An int representing the minimum number of segments per arcs of any radius, except when the results in segment lengths greater than or less than the minimum and maximum segment length. Set to 0 to disable.
  • F - An int representing the number of segments per second, unless this results in segment lengths greater than or less than the minimum and maximum segment length. Set to 0 to disable.


M214 - Set Arc Parameters (Use M500 to store in eeprom) P<MM_PER_ARC_SEGMENT> S<MIN_MM_PER_ARC_SEGMENT> R<MIN_ARC_SEGMENTS> F<ARC_SEGMENTS_PER_SEC>

M220 Set feedrate percentage M220: Set speed factor override percentage

Usage

M220 [ B | S | R ]

Parameters

  • B - Backup current speed factor
  • S - Speed factor override percentage (0..100 or higher)
  • R - Restore previous speed factor

M221 - Set extrude factor override percentage M221: Set extrude factor override percentage

Usage

M221 [ S ]

Parameters

  • S - Extrude factor override percentage (0..100 or higher), default 100%

M226 - Wait for Pin state M226: Wait for pin state

Wait until the specified pin reaches the state required

Usage

M226 [ P | S ]

Parameters

  • P - pin number
  • S - pin state

M280 - Set/Get servo position M280: Set servo position

In Prusa Firmware this G-code is deactivated by default, must be turned on in the source code.

Usage

M280 [ P | S ]

Parameters

  • P - Servo index (id)
  • S - Target position

M300 - Play tone M300: Play beep sound

In Prusa Firmware the defaults are 100Hz and 1000ms, so that M300 without parameters will beep for a second.

Usage

M300 [ S | P ]

Parameters

  • S - frequency in Hz. Not all firmware versions support this parameter
  • P - duration in milliseconds

M301 - Set hotend PID M301: Set PID parameters

Sets Proportional (P), Integral (I) and Derivative (D) values for hot end. See also PID Tuning.

Usage

M301 [ P | I | D ]

Parameters

  • P - proportional (Kp)
  • I - integral (Ki)
  • D - derivative (Kd)

M304 - Set bed PID M304: Set PID parameters - Bed

Sets Proportional (P), Integral (I) and Derivative (D) values for bed. See also PID Tuning.

Usage

M304 [ P | I | D ]

Parameters

  • P - proportional (Kp)
  • I - integral (Ki)
  • D - derivative (Kd)

M240 - Trigger camera M240: Trigger camera

In Prusa Firmware this G-code is deactivated by default, must be turned on in the source code.

You need to (re)define and assign CHDK or PHOTOGRAPH_PIN the correct pin number to be able to use the feature.

M302 - Allow cold extrude, or set minimum extrude temperature M302: Allow cold extrudes

This tells the printer to allow movement of the extruder motor above a certain temperature, or if disabled, to allow extruder movement when the hotend is below a safe printing temperature.

Usage

M302 [ S ]

Parameters

  • S - Cold extrude minimum temperature

M303 - PID autotune M303: Run PID tuning

PID Tuning refers to a control algorithm used in some repraps to tune heating behavior for hot ends and heated beds. This command generates Proportional (Kp), Integral (Ki), and Derivative (Kd) values for the hotend or bed. Send the appropriate code and wait for the output to update the firmware values.

Usage

M303 [ E | S | C ]

Parameters

  • E - Extruder, default E0. Use E-1 to calibrate the bed PID
  • S - Target temperature, default 210°C for hotend, 70 for bed
  • C - Cycles, default 5

M310 - Thermal model settings M310: Thermal model settings

Usage

M310                                           ; report values
M310 [ A ] [ F ]                               ; autotune
M310 [ S ]                                     ; set 0=disable 1=enable
M310 [ I ] [ R ]                               ; set resistance at index
M310 [ P | U | V | C ]                         ; set power, temperature coefficient, intercept, capacitance
M310 [ D | L ]                                 ; set simulation filter, lag
M310 [ B | E | W ]                             ; set beeper, warning and error threshold
M310 [ T ]                                     ; set ambient temperature correction

Parameters

  • I - resistance index position (0-15)
  • R - resistance value at index (K/W; requires I)
  • P - power (W)
  • U - linear temperature coefficient (W/K/power)
  • V - linear temperature intercept (W/power)
  • C - capacitance (J/K)
  • D - sim. 1st order IIR filter factor (f=100/27)
  • L - sim. response lag (ms, 0-2160)
  • S - set 0=disable 1=enable
  • B - beep and warn when reaching warning threshold 0=disable 1=enable (default: 1)
  • E - error threshold (K/s; default in variant)
  • W - warning threshold (K/s; default in variant)
  • T - ambient temperature correction (K; default in variant)
  • A - autotune C+R values
  • F - force model self-test state (0=off 1=on) during autotune using current values

M400 - Wait for all moves to finish M400: Wait for current moves to finish

Finishes all current moves and and thus clears the buffer. Equivalent to G4 with no parameters.

M403 - Set filament type (material) for particular extruder and notify the MMU M403 - Set filament type (material) for particular extruder and notify the MMU

Currently three different materials are needed (default, flex and PVA).
And storing this information for different load/unload profiles etc. in the future firmware does not have to wait for "ok" from MMU.

Usage

M403 [ E | F ]

Parameters

  • E - Extruder number. 0-indexed.
  • F - Filament type

M405 - Filament Sensor on M405: Filament Sensor on

Turn on Filament Sensor extrusion control.

Usage

M405

M406 - Filament Sensor off M406: Filament Sensor off

Turn off Filament Sensor extrusion control.

Usage

M406

M500 - Store settings in EEPROM M500: Store parameters in non-volatile storage

Save current parameters to EEPROM.

M501 - Read settings from EEPROM M501: Read parameters from EEPROM

Set the active parameters to those stored in the EEPROM. This is useful to revert parameters after experimenting with them.

M502 - Revert all settings to factory default M502: Restore Default Settings

This command resets all tunable parameters to their default values, as set in the firmware's configuration files. This doesn't reset any parameters stored in the EEPROM, so it must be followed by M500 to write the default settings.

M503 - Repport all settings currently in memory M503: Report Current Settings

This command asks the firmware to reply with the current print settings as set in memory. Settings will differ from EEPROM contents if changed since the last load / save. The reply output includes the G-Code commands to produce each setting. For example, Steps-Per-Unit values are displayed as an M92 command.

M509 - Force language selection M509: Force language selection

Resets the language to English. Only on Original Prusa i3 MK2.5/s and MK3/s with multiple languages.

M540 - Abort print on endstop hit (enable/disable) M540 in Marlin: Enable/Disable "Stop SD Print on Endstop Hit"

In Prusa Firmware this G-code is deactivated by default, must be turned on in the source code. You must define ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED.

Usage

M540 [ S ]

Parameters

  • S - disabled=0, enabled=1

M851 - Set Z-Probe Offset M851: Set Z-Probe Offset"

Sets the Z-probe Z offset. This offset is used to determine the actual Z position of the nozzle when using a probe to home Z with G28. This value may also be used by G81 (Prusa) / G29 (Marlin) to apply correction to the Z position. This value represents the distance from nozzle to the bed surface at the point where the probe is triggered. This value will be negative for typical switch probes, inductive probes, and setups where the nozzle makes a circuit with a raised metal contact. This setting will be greater than zero on machines where the nozzle itself is used as the probe, pressing down on the bed to press a switch. (This is a common setup on delta machines.)

Usage

M851 [ Z ]

Parameters

  • Z - Z offset probe to nozzle.

M552 - Set IP address M552: Set IP address, enable/disable network interface"

Sets the printer IP address that is shown in the support menu. Designed to be used with the help of host software. If P is not specified nothing happens. If the structure of the IP address is invalid, 0.0.0.0 is assumed and nothing is shown on the screen in the Support menu.

Usage

M552 [ P<IP_address> ]

Parameters

  • P - The IP address in xxx.xxx.xxx.xxx format. Eg: P192.168.1.14

M600 - Initiate Filament change procedure M600: Filament change pause

Initiates Filament change, it is also used during Filament Runout Sensor process. If the M600 is triggered under 25mm it will do a Z-lift of 25mm to prevent a filament blob.

Usage

M600 [ X | Y | Z | E | L | AUTO ]
  • X - X position, default FILAMENTCHANGE_XPOS
  • Y - Y position, default FILAMENTCHANGE_YPOS
  • Z - relative lift Z, default MIN_Z_FOR_SWAP.
  • E - initial retract, default FILAMENTCHANGE_FIRSTRETRACT
  • L - later retract distance for removal, default FILAMENTCHANGE_FINALRETRACT
  • AUTO - Automatically (only with MMU)

M601 - Pause print M601: Pause print

M125 - Pause print (TODO: not implemented)

M25 - Pause SD print M25: Pause SD print

M602 - Resume print M602: Resume print

M603 - Stop print M603: Stop print

M850 - set sheet parameters

//!
M850 - Set sheet data S[id] Z[offset] L[label] B[bed_temp] P[PINDA_TEMP]

M860 - Wait for extruder temperature (PINDA) M860 Wait for Probe Temperature

Wait for PINDA thermistor to reach target temperature

Usage

M860 [ S ]

Parameters

  • S - Target temperature

M861 - Set/Get PINDA temperature compensation offsets M861 Set Probe Thermal Compensation

Set compensation ustep value S for compensation table index I.

Usage

M861 [ ? | ! | Z | S | I ]

Parameters

  • ? - Print current EEPROM offset values
  • ! - Set factory default values
  • Z - Set all values to 0 (effectively disabling PINDA temperature compensation)
  • S - Microsteps
  • I - Table index

M862 - Print checking M862: Print checking

Checks the parameters of the printer and gcode and performs compatibility check

  • M862.1 { P<nozzle_diameter> | Q } 0.25/0.40/0.60
  • M862.2 { P<model_code> | Q }
  • M862.3 { P"<model_name>" | Q }
  • M862.4 { P<fw_version> | Q }
  • M862.5 { P<gcode_level> | Q }

When run with P<> argument, the check is performed against the input value. When run with Q argument, the current value is shown.

M862.3 accepts text identifiers of printer types too. The syntax of M862.3 is (note the quotes around the type):

  M862.3 P "MK3S"

Accepted printer type identifiers and their numeric counterparts:

  • MK1 (100)
  • MK2 (200)
  • MK2MM (201)
  • MK2S (202)
  • MK2SMM (203)
  • MK2.5 (250)
  • MK2.5MMU2 (20250)
  • MK2.5S (252)
  • MK2.5SMMU2S (20252)
  • MK3 (300)
  • MK3MMU2 (20300)
  • MK3MMU3 (30300)
  • MK3S (302)
  • MK3SMMU2S (20302)
  • MK3SMMU3 (30302)

M900 - Set Linear advance options M900 Set Linear Advance Scaling Factors

Sets the advance extrusion factors for Linear Advance. If any of the R, W, H, or D parameters are set to zero the ratio will be computed dynamically during printing.

Usage

M900 [ K | R | W | H | D]

Parameters

  • K - Advance K factor
  • R - Set ratio directly (overrides WH/D)
  • W - Width
  • H - Height
  • D - Diameter Set ratio from WH/D

M907 - Set digital trimpot motor current in mA using axis codes M907: Set digital trimpot motor

Set digital trimpot motor current using axis codes (X, Y, Z, E, B, S). M907 has no effect when the experimental Extruder motor current scaling mode is active (that applies to farm printing as well)

Usage

M907 [ X | Y | Z | E | B | S ]

Parameters

  • X - X motor driver
  • Y - Y motor driver
  • Z - Z motor driver
  • E - Extruder motor driver
  • B - Second Extruder motor driver
  • S - All motors

M908 - Control digital trimpot directly M908: Control digital trimpot directly

In Prusa Firmware this G-code is deactivated by default, must be turned on in the source code. Not usable on Prusa printers.

Usage

M908 [ P | S ]

Parameters

  • P - channel
  • S - current

M910 - TMC2130 init M910: TMC2130 init

Not active in default, only if TMC2130_SERVICE_CODES_M910_M918 is defined in source code.

M911 - Set TMC2130 holding currents M911: Set TMC2130 holding currents

Not active in default, only if TMC2130_SERVICE_CODES_M910_M918 is defined in source code.

Usage

M911 [ X | Y | Z | E ]

Parameters

  • X - X stepper driver holding current value
  • Y - Y stepper driver holding current value
  • Z - Z stepper driver holding current value
  • E - Extruder stepper driver holding current value

M912 - Set TMC2130 running currents M912: Set TMC2130 running currents

Not active in default, only if TMC2130_SERVICE_CODES_M910_M918 is defined in source code.

Usage

M912 [ X | Y | Z | E ]

Parameters

  • X - X stepper driver running current value
  • Y - Y stepper driver running current value
  • Z - Z stepper driver running current value
  • E - Extruder stepper driver running current value

M913 - Print TMC2130 currents M913: Print TMC2130 currents

Not active in default, only if TMC2130_SERVICE_CODES_M910_M918 is defined in source code. Shows TMC2130 currents.

M914 - Set TMC2130 normal mode M914: Set TMC2130 normal mode

Updates EEPROM only if "P" is given, otherwise temporary (lasts until reset or motor idle timeout)

Usage

M914 [ P | R ]

Parameters

  • P - Make the mode change permanent (write to EEPROM)
  • R - Revert to EEPROM value

M915 - Set TMC2130 silent mode M915: Set TMC2130 silent mode

Updates EEPROM only if "P" is given, otherwise temporary (lasts until reset or motor idle timeout)

Usage

M915 [ P | R ]

Parameters

  • P - Make the mode change permanent (write to EEPROM)
  • R - Revert to EEPROM value

M916 - Set TMC2130 Stallguard sensitivity threshold M916: Set TMC2130 Stallguard sensitivity threshold

Not active in default, only if TMC2130_SERVICE_CODES_M910_M918 is defined in source code.

Usage

M916 [ X | Y | Z | E ]

Parameters

  • X - X stepper driver stallguard sensitivity threshold value
  • Y - Y stepper driver stallguard sensitivity threshold value
  • Z - Z stepper driver stallguard sensitivity threshold value
  • E - Extruder stepper driver stallguard sensitivity threshold value

M917 - Set TMC2130 PWM amplitude offset (pwm_ampl) M917: Set TMC2130 PWM amplitude offset (pwm_ampl)

Not active in default, only if TMC2130_SERVICE_CODES_M910_M918 is defined in source code.

Usage

M917 [ X | Y | Z | E ]

Parameters

  • X - X stepper driver PWM amplitude offset value
  • Y - Y stepper driver PWM amplitude offset value
  • Z - Z stepper driver PWM amplitude offset value
  • E - Extruder stepper driver PWM amplitude offset value

M918 - Set TMC2130 PWM amplitude gradient (pwm_grad) M918: Set TMC2130 PWM amplitude gradient (pwm_grad)

Not active in default, only if TMC2130_SERVICE_CODES_M910_M918 is defined in source code.

Usage

M918 [ X | Y | Z | E ]

Parameters

  • X - X stepper driver PWM amplitude gradient value
  • Y - Y stepper driver PWM amplitude gradient value
  • Z - Z stepper driver PWM amplitude gradient value
  • E - Extruder stepper driver PWM amplitude gradient value

M350 - Set microstepping mode M350: Set microstepping mode

Printers with TMC2130 drivers have X, Y, Z and E as options. The steps-per-unit value is updated accordingly. Not all resolutions are valid! Printers without TMC2130 drivers also have B and S options. In this case, the steps-per-unit value in not changed!

Usage

M350 [ X | Y | Z | E | B | S ]

Parameters

  • X - X new resolution
  • Y - Y new resolution
  • Z - Z new resolution
  • E - E new resolution

Only valid for MK2.5(S) or printers without TMC2130 drivers

  • B - Second extruder new resolution
  • S - All axes new resolution

M351 - Toggle Microstep Pins M351: Toggle MS1 MS2 pins directly

Toggle MS1 MS2 pins directly.

Usage

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

Parameters

  • X - Update X axis
  • Y - Update Y axis
  • Z - Update Z axis
  • E - Update E axis
  • S - which MSx pin to toggle
  • B - new pin value

M701 - Load filament to extruder M701: Load filament

Load filament into the active extruder.

Usage

M701 [ P | T | L | Z ]

Parameters

  • P - n index of MMU slot (zero based, so 0-4 like T0 and T4)
  • T - Alias of P. Used for compatibility with Marlin
  • L - Extrude distance for insertion (positive value)(manual reload)
  • Z - Move the Z axis by this distance. Default value is 0 to maintain backwards compatibility with older gcodes.

M702 - Unload filament M702: Unload filament

Usage

M702 [ U | Z ]

Parameters

  • U - Retract distance for removal (manual reload). Default value is FILAMENTCHANGE_FINALRETRACT.
  • Z - Move the Z axis by this distance. Default value is 0 to maintain backwards compatibility with older gcodes.

M704 - Preload to MMU M704: Preload to MMU

Usage

M704 [ P ]

Parameters

  • P - n index of slot (zero based, so 0-4 like T0 and T4)

M705 - Eject filament M705: Eject filament

Usage

M705 [ P ]

Parameters

  • P - n index of slot (zero based, so 0-4 like T0 and T4)

M706 - Cut filament M706: Cut filament

Usage

M706 [ P ]

Parameters

  • P - n index of slot (zero based, so 0-4 like T0 and T4)

M707 - Read from MMU register M707: Read from MMU register

Usage

M707 [ A ]

Parameters

  • A - Address of register in hexidecimal.

Example

M707 A0x1b - Read a 8bit integer from register 0x1b and prints the result onto the serial line.

Does nothing if the A parameter is not present or if MMU is not enabled.

M708 - Write to MMU register M707: Write to MMU register

Usage

M708 [ A | X ]

Parameters

  • A - Address of register in hexidecimal.
  • X - Data to write (16-bit integer). Default value 0.

Example

M708 A0x1b X05 - Write to register 0x1b the value 05.

Does nothing if A parameter is missing or if MMU is not enabled.

M709 - MMU reset M709: MMU reset

The MK3S cannot not power off the MMU, for that reason the functionality is not supported.

Usage

M709 [ X ]

Parameters

  • X - Reset MMU (0:soft reset | 1:hardware reset)

Example

M709 X0 - issue an X0 command via communication into the MMU (soft reset)

M709 X1 - toggle the MMU's reset pin (hardware reset)

End of M-Commands


T<extruder nr.> - select extruder in case of multi extruder printer. Selects filament position 1-5 (T0-T4) in case of MMU.

For MMU2/S / MMU3: T<extruder nr.> - Selects the filament position. A Gcode to load a filament to the nozzle must follow. Tx - Printer asks user to select a filament position. Then loads the filament from the MMU unit into the extruder wheels only. G-code to heat up the nozzle follows. Tc - Loads the filament tip from the extruder wheels into the nozzle. T? - acts the same as Tx followed by Tc

End of T-Codes


D codes

D-1 - Endless Loop D-1: Endless Loop

D0 - Reset D0: Reset

Usage

D0 [ B ]

Parameters

  • B - Bootloader

D1 - Clear EEPROM and RESET D1: Clear EEPROM and RESET

  D1

D2 - Read/Write RAM D3: Read/Write RAM

This command can be used without any additional parameters. It will read the entire RAM.

Usage

D2 [ A | C | X ]

Parameters

  • A - Address (x0000-x1fff)
  • C - Count (1-8192)
  • X - Data

Notes

  • The hex address needs to be lowercase without the 0 before the x
  • Count is decimal
  • The hex data needs to be lowercase

D3 - Read/Write EEPROM D3: Read/Write EEPROM

This command can be used without any additional parameters. It will read the entire eeprom.

Usage

D3 [ A | C | X ]

Parameters

  • A - Address (x0000-x0fff)
  • C - Count (1-4096)
  • X - Data (hex)

Notes

  • The hex address needs to be lowercase without the 0 before the x
  • Count is decimal
  • The hex data needs to be lowercase

D4 - Read/Write PIN D4: Read/Write PIN

To read the digital value of a pin you need only to define the pin number.

Usage

D4 [ P | F | V ]

Parameters

  • P - Pin (0-255)
  • F - Function in/out (0/1)
  • V - Value (0/1)

D5 - Read/Write FLASH D5: Read/Write Flash

This command can be used without any additional parameters. It will read the 1kb FLASH.

Usage

D5 [ A | C | X | E ]

Parameters

  • A - Address (x00000-x3ffff)
  • C - Count (1-8192)
  • X - Data (hex)
  • E - Erase

Notes

  • The hex address needs to be lowercase without the 0 before the x
  • Count is decimal
  • The hex data needs to be lowercase

D6 - Read/Write external FLASH D6: Read/Write external Flash

Reserved

D7 - Read/Write Bootloader D7: Read/Write Bootloader

Reserved

D8 - Read/Write PINDA D8: Read/Write PINDA

Usage

D8 [ ? | ! | P | Z ]

Parameters

  • ? - Read PINDA temperature shift values
  • ! - Reset PINDA temperature shift values to default
  • P - Pinda temperature [C]
  • Z - Z Offset [mm]

D9 - Read ADC D9: Read ADC

Usage

D9 [ I | V ]

Parameters

  • I - ADC channel index
    • 0 - Heater 0 temperature
    • 1 - Heater 1 temperature
    • 2 - Bed temperature
    • 3 - PINDA temperature
    • 4 - PWR voltage
    • 5 - Ambient temperature
    • 6 - BED voltage
  • V Value to be written as simulated

D10 - Set XYZ calibration = OK D10: Set XYZ calibration = OK

D12 - Time D12: Time

Writes the current time in the log file.

D20 - Generate an offline crash dump D20: Generate an offline crash dump

Generate a crash dump for later retrival.

Usage

D20 [E]

Parameters

  • E - Perform an emergency crash dump (resets the printer).

    Notes

  • A crash dump can be later recovered with D21, or cleared with D22.
  • An emergency crash dump includes register data, but will cause the printer to reset after the dump is completed.

D21 - Print crash dump to serial D21: Print crash dump to serial

Output the complete crash dump (if present) to the serial.

Usage

D21

Notes

  • The starting address can vary between builds, but it's always at the beginning of the data section.

D22 - Clear crash dump state D22: Clear crash dump state

Clear an existing internal crash dump.

Usage

D22

D23 - Request emergency dump on serial D23: Request emergency dump on serial

On boards without offline dump support, request online dumps to the serial port on firmware faults. When online dumps are enabled, the FW will dump memory on the serial before resetting.

Usage

D23 [E] [R]

Parameters

  • E - Perform an emergency crash dump (resets the printer).
  • R - Disable online dumps.

D70 - Enable low-level thermal model logging for offline simulation

Usage

D70 [ S ]

Parameters

  • S - Enable 0-1 (default 0)

D80 - Bed check D80: Bed check

This command will log data to SD card file "mesh.txt".

Usage

D80 [ E | F | G | H | I | J ]

Parameters

  • E - Dimension X (default 40)
  • F - Dimention Y (default 40)
  • G - Points X (default 40)
  • H - Points Y (default 40)
  • I - Offset X (default 74)
  • J - Offset Y (default 34)

D81 - Bed analysis D80: Bed analysis

This command will log data to SD card file "wldsd.txt".

Usage

D81 [ E | F | G | H | I | J ]

Parameters

  • E - Dimension X (default 40)
  • F - Dimention Y (default 40)
  • G - Points X (default 40)
  • H - Points Y (default 40)
  • I - Offset X (default 74)
  • J - Offset Y (default 34)

D106 - Print measured fan speed for different pwm values D106: Print measured fan speed for different pwm values

D2130 - Trinamic stepper controller D2130: Trinamic stepper controller

Todo:Please review by owner of the code. RepRap Wiki Gcode needs to be updated after review of owner as well.

Usage

D2130 [ Axis | Command | Subcommand | Value ]

Parameters

  • Axis
    • X - X stepper driver
    • Y - Y stepper driver
    • Z - Z stepper driver
    • E - Extruder stepper driver
  • Commands
    • 0 - Current off
    • 1 - Current on
    • + - Single step
    • - - Single step oposite direction
    • NNN - Value sereval steps
    • ? - Read register
    • Subcommands for read register
      • mres - Micro step resolution. More information in datasheet '5.5.2 CHOPCONF – Chopper Configuration'
      • step - Step
      • mscnt - Microstep counter. More information in datasheet '5.5 Motor Driver Registers'
      • mscuract - Actual microstep current for motor. More information in datasheet '5.5 Motor Driver Registers'
      • wave - Microstep linearity compensation curve
    • ! - Set register
    • Subcommands for set register
      • mres - Micro step resolution
      • step - Step
      • wave - Microstep linearity compensation curve
      • Values for set register
        • 0, 180 --> 250 - Off
        • 0.9 --> 1.25 - Valid values (recommended is 1.1)
    • @ - Home calibrate axis

Examples:

  D2130E?wave

Print extruder microstep linearity compensation curve

D2130E!wave0

Disable extruder linearity compensation curve, (sine curve is used)

D2130E!wave220

(sin(x))^1.1 extruder microstep compensation curve used

Notes: For more information see https://www.trinamic.com/fileadmin/assets/Products/ICs_Documents/TMC2130_datasheet.pdf

D9125 - PAT9125 filament sensor D9125: PAT9125 filament sensor

Usage

D9125 [ ? | ! | R | X | Y | L ]

Parameters

  • ? - Print values
  • ! - Print values
  • R - Resolution. Not active in code
  • X - X values
  • Y - Y values
  • L - Activate filament sensor log

End of D-Codes