Prusa Knowledge Base
EN
  • Čeština
  • Español
  • Italiano
  • Deutsch
  • Polski
  • Français
Login

Prusa-specific G-codes

Last updated 10 months ago
This article is also available in following languages: 
CSDEESFRITPL

This is a list of currently implemented G Codes in Prusa firmware as of 7th of May 2021. The description is only for Prusa Research-specific G-codes. The rest can be found on RepRap Wiki. With exception of M117, they are all shown in order of appearance in the code. There are reasons why some G Codes aren't in numerical order.

Full G-code documentation for Original Prusa MINI is yet to be published, but except for some differences, the best source of information is the official Marlin2 documentation.

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

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

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

Set of internal PRUSA commands

Usage

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

Parameters

  • Ping
  • PRN
    - Prints revision of the printer
  • FAN
    - Prints fan details
  • fn
    - Prints farm no.
  • 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
  • Beat
    - Kick farm link timer
  • 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
  • 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 perform 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

The 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

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

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

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 movement prior 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
    - Exruder

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 unit for the X drive
  • Y
    - Steps per unit for the Y drive
  • Z
    - Steps per unit for the Z drive
  • E
    - Steps per unit 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

This causes the given message to be shown in the status line on an attached LCD. It is processed early as to allow printing messages that contain G, M, N, or T.

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.

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.

M203 - Set Max Feedrate M203: Set maximum feedrate

For each axis individually.

M204 - Acceleration settings M204: Set default acceleration

Old format:

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

New format:

Usage
M204 [ P | R | T ]
Parameters
  • P
    - printing moves
  • R
    - filament 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

M218 - Set hotend offset M218: Set Hotend Offset

In Prusa Firmware this G-code is only active if

EXTRUDERS
is higher then 1 in the source code. On Original i3 Prusa MK2/s MK2.5/s MK3/s it is not active.

Usage

M218 [ X | Y ]

Parameters

  • X
    - X offset
  • Y
    - Y offset

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

Parameters

  • S
    - Extrude factor override percentage (0..100 or higher), default 100%
  • T
    - Extruder drive number (Prusa Firmware only), default 0 if not set.

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

Parameters

  • P
    - proportional (Kp)
  • I
    - integral (Ki)
  • D
    - derivative (Kd)
  • C
    - heating power=Kc*(e_speed0)

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

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

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 211
  • Y
    - Y position, default 0
  • Z
    - relative lift Z, default 2.
  • E
    - initial retract, default -2
  • L
    - later retract distance for removal, default -80
  • AUTO
    - Automatically (only with MMU)

M601 - Pause print M601: Pause print

M125 - Pause print (not implemented)

M25 - Pause SD print M25: Pause SD print

M602 - Resume print M602: Resume print

M603 - Stop print M603: Stop print

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)
  • MK3S (302)
  • MK3SMMU2S (20302)

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

Not active in default, only if

TMC2130_SERVICE_CODES_M910_M918
is defined in source code.

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

Not active in default, only if

TMC2130_SERVICE_CODES_M910_M918
is defined in source code.

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 M701: Load filament

M702 - Unload filament G32: Undock Z Probe sled

Usage

M702 [ U | C ]

Parameters

  • U
    - Unload all filaments used in current print
  • C
    - Unload just current filament
  • without any parameters unload all filaments

if "U" unload all filaments which were used in current print

if "C" unload just current filament

otherwise unload all filaments

if "C" unload current filament; if mmu is not present no action is performed

unload current filament

M999 - Restart after being stopped M999: Restart after being stopped by error

End of M-Commands


T Codes

T<extruder nr.> - select extruder in case of multi extruder printer. select filament in case of MMU_V2.

For MMU_V2:

T<n> Gcode to extrude at least 38.10 mm at feedrate 19.02 mm/s must follow immediately to load to extruder wheels.
T? Gcode to extrude shouldn't have to follow, load to extruder wheels is done automatically
Tx Same as T?, except nozzle doesn't have to be preheated. Tc must be placed after extruder nozzle is preheated to finish filament load.
Tc Load to nozzle after filament was prepared by Tc and extruder nozzle is already heated.

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.

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

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

Comments

Please sign in before adding a comment.
0
Still have questions?

Still have questions?

If you have a question about something that isn't covered here, check out our additional resources.
And if that doesn't do the trick, you can send an inquiry to info@prusa3d.com or through the button below.