This is a list of currently implemented G-Codes in Prusa firmware for i3 series printers. 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. That is why some G Codes aren't in numerical order.
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:
M0 [P<ms<] [S<sec>] [string] M1 [P<ms>] [S<sec>] [string]
Set of internal PRUSA commands
PRUSA [ Ping | PRN | FAN | fn | thx | uvlo | MMURES | RESET | fv | M28 | SN | Fir | Rev | Lang | Lz | Beat | FR ]
In Prusa Firmware G0 and G1 are the same.
G0 [ X | Y | Z | E | F | S ] G1 [ X | Y | Z | E | F | S ]
These commands don't propperly work with MBL enabled. The compensation only happens at the end of the move, so avoid long arcs.
G2 [ X | Y | I | E | F ] (Clockwise Arc)
G3 [ X | Y | I | E | F ] (Counter-Clockwise Arc)
Pause the machine for a period of time.
G4 [ P | S ]
Retracts filament according to settings of
Unretracts/recovers filament according to settings of
Units are in millimeters. Prusa doesn't support inches.
Using without any parameters will perform homing of all axes AND mesh bed leveling, while will just home all axes (no mesh bed leveling).
G28 [ X | Y | Z | W | C ]
G28 issued without parameters homes the MMU as well (invalidates the homing flags of Selector and Idler and these will perform homing async once it is considered safe, i.e. no filament in the selector)
In Prusa i3 Firmware this G-code is deactivated by default, must be turned on in the source code.
See
In Prusa Firmware this G-code is deactivated by default, must be turned on in the source code.
In Prusa Firmware this G-code is deactivated by default, must be turned on in the source code.
In Prusa Firmware this G-code is deactivated by default, must be turned on in the source code.
The sensor must be over the bed. The maximum travel distance before an error is triggered is 10mm.
Show/print PINDA temperature interpolating.
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.
Default 3x3 grid can be changed on MK2.5/s and MK3/s to 7x7 grid.
G80 [ N | C | O | M | L | R | F | B | X | Y | W | H ]
Using the following parameters enables additional "manual" bed leveling correction. Valid values are -100 microns to 100 microns.
The following parameters are used to define the area used by the print:
Prints mesh bed leveling status and bed profile if activated.
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.
In Prusa Firmware this G-code is deactivated by default, must be turned on in the source code.
In Prusa Firmware this G-code is deactivated by default, must be turned on in the source code.
In Prusa Firmware this G-code is deactivated by default, must be turned on in the source code.
This G-code will be performed at the start of a calibration script. (Prusa3D specific)
This G-code will be performed at the end of a calibration script. (Prusa3D specific)
Currently has no effect.
All coordinates from now on are absolute relative to the origin of the machine. E axis is left intact.
All coordinates from now on are relative to the last position. E axis is left intact.
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 , , or axis are specified, the move afterwards might stutter because of Mesh Bed Leveling. axis is not affected if the target position is 0 (). A G92 without coordinates will reset all axes to zero on some firmware. This is not the case for Prusa-Firmware!
G92 [ X | Y | Z | E ]
Enable Prusa-specific Farm functions and g-code. See Internal Prusa commands.
Disables Prusa-specific Farm functions and g-code.
M20 [ L | T ]
M23 [filename]
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.
M26 [ S ]
M27 [ P ]
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 [filename]
M928 [filename]
M42 [ P | S ]
M45 [ V ]
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 ]
Without any parameter get printer state.
0 = NotReady Used by PrusaConnect
1 = IsReady Used by PrusaConnect
2 = Idle
3 = SD printing finished
4 = Host printing finished
5 = SD printing
6 = Host printing
M72 [ S ]
M73 [ P | R | Q | S | C | D ]
Start the printer-host enable keep-alive timer. While the timer has not expired, the printer will enable host specific features.
M79 [ S ]
M104 [ S ]
It is processed much earlier as to bypass the cmdqueue.
M140 [ S ]
Prints temperatures:
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 [ S ] [ C ]
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
M104 [ B | R | S ]
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 [ R | S ]
If no parameter is supplied, waits for heating or cooling to previously set temperature.
M106 [ S ]
Only works if the firmware is compiled with PS_ON_PIN defined.
Only works if the firmware is compiled with PS_ON_PIN defined.
Makes the extruder interpret extrusion as absolute positions.
Makes the extruder interpret extrusion values as relative positions.
This command can be used to set the stepper inactivity timeout () or to disable steppers (,,,) 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 ]
Equal to M84 (compatibility)
M85 [ S ]
When safety timer expires, heatbed and nozzle target temperatures are set to zero.
M86 [ S ]
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)
M92 [ X | Y | Z | E ]
Sets the line number in G-code
M110 [ N ]
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).
M113 [ S ]
Print the firmware info and capabilities Without any arguments, prints Prusa firmware version number, machine type, extruder count and UUID. 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:
results:
results:
results on LCD display for 30s or user interaction:
M115 [ V | U ]
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.
M118 [ A1 | E1 ] [ String ]
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.
This command is used to report fan speeds and fan pwm values.
M123
Example:
E0:3240 RPM PRN1:4560 RPM E0@:255 PRN1@:255
In Prusa Firmware this G-code is deactivated by default, must be turned on in the source code by defining BLINKM and its dependencies.
M150 [ R | U | B ]
M200 [ D | T ]
For each axis individually.
For each axis individually.
M204 [ S | T ]
M204 [ P | R | T ]
Set some advanced settings related to movement.
M205 [ S | T | B | X | Y | Z | E ]
M206 [ X | Y | Z ]
M207 [ S | F | Z ]
M208 [ S | F ]
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.
M209 [ S ]
M214 [P] [S] [N] [R] [F]
In Prusa Firmware this G-code is only active if is higher then 1 in the source code. On Original i3 Prusa MK2/s MK2.5/s MK3/s it is not active.
M218 [ X | Y ]
M220 [ B | S | R ]
M221 [ S | T ]
Wait until the specified pin reaches the state required
M226 [ P | S ]
In Prusa Firmware this G-code is deactivated by default, must be turned on in the source code.
M280 [ P | S ]
In Prusa Firmware the defaults are and , so that without parameters will beep for a second.
M300 [ S | P ]
Sets Proportional (P), Integral (I) and Derivative (D) values for hot end. See also PID Tuning.
M301 [ P | I | D | C ]
Sets Proportional (P), Integral (I) and Derivative (D) values for bed. See also PID Tuning.
M304 [ P | I | D ]
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 or the correct pin number to be able to use the feature.
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.
M302 [ S ]
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.
M303 [ E | S | C ]
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
Finishes all current moves and and thus clears the buffer. Equivalent to with no parameters.
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.
M403 [ E | F ]
Turn on Filament Sensor extrusion control.
M405
Turn off Filament Sensor extrusion control.
M406
Prints mesh bed leveling status and bed profile if activated.
Save current parameters to EEPROM.
Set the active parameters to those stored in the EEPROM. This is useful to revert parameters after experimenting with them.
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.
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.
Resets the language to English. Only on Original Prusa i3 MK2.5/s and MK3/s with multiple languages.
In Prusa Firmware this G-code is deactivated by default, must be turned on in the source code. You must define .
M540 [ S ]
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.)
M851 [ Z ]
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.
M552 [ P<IP_address> ]
Initiates Filament change, it is also used during Filament Runout Sensor process. If the is triggered under 25mm it will do a Z-lift of 25mm to prevent a filament blob.
M600 [ X | Y | Z | E | L | AUTO ]
Without any parameters it will park the extruder to default or last set position. The default pause position will be set during power up and a reset, the new pause positions aren't permanent.
M601 [ X | Y | Z | S ]
Without any parameters it will park the extruder to default or last set position. The default pause position will be set during power up and a reset, the new pause positions aren't permanent.
M125 [ X | Y | Z | S ]
Without any parameters it will park the extruder to default or last set position. The default pause position will be set during power up and a reset, the new pause positions aren't permanent.
M25 [ X | Y | Z | S ]
Get and Set Sheet parameters.
M850 [ S | Z | L | B | P | A ]
Z and L are optional, if one or both are missing the current values are reported instead.
If L and/or Z are specified, the sheet's values are updated.
Z range is validated
Sheet index is validated
Requesting info (no L or Z) on an uncalibrated sheet reports as such.
Pronterface capitalizes anything sent. To use lowercase in your sheet names you'll need to use a different terminal program.
Wait for PINDA thermistor to reach target temperature
M860 [ S ]
Set compensation ustep value for compensation table index .
M861 [ ? | ! | Z | S | I ]
Checks the parameters of the printer and gcode and performs compatibility check
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:
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.
M900 [ K | R | W | H | D]
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)
M907 [ X | Y | Z | E | B | S ]
In Prusa Firmware this G-code is deactivated by default, must be turned on in the source code. Not usable on Prusa printers.
M908 [ P | S ]
Not active in default, only if is defined in source code.
Not active in default, only if is defined in source code.
M911 [ X | Y | Z | E ]
Not active in default, only if is defined in source code.
M912 [ X | Y | Z | E ]
Not active in default, only if is defined in source code. Shows TMC2130 currents.
Updates EEPROM only if "P" is given, otherwise temporary (lasts until reset or motor idle timeout)
M914 [ P | R | Q ]
Updates EEPROM only if "P" is given, otherwise temporary (lasts until reset or motor idle timeout)
M915 [ P | R | Q]
Not active in default, only if is defined in source code.
M916 [ X | Y | Z | E ]
Not active in default, only if is defined in source code.
M917 [ X | Y | Z | E ]
Not active in default, only if is defined in source code.
M918 [ X | Y | Z | E ]
Printers with TMC2130 drivers have , , and as options. The steps-per-unit value is updated accordingly. Not all resolutions are valid! Printers without TMC2130 drivers also have and options. In this case, the steps-per-unit value in not changed!
M350 [ X | Y | Z | E | B | S ]
Only valid for MK2.5(S) or printers without TMC2130 drivers
Toggle MS1 MS2 pins directly.
M351 [B<0|1>] [E<0|1>] S<1|2> [X<0|1>] [Y<0|1>] [Z<0|1>]
Load filament into the active extruder.
M701 [ P | T | L | Z ]
M702 [ U | Z ]
M704 [ P ]
M705 [ P ]
M706 [ P ]
M707 [ A ]
M707 A0X19 - Read a 8bit integer from register 0X19 (Idler_sg_thrs_R) and prints the result onto the serial line.
Does nothing if the A parameter is not present or if MMU is not enabled.
M708 [ A | X ]
M708 A0x19 X07 - Write to register 0x19 (Idler_sg_thrs_R) the value 07. Does nothing if A parameter is missing or if MMU is not enabled.
The MK3S cannot not power off the MMU, for that reason the functionality is not supported.
M709 [ S | X ]
S - En-/disable the MMU (0:off | 1:on)
M709 X0 - issue an X0 command via communication into the MMU (soft reset)
M709 X1 - toggle the MMU's reset pin (hardware reset)
M709 X42 - erase MMU EEPROM
M709 S1 - enable MMU
M709 S0 - disable MMU
M709 - Serial message if en- or disabled
End of M-Commands
T
T? - Printer asks user to select a filament position. Then loads the desired filament from the multiplexer (Y-splitter) into the nozzle.
T
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.
D0 [ B ]
D1
This command can be used without any additional parameters. It will read the entire RAM.
D2 [ A | C | X ]
This command can be used without any additional parameters. It will read the entire eeprom.
D3 [ A | C | X ]
To read the digital value of a pin you need only to define the pin number.
D4 [ P | F | V ]
This command can be used without any additional parameters. It will read the 1kb FLASH.
D5 [ A | C | X | E ]
Reserved
Reserved
D8 [ ? | ! | P | Z ]
D9 [ I | V ]
Writes the current time in the log file.
Generate a crash dump for later retrival.
D20 [E]
Output the complete crash dump (if present) to the serial.
D21
The starting address can vary between builds, but it's always at the beginning of the data section.
Clear an existing internal crash dump.
D22
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.
D23 [E] [R]
D70 [ S ]
This command will log data to SD card file "mesh.txt".
D80 [ E | F | G | H | I | J ]
This command will log data to SD card file "wldsd.txt".
D81 [ E | F | G | H | I | J ]
D2130 [ Axis | Command | Subcommand | Value ]
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 [ ? | ! | R | X | Y | L ]
Relevant for
12 comments
Hi Martin. For MK3.5, you should be rather looking at
Buddy compatible G-codes article instead.
Also, so far, there is no thermal model on MK3.5. A 3rd party hotend might a matter of tuning the PID parameters, in case its thermal capacity and power parameters differ.
For anyone else looking for MK3.5 gcode commands, just igonr the "relevant to" section at the top of the article where it says MK3.5.
While most i3 G-codes are compatible, the MK3.5 shouldn’t be listed here. Thanks for the mention. Fixed.