Convert c code to machine code

Convert c code to machine code

Uman Tabassum

Follow

Jun 1, 2021

·

2 min read

Converting C code to machine code

Converting C code into machine code
It is very difficult to write machine code, So
we introduced languages and written easily to solve our problems
We are going to learn how c code is converted into machine
code @cool let’s get into the topic……. that’s awesome

Photo by Markus Spiske on Unsplash

The compiler recognizes the c code and converts it into machine
code which is understood by the system we r working on
The conversion is in this way 10010001010101
‘0’ and ‘1’ s.In this way 0 and 1 the machine code is
written.

C language consists of inbuilt functions like printf,scanf,gets and puts, etc these are all the functions inbuilt we can use that inbuilt
functions and write our source code which language u wanted to solve.
We need not write code for printf and scanf

Process of converting source code into machine code
{
First the source code for example it is saved as jav. c
this extension in c is recognized by the compiler and
starts converting it into machine code cool right
and the compiler doesn’t fully convert into machine language
it doesn’t convert the inbuilt functions because they were
already converted right so here comes the linker. Linker is
a software used to convert the inbuilt functions into machine code
and there comes the executable code and finally the total executable
the file is converted into machine code and now we get an output in
the integrated environment we choose ok!
}
One new snippet is a 16-bit computer the int size is 2 bit
but in 32 and 64-bit computer the int size is 4 bits.
We need not run step by step like using compiler converting into machine code and converting inbuilt functions into machine code
by using linker ok cool everything is integrated into ide’s “INTEGRATED DEVELOPMENT ENVIRONMENT” #COOL BRO

Have you ever wondered how your computer interprets human written (C-) code, compiles it to machine code and executes the operation you just programmed? For me those internal mechanics were a “miracle” for a long time — you hit compile, wait several seconds and voilà, your application runs!

This page tries to describe the flavour of G-codes that the RepRap firmwares use and how they work. The main target is additive fabrication using FFF processes. Codes for print head movements follow the NIST RS274NGC G-code standard, so RepRap firmwares are quite usable for CNC milling and similar applications as well. See also on Wikipedia's G-code article.

There are a few different ways to prepare G-code for a printer. One method would be to use a slicing program such as Slic3r, Skeinforge or Cura. These programs import a CAD model, slice it into layers, and output the G-code required to print each layer. Slicers are the easiest way to go from a 3D model to a printed part, however the user sacrifices some flexibility when using them. Another option for G-code generation is to use a lower level library like mecode. Libraries like mecode give you precise control over the tool path, and thus are useful if you have a complex print that is not suitable for naive slicing. The final option is to just write the G-code yourself. This may be the best choice if you just need to run a few test lines while calibrating your printer.

As many different firmwares exist and their developers tend to implement new features without discussing strategies or looking what others did before them, a lot of different sub-flavours for the 3D-Printer specific codes developed over the years. This particular page is the master page for RepRap. Nowhere in here should the same code be used for two different things; there are always more numbers to use... The rule is: add your new code here, then implement it.

Unfortunately human nature being what it is, the best procedures aren't always followed, so some multiple uses of the same code exist. The rule which should be followed is that later appearances of a code on this page (later than the original use of a code), are deprecated and should be changed, unless there is a good technical reason (like the general G-Code standard) why a later instance should be preferred. Note that the key date is appearance here, not date of implementation.

Introduction

A typical piece of G-code as sent to a RepRap machine might look like this:

N3 T0*57
N4 G92 E0*67
N5 G28*22
N6 G1 F1500.0*82
N7 G1 X2.0 Y2.0 F3000.0*85
N8 G1 X3.0 Y3.0*33

G-code can also be stored in files on SD cards. A file containing RepRap G-code usually has the extension

N123
20,
N123
21 or
N123
22. Files for BFB/RapMan have the extension
N123
23. G-code stored in file or produced by a slicer might look like this:

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0

The meaning of all those symbols and numbers (and more) is explained below.

Slicers will (optionally?) add G-code scripts to the beginning and end of their output file to perform specified actions before and/or after a print such as z-probing the build-area, heating/cooling the bed and hotend, performing ooze free "nozzle wipe" startup routine, switching system power on/off, and even "ejecting" parts. More info on the Start GCode routines and End GCode routines pages.

To find out which specific G-code(s) are implemented in any given firmware, there are little tables attached to the command descriptions, like this one:

Here means:

{{yes}}The G-code is fully supported by the firmware.{{partial}} or {{experimental}}There is some support for the G-code. Often it is required to check out the source code branch for the firmware (usually stored in a different branch) or to flip configuration switches on the mainboard.{{automatic}}The firmware handles this G-code automatically, so there's no need to send the command. An example is power supply on/off G-code (M80/M81) in the Teacup firmware.{{???}}It is unknown if the firmware supports this G-code. You may want to test this yourself before using it in production.{{no}}The firmware does not support this G-code.

For the technically-minded, G-code line endings are Unix Line Endings (

N123
24), but will accept Windows Line Endings (
N123
25), so you should not need to worry about converting between the two, but it is best practice to use Unix Line Endings where possible.

Fields

A RepRap G-code is a list of fields that are separated by white spaces or line breaks. A field can be interpreted as a command, parameter, or for any other special purpose. It consists of one letter directly followed by a number, or can be only a stand-alone letter (Flag). The letter gives information about the meaning of the field (see the list below in this section). Numbers can be integers (128) or fractional numbers (12.42), depending on context. For example, an X coordinate can take integers (

N123
26) or fractionals (
N123
27), but selecting extruder number 2.76 would make no sense. In this description, the numbers in the fields are represented by
N123
28 as a placeholder.

In RepRapFirmware, some parameters can be followed by more than one number, with colon used to separate them. Typically this is used to specify extruder parameters, with one value provided per extruder. If only one value is provided where a value is needed for each extruder, then that value is applied to all extruders.

LetterMeaningGnnnStandard G-code command, such as move to a pointMnnnRepRap-defined command, such as turn on a cooling fanTnnnSelect tool nnn. In RepRap, a tool is typically associated with a nozzle, which may be fed by one or more extruders.SnnnCommand parameter, such as time in seconds; temperatures; voltage to send to a motorPnnnCommand parameter, such as time in milliseconds; proportional (Kp) in PID TuningXnnnA X coordinate, usually to move to. This can be an Integer or Fractional number.YnnnA Y coordinate, usually to move to. This can be an Integer or Fractional number.ZnnnA Z coordinate, usually to move to. This can be an Integer or Fractional number.U,V,WAdditional axis coordinates (RepRapFirmware)InnnParameter - X-offset in arc move; integral (Ki) in PID TuningJnnnParameter - Y-offset in arc moveDnnnParameter - used for diameter; derivative (Kd) in PID TuningHnnnParameter - used for heater number in PID TuningFnnnFeedrate in mm per minute. (Speed of print head movement)RnnnParameter - used for temperaturesQnnnParameter - not currently usedEnnnLength of extrudate. This is exactly like X, Y and Z, but for the length of filament to consume.NnnnLine number. Used to request repeat transmission in the case of communications errors.*nnnChecksum. Used to check for communications errors.

Case sensitivity

The original NIST G-code standard requires gcode interpreters to be case-insensitive, except for characters in comments. However, not all 3D printer firmwares conform to this and some recognise uppercase command letters and parameters only.

Firmwares that are known to be case-insensitiveRepRapFirmware version 1.19 and later (except within quoted strings)Firmwares that are known to be case-sensitiveRepRapFirmware version 1.18 and earlier

Quoted strings

In RepRapFirmware, some commands support quoted strings when providing file names and other string parameters. This allows file names, WiFi passwords etc. to contain spaces, semicolons and other characters that would otherwise not be permitted. Double-quote characters are used to delimit the string, and any double-quote character within the string must be repeated.

Unfortunately, some gcode sender programs convert all characters to uppercase and don't provide any means to disable this feature. Therefore, within a quoted-string, the single-quote character is used as a flag to force the following character to lowercase. If you want to include a single quote character in the string, use two single quote characters to represent one single quote character.

Example: to add SSID MYROUTER with password

N123
29 to the WiFi network list, use command:

N123
30

or if you can't send lowercase characters:

N123
31

Using expressions in parameters

RepRapFirmware 3.1 and later allow parameter values to be computed from an expression enclosed in { }. Such an expression may include constants, values from the machine object model, operators and functions. Example:

N123
32

See https://duet3d.dozuki.com/Wiki/GCode_Meta_Commands#Section_Use_of_expressions_within_GCode_commands for more details.

G-code comments begin at a semicolon, and end at the end of the line:

N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22

Some firmwares also obey the CNC G-code standard, which is to enclose comments in round brackets. Comments of this form must start and end on the same line:

(Home some axes)
G28 (here come the axes to be homed) X Y

Comments and white space will be ignored by your RepRap Printer. It's better to strip these out on the host computer before sending the G-code to your printer, as this saves bandwidth.

Special fields

N: Line number

Example
N123

If present, the line number should be the first field in a line. For G-code stored in files on SD cards the line number is usually omitted.

If checking is supported, the RepRap firmware expects line numbers to increase by 1 each line, and if that doesn't happen it is flagged as an error. But you can reset the count using

N123
33 (see below).

Although supported, usage of N in Machinekit is discouraged as it serves no purpose.

*: Checksum

Example:

N123
34

If present, the checksum should be the last field in a line, but before a comment. For G-code stored in files on SD cards the checksum is usually omitted.

The firmware compares the checksum against a locally-computed value. If they differ, it requests a repeat transmission of the line.

*: CRC

Example:

N123
35

The 8-bit checksum provides insufficient protection against noise on the received data connection in some situations, for example where the cable from a display device runs close to an extruder cable. Therefore RepRapFirmware allows a CRC to be used in place of a checksum. If present, the CRC should be the last field in a line, but before a comment. RepRapFirmware assumes that * followed by 5 digits is a CRC, whereas * followed by 1, 2 or 3 digits is a checksum. The polynomial used is 0x1021 as for CCITT CRC16.

Checking

Example
N123 [...G Code in here...] *71

The RepRap firmware checks the line number and the checksum (or CRC if supported). You can leave both of these out - RepRap will still work, but it won't do checking. You have to have both or neither though. If only one appears, it produces an error.

The checksum "cs" for a G-code string "cmd" (including its line number) is computed by exor-ing the bytes in the string up to and not including the * character as follows:

int cs = 0;
for(i = 0; cmd[i] != '*' && cmd[i] != NULL; i++)
   cs = cs ^ cmd[i];
cs &= 0xff;  // Defensive programming...

and the value is appended as a decimal integer to the command after the * character.

Conditional Execution and Loops

RepRapFirmware 3.01 and later supports conditions and loops in GCode. Properties from the firmware object model (e.g. current position, current tool) can be included in controlling expressions. See https://duet3d.dozuki.com/Wiki/GCode_Meta_Commands for details.

Buffering

If buffering is supported, the RepRap firmware stores some commands in a ring buffer internally for execution. This means that there is no (appreciable) delay while a command is acknowledged and the next transmitted. In turn, this means that sequences of line segments can be plotted without a dwell between one and the next. As soon as one of these buffered commands is received it is acknowledged and stored locally. If the local buffer is full, then the acknowledgment is delayed until space for storage in the buffer is available. This is how flow control is achieved.

Typically, the following moving commands are buffered:

N123
36-
N123
37 and
N123
38-
N123
39. The Teacup Firmware buffers also some setting commands:
N123
40,
N123
41,
N123
42 and
N123
43. All other
N123
44,
N123
45 or
N123
46 commands are not buffered.

RepRapFirmware also implements an internal queue to ensure that certain codes (like M106) are executed in the right order and not when the last move has been added to the look-ahead queue.

When an unbuffered command is received it is stored, but it is not acknowledged to the host until the buffer is exhausted and then the command has been executed. Thus the host will pause at one of these commands until it has been done. Short pauses between these commands and any that might follow them do not affect the performance of the machine.

G-commands

G0 & G1: Move

  • N123
    
    36 : Rapid Move
  • N123
    
    48 : Linear Move
Usage
N123
49
N123
50ParametersNot all parameters need to be used, but at least one has to be used
N123
51 The position to move to on the X axis
N123
52 The position to move to on the Y axis
N123
53 The position to move to on the Z axis
N123
54 The amount to extrude between the starting point and ending point
N123
55 The feedrate per minute of the move between the starting point and ending point (if supplied)
N123
56 (RepRapFirmware) Flag to check if an endstop was hit (
N123
57 to check,
N123
58 to ignore, other
N123
56 see note, default is
N123
58)1
N123
61 (RepRapFirmware) Restore point number 4
N123
62 Laser cutter/engraver power. In RepRapFirmware, when not in laser mode S in interpreted the same as H.Examples
G0 X12               ; move to 12mm on the X axis
G0 F1500             ; Set the feedrate to 1500mm/min
G1 X90.6 Y13.8 E22.4 ; Move to 90.6mm on the X axis and 13.8mm on the Y axis while extruding 22.4mm of material

The RepRap firmware spec treats

N123
36 and
N123
48 as the same command, since it's just as efficient as not doing so.2

Most RepRap firmwares do subtle things with feedrates.

G1 F1500           ; Set feedrate to 1500mm/min
G1 X50 Y25.3 E22.4 ; Move and extrude

In the above example, we first set the feedrate to 1500mm/min, then move to 50mm on X and 25.3mm on Y while extruding 22.4mm of filament between the two points.

G1 F1500                 ; Feedrate 1500mm/min
G1 X50 Y25.3 E22.4 F3000 ; Accelerate to 3000mm/min

However, in the above example, we set a feedrate of 1500 mm/min, then do the same move, but accelerating to 3000 mm/min. Everything stays synchronized, so extrusion accelerates right along with X and Y movement.

The RepRap spec treats the feedrate as simply another variable (like X, Y, Z, and E) to be linearly interpolated. This gives complete control over the acceleration and deceleration of the printer head in a way that ensures everything moves smoothly together and the right volume of material is extruded at all points.3

To reverse the extruder by a given amount (for example to reduce its internal pressure while it does an in-air movement so that it doesn't dribble) simply use

N123
36 or
N123
48 to send an
N123
67 value that is less than the currently extruded length.

Notes

1Some firmwares allow for the RepRap to enable or disable the "sensing" of endstops during a move. Please check with whatever firmware you are using to see if they support the

N123
68 parameter in this way, as damage may occur if you assume incorrectly. In RepRapFirmware, using the
N123
57 or
N123
70 parameter on a delta printer causes the
N123
71 parameters to refer to the individual tower motor positions instead of the head position, and to enable endstop detection as well if the parameter is H1. H3 may be used to measure axis lengths and H4 can be used to stop when an endstop is hit while updating the position only (H4 is supported in 3.2-b4 and later).

2In the RS274NGC Spec,

N123
36 is Rapid Move, which was used to move between the current point in space and the new point as quickly and efficiently as possible, and
N123
48 is Controlled Move, which was used to move between the current point in space and the new point as precise as possible. In RepRapFirmware, G1 is always a linear move but G0 may not be linear (e.g. on a SCARA machine); however a G0 move will never go below the lower of the initial and final Z height of the move.

3Some firmwares may not support setting the feedrate inline with a move.

4RepRapFirmware provides an additional 'R' parameter to tell the machine to add the coordinates of the specified restore point to all axis coordinates mentioned in the G0 or G1 command. Axes that are not mentioned in the G0 or G1 command are not moved. When a print is paused, the coordinates are saved in restore point #1. When a tool change is commenced, the coordinates are saved in restore point #2. Coordinates can also be saved in restore points explicity using the G60 command.

Some older machines, CNC or otherwise, used to move faster if they did not move in a straight line. This is also true for some non-Cartesian printers, like delta or polar printers, which move easier and faster in a curve.

G2 & G3: Controlled Arc Move

Usage
N123
74 (Clockwise Arc)
N123
75 (Counter-Clockwise Arc)Parameters
N123
51 The position to move to on the X axis
N123
52 The position to move to on the Y axis
N123
78 The point in X space from the current X position to maintain a constant distance from
N123
79 The point in Y space from the current Y position to maintain a constant distance from
N123
54 The amount to extrude between the starting point and ending point
N123
55 The feedrate per minute of the move between the starting point and ending point (if supplied)Examples
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
0

(Move in a Clockwise arc from the current point to point (X=90.6,Y=13.8), with a center point at (X=current_X+5, Y=current_Y+10), extruding 22.4mm of material between starting and stopping)

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
1

(Move in a Counter-Clockwise arc from the current point to point (X=90.6,Y=13.8), with a center point at (X=current_X+5, Y=current_Y+10), extruding 22.4mm of material between starting and stopping)

Notes

1In Marlin Firmware not implemented for DELTA printers.

2Prusa Firmware implements arcs only in Cartesian XY.

3On Klipper, a

N123
82 section must be enabled in the configuration file.

G4: Dwell

Pause the machine for a period of time.

Parameters
N123
83 Time to wait, in milliseconds (In Teacup, P0, wait until all previous moves are finished)
N123
62 Time to wait, in seconds (Only on Repetier, Marlin, Prusa, Smoothieware, and RepRapFirmware 1.16 and later)Example
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
2

In this case sit still doing nothing for 200 milliseconds. During delays the state of the machine (for example the temperatures of its extruders) will still be preserved and controlled.

On Marlin, Smoothie and RepRapFirmware, the "S" parameter will wait for seconds, while the "P" parameter will wait for milliseconds. "G4 S2" and "G4 P2000" are equivalent.

G6: Direct Stepper Move

Perform a direct, uninterpolated, and non-kinematic synchronized move of one or more steppers directly. Units may be linear (e.g., mm or inches on

N123
85) or specified in degrees (SCARA). This command is useful for initialization, diagnostics, and calibration, and should be disabled on production equipment. This type of move can be potentially dangerous, especially for deltabots, so implementations should do their best to limit movement to prevent twerking and damaging the carriage assembly.

Parameters
N123
86 Stepper A position or angle
N123
87 Stepper B position or angle
N123
88 Stepper C position or angle
N123
89 Relative move flagSCARA Examples
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
3DELTA Example
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
4

G10: Set tool Offset and/or workplace coordinates and/or tool temperatures

Usage
N123
901Parameters
N123
83 Tool number
N123
92 Offset mode 5
N123
51 X offset
N123
52 Y offset
N123
53 Z offset2
N123
96 other axis offsets4
N123
61 Standby temperature(s) (RepRapFirmware)
N123
62 Active temperature(s) (RepRapFirmware)Examples
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
5

(sets the offset for tool 2 to the X, Y, and Z values specified)

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
6

(RepRapFirmware only - set standby and active temperatures3 for tool 1)

Remember that any parameter that you don't specify will automatically be set to the last value for that parameter. That usually means that you want explicitly to set Z0.0. RepRapFirmware will report the tool parameters if only the tool number is specified.

The precise meaning of the X, Y (and other offset) values is: with no offset this tool is at this position relative to where a tool with offset (0, 0, 0) would be. So if the tool is 10mm to the left of a zero-offset tool the X value would be -10, and so on.

The

N123
89 value is the standby temperature in oC that will be used for the tool, and the
N123 [...G Code in here...] *71
00 value is its operating temperature. If you don't want the tool to be at a different temperature when not in use, set both values the same. See the T code (select tool) below. In tools with multiple heaters the temperatures for them all are specified thus: R100.0:90.0:20.0 S185.0:200.0:150.0 .

See also

N123 [...G Code in here...] *71
01.

Notes

1Marlin uses G10/G11 for executing a retraction/unretraction move. Smoothie uses

N123 [...G Code in here...] *71
02 for retract and
N123 [...G Code in here...] *71
03 for setting workspace coordinates. RepRapFirmware interprets a G10 command with no P or L parameter as a retraction command.

2It's usually a bad idea to put a non-zero

N123 [...G Code in here...] *71
04 value in as well unless the tools are loaded and unloaded by some sort of tool changer or are on indepedent carriages. When all the tools are in the machine at once they should all be set to the same Z height.

3If the absolute zero temperature (-273.15) is passed as active and standby temperatures, RepRapFirmware will only switch off the tool heater(s) without changing their preset active or standby temperatures. RepRapFirmware-dc42 does not support this setting.

4Tool offsets are applied after any X axis mapping has been performed. Therefore if for example you map X to U in your

N123 [...G Code in here...] *71
05 command to create the tool, you should specify a U offset not an X offset. If you map X to both X and U, you can specify both offsets. (Not supported on all firmwares).

5L1 sets the offsets of the specified tool relative to the head reference point to the specified values. L2 sets the current workplace coordinate offsets to the specified values. L20 adjusts the current workplace coordinate offsets so that the current tool head position has the specified coordinates. NOTE on some firmwares L is required (and is required by NIST standard). P is also required to specify either the tool to update or the WCS to update.

G10: Retract

Parameters
N123
62 retract length (S1 = long retract, S0 = short retract = default) (Repetier only)Example
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
7

Retracts filament according to settings of

N123 [...G Code in here...] *71
07 (Marlin, RepRapFirmware) or according to the
N123 [...G Code in here...] *71
00 value (Repetier).

RepRapFirmware recognizes

N123 [...G Code in here...] *71
02 as a command to set tool offsets and/or temperatures if the
N123 [...G Code in here...] *71
10 parameter is present, and as a retraction command if it is absent.

G11: Unretract

Parameters
N123
62 retract length (S1 = long retract, S0 = short retract = default) (Repetier only)Example
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
8

Unretracts/recovers filament according to settings of

N123 [...G Code in here...] *71
12 (Marlin, RepRapFirmware) or according to the
N123 [...G Code in here...] *71
00 value (Repetier).

G12: Clean Tool

Usage
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
9
N123 [...G Code in here...] *71
14Parameters
N123
831 Pattern style selection
N123
62 Number of strokes (i.e. back-and-forth movements)
N123 [...G Code in here...] *71
17 Number of repetitions
N123
54 0=Never 1=Always apply software endstops (Marlin 2.0.6+)Examples

G12 ; stroke pattern (default)

To generate a three triangle zig-zag pattern which will be stroked three times time use the following command. G12 P1 S3 T2 ; zig-zag pattern with 2 triangles

Notes

1In Marlin firmware and Derivatives Mk4duo this is implemented by hard-coded firmware behaviours As defined for variables NOZZLE_CLEAN_STROKES, NOZZLE_CLEAN_START_POINT, NOZZLE_CLEAN_END_POINT and NOZZLE_CLEAN_PARK.

With NOZZLE_CLEAN_PARK enabled, the nozzle will automatically return to the XYZ position after G12 is run.

More on this behaviour is documented inside of the code base.

The use of G12 for tool cleaning clashes with the established use of G12 for circular pocket milling on CNC machines. For this reason, RepRapFirmware does not support G12.

G17..19: Plane Selection (CNC specific)

These codes set the current plane as follows:

  • N123 [...G Code in here...] *71
    
    19 : XY (default)
  • N123 [...G Code in here...] *71
    
    20 : ZX
  • N123 [...G Code in here...] *71
    
    21 : YZ

This mode applies to

N123 [...G Code in here...] *71
22/
N123
37 arc moves. Normal arc moves are in the XY plane, and for most applications that's all you need. For CNC routing it can be useful to do small "digging" moves while making cuts, so to keep the G-code compact it uses
N123 [...G Code in here...] *71
22/
N123
37 arcs involving the Z plane.

These commands are supported in Marlin 1.1.4 and later with

N123 [...G Code in here...] *71
26 and
N123 [...G Code in here...] *71
27 enabled.

G20: Set Units to Inches

Example
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
0

Units from now on are in inches. In RepRapFirmware, the inches/mm setting applies to regular printing and travel moves (G0, G1, G2 etc.) but not to configuration commands. Therefore configuration should be done in mm.

When executing a macro file, RepRapFirmware remembers the initial inches/mm setting and restores it after execution of the macro has completed.

G21: Set Units to Millimeters

Example
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
1

Units from now on are in millimeters. (This is the RepRap default.)

In RepRapFirmware, the inches/mm setting applies to regular printing and travel moves (G0, G1, G2 etc.) but not to configuration commands. Therefore configuration should be done in mm.

When executing a macro file, RepRapFirmware remembers the initial inches/mm setting and restores it after execution of the macro has completed. So a macro file such as pause.g (executed when a pause command is received) can safely use G21 at the start to switch the units to mm without affecting the job after the macro completes, regardless of whether the job was using inches or mm.

G22: Firmware Retract

Usage
N123 [...G Code in here...] *71
28

Use this command (along with

N123 [...G Code in here...] *71
29) to have the firmware to do retraction moves (in contrast to generating an E axis
N123
48 move). The retract length and speed are set in the firmware.

G23: Firmware Recover

Usage
N123 [...G Code in here...] *71
31

Use this command (along with

N123 [...G Code in here...] *71
32) to have the firmware to do a recover move. The recover length and speed are set in the firmware.

G26: Mesh Validation Pattern

Usage
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
2

The

N123 [...G Code in here...] *71
33 Mesh Validation Pattern is designed to be used in conjunction with various Mesh Bed Leveling systems – those that adjust for an uneven —rather than just tilted— bed. The
N123 [...G Code in here...] *71
33 command prints a single layer pattern over the entire print bed, giving a clear indication of how accurately every mesh point is defined.
N123 [...G Code in here...] *71
33 can be used to determine which areas of the mesh are less-than-perfect and how much to adjust each mesh point.

N123 [...G Code in here...] *71
33 has large feature list, including a built-in test that extrudes material onto the bed. By default this is configured for PLA temperatures and a nozzle size of 0.4mm. (This will be adjustable in an upcoming version of Marlin.)

See the

N123 [...G Code in here...] *71
37 file in the Marlin source code for full documentation of the
N123 [...G Code in here...] *71
33 parameter list.

G27: Park toolhead

Park the toolhead (i.e., nozzle) at a predefined XY position, with a Z raise value that applies over 0 or over the current position depending on the

N123 [...G Code in here...] *71
10 parameter.

In Marlin this G-code is enabled by

N123 [...G Code in here...] *71
40 and the park position is defined by
N123 [...G Code in here...] *71
41. See G27 Park Toolhead for details.

Usage
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
3

G28: Move to Origin (Home)

ParametersThis command can be used without any additional parameters.
N123 [...G Code in here...] *71
42 Flag to go back to the X axis origin
N123 [...G Code in here...] *71
43 Flag to go back to the Y axis origin
N123 [...G Code in here...] *71
04 Flag to go back to the Z axis origin
N123 [...G Code in here...] *71
10 Reserved by Prusa
N123 [...G Code in here...] *71
46 Reserved by PrusaExamples
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
4

When the firmware receives this command, it quickly moves the specified axes (or all axes if none are given) to the endstops, backs away from each endstop by a short distance, and slowly bumps the endstop again to increase positional accuracy. This process, known as "Homing", is required to determine the position of the print carriage(s). Some firmware may even forbid movement away from endstops and other operations until the axes have been homed.

The

N123 [...G Code in here...] *71
42,
N123 [...G Code in here...] *71
43, and
N123 [...G Code in here...] *71
04 parameters act only as flags. Any coordinates given are ignored. For example,
N123 [...G Code in here...] *71
50 results in the same behavior as
N123 [...G Code in here...] *71
51. Delta printers cannot home individual axes, but must always home all three towers, so the
N123 [...G Code in here...] *71
52 parameters are simply ignored on these machines.

Marlin firmware (version 1.1.0 and later) provides an option called

N123 [...G Code in here...] *71
53 for printers that use a Z probe to home Z instead of an endstop. With this option, the XY axes are homed first, then the carriage moves to a position –usually the middle of the bed– where it can safely probe downward to home Z.

RepRapFirmware uses macro files to home either all axes or individual axes. If all axes are homed, the file

N123 [...G Code in here...] *71
54 is processed. For individual axes the
N123 [...G Code in here...] *71
55,
N123 [...G Code in here...] *71
56, or
N123 [...G Code in here...] *71
57 file will be used. On Delta printers,
N123
38 command will always home all three towers by processing the
N123 [...G Code in here...] *71
59 file, regardless of any
N123 [...G Code in here...] *71
42
N123 [...G Code in here...] *71
43
N123 [...G Code in here...] *71
04 parameters.

Because the behavior of

N123
38 is unspecified, it is recommended not to automatically include
N123
38 in your ending G-code. On a Cartesian this will result in damaging the printed object. If you need to move the carriage at the completion of a print, use
N123
36 or
N123
48.

Notes

1 MK4duo has a

N123 [...G Code in here...] *71
67 parameter that tells the printer to return to the coordinates it was at before homing.
2 Original Prusa i3 MK2/s, MK2.5/s, MK3/s supports a
N123 [...G Code in here...] *71
68 parameter to suppress mesh bed leveling. If
N123 [...G Code in here...] *71
68 is omitted, G28 will home only and NOT perform mesh bed leveling. Original Prusa i3 MK3/s (TMC2130 drivers) supports a
N123 [...G Code in here...] *71
70 parameter to calibrate the X and Y home position.

N123 [...G Code in here...] *71
68 Suppress mesh bed leveling (Prusa MK2/s, MK2.5/s and MK3/s only)2
N123 [...G Code in here...] *71
70 Calibrate X and Y home position (Prusa MK3/s only)2

G29: Detailed Z-Probe

This command uses a probe to measure the bed height at 3 or more points to determine its tilt and overall flatness. It then enables compensation so that the nozzle will remain parallel to the bed. The printer must be homed with

N123
38 before using this command.

Each firmware behaves differently and depends on the type of bed leveling that's been configured. For example, Marlin 1.0.2 provides 3 different types of automatic bed leveling (probe required) and a manual bed leveling option. See your firmware's documentation for the specific options available.

Usage
N123 [...G Code in here...] *71
74
N123 [...G Code in here...] *71
75Parameters
N123
62 Firmware-dependent behavior
N123 [...G Code in here...] *71
77 Optional file name for bed height map file (RepRapFirmware only)Examples
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
5
G29 Auto Bed Leveling (Marlin - MK4duo)

Marlin 1.0.2 and earlier provides three options for automatic bed leveling:

  • The 3-point method probes the bed at three points to produce a matrix, adjusting for a flat but tilted bed.
  • The planar grid method (non-Delta) probes a grid pattern to produce a matrix by the "least-squares" method, adjusting for a flat but tilted bed.
  • The bilinear grid method (Delta only) probes a grid pattern to produce a mesh, using bilinear interpolation to adjust for an uneven bed.

Marlin 1.1.0 and later allows the bilinear grid (i.e., "mesh") method to be used on all types of machines, not just deltas. This is the recommended leveling method going forward.

Also in Marlin 1.1.0 and later, the

N123 [...G Code in here...] *71
78 option allows all forms of Auto Bed Leveling to be used without a probe. The procedure is similar to that of
N123 [...G Code in here...] *71
79 (see below). Begin the process with
N123 [...G Code in here...] *71
74 to move the nozzle to the first point. Adjust the Z axis using
N123
48 or your host software. Send
N123 [...G Code in here...] *71
74 again to move to the next point and repeat until all points have been sampled.

Parameters
N123 [...G Code in here...] *71
10 Set the size of the grid that will be probed (P x P points). Not supported by non-linear delta printer bed leveling. Example:
N123 [...G Code in here...] *71
84
N123 [...G Code in here...] *71
00 Set the XY travel speed between probe points (in units/min)
N123 [...G Code in here...] *71
86 Dry-Run mode. Just evaluate the bed Topology - Don't apply or clean the rotation Matrix. Useful to check the topology after a first run of G29.
N123 [...G Code in here...] *71
87 Set the verbose level (0-4). Example:
N123 [...G Code in here...] *71
88
N123
46 Generate a Bed Topology Report. Example:
N123 [...G Code in here...] *71
90 for a detailed report. This is useful for manual bed leveling and finding flaws in the bed (to assist with part placement). Not supported by non-linear delta printer bed leveling.
N123 [...G Code in here...] *71
91 Set the Front limit of the probing grid
N123 [...G Code in here...] *71
67 Set the Back limit of the probing grid
N123 [...G Code in here...] *71
93 Set the Left limit of the probing grid
N123
89 Set the Right limit of the probing gridGlobal Parameters
N123
67 By default
N123 [...G Code in here...] *71
74 will engage the Z probe, test the bed, then disengage. Include
N123
67 or
N123 [...G Code in here...] *71
98 to engage/disengage the Z probe for each sample. (This has no effect for fixed probes.)
G29 Unified Bed Leveling (Marlin - MK4duo)

Marlin firmware (version 1.1.0 and later) includes the

N123 [...G Code in here...] *71
99 option for Unified Bed Leveling. UBL combines mesh leveling, tilted plane adjustment, 3-point leveling, and manual editing tools all together in a single package. To accomplish so much, UBL overloads `G29` with several new parameters and provides an additional
N123 [...G Code in here...] *71
33 Mesh Tuning feature.

See the MarlinFW website for a dedicated Unified Bed Leveling page and complete documentation on `G29` for UBL and `G26` Mesh Validation.

G29 UBL Parameters (synopsis)
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
6
G29 Manual Bed Leveling (Marlin - MK4duo)

Marlin firmware (version 1.0.2 and later) also provides a

N123 [...G Code in here...] *71
79 feature that can be used to perform bed leveling on machines lacking a probe. This form of bed leveling compensates for uneven Z height across the surface of the bed using a mesh and bilinear interpolation.

Manual Bed Leveling Usage
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
7Options for the
N123 [...G Code in here...] *71
00 parameter
int cs = 0;
for(i = 0; cmd[i] != '*' && cmd[i] != NULL; i++)
   cs = cs ^ cmd[i];
cs &= 0xff;  // Defensive programming...
03 Produces a mesh report
int cs = 0;
for(i = 0; cmd[i] != '*' && cmd[i] != NULL; i++)
   cs = cs ^ cmd[i];
cs &= 0xff;  // Defensive programming...
04 Start probing mesh points
int cs = 0;
for(i = 0; cmd[i] != '*' && cmd[i] != NULL; i++)
   cs = cs ^ cmd[i];
cs &= 0xff;  // Defensive programming...
05 Probe the next mesh point
int cs = 0;
for(i = 0; cmd[i] != '*' && cmd[i] != NULL; i++)
   cs = cs ^ cmd[i];
cs &= 0xff;  // Defensive programming...
06 Manually modify a single point
int cs = 0;
for(i = 0; cmd[i] != '*' && cmd[i] != NULL; i++)
   cs = cs ^ cmd[i];
cs &= 0xff;  // Defensive programming...
07 Set z offset. Positive away from bed, negative closer to bed.
G29 Auto Bed Leveling (Repetier-Firmware)

Repetier firmware since v0.91 supports

N123 [...G Code in here...] *71
74 with the optional Snnn parameter as described below. Useful to simply detect the Z bed angle so you can manually readjust your bed and get it as close to in plane as possible. If you wish to apply automatic software Z plane compensation on Repetier, use
N123
39 instead with firmware 0.92.8 and above.

int cs = 0;
for(i = 0; cmd[i] != '*' && cmd[i] != NULL; i++)
   cs = cs ^ cmd[i];
cs &= 0xff;  // Defensive programming...
03 Default value. Z bed heights are calculated at the measured points, relative to current Z position before issuing
N123 [...G Code in here...] *71
74.
int cs = 0;
for(i = 0; cmd[i] != '*' && cmd[i] != NULL; i++)
   cs = cs ^ cmd[i];
cs &= 0xff;  // Defensive programming...
04 Same as
int cs = 0;
for(i = 0; cmd[i] != '*' && cmd[i] != NULL; i++)
   cs = cs ^ cmd[i];
cs &= 0xff;  // Defensive programming...
03, except printer immediately moves to Z maximum position (Z max endstop required!), and calculates new Z maximum height. You must first issue
int cs = 0;
for(i = 0; cmd[i] != '*' && cmd[i] != NULL; i++)
   cs = cs ^ cmd[i];
cs &= 0xff;  // Defensive programming...
14 to home to Z maximum position before issuing
N123 [...G Code in here...] *71
75 for this to work correctly, or the printer height will be invalid.
int cs = 0;
for(i = 0; cmd[i] != '*' && cmd[i] != NULL; i++)
   cs = cs ^ cmd[i];
cs &= 0xff;  // Defensive programming...
05 Same as
int cs = 0;
for(i = 0; cmd[i] != '*' && cmd[i] != NULL; i++)
   cs = cs ^ cmd[i];
cs &= 0xff;  // Defensive programming...
04, except new calculated Z height is also stored to EEPROM.
G29 Mesh Bed Compensation (RepRapFirmware)

RepRapFirmware:

int cs = 0;
for(i = 0; cmd[i] != '*' && cmd[i] != NULL; i++)
   cs = cs ^ cmd[i];
cs &= 0xff;  // Defensive programming...
03 (default if no
N123 [...G Code in here...] *71
00 parameter) Probe the bed, save the height map in a file on the SD card, and activate the height map. The default folder for the height map file is
int cs = 0;
for(i = 0; cmd[i] != '*' && cmd[i] != NULL; i++)
   cs = cs ^ cmd[i];
cs &= 0xff;  // Defensive programming...
20 and the default file name is
int cs = 0;
for(i = 0; cmd[i] != '*' && cmd[i] != NULL; i++)
   cs = cs ^ cmd[i];
cs &= 0xff;  // Defensive programming...
21.
int cs = 0;
for(i = 0; cmd[i] != '*' && cmd[i] != NULL; i++)
   cs = cs ^ cmd[i];
cs &= 0xff;  // Defensive programming...
04 Load the height map from file and activate bed compensation. The default folder and filename as for
int cs = 0;
for(i = 0; cmd[i] != '*' && cmd[i] != NULL; i++)
   cs = cs ^ cmd[i];
cs &= 0xff;  // Defensive programming...
03.
int cs = 0;
for(i = 0; cmd[i] != '*' && cmd[i] != NULL; i++)
   cs = cs ^ cmd[i];
cs &= 0xff;  // Defensive programming...
05 Clear the currently-loaded bed height map

To define the grid, see M557.

In RepRapFirmware 3.2 and later, G29 runs macro file mesh.g if it exists, otherwise it behaves like G29 S0. The mesh.g file can perform other actions (e.g. homing or tool selection) and then use G29 S0 to do the probing.

Notes

In Prusa Firmware

N123 [...G Code in here...] *71
74 is not active by default, instead G81 is used.1

G29.1: Set Z probe head offset

Example
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
8

Set the offset of the Z probe head. The offset will be subtracted from all probe moves.

G29.2: Set Z probe head offset calculated from toolhead position

Example
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
9

Set the offset of the Z probe head. The offset will be subtracted from all probe moves. The calculated value is derived from the distance of the toolhead from the current axis zero point.

The user would typically place the toolhead at the zero point of the axis and issue the

int cs = 0;
for(i = 0; cmd[i] != '*' && cmd[i] != NULL; i++)
   cs = cs ^ cmd[i];
cs &= 0xff;  // Defensive programming...
26 command.

G30: Single Z-Probe

Usage
int cs = 0;
for(i = 0; cmd[i] != '*' && cmd[i] != NULL; i++)
   cs = cs ^ cmd[i];
cs &= 0xff;  // Defensive programming...
27Parameters
N123
83 Probe point number
N123
51 X coordinate
N123
52 Y coordinate
N123
53 Z coordinate
N123
56 Height correction
N123
62 Set parameterExample
(Home some axes)
G28 (here come the axes to be homed) X Y
0Examples (RepRapFirmware)
(Home some axes)
G28 (here come the axes to be homed) X Y
1

In its simplest form probes bed at current XY location.

RepRapFirmware supports additional behaviour: if a

int cs = 0;
for(i = 0; cmd[i] != '*' && cmd[i] != NULL; i++)
   cs = cs ^ cmd[i];
cs &= 0xff;  // Defensive programming...
34 field is specified the probed
N123 [...G Code in here...] *71
42,
N123 [...G Code in here...] *71
43, and
N123 [...G Code in here...] *71
04 values are saved as point n on the bed for calculating the offset plane or for performing delta printer calibration. If
N123 [...G Code in here...] *71
42,
N123 [...G Code in here...] *71
43, or
N123 [...G Code in here...] *71
04 values are specified (e.g.
int cs = 0;
for(i = 0; cmd[i] != '*' && cmd[i] != NULL; i++)
   cs = cs ^ cmd[i];
cs &= 0xff;  // Defensive programming...
41) then those values are used instead of the machine's current coordinates. A silly
N123 [...G Code in here...] *71
04 value (less than -9999.0) causes the machine to probe at the current point to get Z, rather than using the given value. If an S field is specified (e.g.
int cs = 0;
for(i = 0; cmd[i] != '*' && cmd[i] != NULL; i++)
   cs = cs ^ cmd[i];
cs &= 0xff;  // Defensive programming...
43) the bed plane is computed for compensation and stored. The combination of these options allows for the machine to be moved to points using
N123
48 commands, and then probe the bed, or for the user to position the nozzle interactively and use those coordinates. The user can also record those values and place them in a setup G-code file for automatic execution.

RepRapFirmware uses the value of the

N123 [...G Code in here...] *71
00 parameter to specify what computation to perform. If the value is -1 then the Z offsets of all the points probed are printed, but no calibration is done. If the value is zero or not present, then this specifies that the number of factors to be calibrated is the same as the number of points probed. Otherwise, the value indicates the number of factors to be calibrated, which must be no greater than the number of points probed. In version 1.09, the number of factors may be 3, 4 or 5 when doing auto bed compensation on a Cartesian or CoreXY printer, and 3, 4, 6 or 7 when doing auto calibration of a Delta printer.

RepRapFirmware supports an optional

N123
68 parameter, which is a height correction for that probe point. It allows for the Z probe having a trigger height that varies with XY position. The nominal trigger height of the Z probe (e.g. at bed centre) is declared in the
N123 [...G Code in here...] *71
04 parameter of the
int cs = 0;
for(i = 0; cmd[i] != '*' && cmd[i] != NULL; i++)
   cs = cs ^ cmd[i];
cs &= 0xff;  // Defensive programming...
48 command in the config.g file. When you probe using
int cs = 0;
for(i = 0; cmd[i] != '*' && cmd[i] != NULL; i++)
   cs = cs ^ cmd[i];
cs &= 0xff;  // Defensive programming...
49 and the probe triggers, the firmware will assume that the nozzle is at the nominal trigger height plus the value you have in the
N123
68 parameter.

1MK4duo Firmware support an optional parameter for Delta.

Usage
int cs = 0;
for(i = 0; cmd[i] != '*' && cmd[i] != NULL; i++)
   cs = cs ^ cmd[i];
cs &= 0xff;  // Defensive programming...
51Parameters
N123
51 X coordinate
N123
52 Y coordinate
int cs = 0;
for(i = 0; cmd[i] != '*' && cmd[i] != NULL; i++)
   cs = cs ^ cmd[i];
cs &= 0xff;  // Defensive programming...
54 Stows the probe if 1 (default=1)
int cs = 0;
for(i = 0; cmd[i] != '*' && cmd[i] != NULL; i++)
   cs = cs ^ cmd[i];
cs &= 0xff;  // Defensive programming...
55with a non-zero value will apply the result to current delta_height
int cs = 0;
for(i = 0; cmd[i] != '*' && cmd[i] != NULL; i++)
   cs = cs ^ cmd[i];
cs &= 0xff;  // Defensive programming...
34with a non-zero value will apply the result to current zprobe_zoffsetNotes

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

G31: Set or Report Current Probe status

Usage
int cs = 0;
for(i = 0; cmd[i] != '*' && cmd[i] != NULL; i++)
   cs = cs ^ cmd[i];
cs &= 0xff;  // Defensive programming...
57Parameters
N123
83 Trigger value
N123
51 Probe X offset1
N123
52 Probe Y offset1
N123
53 Trigger Z height
N123
88 Temperature coefficient(s) of trigger height2
N123
62 Calibration temperature2
N123 [...G Code in here...] *71
17 (RepRapFirmware 1.17 and later) Z probe type to which these parameters apply, defaults to the current Z probe type as defined by
int cs = 0;
for(i = 0; cmd[i] != '*' && cmd[i] != NULL; i++)
   cs = cs ^ cmd[i];
cs &= 0xff;  // Defensive programming...
65 parameterExamples
(Home some axes)
G28 (here come the axes to be homed) X Y
2

When used on its own this reports whether the Z probe is triggered, or gives the Z probe value in some units if the probe generates height values. If combined with a Z and P field (example:

int cs = 0;
for(i = 0; cmd[i] != '*' && cmd[i] != NULL; i++)
   cs = cs ^ cmd[i];
cs &= 0xff;  // Defensive programming...
66) this will set the Z height to 0.7mm when the Z-probe value reaches 312 when a
int cs = 0;
for(i = 0; cmd[i] != '*' && cmd[i] != NULL; i++)
   cs = cs ^ cmd[i];
cs &= 0xff;  // Defensive programming...
67 (zero Z axis) command is sent. The machine will then move a further -0.7mm in Z to place itself at Z = 0. This allows non-contact measuring probes to approach but not touch the bed, and for the gap left to be allowed for. If the probe is a touch probe and generates a simple 0/1 off/on signal, then
int cs = 0;
for(i = 0; cmd[i] != '*' && cmd[i] != NULL; i++)
   cs = cs ^ cmd[i];
cs &= 0xff;  // Defensive programming...
68 will tell the RepRap machine that it is at a height of 0.7mm when the probe is triggered.

In RepRapFirmware, separate

int cs = 0;
for(i = 0; cmd[i] != '*' && cmd[i] != NULL; i++)
   cs = cs ^ cmd[i];
cs &= 0xff;  // Defensive programming...
48 parameters may be defined for different probe types (i.e. 0+4 for switches, 1+2 for IR probes and 3 for alternative sensors). To specify which probe you are setting parameters for, send a M558 command to select the probe type before sending the
int cs = 0;
for(i = 0; cmd[i] != '*' && cmd[i] != NULL; i++)
   cs = cs ^ cmd[i];
cs &= 0xff;  // Defensive programming...
48 command, or use the
N123
46 parameter.

In Repetier,

int cs = 0;
for(i = 0; cmd[i] != '*' && cmd[i] != NULL; i++)
   cs = cs ^ cmd[i];
cs &= 0xff;  // Defensive programming...
48 supports no parameters and simply prints the high/low status of the Z probe.

Notes

1X and Y offsets of the Z probe relative to the print head (i.e. the position when the empty tool is selected) can be specified in RepRapFirmware. This allows you to calculate your probe coordinates based on the geometry of the bed, without having to correct them for Z probe X and Y offset.

2In RepRapFirmware, additional parameters 'S' (bed temperature in oC at which the specified

N123 [...G Code in here...] *71
04 parameter is correct, default is current bed temperature) and 'C' (temperature coefficient of
N123 [...G Code in here...] *71
04 parameter in mm/oC, default zero) can be set for the alternative (ultrasonic) sensor. This is useful for probes that are affected by temperature such as PINDA. RepRapFirmware 3.1 and later allow both first and second order temperature coefficients to be specified, e.g. C0.015:0.001.

G31: Dock Z Probe sled

Notes

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

G32: Probe Z and calculate Z plane

Usage
(Home some axes)
G28 (here come the axes to be homed) X Y
3

This command is implemented as a more sophisticated form of bed leveling (which uses a transformation matrix or motorized correction. Smoothieware uses this code instead of `G29`.

Each firmware behaves differently. For example, Repetier firmware allows for motorized rotation of the bed whilst ReprapFirmware probes the bed with a transformation matrix.

Probe and calculate in Reprapfirmware

RepRapFirmware executes macro file

int cs = 0;
for(i = 0; cmd[i] != '*' && cmd[i] != NULL; i++)
   cs = cs ^ cmd[i];
cs &= 0xff;  // Defensive programming...
75 in response to the G31 command. The
int cs = 0;
for(i = 0; cmd[i] != '*' && cmd[i] != NULL; i++)
   cs = cs ^ cmd[i];
cs &= 0xff;  // Defensive programming...
75 file is typically used to probe the bed and then perform delta calibration if the printer is a delta, or to perform individual leadscrew adjustment to level the bed if the printer has multiple independently-controlled Z motors, or to advise the user on how much to adjust each bed levelling adjustment screw.

Probe and calculate in Repetier firmware

This command probes the bed at 3 or more pre-defined points and implements bed leveling compensation by either moving the A axis during printing (as with regular bed leveling,

N123 [...G Code in here...] *71
74) or by tilting the bed with motors.

Parameters
N123
62 Bed leveling method
N123
83 Bed correction method

The values for Snnn and Pnnn are as follows:

int cs = 0;
for(i = 0; cmd[i] != '*' && cmd[i] != NULL; i++)
   cs = cs ^ cmd[i];
cs &= 0xff;  // Defensive programming...
03 This method measures at the 3 probe points and creates a plane through these points. If you have a really planar bed this gives the optimum result. The 3 points must not be in one line and have a long distance to increase numerical stability.
int cs = 0;
for(i = 0; cmd[i] != '*' && cmd[i] != NULL; i++)
   cs = cs ^ cmd[i];
cs &= 0xff;  // Defensive programming...
04 This measures a grid. Probe point 1 is the origin and points 2 and 3 span a grid. We measure BED_LEVELING_GRID_SIZE points in each direction and compute a regression plane through all points. This gives a good overall plane if you have small bumps measuring inaccuracies.
int cs = 0;
for(i = 0; cmd[i] != '*' && cmd[i] != NULL; i++)
   cs = cs ^ cmd[i];
cs &= 0xff;  // Defensive programming...
05 Bending correcting 4 point measurement. This is for cantilevered beds that have the rotation axis not at the side but inside the bed. Here we can assume no bending on the axis and a symmetric bending to both sides of the axis. So probe points 2 and 3 build the symmetric axis and point 1 is mirrored to 1m across the axis. Using the symmetry we then remove the bending from 1 and use that as plane.
int cs = 0;
for(i = 0; cmd[i] != '*' && cmd[i] != NULL; i++)
   cs = cs ^ cmd[i];
cs &= 0xff;  // Defensive programming...
83 Use a rotation matrix. This will make z axis go up/down while moving in x/y direction to compensate the tilt. For multiple extruders make sure the height match the tilt of the bed or one will scratch. This is the default.
int cs = 0;
for(i = 0; cmd[i] != '*' && cmd[i] != NULL; i++)
   cs = cs ^ cmd[i];
cs &= 0xff;  // Defensive programming...
84 Motorized correction. This method needs a bed that is fixed on 3 points from which 2 have a motor to change the height. The positions are defined in firmware by BED_MOTOR_1_X, BED_MOTOR_1_Y, BED_MOTOR_2_X, BED_MOTOR_2_Y, BED_MOTOR_3_X, BED_MOTOR_3_Y Motor 2 and 3 are the one driven by motor driver 0 and 1. These can be extra motors like Felix Pro 1 uses them or a system with 3 z axis where motors can be controlled individually like the Sparkcube does. This method requires a Z max endstop.

G32: Undock Z Probe sled

Notes

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

G33: Firmware dependent

G33: Measure/List/Adjust Distortion Matrix (Repetier - Redeem)
Usage
int cs = 0;
for(i = 0; cmd[i] != '*' && cmd[i] != NULL; i++)
   cs = cs ^ cmd[i];
cs &= 0xff;  // Defensive programming...
85
int cs = 0;
for(i = 0; cmd[i] != '*' && cmd[i] != NULL; i++)
   cs = cs ^ cmd[i];
cs &= 0xff;  // Defensive programming...
86
int cs = 0;
for(i = 0; cmd[i] != '*' && cmd[i] != NULL; i++)
   cs = cs ^ cmd[i];
cs &= 0xff;  // Defensive programming...
87
int cs = 0;
for(i = 0; cmd[i] != '*' && cmd[i] != NULL; i++)
   cs = cs ^ cmd[i];
cs &= 0xff;  // Defensive programming...
88Parameters
int cs = 0;
for(i = 0; cmd[i] != '*' && cmd[i] != NULL; i++)
   cs = cs ^ cmd[i];
cs &= 0xff;  // Defensive programming...
89 List distortion matrix in a report
int cs = 0;
for(i = 0; cmd[i] != '*' && cmd[i] != NULL; i++)
   cs = cs ^ cmd[i];
cs &= 0xff;  // Defensive programming...
90 Reset distortion matrix
int cs = 0;
for(i = 0; cmd[i] != '*' && cmd[i] != NULL; i++)
   cs = cs ^ cmd[i];
cs &= 0xff;  // Defensive programming...
91 Set correction for nearest pointExamples
(Home some axes)
G28 (here come the axes to be homed) X Y
4

When used with no parameters,

int cs = 0;
for(i = 0; cmd[i] != '*' && cmd[i] != NULL; i++)
   cs = cs ^ cmd[i];
cs &= 0xff;  // Defensive programming...
85 will measure a grid of points and store the distortion dips and valleys in the bed surface, and then enable software distortion correction for the first few or several layers. The values will be stored in EEPROM if enabled in firmware. You must previously have
N123
38 homed, and your Z minimum/maximum height must be set correctly for this to work. Use the optional parameters to list, reset or modify the distortion settings. Distortion correction behavior can be later turned on or off by code
int cs = 0;
for(i = 0; cmd[i] != '*' && cmd[i] != NULL; i++)
   cs = cs ^ cmd[i];
cs &= 0xff;  // Defensive programming...
94.

G33: Delta Auto Calibration (Marlin 1.1.x - MK4duo)

End-stops and tower angle corrections are normalized (P0);

Performs a 1-4-7 point calibration of delta height (P1), end-stops, delta radius (P2) and tower angle corrections (P>=3) by a least squares iteration process based on the displacement method.

Usage
int cs = 0;
for(i = 0; cmd[i] != '*' && cmd[i] != NULL; i++)
   cs = cs ^ cmd[i];
cs &= 0xff;  // Defensive programming...
85
int cs = 0;
for(i = 0; cmd[i] != '*' && cmd[i] != NULL; i++)
   cs = cs ^ cmd[i];
cs &= 0xff;  // Defensive programming...
96Parameters
int cs = 0;
for(i = 0; cmd[i] != '*' && cmd[i] != NULL; i++)
   cs = cs ^ cmd[i];
cs &= 0xff;  // Defensive programming...
34 Number of probe points: n*n (n= 0-10), when P is omitted the default set in Configuration.h is used.
N123
46 Do not calibrate tower angle corrections (if used with P>=3); do not use the probe points near the towers, but the probe points opposite to the towers (if used with P=2)
int cs = 0;
for(i = 0; cmd[i] != '*' && cmd[i] != NULL; i++)
   cs = cs ^ cmd[i];
cs &= 0xff;  // Defensive programming...
99 Force the iterations to stop when a standard deviation from the zero plane less then x.xx mm is achieved; when C is omitted the iterations go on until the best possible standard deviation is reached.
G0 X12               ; move to 12mm on the X axis
G0 F1500             ; Set the feedrate to 1500mm/min
G1 X90.6 Y13.8 E22.4 ; Move to 90.6mm on the X axis and 13.8mm on the Y axis while extruding 22.4mm of material
00 Force to run at least n iterations (n=1-30) and take the best result
G0 X12               ; move to 12mm on the X axis
G0 F1500             ; Set the feedrate to 1500mm/min
G1 X90.6 Y13.8 E22.4 ; Move to 90.6mm on the X axis and 13.8mm on the Y axis while extruding 22.4mm of material
01 Verbose level: (n=0-3) 0 = dry run without calibration; 1(default) = settings at start and end; 2 = settings at all iterations; 3 = settings and probe results
N123
67 Engage the probe for each point
G0 X12               ; move to 12mm on the X axis
G0 F1500             ; Set the feedrate to 1500mm/min
G1 X90.6 Y13.8 E22.4 ; Move to 90.6mm on the X axis and 13.8mm on the Y axis while extruding 22.4mm of material
03 Do not probe at the required kinematic points but at positions offseted to the probe-offsets 1
N123
89 Temporary reduce the size of the probe grid by the specified amount (mm) 1Notes

1 since 2.0.9.2

Examples
(Home some axes)
G28 (here come the axes to be homed) X Y
5
(Home some axes)
G28 (here come the axes to be homed) X Y
6
(Home some axes)
G28 (here come the axes to be homed) X Y
7
(Home some axes)
G28 (here come the axes to be homed) X Y
8
(Home some axes)
G28 (here come the axes to be homed) X Y
9

note: Height = delta height; Ex, Ey, Ez = end-stop corrections; Radius = delta radius; Tx, Ty, Tz = tower angular corrections; c, x, y, z, yz, zx, xy = probe results at center, towers and opposite to towers; std dev = standard deviation of the probe results towards the zero plane.

G34: Z Stepper Auto-Align

Use multiple Z steppers and a probe to align Z axis connection points. See

G0 X12               ; move to 12mm on the X axis
G0 F1500             ; Set the feedrate to 1500mm/min
G1 X90.6 Y13.8 E22.4 ; Move to 90.6mm on the X axis and 13.8mm on the Y axis while extruding 22.4mm of material
05 for other options.

Example
N123
0

G34: Calculate Delta Height from toolhead position (DELTA)

Example
N123
1

The values specified are added to the calculated end stop position when the axes are referenced. The calculated value is derived from the distance of the toolhead from the current axis zero point. The user would typically place the toolhead at the zero point of the axis and issue the

G0 X12               ; move to 12mm on the X axis
G0 F1500             ; Set the feedrate to 1500mm/min
G1 X90.6 Y13.8 E22.4 ; Move to 90.6mm on the X axis and 13.8mm on the Y axis while extruding 22.4mm of material
06 command. This value can be saved to EEPROM using the
G0 X12               ; move to 12mm on the X axis
G0 F1500             ; Set the feedrate to 1500mm/min
G1 X90.6 Y13.8 E22.4 ; Move to 90.6mm on the X axis and 13.8mm on the Y axis while extruding 22.4mm of material
07 command.

G38.x Straight Probe (CNC specific)

G38.2 probe toward workpiece, stop on contact, signal error if failure

Monitors probe input while moving linearly towards the specified coordinates, stopping upon detecting contact or reaching specified coordinates.

Usage
G0 X12               ; move to 12mm on the X axis
G0 F1500             ; Set the feedrate to 1500mm/min
G1 X90.6 Y13.8 E22.4 ; Move to 90.6mm on the X axis and 13.8mm on the Y axis while extruding 22.4mm of material
08Parameters
N123
51 target X coordinate
N123
52 target Y coordinate
N123
53 target Z coordinate
N123
55 Feedrate in mm/minExample
N123
2
G38.3 probe toward workpiece, stop on contact
G38.4 probe away from workpiece, stop on loss of contact, signal error if failure
G38.5 probe away from workpiece, stop on loss of contact

G40: Compensation Off (CNC specific)

G0 X12               ; move to 12mm on the X axis
G0 F1500             ; Set the feedrate to 1500mm/min
G1 X90.6 Y13.8 E22.4 ; Move to 90.6mm on the X axis and 13.8mm on the Y axis while extruding 22.4mm of material
13 turns off cutter compensation. If tool compensation was on the next move must be a linear move and longer than the tool diameter. It is OK to turn compensation off when it is already off. http://www.linuxcnc.org/docs/2.5/html/gcode/tool_compensation.html

G42: Move to Grid Point

G0 X12               ; move to 12mm on the X axis
G0 F1500             ; Set the feedrate to 1500mm/min
G1 X90.6 Y13.8 E22.4 ; Move to 90.6mm on the X axis and 13.8mm on the Y axis while extruding 22.4mm of material
14 does a fast move in XY to any of the intersection points in the bed calibration grid. This is useful during calibration to align the nozzle or probe.

Parameters
G0 X12               ; move to 12mm on the X axis
G0 F1500             ; Set the feedrate to 1500mm/min
G1 X90.6 Y13.8 E22.4 ; Move to 90.6mm on the X axis and 13.8mm on the Y axis while extruding 22.4mm of material
15 Grid X index (zero-based). If omitted, the nearest latitude.
G0 X12               ; move to 12mm on the X axis
G0 F1500             ; Set the feedrate to 1500mm/min
G1 X90.6 Y13.8 E22.4 ; Move to 90.6mm on the X axis and 13.8mm on the Y axis while extruding 22.4mm of material
16 Grid Y index (zero-based). If omitted, the nearest longitude.
N123 [...G Code in here...] *71
10 Probe flag. Moves the probe to the grid point (instead of the nozzle).
N123
55 Feedrate (mm/min)Example
N123
3

G53..59: Coordinate System Select (CNC specific)

See linuxcnc.org for more help

Not all builds of RepRapFirmware support these commands. For those that do (e.g. Duet WiFi/Ethernet and Duet 3), from firmware version 2.02 the workplace coordinate offsets are included in the data saved to config-override.g by the M500 command.

G60: save current position to slot

Usage
G0 X12               ; move to 12mm on the X axis
G0 F1500             ; Set the feedrate to 1500mm/min
G1 X90.6 Y13.8 E22.4 ; Move to 90.6mm on the X axis and 13.8mm on the Y axis while extruding 22.4mm of material
19Parameters
G0 X12               ; move to 12mm on the X axis
G0 F1500             ; Set the feedrate to 1500mm/min
G1 X90.6 Y13.8 E22.4 ; Move to 90.6mm on the X axis and 13.8mm on the Y axis while extruding 22.4mm of material
20specifies memory slot # (0-based) to save into (default 0)

Implementation in RepRapFirmware:

  • Slots 0, 1 and 2 are available from RepRapFirmware 1.21, also slots 4 and 5 in RRF 2.02. When a print is paused the coordinates are saved to slot 1 automatically, and at the start of a tool change the coordinates are saved to slot 2 automatically. Use G0 or G1 with the R0, R1 or R2 parameter to move the current tool to a saved position.

G68: Coordinate rotation

Usage
G0 X12               ; move to 12mm on the X axis
G0 F1500             ; Set the feedrate to 1500mm/min
G1 X90.6 Y13.8 E22.4 ; Move to 90.6mm on the X axis and 13.8mm on the Y axis while extruding 22.4mm of material
21
G0 X12               ; move to 12mm on the X axis
G0 F1500             ; Set the feedrate to 1500mm/min
G1 X90.6 Y13.8 E22.4 ; Move to 90.6mm on the X axis and 13.8mm on the Y axis while extruding 22.4mm of material
22Parameters
G0 X12               ; move to 12mm on the X axis
G0 F1500             ; Set the feedrate to 1500mm/min
G1 X90.6 Y13.8 E22.4 ; Move to 90.6mm on the X axis and 13.8mm on the Y axis while extruding 22.4mm of material
23 Centre coordinates to rotate about
N123
86 first centre coordinate in the selected plane (e.g. equivalent to Xnnn if the selected plane is XY)
N123
87 second centre coordinate in the selected plane (e.g. equivalent to Ynnn if the selected plane is XY)
N123
61 angle to rotate in degrees. Positive angles rotate anticlockwise when viewing the selected plane from above.
N123 [...G Code in here...] *71
46 if this parameter is present, the R parameter is added to the existing rotation instead of being absolute

Rotates the coordinate system in the current plane as selected by G17, G18 or G19. You may either specify the coordinates of the two axes of the selected plan (e.g. X and Y if using the default XY plane or after G17) or you may specify A and B coordinates.

RepRapFirmware implements G68 for the XY plane only.

G69: Cancel coordinate rotation

Usage
G0 X12               ; move to 12mm on the X axis
G0 F1500             ; Set the feedrate to 1500mm/min
G1 X90.6 Y13.8 E22.4 ; Move to 90.6mm on the X axis and 13.8mm on the Y axis while extruding 22.4mm of material
28

This cancels any coordinate rotation that was set up by G68.

G75: Print temperature interpolation

Show/print PINDA temperature interpolating.

Usage
G0 X12               ; move to 12mm on the X axis
G0 F1500             ; Set the feedrate to 1500mm/min
G1 X90.6 Y13.8 E22.4 ; Move to 90.6mm on the X axis and 13.8mm on the Y axis while extruding 22.4mm of material
29

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.

Usage
G0 X12               ; move to 12mm on the X axis
G0 F1500             ; Set the feedrate to 1500mm/min
G1 X90.6 Y13.8 E22.4 ; Move to 90.6mm on the X axis and 13.8mm on the Y axis while extruding 22.4mm of material
30
G0 X12               ; move to 12mm on the X axis
G0 F1500             ; Set the feedrate to 1500mm/min
G1 X90.6 Y13.8 E22.4 ; Move to 90.6mm on the X axis and 13.8mm on the Y axis while extruding 22.4mm of material
311
G0 X12               ; move to 12mm on the X axis
G0 F1500             ; Set the feedrate to 1500mm/min
G1 X90.6 Y13.8 E22.4 ; Move to 90.6mm on the X axis and 13.8mm on the Y axis while extruding 22.4mm of material
321Parameters
N123 [...G Code in here...] *71
67 Calibrate bed only 1
N123 [...G Code in here...] *71
10 Calibrate probe only 1Example
N123
4Notes1

Marlin requires

G0 X12               ; move to 12mm on the X axis
G0 F1500             ; Set the feedrate to 1500mm/min
G1 X90.6 Y13.8 E22.4 ; Move to 90.6mm on the X axis and 13.8mm on the Y axis while extruding 22.4mm of material
35.

This process can take a very long time. The timeout is currently set to 15min to allow the parts to fully heat up and cool down.

Use

G0 X12               ; move to 12mm on the X axis
G0 F1500             ; Set the feedrate to 1500mm/min
G1 X90.6 Y13.8 E22.4 ; Move to 90.6mm on the X axis and 13.8mm on the Y axis while extruding 22.4mm of material
07 to save the result to EEPROM.

At this moment it is only supported in Marlin bugfix-2.0.x branch.

G80: Cancel Canned Cycle (CNC specific)

It cancel canned cycle modal motion. G80 is part of modal group 1, so programming any other G code from modal group 1 will also cancel the canned cycle.

G80: Mesh-based Z probe

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

ParametersThis command can be used without any additional parameters.
G0 X12               ; move to 12mm on the X axis
G0 F1500             ; Set the feedrate to 1500mm/min
G1 X90.6 Y13.8 E22.4 ; Move to 90.6mm on the X axis and 13.8mm on the Y axis while extruding 22.4mm of material
37 Number of mesh points on x axis. Default is 3. Valid values are 3 and 7.
N123
89 Probe retries. Default 3 max. 10
N123 [...G Code in here...] *71
87 Verbosity level 1=low, 10=mid, 20=high.It can be only used if 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.

N123 [...G Code in here...] *71
93 Left Bed Level correct value in um.
N123
89 Right Bed Level correct value in um.
N123 [...G Code in here...] *71
91 Front Bed Level correct value in um.
N123 [...G Code in here...] *71
67 Back Bed Level correct value in um.

G81: Mesh bed leveling status

Prints mesh bed leveling status and bed profile if activated.

Usage
G0 X12               ; move to 12mm on the X axis
G0 F1500             ; Set the feedrate to 1500mm/min
G1 X90.6 Y13.8 E22.4 ; Move to 90.6mm on the X axis and 13.8mm on the Y axis while extruding 22.4mm of material
44Notes

Equivalent to

G0 X12               ; move to 12mm on the X axis
G0 F1500             ; Set the feedrate to 1500mm/min
G1 X90.6 Y13.8 E22.4 ; Move to 90.6mm on the X axis and 13.8mm on the Y axis while extruding 22.4mm of material
45 in Marlin Firmware (and possibly G29 T depending on leveling system).

WARNING! USE WITH CAUTION! If you'll try to probe where is no leveling pad, nasty things can happen!

Usage
G0 X12               ; move to 12mm on the X axis
G0 F1500             ; Set the feedrate to 1500mm/min
G1 X90.6 Y13.8 E22.4 ; Move to 90.6mm on the X axis and 13.8mm on the Y axis while extruding 22.4mm of material
46Notes

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

G83: Babystep in Z and store to EEPROM

Usage
G0 X12               ; move to 12mm on the X axis
G0 F1500             ; Set the feedrate to 1500mm/min
G1 X90.6 Y13.8 E22.4 ; Move to 90.6mm on the X axis and 13.8mm on the Y axis while extruding 22.4mm of material
47Notes

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

G84: UNDO Babystep Z (move Z axis back)

Usage
G0 X12               ; move to 12mm on the X axis
G0 F1500             ; Set the feedrate to 1500mm/min
G1 X90.6 Y13.8 E22.4 ; Move to 90.6mm on the X axis and 13.8mm on the Y axis while extruding 22.4mm of material
48Notes

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

G85: Pick best babystep

Usage
G0 X12               ; move to 12mm on the X axis
G0 F1500             ; Set the feedrate to 1500mm/min
G1 X90.6 Y13.8 E22.4 ; Move to 90.6mm on the X axis and 13.8mm on the Y axis while extruding 22.4mm of material
49Notes

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

G86: Disable babystep correction after home

This G-code will be performed at the start of a calibration script.

Usage
G0 X12               ; move to 12mm on the X axis
G0 F1500             ; Set the feedrate to 1500mm/min
G1 X90.6 Y13.8 E22.4 ; Move to 90.6mm on the X axis and 13.8mm on the Y axis while extruding 22.4mm of material
50

G87: Enable babystep correction after home

This G-code will be performed at the end of a calibration script.

Usage
G0 X12               ; move to 12mm on the X axis
G0 F1500             ; Set the feedrate to 1500mm/min
G1 X90.6 Y13.8 E22.4 ; Move to 90.6mm on the X axis and 13.8mm on the Y axis while extruding 22.4mm of material
51

G88: Reserved

Usage
G0 X12               ; move to 12mm on the X axis
G0 F1500             ; Set the feedrate to 1500mm/min
G1 X90.6 Y13.8 E22.4 ; Move to 90.6mm on the X axis and 13.8mm on the Y axis while extruding 22.4mm of material
52Notes

This G-code currently does not do anything.

G90: Set to Absolute Positioning

Example
N123
5

All coordinates from now on are absolute relative to the origin of the machine. (This is the RepRap default.)

G91: Set to Relative Positioning

Example
N123
6

All coordinates from now on are relative to the last position. Note: RepRapFirmware latest revision firmware uses

G0 X12               ; move to 12mm on the X axis
G0 F1500             ; Set the feedrate to 1500mm/min
G1 X90.6 Y13.8 E22.4 ; Move to 90.6mm on the X axis and 13.8mm on the Y axis while extruding 22.4mm of material
53 to set the extruder to relative mode: extrusion is NOT set to relative by ReprapFirmware on
N123
43: only X,Y and Z are set to relative. By contrast, Marlin (for example) DOES also set extrusion to relative on a
N123
43 command, as well as setting X, Y and Z.

G92: Set Position

ParametersThis command can be used without any additional parameters.
N123
51 new X axis position
N123
52 new Y axis position
N123
53 new Z axis position
N123
54 new extruder positionExample
N123
7

Allows programming of absolute zero point, by reseting the current position to the values specified. This would set the machine's X coordinate to 10, and the extrude coordinate to 90. No physical motion will occur.

A

G0 X12               ; move to 12mm on the X axis
G0 F1500             ; Set the feedrate to 1500mm/min
G1 X90.6 Y13.8 E22.4 ; Move to 90.6mm on the X axis and 13.8mm on the Y axis while extruding 22.4mm of material
60 without coordinates will reset all axes to zero on some firmware. This does not apply to RepRapFirmware.

G92.x: Reset Coordinate System Offsets (CNC specific)
Usage
G0 X12               ; move to 12mm on the X axis
G0 F1500             ; Set the feedrate to 1500mm/min
G1 X90.6 Y13.8 E22.4 ; Move to 90.6mm on the X axis and 13.8mm on the Y axis while extruding 22.4mm of material
61 - Reset axis offsets (and parameters 5211-5219) to zero. (
G0 X12               ; move to 12mm on the X axis
G0 F1500             ; Set the feedrate to 1500mm/min
G1 X90.6 Y13.8 E22.4 ; Move to 90.6mm on the X axis and 13.8mm on the Y axis while extruding 22.4mm of material
62)
G0 X12               ; move to 12mm on the X axis
G0 F1500             ; Set the feedrate to 1500mm/min
G1 X90.6 Y13.8 E22.4 ; Move to 90.6mm on the X axis and 13.8mm on the Y axis while extruding 22.4mm of material
63 - Reset axis offsets to zero

G0 X12               ; move to 12mm on the X axis
G0 F1500             ; Set the feedrate to 1500mm/min
G1 X90.6 Y13.8 E22.4 ; Move to 90.6mm on the X axis and 13.8mm on the Y axis while extruding 22.4mm of material
64 is Inverse Time Mode. In inverse time feed rate mode, an
N123 [...G Code in here...] *71
91 word means the move should be completed in (one divided by the
N123 [...G Code in here...] *71
91 number) minutes. For example,
G0 X12               ; move to 12mm on the X axis
G0 F1500             ; Set the feedrate to 1500mm/min
G1 X90.6 Y13.8 E22.4 ; Move to 90.6mm on the X axis and 13.8mm on the Y axis while extruding 22.4mm of material
67 means the move should be completed in a half a minute.

When the inverse time feed rate mode is active, an

N123 [...G Code in here...] *71
91 word must appear on every line which has a
N123
48,
N123 [...G Code in here...] *71
22, or
N123
37 motion, and an
N123 [...G Code in here...] *71
91 word on a line that does not have
N123
48,
N123 [...G Code in here...] *71
22, or
N123
37 is ignored. Being in inverse time feed rate mode does not affect
N123
36 (rapid move) motions.

G94: Feed Rate Mode (Units per Minute) (CNC specific)

G94 is Units per Minute Mode. In units per minute feed mode, an F word is interpreted to mean the controlled point should move at a certain number of inches per minute, millimeters per minute, or degrees per minute, depending upon what length units are being used and which axis or axes are moving.

G98: Activate farm mode

Enable Prusa-specific Farm functions and g-code.

Usage

G0 X12               ; move to 12mm on the X axis
G0 F1500             ; Set the feedrate to 1500mm/min
G1 X90.6 Y13.8 E22.4 ; Move to 90.6mm on the X axis and 13.8mm on the Y axis while extruding 22.4mm of material
77

Notes

Set of internal Prusa commands

G0 X12               ; move to 12mm on the X axis
G0 F1500             ; Set the feedrate to 1500mm/min
G1 X90.6 Y13.8 E22.4 ; Move to 90.6mm on the X axis and 13.8mm on the Y axis while extruding 22.4mm of material
78

Parameters
G0 X12               ; move to 12mm on the X axis
G0 F1500             ; Set the feedrate to 1500mm/min
G1 X90.6 Y13.8 E22.4 ; Move to 90.6mm on the X axis and 13.8mm on the Y axis while extruding 22.4mm of material
79
G0 X12               ; move to 12mm on the X axis
G0 F1500             ; Set the feedrate to 1500mm/min
G1 X90.6 Y13.8 E22.4 ; Move to 90.6mm on the X axis and 13.8mm on the Y axis while extruding 22.4mm of material
80 Prints revision of the printer.
G0 X12               ; move to 12mm on the X axis
G0 F1500             ; Set the feedrate to 1500mm/min
G1 X90.6 Y13.8 E22.4 ; Move to 90.6mm on the X axis and 13.8mm on the Y axis while extruding 22.4mm of material
81 Prints fan details.
G0 X12               ; move to 12mm on the X axis
G0 F1500             ; Set the feedrate to 1500mm/min
G1 X90.6 Y13.8 E22.4 ; Move to 90.6mm on the X axis and 13.8mm on the Y axis while extruding 22.4mm of material
82 Prints farm number.
G0 X12               ; move to 12mm on the X axis
G0 F1500             ; Set the feedrate to 1500mm/min
G1 X90.6 Y13.8 E22.4 ; Move to 90.6mm on the X axis and 13.8mm on the Y axis while extruding 22.4mm of material
83
G0 X12               ; move to 12mm on the X axis
G0 F1500             ; Set the feedrate to 1500mm/min
G1 X90.6 Y13.8 E22.4 ; Move to 90.6mm on the X axis and 13.8mm on the Y axis while extruding 22.4mm of material
84 Resets UVLO aka Power Panic and continues SD print.
G0 X12               ; move to 12mm on the X axis
G0 F1500             ; Set the feedrate to 1500mm/min
G1 X90.6 Y13.8 E22.4 ; Move to 90.6mm on the X axis and 13.8mm on the Y axis while extruding 22.4mm of material
85 Filament sensor recover - restore print and continue.
G0 X12               ; move to 12mm on the X axis
G0 F1500             ; Set the feedrate to 1500mm/min
G1 X90.6 Y13.8 E22.4 ; Move to 90.6mm on the X axis and 13.8mm on the Y axis while extruding 22.4mm of material
86 Reset MMU.
G0 X12               ; move to 12mm on the X axis
G0 F1500             ; Set the feedrate to 1500mm/min
G1 X90.6 Y13.8 E22.4 ; Move to 90.6mm on the X axis and 13.8mm on the Y axis while extruding 22.4mm of material
87 Resets Printer.
G0 X12               ; move to 12mm on the X axis
G0 F1500             ; Set the feedrate to 1500mm/min
G1 X90.6 Y13.8 E22.4 ; Move to 90.6mm on the X axis and 13.8mm on the Y axis while extruding 22.4mm of material
88  ??? get file version. ???
G0 X12               ; move to 12mm on the X axis
G0 F1500             ; Set the feedrate to 1500mm/min
G1 X90.6 Y13.8 E22.4 ; Move to 90.6mm on the X axis and 13.8mm on the Y axis while extruding 22.4mm of material
89 M28 write to SD.
G0 X12               ; move to 12mm on the X axis
G0 F1500             ; Set the feedrate to 1500mm/min
G1 X90.6 Y13.8 E22.4 ; Move to 90.6mm on the X axis and 13.8mm on the Y axis while extruding 22.4mm of material
90 Get serial number from 32U2 processor. Typical format of S/N is:CZPX0917X003XC13518
G0 X12               ; move to 12mm on the X axis
G0 F1500             ; Set the feedrate to 1500mm/min
G1 X90.6 Y13.8 E22.4 ; Move to 90.6mm on the X axis and 13.8mm on the Y axis while extruding 22.4mm of material
91 Prints firmware version.
G0 X12               ; move to 12mm on the X axis
G0 F1500             ; Set the feedrate to 1500mm/min
G1 X90.6 Y13.8 E22.4 ; Move to 90.6mm on the X axis and 13.8mm on the Y axis while extruding 22.4mm of material
92 Prints filament size, elelectronics, nozzle type.
G0 X12               ; move to 12mm on the X axis
G0 F1500             ; Set the feedrate to 1500mm/min
G1 X90.6 Y13.8 E22.4 ; Move to 90.6mm on the X axis and 13.8mm on the Y axis while extruding 22.4mm of material
93 Reset the language.
G0 X12               ; move to 12mm on the X axis
G0 F1500             ; Set the feedrate to 1500mm/min
G1 X90.6 Y13.8 E22.4 ; Move to 90.6mm on the X axis and 13.8mm on the Y axis while extruding 22.4mm of material
94  ??? maybe resets Live Z values to 0 ???
G0 X12               ; move to 12mm on the X axis
G0 F1500             ; Set the feedrate to 1500mm/min
G1 X90.6 Y13.8 E22.4 ; Move to 90.6mm on the X axis and 13.8mm on the Y axis while extruding 22.4mm of material
95 Kick farm link timer.
G0 X12               ; move to 12mm on the X axis
G0 F1500             ; Set the feedrate to 1500mm/min
G1 X90.6 Y13.8 E22.4 ; Move to 90.6mm on the X axis and 13.8mm on the Y axis while extruding 22.4mm of material
96 Full factory reset.
G0 X12               ; move to 12mm on the X axis
G0 F1500             ; Set the feedrate to 1500mm/min
G1 X90.6 Y13.8 E22.4 ; Move to 90.6mm on the X axis and 13.8mm on the Y axis while extruding 22.4mm of material
97 Set nozzle diameter.
G0 X12               ; move to 12mm on the X axis
G0 F1500             ; Set the feedrate to 1500mm/min
G1 X90.6 Y13.8 E22.4 ; Move to 90.6mm on the X axis and 13.8mm on the Y axis while extruding 22.4mm of material
98 Check nozzle diameter.
G0 X12               ; move to 12mm on the X axis
G0 F1500             ; Set the feedrate to 1500mm/min
G1 X90.6 Y13.8 E22.4 ; Move to 90.6mm on the X axis and 13.8mm on the Y axis while extruding 22.4mm of material
99 Print nozzle diameter

G99: Deactivate farm mode

Usage

G1 F1500           ; Set feedrate to 1500mm/min
G1 X50 Y25.3 E22.4 ; Move and extrude
00

G100: Calibrate floor or rod radius

Parameters
N123 [...G Code in here...] *71
42 Flag to set floor for X axis
N123 [...G Code in here...] *71
43 Flag to set floor for Y axis
N123 [...G Code in here...] *71
04 Flag to set floor for Z axis
N123
61 Radius to addExamples
N123
8

G130: Set digital potentiometer value

Example
N123
9

Set the digital potentiometer value for the given axes. This is used to configure the current applied to each stepper axis. The value is specified as a value from 0-127; the mapping from current to potentimeter value is machine specific.

G131: Remove offset

G132: Calibrate endstop offsets

G133: Measure steps to top

G161: Home axes to minimum

Parameters
N123 [...G Code in here...] *71
42 Flag to home the X axis to its minimum position
N123 [...G Code in here...] *71
43 Flag to home the Y axis to its minimum position
N123 [...G Code in here...] *71
04 Flag to home the Z axis to its minimum position
N123
55 Desired feedrate for this commandExample
N123 [...G Code in here...] *71
0

Instruct the machine to home the specified axes to their minimum position. Similar to

N123
38, which decides on its own in which direction to search endstops.

G162: Home axes to maximum

Parameters
N123 [...G Code in here...] *71
42 Flag to home the X axis to its maximum position
N123 [...G Code in here...] *71
43 Flag to home the Y axis to its maximum position
N123 [...G Code in here...] *71
04 Flag to home the Z axis to its maximum position
N123
55 Desired feedrate for this commandExample
N123 [...G Code in here...] *71
1

Instruct the machine to home the specified axes to their maximum position.

G425: Perform auto-calibration with calibration cube

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

Parameters
N123 [...G Code in here...] *71
67 Perform calibration of backlash only.
N123 [...G Code in here...] *71
17 Perform calibration of toolhead only.
N123 [...G Code in here...] *71
87 Probe cube and print position, error, backlash and hotend offset.
G1 F1500           ; Set feedrate to 1500mm/min
G1 X50 Y25.3 E22.4 ; Move and extrude
17 Uncertainty, how far to start probe away from the cube (mm)Examples (Marlin)
N123 [...G Code in here...] *71
2

M-commands

M0: Stop or Unconditional stop

ParametersThis command can be used without any additional parameters.
N123
83 Time to wait, in milliseconds1
N123
62 Time to wait, in seconds2Example
N123 [...G Code in here...] *71
3

The RepRap machine finishes any moves left in its buffer, then shuts down. All motors and heaters are turned off. It can be started again by pressing the reset button on the master microcontroller, although this step is not mandatory on RepRapFirmware. See also

G1 F1500           ; Set feedrate to 1500mm/min
G1 X50 Y25.3 E22.4 ; Move and extrude
20,
G1 F1500           ; Set feedrate to 1500mm/min
G1 X50 Y25.3 E22.4 ; Move and extrude
21.

The Marlin Firmware does wait for user to press a button on the LCD, or a specific time. "M0 P2000" waits 2000 milliseconds, "M0 S2" waits 2 seconds.

RepRapFirmware executes cancel.g if this file is present, if the print is paused and if the axes are homed. Otherwise stop.g is run and the drives are put into idle mode. Also the heaters are turned off if no 'H1' parameter is specified.

Notes

1Not available in RepRapFirmware, but as a work-around

G1 F1500           ; Set feedrate to 1500mm/min
G1 X50 Y25.3 E22.4 ; Move and extrude
22 can be run before
G1 F1500           ; Set feedrate to 1500mm/min
G1 X50 Y25.3 E22.4 ; Move and extrude
23.

2Only available on Marlin and Prusa Firmware.

3"Wait for user ..." is shown on LCD in Prusa Firmware.

M1: Sleep or Conditional stop

Example
N123 [...G Code in here...] *71
4

The RepRap machine finishes any moves left in its buffer, then shuts down. All motors and heaters are turned off. It can still be sent G and M codes, the first of which will wake it up again. See also

G1 F1500           ; Set feedrate to 1500mm/min
G1 X50 Y25.3 E22.4 ; Move and extrude
23,
G1 F1500           ; Set feedrate to 1500mm/min
G1 X50 Y25.3 E22.4 ; Move and extrude
21.

The Marlin does the same as

G1 F1500           ; Set feedrate to 1500mm/min
G1 X50 Y25.3 E22.4 ; Move and extrude
23.

In Prusa 8-bit Firmware 1 the

G1 F1500           ; Set feedrate to 1500mm/min
G1 X50 Y25.3 E22.4 ; Move and extrude
20 needs at least a space behind the command to be executed correctly. It can be used the same as
G1 F1500           ; Set feedrate to 1500mm/min
G1 X50 Y25.3 E22.4 ; Move and extrude
28 or
G1 F1500           ; Set feedrate to 1500mm/min
G1 X50 Y25.3 E22.4 ; Move and extrude
29 but will ignore the following "message".

Prusa Firmware 8-bit example
N123 [...G Code in here...] *71
5


If Marlin is emulated in RepRapFirmware, this does the same as M25 if the code was read from a serial or Telnet connection, else the macro file

G1 F1500           ; Set feedrate to 1500mm/min
G1 X50 Y25.3 E22.4 ; Move and extrude
30 is run before all heaters and drives are turned off.

M2: Program End

Example
N123 [...G Code in here...] *71
6

Teacup firmware does the same as

G1 F1500           ; Set feedrate to 1500mm/min
G1 X50 Y25.3 E22.4 ; Move and extrude
31.

M3: Spindle On, Clockwise (CNC specific)

Parameters
N123
62 Spindle RPMExample
N123 [...G Code in here...] *71
7

The spindle is turned on with a speed of 4000 RPM.

Teacup firmware turn extruder on (same as

G1 F1500           ; Set feedrate to 1500mm/min
G1 X50 Y25.3 E22.4 ; Move and extrude
33).

RepRapFirmware interprets this code only if in CNC mode (

G1 F1500           ; Set feedrate to 1500mm/min
G1 X50 Y25.3 E22.4 ; Move and extrude
34), in laser mode (
G1 F1500           ; Set feedrate to 1500mm/min
G1 X50 Y25.3 E22.4 ; Move and extrude
35) or if a Roland mill has been configured. You must always provide an S parameter with this command to specify the required spindle speed pr laser power. In RepRapFirmware 2.05RC2 and later, and RepRapFirmware 3.0beta13 and later, in laser mode (M452) the laser will only fire during G1/G2/G2 moves.

In Repetier-Firmware in laser mode you need

int cs = 0;
for(i = 0; cmd[i] != '*' && cmd[i] != NULL; i++)
   cs = cs ^ cmd[i];
cs &= 0xff;  // Defensive programming...
03..
G1 F1500           ; Set feedrate to 1500mm/min
G1 X50 Y25.3 E22.4 ; Move and extrude
37 to set laser intensity. Normally you use
G1 F1500           ; Set feedrate to 1500mm/min
G1 X50 Y25.3 E22.4 ; Move and extrude
37 to turn it on full power for moves. Laser will only fire during
N123
48/
N123 [...G Code in here...] *71
22/
N123
37 moves and in laser mode (
G1 F1500           ; Set feedrate to 1500mm/min
G1 X50 Y25.3 E22.4 ; Move and extrude
35).

M4: Spindle On, Counter-Clockwise (CNC specific)

Example
N123 [...G Code in here...] *71
8

The spindle is turned on with a speed of 4000 RPM.

M5: Spindle Off (CNC specific)

Example
N123 [...G Code in here...] *71
9

The spindle is turned off.

Teacup firmware turn extruder off (same as

G1 F1500           ; Set feedrate to 1500mm/min
G1 X50 Y25.3 E22.4 ; Move and extrude
43).

M6: Tool change

Example
int cs = 0;
for(i = 0; cmd[i] != '*' && cmd[i] != NULL; i++)
   cs = cs ^ cmd[i];
cs &= 0xff;  // Defensive programming...
0

M7: Mist Coolant On (CNC specific)

Example
int cs = 0;
for(i = 0; cmd[i] != '*' && cmd[i] != NULL; i++)
   cs = cs ^ cmd[i];
cs &= 0xff;  // Defensive programming...
1

Mist coolant is turned on (if available)

Teacup firmware turn on the fan, and set fan speed (same as

G1 F1500           ; Set feedrate to 1500mm/min
G1 X50 Y25.3 E22.4 ; Move and extrude
44).

M8: Flood Coolant On (CNC specific)

Example
int cs = 0;
for(i = 0; cmd[i] != '*' && cmd[i] != NULL; i++)
   cs = cs ^ cmd[i];
cs &= 0xff;  // Defensive programming...
2

Flood coolant is turned on (if available)

M9: Coolant Off (CNC specific)

Example
int cs = 0;
for(i = 0; cmd[i] != '*' && cmd[i] != NULL; i++)
   cs = cs ^ cmd[i];
cs &= 0xff;  // Defensive programming...
3

All coolant systems are turned off.

M10: Vacuum On (CNC specific)

Example
int cs = 0;
for(i = 0; cmd[i] != '*' && cmd[i] != NULL; i++)
   cs = cs ^ cmd[i];
cs &= 0xff;  // Defensive programming...
4

Dust collection vacuum system turned on.

M11: Vacuum Off (CNC specific)

Example
int cs = 0;
for(i = 0; cmd[i] != '*' && cmd[i] != NULL; i++)
   cs = cs ^ cmd[i];
cs &= 0xff;  // Defensive programming...
5

Dust collection vacuum system turned off.

M13: Spindle on (clockwise rotation) and coolant on (flood)

This one M-code does the work of both M03 and M08. It is not unusual for specific machine models to have such combined commands, which make for shorter, more quickly written programs.

Example
int cs = 0;
for(i = 0; cmd[i] != '*' && cmd[i] != NULL; i++)
   cs = cs ^ cmd[i];
cs &= 0xff;  // Defensive programming...
6

M16: Expected Printer Check

Do a case-sensitive comparison between the string argument and the configured

G1 F1500           ; Set feedrate to 1500mm/min
G1 X50 Y25.3 E22.4 ; Move and extrude
45. If the machine name doesn't match, halt the printer so that a reset is required. This safety feature is meant to prevent G-code sliced for a specific machine from being used on any other machine. In Marlin this feature is enabled with
G1 F1500           ; Set feedrate to 1500mm/min
G1 X50 Y25.3 E22.4 ; Move and extrude
46.

Example
int cs = 0;
for(i = 0; cmd[i] != '*' && cmd[i] != NULL; i++)
   cs = cs ^ cmd[i];
cs &= 0xff;  // Defensive programming...
7

M17: Enable/Power all stepper motors

ParametersThis command can be used without any additional parameters.1
N123 [...G Code in here...] *71
42 X axis
N123 [...G Code in here...] *71
43 Y axis
N123 [...G Code in here...] *71
04 Z axis
N123
67 All extrudersExample
int cs = 0;
for(i = 0; cmd[i] != '*' && cmd[i] != NULL; i++)
   cs = cs ^ cmd[i];
cs &= 0xff;  // Defensive programming...
8

Powers on stepper motors.

Notes

1Ability to specify axes was added to Marlin 2.0 and may not be available on other firmware implementations.

M18: Disable all stepper motors

ParametersThis command can be used without any additional parameters.13
N123 [...G Code in here...] *71
42 X axis
N123 [...G Code in here...] *71
43 Y axis
N123 [...G Code in here...] *71
04 Z axis
N123
67 Extruder drive(s)2
N123 [...G Code in here...] *71
00 Seconds3Examples
int cs = 0;
for(i = 0; cmd[i] != '*' && cmd[i] != NULL; i++)
   cs = cs ^ cmd[i];
cs &= 0xff;  // Defensive programming...
9

Disables stepper motors and allows axes to move 'freely.'

On Marlin,

G1 F1500           ; Set feedrate to 1500mm/min
G1 X50 Y25.3 E22.4 ; Move and extrude
56 is a synonym of
G1 F1500           ; Set feedrate to 1500mm/min
G1 X50 Y25.3 E22.4 ; Move and extrude
31, so it can also be used to configure or disable the idle timeout.

Examples
G0 X12               ; move to 12mm on the X axis
G0 F1500             ; Set the feedrate to 1500mm/min
G1 X90.6 Y13.8 E22.4 ; Move to 90.6mm on the X axis and 13.8mm on the Y axis while extruding 22.4mm of material
0Notes

1Some firmware implementations do not support parameters to be passed, but at least Marlin and RepRapFirmware do.

2RepRapFirmware allows stepper motors to be disabled selectively. For example,

G1 F1500           ; Set feedrate to 1500mm/min
G1 X50 Y25.3 E22.4 ; Move and extrude
58 will disable the X, extruder 0 and extruder 2 motors.

3In Prusa Firmware this command can be used to set the stepper inactivity timeout (`S`) or to disable steppers (`X`,`Y`,`Z`,`E`)

M20: List SD card

ParametersThis command can be used without any additional parameters.
N123
62 Output style1
N123
61 File number to start at1
G1 F1500           ; Set feedrate to 1500mm/min
G1 X50 Y25.3 E22.4 ; Move and extrude
61 Directory to list2
N123 [...G Code in here...] *71
93 Reports long filenames instead of just short filenames. Requires host software parsing (Cap:EXTENDED_M20).4
N123
46 Report timestamps as well. The value is one uint32_t encoded as hex. Requires host software parsing (Cap:EXTENDED_M20).4Examples
G0 X12               ; move to 12mm on the X axis
G0 F1500             ; Set the feedrate to 1500mm/min
G1 X90.6 Y13.8 E22.4 ; Move to 90.6mm on the X axis and 13.8mm on the Y axis while extruding 22.4mm of material
1

This code lists all files in the root folder or G-code directory of the SD card to the serial port. One name per line, like:

G0 X12               ; move to 12mm on the X axis
G0 F1500             ; Set the feedrate to 1500mm/min
G1 X90.6 Y13.8 E22.4 ; Move to 90.6mm on the X axis and 13.8mm on the Y axis while extruding 22.4mm of material
2

Please note that a file list response is usually encapsulated. Standard configurations of RepRapFirmware mimic this style in emulation mode:

G0 X12               ; move to 12mm on the X axis
G0 F1500             ; Set the feedrate to 1500mm/min
G1 X90.6 Y13.8 E22.4 ; Move to 90.6mm on the X axis and 13.8mm on the Y axis while extruding 22.4mm of material
3

The file size may be appended as an integer representing the size in bytes:

G0 X12               ; move to 12mm on the X axis
G0 F1500             ; Set the feedrate to 1500mm/min
G1 X90.6 Y13.8 E22.4 ; Move to 90.6mm on the X axis and 13.8mm on the Y axis while extruding 22.4mm of material
4

At least OctoPrint also supports an additional format showing the file's long name (see also M33) after the size:

G0 X12               ; move to 12mm on the X axis
G0 F1500             ; Set the feedrate to 1500mm/min
G1 X90.6 Y13.8 E22.4 ; Move to 90.6mm on the X axis and 13.8mm on the Y axis while extruding 22.4mm of material
5

If RepRapFirmware emulates no firmware compatibility, a typical response looks like:

G0 X12               ; move to 12mm on the X axis
G0 F1500             ; Set the feedrate to 1500mm/min
G1 X90.6 Y13.8 E22.4 ; Move to 90.6mm on the X axis and 13.8mm on the Y axis while extruding 22.4mm of material
6

Note that some firmwares list file names in upper case, but - when sent to the

G1 F1500           ; Set feedrate to 1500mm/min
G1 X50 Y25.3 E22.4 ; Move and extrude
64 command (below) they must be in lower case. Teacup and RepRapFirmware have no such trouble and accept both. RepRapFirmware always returns long filenames in the case in which they are stored.

Notes

1If the S2 parameter is used on RepRapFirmware, then the file list (or as much as can be fitted in the output buffer) is returned in JSON format as a single array called "files" with each name that corresponds to a subdirectory preceded by an asterisk, and the directory is returned in variable "dir". The optional R parameter is the file number to start at, default 0. The JSON response also returns value "next" which is the number of the first file that wasn't returned, or 0 if all files were returned. The caller can enumerate all files even if there are very many by making successive M20 S2 calls with each call using R from the "next" value in the previous response, util "next" is zero.

Example
G0 X12               ; move to 12mm on the X axis
G0 F1500             ; Set the feedrate to 1500mm/min
G1 X90.6 Y13.8 E22.4 ; Move to 90.6mm on the X axis and 13.8mm on the Y axis while extruding 22.4mm of material
7Example for
G1 F1500           ; Set feedrate to 1500mm/min
G1 X50 Y25.3 E22.4 ; Move and extrude
654
G0 X12               ; move to 12mm on the X axis
G0 F1500             ; Set the feedrate to 1500mm/min
G1 X90.6 Y13.8 E22.4 ; Move to 90.6mm on the X axis and 13.8mm on the Y axis while extruding 22.4mm of material
8Example for
G1 F1500           ; Set feedrate to 1500mm/min
G1 X50 Y25.3 E22.4 ; Move and extrude
664
G0 X12               ; move to 12mm on the X axis
G0 F1500             ; Set the feedrate to 1500mm/min
G1 X90.6 Y13.8 E22.4 ; Move to 90.6mm on the X axis and 13.8mm on the Y axis while extruding 22.4mm of material
9Example for
G1 F1500           ; Set feedrate to 1500mm/min
G1 X50 Y25.3 E22.4 ; Move and extrude
674
G1 F1500           ; Set feedrate to 1500mm/min
G1 X50 Y25.3 E22.4 ; Move and extrude
0

2This parameter is only supported by RepRapFirmware and defaults to the 0:/gcodes directory, which is the directory that printable gcode files are normally stored in.

3On Klipper, a virtual SD card is required for this to work.

4The timestamp is a combination of both the date and time into a single integer and printed as a hex.

M21: Initialize SD card

Parameters
N123
83 SD card number (RepRapFirmware only, default 0)Examples
G1 F1500           ; Set feedrate to 1500mm/min
G1 X50 Y25.3 E22.4 ; Move and extrude
1

The specified SD card is initialized. If an SD card is loaded when the machine is switched on, this will happen by default. SD card must be initialized for the other SD functions to work.

Marlin 2.0.9.4 added

N123 [...G Code in here...] *71
00 and
G1 F1500           ; Set feedrate to 1500mm/min
G1 X50 Y25.3 E22.4 ; Move and extrude
70 parameters to mount the SD Card or USB drive, respectively. Hosts can look for "
G1 F1500           ; Set feedrate to 1500mm/min
G1 X50 Y25.3 E22.4 ; Move and extrude
71".

Notes

1On Klipper, a virtual SD card is required for this to work.

M22: Release SD card

Parameters
N123
83 SD card number (RepRapFirmware only, default 0)Examples
G1 F1500           ; Set feedrate to 1500mm/min
G1 X50 Y25.3 E22.4 ; Move and extrude
2

The specified SD card is released, so further (accidental) attempts to read from it are guaranteed to fail. Helpful, but not mandatory before removing the card physically.

M23: Select SD file

Example
G1 F1500           ; Set feedrate to 1500mm/min
G1 X50 Y25.3 E22.4 ; Move and extrude
3

The file specified as filename.gco (8.3 naming convention is supported) is selected ready for printing. RepRapFirmware supports long filenames as well as 8.3 format.

Notes

1On Klipper, a virtual SD card is required for this to work.

M24: Start/resume SD print

Example
G1 F1500           ; Set feedrate to 1500mm/min
G1 X50 Y25.3 E22.4 ; Move and extrude
4

The machine prints from the file selected with the

G1 F1500           ; Set feedrate to 1500mm/min
G1 X50 Y25.3 E22.4 ; Move and extrude
64 command. If the print was previously paused with
G1 F1500           ; Set feedrate to 1500mm/min
G1 X50 Y25.3 E22.4 ; Move and extrude
74, printing is resumed from that point. To restart a file from the beginning, use
G1 F1500           ; Set feedrate to 1500mm/min
G1 X50 Y25.3 E22.4 ; Move and extrude
64 to reset it, then
G1 F1500           ; Set feedrate to 1500mm/min
G1 X50 Y25.3 E22.4 ; Move and extrude
76.

When this command is used to resume a print that was paused, RepRapFirmware runs macro file

G1 F1500           ; Set feedrate to 1500mm/min
G1 X50 Y25.3 E22.4 ; Move and extrude
77 prior to resuming the print.

Notes

1On Klipper, a virtual SD card is required for this to work.

M25: Pause SD print

Example
G1 F1500           ; Set feedrate to 1500mm/min
G1 X50 Y25.3 E22.4 ; Move and extrude
5

The machine pauses printing at the current position within the file. To resume printing, use M24. Do not use this code within a GCode file to pause the print at that point, use M226 instead.

Prior to pausing, RepRapFirmware runs macro file

G1 F1500           ; Set feedrate to 1500mm/min
G1 X50 Y25.3 E22.4 ; Move and extrude
78. This allows the head to be moved away from the print, filament to be retracted, etc.

RepRapFirmware 1.20 and later also save the current state of the print to file /sys/resurrect.g. This is so that if the printer is turned off after pausing, the print can subsequently be resumed.

Notes

1On Klipper, a virtual SD card is required for this to work.

M26: Set SD position

Parameters
N123
62 File position from start of file in bytes
N123
83 (Optional, RepRapFirmware only) Proportion of the first move to be skipped, default 0.0, must be less than 1.0ExampleM26 S49315

Set the file offset in bytes from the start of the SD card file selected by M23. The offset must correspond to the start of a G-code command.

Notes

1On Klipper, a virtual SD card is required for this to work.

M27: Report SD print status

ParametersC Report the open file's name and long name (Marlin 1.1.9 and up)Sn Set the auto-report interval (Marlin 1.1.9 and up)Example
G1 F1500           ; Set feedrate to 1500mm/min
G1 X50 Y25.3 E22.4 ; Move and extrude
6

Report SD print status.

Marlin and RepRapFirmware report the number of bytes processed in this format, which can be processed by Pronterface:

G1 F1500           ; Set feedrate to 1500mm/min
G1 X50 Y25.3 E22.4 ; Move and extrude
7

If no file is being printed, only this message is reported:

G1 F1500           ; Set feedrate to 1500mm/min
G1 X50 Y25.3 E22.4 ; Move and extrude
8

In Marlin 1.1.9 and up

G1 F1500           ; Set feedrate to 1500mm/min
G1 X50 Y25.3 E22.4 ; Move and extrude
81 reports the open file's DOS 8.3 name and long filename, if any.

Example
G1 F1500           ; Set feedrate to 1500mm/min
G1 X50 Y25.3 E22.4 ; Move and extrude
9
G1 F1500                 ; Feedrate 1500mm/min
G1 X50 Y25.3 E22.4 F3000 ; Accelerate to 3000mm/min
0

In Marlin 1.1.9 and up

G1 F1500           ; Set feedrate to 1500mm/min
G1 X50 Y25.3 E22.4 ; Move and extrude
82 sets the auto-report interval. This requires the
G1 F1500           ; Set feedrate to 1500mm/min
G1 X50 Y25.3 E22.4 ; Move and extrude
83 configuration option to be enabled. Marlin reports this capability in
G1 F1500           ; Set feedrate to 1500mm/min
G1 X50 Y25.3 E22.4 ; Move and extrude
84 as
G1 F1500           ; Set feedrate to 1500mm/min
G1 X50 Y25.3 E22.4 ; Move and extrude
85 when this option is available.

Example
G1 F1500                 ; Feedrate 1500mm/min
G1 X50 Y25.3 E22.4 F3000 ; Accelerate to 3000mm/min
1Notes

1On Klipper, a virtual SD card is required for this to work.

M28: Begin write to SD card

Example
G1 F1500                 ; Feedrate 1500mm/min
G1 X50 Y25.3 E22.4 F3000 ; Accelerate to 3000mm/min
2

File specified by filename.gco is created (or overwritten if it exists) on the SD card and all subsequent commands sent to the machine are written to that file.

M29: Stop writing to SD card

Example
G1 F1500                 ; Feedrate 1500mm/min
G1 X50 Y25.3 E22.4 F3000 ; Accelerate to 3000mm/min
3

File opened by

G0 X12               ; move to 12mm on the X axis
G0 F1500             ; Set the feedrate to 1500mm/min
G1 X90.6 Y13.8 E22.4 ; Move to 90.6mm on the X axis and 13.8mm on the Y axis while extruding 22.4mm of material
89 command is closed, and all subsequent commands sent to the machine are executed as normal.

M30: Delete a file on the SD card

Example
G1 F1500                 ; Feedrate 1500mm/min
G1 X50 Y25.3 E22.4 F3000 ; Accelerate to 3000mm/min
4
M30: Program Stop

- For Yaskawa and in grbl - Same as M2 in Yaskawa G-code

Example

M30 ; Exchange pallet shuttles and end the program. Pressing cycle start will start the program at the beginning of the file.

Example
G1 F1500                 ; Feedrate 1500mm/min
G1 X50 Y25.3 E22.4 F3000 ; Accelerate to 3000mm/min
5

The response looks like:

G1 F1500                 ; Feedrate 1500mm/min
G1 X50 Y25.3 E22.4 F3000 ; Accelerate to 3000mm/min
6

M32: Select file and start SD print

Example
G1 F1500                 ; Feedrate 1500mm/min
G1 X50 Y25.3 E22.4 F3000 ; Accelerate to 3000mm/min
7

It can be used when printing from SD card and does the same as

G1 F1500           ; Set feedrate to 1500mm/min
G1 X50 Y25.3 E22.4 ; Move and extrude
64 and
G1 F1500           ; Set feedrate to 1500mm/min
G1 X50 Y25.3 E22.4 ; Move and extrude
76.

tba available in marlin(14/6/2014)

M33: Get the long name for an SD card file or folder

Get the long name for a file or folder on the SD card from a dos path. Introduced in Marlin firmware 1.1.0 September 2015.

Example input:

G1 F1500                 ; Feedrate 1500mm/min
G1 X50 Y25.3 E22.4 F3000 ; Accelerate to 3000mm/min
8

Example output:

G1 F1500                 ; Feedrate 1500mm/min
G1 X50 Y25.3 E22.4 F3000 ; Accelerate to 3000mm/min
9

M33: Stop and Close File and save restart.gcode

Stop the printing from SD and save all position in restart.gcode for restart printing in future

M34: Set SD file sorting options

Enable and disable SD card file-sorting, and/or set the folder sorting order. Proposed by Marlin firmware, May 2015.

M35: Upload firmware NEXTION from SD

M36: Return file information

ExampleM36 filename.gcoM36

Returns information in JSON format for the specified SD card file (if a filename was provided) or for the file currently being printed. A sample response is:

{"err":0,"size":436831,"fileName":"EscherLizardModified.gcode","lastModified":"2017-09-21T16:58:07","height":5.20,"layerHeight":0.20,"printTime":660,"simulatedTime":1586,"filament":[1280.7],"generatedBy":"Simplify3D(R) Version 4.0.0"}

The "err" field is zero if successful, nonzero if the file was not found or an error occurred while processing it. The "size" field should always be present if the operation was successful. The presence or absence of other fields depends on whether the corresponding values could be found by reading the file. The "filament" field is an array of the filament lengths required from each spool. The size is in bytes, the times are in seconds, all other values are in mm. "printTime" is the printing time estimated by the slicer, "simulationTime" is the time measured when the print was simulated by the firmware. The fields may appear in any order, and additional fields may be present. Versions of RepRapFirmware prior to 3.4 do not provide the "fileName" field if information for a specific file was requested.

RepRapFirmware 3.4 and later also return information about thumbnail imaged embedded in the GCode file via an additional JSON field "thumbnails". A sample value for this field is:

"thumbnails":[{"width":32,"height":32,"fmt":"qoi","offset":103,"size":2140},{"width":220,"height":220,"fmt":"qoi","offset":2384,"size":25464}]

The "fmt" field denotes the encoding of the thumbnail and is either "png" or "qoi". The "thumbnails" field is omitted entirely if there are no thumbnails embedded in the GCode file.

M36.1: Return embedded thumbnail data

ParametersP"filename" Name of the GCode file from which thumbnail data is to be retrievedSnnnn Byte offset into the file at which thumbnail data is to be fetched

This command is used to return the data for an thumbnail image in a GCode file. The offset value should be either the offset of the start of data for a thumbnail as returned by the M36 command, or the value returned in the "next" field by a previous M36.1 command. The response is in JSON format. Here is a sample response:

{fileName":"EscherLizardModified.gcode","offset":103,"data":"cW9pZgAAACA....AAAAB","next":0,err": 0}

The "fileName" and "offset" values are as given in the command. "data" is part or all of the base64-encoded thumbnail data starting at that offset. "next" is zero if there is no more data for that thumbnail, otherwise not all the thumbnail data was returned and "next" is the byte offset in the file of the rest of the thumbnail data. "err" is 0 if the command was successful, otherwise "err" is nonzero and the other fields may or may not be present.

M37: Simulation mode

ParametersS1 Enter simulation modeS0 Leave simulation modeP"filename" (optional) Simulate printing a file from SD cardExamplesM37 S1M37 P"MyModel.g"

Used to switch between printing mode and simulation mode. Simulation mode allows the electronics to compute an accurate printing time, taking into account the maximum speeds, accelerations etc. that are configured.

M37 S1 enters simulation mode. All G and M codes will not be acted on, but the time they would take to execute will be calculated.

M37 S0 leaves simulation mode and prints the total time taken by simulated moves since entering simulation mode.

M37 with no S parameter prints the time taken by the simulation, from the time it was first entered using M37 S1, up to the current point (if simulation mode is still active) or the point that the simulation was ended (if simulation mode is no longer active).

M37 P"filename" enters simulation mode, prints the specified file, exits simulation mode, reports the print time, and appends it to the G-code file as a comment for later retrieval.

M38 Compute SHA1 hash of target file

Used to compute a hash of a file on the SD card. Examples:

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
00

Returns a hexadecimal string which is the SHA1 of the file. If the file cannot be found, then the string "Cannot find file" is returned instead.

M39 Report SD card information

ParametersPn SD slot number, default 0Sn Response format. S0 returns a plain text response, S2 returns a response in JSON format.ExamplesM39  ; report information for SD card 0 in plain text formatM39 P1 S2 ; report information for SD card 1 in JSON format

This command returns information about the SD card in the specified slot in the requested format. At least the following is returned:

  • Whether or not a usable card is present in the slot
  • The capacity of the card in bytes (if a card is present)
  • The amount of free space on the card in bytes (if a card is present)

The JSON response has the following format (more fields may be added in future):

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
01

The capacity, free space and cluster size are in bytes, and the interface speed is in bytes/second.

M40: Eject

If your RepRap machine can eject the parts it has built off the bed, this command executes the eject cycle. This usually involves cooling the bed and then performing a sequence of movements that remove the printed parts from it. The X, Y and Z position of the machine at the end of this cycle are undefined (though they can be found out using the

G1 F1500           ; Set feedrate to 1500mm/min
G1 X50 Y25.3 E22.4 ; Move and extrude
89 command, q.v.).

See also

G1 F1500           ; Set feedrate to 1500mm/min
G1 X50 Y25.3 E22.4 ; Move and extrude
90 and
G1 F1500           ; Set feedrate to 1500mm/min
G1 X50 Y25.3 E22.4 ; Move and extrude
91 below.

M41: Loop

Example
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
02

If the RepRap machine was building a file from its own memory such as a local SD card (as opposed to a file being transmitted to it from a host computer) this goes back to the beginning of the file and runs it again. So, for example, if your RepRap is capable of ejecting parts from its build bed then you can set it printing in a loop and it will run and run. Use with caution - the only things that will stop it are:

  1. When you press the reset button,
  2. When the build material runs out (if your RepRap is set up to detect this), and
  3. When there's an error (such as a heater failure).

M42: Switch I/O pin

Parameters
N123
83 Pin number
N123
62 Pin valueExample
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
03

G1 F1500           ; Set feedrate to 1500mm/min
G1 X50 Y25.3 E22.4 ; Move and extrude
94 switches a general purpose I/O pin. Use
G1 F1500           ; Set feedrate to 1500mm/min
G1 X50 Y25.3 E22.4 ; Move and extrude
95 to set pin x to value y, when omitting Px the LEDPIN will be used.

In Teacup, general purpose devices are handled like a heater, see M104.

In Marlin Firmware, pin numbers for 32-bit processors are in the form PORT * 100 + PIN. So pin P1_02 on LPC1768 can be set with

G1 F1500           ; Set feedrate to 1500mm/min
G1 X50 Y25.3 E22.4 ; Move and extrude
96.

Marlin 1.x includes an

N123 [...G Code in here...] *71
46 parameter to permit setting "volatile" pins that Marlin is using.

Marlin 2.0.5.2 - 2.0.9.3 uses the

N123
45 parameter to set the pin mode: 0=INPUT, 1=OUTPUT, 2=INPUT_PULLUP, 3=INPUT_PULLDOWN. In Marlin 2.0.9.4 and up the
N123
46 parameter is used instead.

In RepRapFirmware, the S field may be in the range 0..1 or 0..255. The pin reference is an internal firmware reference named "digital pin", see Duet pinout. It maps on different connector pins depending the hardware. On Duet 0.6 and 0.8.5 hardware using pre-1.16 firmware, the supported pin numbers and their names on the expansion connector are:

Duet M42 P value to Expansion Port Pin MappingPNameExpansion Port Pin16TXD11117RXD11218TXD01319RXD01420TWD13521TWCK13623PA141036PC41852AD144167PB1632

In firmware 1.16, the pin numbering has changed.

Duet 0.6 and 0.8.5 v1.16+ M42 P value to Expansion Port Pin MappingPNameExpansion Port Pin60PA10/RXD01461PA11/TXD01362PA12/RXD11263PA13/TXD11164PA14/RTS11065PB12/TWD13566PB13/TWCK13667PB16/DAC1*3268PB21/AD144169PC418
  • Also used as CS signal on external SD card socket
Duet WiFi v1.16+ M42 P value to Expansion Port Pin MappingPSignal NameExpansion Connector LabelExpansion Pin60CS5CS55061CS6E3_STOP962CS7E4_STOP1463CS8E5_STOP19

See Using servos and controlling unused I/O pins for all pin definitions.

Pre-1.16 example:

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
04

On RADDS hardware running RepRapFirmware-dc42, the supported Arduino Due pin numbers and their names are:

5 TIOA6, 6 PWML7, 39 PWMH2, 58 AD3, 59 AD2, 66 DAC0, 67 DAC1, 68 CANRX0, 69 CANTX0, 70 SDA1, 71 SCL1, 72 RX LED, 73 TX LED.

See also

G1 F1500                 ; Feedrate 1500mm/min
G1 X50 Y25.3 E22.4 F3000 ; Accelerate to 3000mm/min
00.

M43: Stand by on material exhausted

Example
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
05

If your RepRap can detect when its material runs out, this decides the behaviour when that happens. The X and Y axes are zeroed (but not Z), and then the machine shuts all motors and heaters off except the heated bed, the temperature of which is maintained. The machine will still respond to G and M code commands in this state.

M43: Pin report and debug

Usage
G1 F1500                 ; Feedrate 1500mm/min
G1 X50 Y25.3 E22.4 F3000 ; Accelerate to 3000mm/min
01Parameters
G1 F1500                 ; Feedrate 1500mm/min
G1 X50 Y25.3 E22.4 F3000 ; Accelerate to 3000mm/min
02 Enable / disable background endstop monitoring
N123
83 Pin to read or watch. If omitted, read/watch all pins
G1 F1500                 ; Feedrate 1500mm/min
G1 X50 Y25.3 E22.4 F3000 ; Accelerate to 3000mm/min
04 bool watch pins -reporting changes- until reset, click, or
G1 F1500                 ; Feedrate 1500mm/min
G1 X50 Y25.3 E22.4 F3000 ; Accelerate to 3000mm/min
05
G1 F1500                 ; Feedrate 1500mm/min
G1 X50 Y25.3 E22.4 F3000 ; Accelerate to 3000mm/min
06 bool Flag to ignore pin protectionNoteYou must have
G1 F1500                 ; Feedrate 1500mm/min
G1 X50 Y25.3 E22.4 F3000 ; Accelerate to 3000mm/min
07 uncommented in your
G1 F1500                 ; Feedrate 1500mm/min
G1 X50 Y25.3 E22.4 F3000 ; Accelerate to 3000mm/min
08 file for M43 to work.

M44: Codes debug - report codes available

In MK4duo you must enable

G1 F1500                 ; Feedrate 1500mm/min
G1 X50 Y25.3 E22.4 F3000 ; Accelerate to 3000mm/min
09 to get this G-code.

Parameters
G1 F1500                 ; Feedrate 1500mm/min
G1 X50 Y25.3 E22.4 F3000 ; Accelerate to 3000mm/min
06 G-code list
G1 F1500                 ; Feedrate 1500mm/min
G1 X50 Y25.3 E22.4 F3000 ; Accelerate to 3000mm/min
11 M-code list

M44: Reset the bed skew and offset calibration

Resets the bed skew and offset calibration on Prusa i3 MK2/s,MK2.5/s,MK3/s.

M45: Bed skew and offset with manual Z up

Runs the xyz calibration on Prusa i3 MK2/s,MK2.5/s,MK3/s.

Parameters
G1 F1500                 ; Feedrate 1500mm/min
G1 X50 Y25.3 E22.4 F3000 ; Accelerate to 3000mm/min
12 Verbosity level 1, 10 and 20 (low, mid, high). Only when SUPPORT_VERBOSITY is defined. This parameter is optional.

M46: Show the assigned IP address

Reports the assigned IP address of a Toshiba FlashAir on Prusa i3 MK2/s,MK2.5/s,MK3/s. At this moment it is deactivated.

M47: Show end stops dialog on the display

Show end stops dialog on the display on Prusa i3 MK2/s,MK2.5/s,MK3/s.

M48: Measure Z-Probe repeatability

Parameters
N123
83 number of points
N123
51 position on the X axis
N123
52 position on the Y axis
G1 F1500                 ; Feedrate 1500mm/min
G1 X50 Y25.3 E22.4 F3000 ; Accelerate to 3000mm/min
16 verbosity
N123
67 engage
N123
92 legs of travel
N123 [...G Code in here...] *71
00 schizoid

As with

N123 [...G Code in here...] *71
74, the E flag causes the probe to stow after each probe.

The S flag will result is a random sized, 5 pointed star, being traced (X and Y axis) between each sample. Usually a user will get worse repeat-ability numbers with S specified because the X axis and Y axis movements will add to the machine's positioning errors.

Prusa specific 1

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

G1 F1500                 ; Feedrate 1500mm/min
G1 X50 Y25.3 E22.4 F3000 ; Accelerate to 3000mm/min
21

Parameters
G1 F1500                 ; Feedrate 1500mm/min
G1 X50 Y25.3 E22.4 F3000 ; Accelerate to 3000mm/min
22 number(AA) of samples, default=10 (valid values between 4 and 50)
N123
51 X position for samples
N123
52 Y position for samples
G0 X12               ; move to 12mm on the X axis
G0 F1500             ; Set the feedrate to 1500mm/min
G1 X90.6 Y13.8 E22.4 ; Move to 90.6mm on the X axis and 13.8mm on the Y axis while extruding 22.4mm of material
01 Verbosity level 1-4 (low to highest)
G1 F1500                 ; Feedrate 1500mm/min
G1 X50 Y25.3 E22.4 F3000 ; Accelerate to 3000mm/min
26 Legs of travel 1-15

M49: Set G26 debug flag

UsageM49 S1 ; Enable G26 verbose debug output

M70: Display message

Example
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
06

Display a message on the LCD.

N123 [...G Code in here...] *71
10 is the time to display message for.

M72: Play a tone or song

Example
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
07

Instruct the machine to play a preset song. Acceptable song IDs are machine specific. P is the ID of the song to play.

M73: Set/Get build percentage

Example
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
08

Tell the firmware the current build progress percentage. The machine is expected to display this on its display. If the percentage is exactly 0 a "Build Start" notification is sent to the host. If the percentage is exactly 100 a "Build End" notification is sent to the host.

Use "M73" by itself to get a report of the current print progress.

Prusa specific1

Prusa firmware shows percent done, time remaining and time to change/pause/user interaction.

Usage

G1 F1500                 ; Feedrate 1500mm/min
G1 X50 Y25.3 E22.4 F3000 ; Accelerate to 3000mm/min
28

ParametersThis command can be used without any additional parameters.
N123 [...G Code in here...] *71
10 Percent in normal mode
N123
89 Time remaining in normal mode (minutes)
G1 F1500                 ; Feedrate 1500mm/min
G1 X50 Y25.3 E22.4 F3000 ; Accelerate to 3000mm/min
31 Percent in silent mode
N123 [...G Code in here...] *71
00 Time remaining in silent mode (minutes)
N123 [...G Code in here...] *71
70 Time to change/pause/user interaction in normal mode (minutes)1
N123 [...G Code in here...] *71
86 Time to change/pause/user interaction in silent mode (minutes)1Examples
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
09

M78: Show statistical information about the print jobs

M80: ATX Power On

Parameters
G1 F1500                 ; Feedrate 1500mm/min
G1 X50 Y25.3 E22.4 F3000 ; Accelerate to 3000mm/min
35 (RepRapFirmware 3.4 and later only) Name of the pin used to control the power supply, default "pson"Examples
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
10

Turns on the ATX power supply from standby mode to fully operational mode. No-op on electronics without standby mode.

Notes
  • Marlin requires the
    G1 F1500                 ; Feedrate 1500mm/min
    G1 X50 Y25.3 E22.4 F3000 ; Accelerate to 3000mm/min
    
    36 configuration option to be set to a non-zero value to enable
    G1 F1500                 ; Feedrate 1500mm/min
    G1 X50 Y25.3 E22.4 F3000 ; Accelerate to 3000mm/min
    
    37.
  • Some firmwares (e.g., Teacup) handle power on/off automatically, so this is redundant there. Also, see RAMPS wiring for ATX on/off.
  • Prusa requires
    G1 F1500                 ; Feedrate 1500mm/min
    G1 X50 Y25.3 E22.4 F3000 ; Accelerate to 3000mm/min
    
    38 and
    G1 F1500                 ; Feedrate 1500mm/min
    G1 X50 Y25.3 E22.4 F3000 ; Accelerate to 3000mm/min
    
    39 must be set.1

M81: ATX Power Off

ParametersP quit the daemon (redeem only)R restart the daemon (redeem only)Sn n=0 turn power off immediately (default), n=1 turn power off when all thermostatic fans have turned off (RepRapFirmware 1.20 and later only)ExamplesM81  ; turn power off immediatelyM81 S1 ; turn power off when everything has cooled down (RepRapFirmware)

Turns off the ATX power supply. Counterpart to

G1 F1500                 ; Feedrate 1500mm/min
G1 X50 Y25.3 E22.4 F3000 ; Accelerate to 3000mm/min
37.

Notes
  • Prusa requires
    G1 F1500                 ; Feedrate 1500mm/min
    G1 X50 Y25.3 E22.4 F3000 ; Accelerate to 3000mm/min
    
    38 and
    G1 F1500                 ; Feedrate 1500mm/min
    G1 X50 Y25.3 E22.4 F3000 ; Accelerate to 3000mm/min
    
    39 must be set to Power off.1

M82: Set extruder to absolute mode

Example
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
11

Makes the extruder interpret extrusion as absolute positions.

This is the default in repetier and for Yaskawa controllers.

M83: Set extruder to relative mode

Example
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
12

Makes the extruder interpret extrusion values as relative positions.

Note that the Ultimaker 3 will revert back to absolute extrusion after each tool change.

M84: Stop idle hold

ParametersThis command can be used without any additional parameters.
N123
78 Reset flags1Example
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
13

Stop the idle hold on all axis and extruder. In some cases the idle hold causes annoying noises, which can be stopped by disabling the hold. Be aware that by disabling idle hold during printing, you will get quality issues. This is recommended only in between or after printjobs.

On Marlin, Repetier and RepRapFirmware,

G1 F1500           ; Set feedrate to 1500mm/min
G1 X50 Y25.3 E22.4 ; Move and extrude
31 can also be used to configure or disable the idle timeout. For example, "M84 S10" will idle the stepper motors after 10 seconds of inactivity. "M84 S0" will disable idle timeout; steppers will remain powered up regardless of activity. For Yaskawa systems M84 is not applicable due to servo motors not producing the annoying noises.

Notes

1RepRapFirmware-dc42 and other firmware may not support this parameter.

2Prusa firmware uses

G1 F1500           ; Set feedrate to 1500mm/min
G1 X50 Y25.3 E22.4 ; Move and extrude
31 similar to G-code#M18:_Disable_all_stepper_motors

3On Klipper

G1 F1500           ; Set feedrate to 1500mm/min
G1 X50 Y25.3 E22.4 ; Move and extrude
31 is equivalent to G-code#M18:_Disable_all_stepper_motors

Prusa Usage
G1 F1500                 ; Feedrate 1500mm/min
G1 X50 Y25.3 E22.4 F3000 ; Accelerate to 3000mm/min
47Prusa ParametersThis command can be used without any additional parameters.2
N123
67 Extruder drive(s)2
N123 [...G Code in here...] *71
00 Seconds
N123 [...G Code in here...] *71
42 X axis
N123 [...G Code in here...] *71
43 Y axis
N123 [...G Code in here...] *71
04 Z axisExample
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
14

Set Inactivity Shutdown Timer with parameter S. "M85 S0" will disable the inactivity shutdown time (default)

Usage
G1 F1500                 ; Feedrate 1500mm/min
G1 X50 Y25.3 E22.4 F3000 ; Accelerate to 3000mm/min
53Parameters
N123 [...G Code in here...] *71
00 Seconds

Similar to

G1 F1500                 ; Feedrate 1500mm/min
G1 X50 Y25.3 E22.4 F3000 ; Accelerate to 3000mm/min
55 but applies to the "safety timer" in Prusa Firmware.

Sets the safety timer expiration time in seconds. M86 S0 will disable safety timer.

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

Usage
G1 F1500                 ; Feedrate 1500mm/min
G1 X50 Y25.3 E22.4 F3000 ; Accelerate to 3000mm/min
56

Cancels the safety timer. Equivalent to

G1 F1500                 ; Feedrate 1500mm/min
G1 X50 Y25.3 E22.4 F3000 ; Accelerate to 3000mm/min
57.

M92: Set axis_steps_per_unit

Parameters
N123
51 Steps per unit for the X drive
N123
52 Steps per unit for the Y drive
N123
53 Steps per unit for the Z drive
N123
54 Steps per unit for the extruder drive(s)
N123
62 Defines in which microstepping the above steps per unit are given. If omitted it will use the microstepping currently set by M350.1Examples
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
15

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 (

G0 X12               ; move to 12mm on the X axis
G0 F1500             ; Set the feedrate to 1500mm/min
G1 X90.6 Y13.8 E22.4 ; Move to 90.6mm on the X axis and 13.8mm on the Y axis while extruding 22.4mm of material
07 in Marlin) or in the configuration file (config.g in RepRapFirmware). Very useful for calibration.

RepRapFirmware will report the current steps/mm if you send

G1 F1500                 ; Feedrate 1500mm/min
G1 X50 Y25.3 E22.4 F3000 ; Accelerate to 3000mm/min
64 without any parameters. For Yaskawa systems M92/M93 is not applicable due to use of servo motors.

Notes

1 Only available in RepRapFirmware >=2.03

M93: Send axis_steps_per_unit

M98: Call Macro/Subprogram

Parameters
N123
83 Macro filename. In RepRapFirmware 3 this must be enclosed in double-quote characters. In RepRapFirmware 2 the double-quote characters are optional.Example
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
16

Runs the macro in the file mymacro.g. In conventional G Codes for CNC machines the

N123 [...G Code in here...] *71
10 parameter normally refers to a line number in the program itself (P2000 would run the Macro starting at line O2000, say). For RepRap, which almost always has some sort of mass storage device inbuilt, it simply refers to the name of a G-code file that is executed by the
G0 X12               ; move to 12mm on the X axis
G0 F1500             ; Set the feedrate to 1500mm/min
G1 X90.6 Y13.8 E22.4 ; Move to 90.6mm on the X axis and 13.8mm on the Y axis while extruding 22.4mm of material
77 call. That G-code file does not need to end with an
G1 F1500                 ; Feedrate 1500mm/min
G1 X50 Y25.3 E22.4 F3000 ; Accelerate to 3000mm/min
68 (return) as the end-of-file automatically causes a return. RepRapFirmware supports nested macro calls up to a depth of 5.

Certain machine parameters are saved at the start of the macro call and restored at the end. For RepRapFirmware these are: axis movement relative/absolute mode, extruder movement absolute/relative mode, feed rate, inches/mm setting, and whether or not volumetric extrusion is selected. This allows the macro to change these settings without affecting the subsequent behaviour of the calling file.

RepRapFirmware also allows the filename to include a path to a subdirectory. For relative paths, the default folder is /sys, but some implementations may check the /macros directory too. Absolute file paths are supported by RepRapFirmware too.

M99: Return from Macro/Subprogram

Example
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
17

Returns from an

G1 F1500                 ; Feedrate 1500mm/min
G1 X50 Y25.3 E22.4 F3000 ; Accelerate to 3000mm/min
69 call.

RepRapFirmware closes the currently active macro file. If a nested macro is being run, RepRapFirmware goes up one stack level.

M101: Turn extruder 1 on (Forward), Undo Retraction

In Teacup firmware: If a DC extruder is present, turn that on. Else, undo filament retraction, which means, make the extruder ready for extrusion. Complement to

G1 F1500           ; Set feedrate to 1500mm/min
G1 X50 Y25.3 E22.4 ; Move and extrude
43.

In BFB/RapMan: Turn extruder on (forward/filament in).

In RepRapFirmware: undo filament retraction. The length and speed are set by the

N123 [...G Code in here...] *71
07 command. RepRapFirmware supports this command for compatibility with Simplify3D.

In other firmwares: Deprecated. Regarding filament retraction, see

N123 [...G Code in here...] *71
02,
G1 F1500                 ; Feedrate 1500mm/min
G1 X50 Y25.3 E22.4 F3000 ; Accelerate to 3000mm/min
73,
N123 [...G Code in here...] *71
07,
N123 [...G Code in here...] *71
12,
G1 F1500                 ; Feedrate 1500mm/min
G1 X50 Y25.3 E22.4 F3000 ; Accelerate to 3000mm/min
76,
G1 F1500                 ; Feedrate 1500mm/min
G1 X50 Y25.3 E22.4 F3000 ; Accelerate to 3000mm/min
77,
G1 F1500                 ; Feedrate 1500mm/min
G1 X50 Y25.3 E22.4 F3000 ; Accelerate to 3000mm/min
78.

M102: Turn extruder 1 on (Reverse)

In BFB/RapMan firmware: Turn extruder on Reverse (Still to add)

M102: Configure Distance Sensor

For Marlin's

G1 F1500                 ; Feedrate 1500mm/min
G1 X50 Y25.3 E22.4 F3000 ; Accelerate to 3000mm/min
79 option, configure the sensor.

G1 F1500                 ; Feedrate 1500mm/min
G1 X50 Y25.3 E22.4 F3000 ; Accelerate to 3000mm/min
80 : Set adjustable Z height in 10ths of a mm (e.g., '
G1 F1500                 ; Feedrate 1500mm/min
G1 X50 Y25.3 E22.4 F3000 ; Accelerate to 3000mm/min
81' enables adjusting for Z <= 0.4mm.)
G1 F1500                 ; Feedrate 1500mm/min
G1 X50 Y25.3 E22.4 F3000 ; Accelerate to 3000mm/min
82 : Disable adjustable Z height.Negative S values are commands
G1 F1500                 ; Feedrate 1500mm/min
G1 X50 Y25.3 E22.4 F3000 ; Accelerate to 3000mm/min
83 : Read sensor information
G1 F1500                 ; Feedrate 1500mm/min
G1 X50 Y25.3 E22.4 F3000 ; Accelerate to 3000mm/min
84 : Read raw Calibration data
G1 F1500                 ; Feedrate 1500mm/min
G1 X50 Y25.3 E22.4 F3000 ; Accelerate to 3000mm/min
85 : Start Calibration

M103: Turn all extruders off, Extruder Retraction

In Teacup firmware: If a DC extruder is present, turn that off. Else, retract the filament in the hope to prevent nozzle drooling. Complement to

G1 F1500           ; Set feedrate to 1500mm/min
G1 X50 Y25.3 E22.4 ; Move and extrude
33.

In BFB/RapMan firmware: Turn extruder off.

In RepRapFirmware: retract filament. The length and speed are set by the

N123 [...G Code in here...] *71
07 command. RepRapFirmware supports this command for compatibility with Simplify3D.

In other firmwares: Deprecated. Regarding filament retraction, see

N123 [...G Code in here...] *71
02,
G1 F1500                 ; Feedrate 1500mm/min
G1 X50 Y25.3 E22.4 F3000 ; Accelerate to 3000mm/min
73,
N123 [...G Code in here...] *71
07,
N123 [...G Code in here...] *71
12,
G1 F1500                 ; Feedrate 1500mm/min
G1 X50 Y25.3 E22.4 F3000 ; Accelerate to 3000mm/min
76,
G1 F1500                 ; Feedrate 1500mm/min
G1 X50 Y25.3 E22.4 F3000 ; Accelerate to 3000mm/min
77,
G1 F1500                 ; Feedrate 1500mm/min
G1 X50 Y25.3 E22.4 F3000 ; Accelerate to 3000mm/min
78.

M104: Set Extruder Temperature

Parameters
N123 [...G Code in here...] *71
70 Use fan for cooling (Only Prusa)
G1 F1500                 ; Feedrate 1500mm/min
G1 X50 Y25.3 E22.4 F3000 ; Accelerate to 3000mm/min
96 Display temperature (Only Prusa)
N123
62 Target temperature
N123
61 Idle temperature (Only MK4duo)Example
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
18

Set the temperature of the current extruder to 190oC and return control to the host immediately (i.e. before that temperature has been reached by the extruder). See also M109.

See also using G10. Deprecation of

G1 F1500                 ; Feedrate 1500mm/min
G1 X50 Y25.3 E22.4 F3000 ; Accelerate to 3000mm/min
99 is subject to discussion. --Traumflug 11:33, 19 July 2012 (UTC)

M104 in Marlin Firmware

See Marlin Wiki. In Marlin Firmware, using

G1 F1500                 ; Feedrate 1500mm/min
G1 X50 Y25.3 E22.4 F3000 ; Accelerate to 3000mm/min
99 with no parameters will turn off the heater for the current extruder. This is also the case for
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
001 without a number after the
N123 [...G Code in here...] *71
00 parameter.

M104 in Teacup Firmware

In Teacup Firmware,

G1 F1500                 ; Feedrate 1500mm/min
G1 X50 Y25.3 E22.4 F3000 ; Accelerate to 3000mm/min
99 can be additionally used to handle all devices using a temperature sensor. It supports the additional
N123 [...G Code in here...] *71
10 parameter, which is a zero-based index into the list of sensors in config.h. For devices without a temp sensor, see M106.

Example
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
19

Set the temperature of the device attached to the second temperature sensor to 100°C.

M104 in RepRapFirmware and Klipper

RepRapFirmware and some other firmwares support the optional

N123
46 parameter (as generated by slic3r) to specify which tool the command applies to.

M105: Get Extruder Temperature

ParametersThis command can be used without any additional parameters.Examples
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
20

Request the temperature of the current extruder, the build base and the build chamber in degrees Celsius. The temperatures are returned to the host computer. For example, the line sent to the host in response to this command can look like:

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
21

The parameters mean the following:

  • T, T0, ..., Tn - extruder temperature. In a single extruder setup, only T will be reported. Some firmware variants will report no T0 in multi extruder setups - in that case T is to be considered the temperature of the first tool. Otherwise, T should be considered the temperature of the currently selected tool (which will be repeated in one of the Tn entries)
  • B - bed temperature
  • C - chamber temperature
  • @ - Hotend power
  • [email protected] - Bed power
  • P - PINDAv2 actual (Prusa MK2.5/s MK3/s only)1
  • A - Ambient actual (Prusa MK3/s only)1

A temperature report will usually include actual and target temperature for all available heaters, with the format being "actual/target" or - for some firmware variants - "actual /target". During a blocking heatup some firmware variants only report the temperature tuple for the heater that is currently in blocking heatup state.

Note that temperatures can be reported as integers or floats. There sadly are a lot of interpretations of how an M105 response should look like across firmware variants, making parsing them potentially tricky.

Expansion/generalization of

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
006 to be considered using S1 parameter as noted in Pronterface I/O Monitor

In Repetier and MK4duo you can add X0 (X1 MK4duo) to get raw values as well:

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
22

Recent versions of RepRapFirmware also report the current and target temperatures of all active heaters.

M106: Fan On

Parameters
N123
83 Fan number (optional, defaults to 0)2
N123
62 Fan speed (0 to 255; RepRapFirmware also accepts 0.0 to 1.0))Extra Parameters
N123
78 Invert signal, or disable fan1 3
N123
55 Set fan PWM frequency, in Hz1 3
N123
92 Set minimum fan speed (0 to 255 or 0.0 to 1.0)1 3
N123
51 Set maximum fan speed (0 to 255 or 0.0 to 1.0)1 3
N123
87 Blip time - fan will be run at full PWM for this number of seconds when started from standstill1
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
014 Select heaters monitored when in thermostatic mode1 3
N123
61 Restore fan speed to the value it has when the print was paused1
N123 [...G Code in here...] *71
17 Set thermostatic mode trigger temperature
N123
88 Set custom name (RRF > 2.01 only)1Example
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
23Examples (RepRapFirmware)
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
24

The first example turns on the default cooling fan at half speed. The second one inverts the cooling fan signal of the second fan and sets its value to 1/3 of its maximum. The third one sets the second fan to a thermostatic fan for heaters 1 and 2 (e.g. the extruder heaters in a dual-nozzle machine) such that the fan will be on when either hot end is at or above 45C.

Mandatory parameter 'S' declares the PWM value (0-255).

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
018 turns the fan off. In some implementations like RepRapFirmware the PWM value may alternatively be specified as a real fraction:
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
019.

Notes

1These parameters are only available in RepRapFirmware.

2Marlin 1.0 to 1.1.6 only supports a single fan. Marlin 1.1.7 and up supports up to 3 fans.

3These parameters are only available in MK4duo.

M106 in RepRapFirmware

If an

N123 [...G Code in here...] *71
00 parameter is provided but no other parameter is present, then the speeds of the print cooling fans associated with the current tool will be set (see the
N123 [...G Code in here...] *71
91 parameter in the
N123 [...G Code in here...] *71
05 command). If no tool is active then the speed of Fan 0 will be set. Either way, the speed is remembered so that it can be recalled using the
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
023 parameter (see below).

If no

N123 [...G Code in here...] *71
00 parameter is given but the R1 parameter is used, the fan speed when the print was last paused will be set. If the
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
023 parameter is used, then the speeds of the print cooling fans associated with the current tool will be set to the remembered value (see above).

The

N123
46 and
N123
68 parameters allow a fan to be configured to operate in thermostatic mode, for example to use one of the fan channels to control the hot end fan. In this mode the fan will be fully on when the temperature of any of the heaters listed in the
N123
68 parameter is at or above the trigger temperature set by the
N123
46 parameter, and off otherwise. Thermostatic mode can be disabled using parameter H-1.

The

N123 [...G Code in here...] *71
67 parameter sets the time for which the fan will be operated at full PWM when started from cold, to allow low fan speeds t be used. A value of 0.1 seconds is usually sufficient.

The

N123 [...G Code in here...] *71
93 parameter defines the minimum PWM value that is usable with this fan. If a lower value is commanded that is not zero, it will be rounded up to this value. The
N123 [...G Code in here...] *71
42 parameter defines the maximum PWM value that is allowed for this fan. If a higher value is commanded, it will be rounded down to this value.

The

N123 [...G Code in here...] *71
46 parameter causes the fan output signal to be inverted if its value is greater than zero. This makes the cooling fan output suitable for feeding the PWM input of a 4-wire fan via a diode. If the parameter is present and zero, the output is not inverted. If the
N123 [...G Code in here...] *71
46 parameter is negative then in RRF 1.16 and later the fan is disabled, which frees up the pin for use as a general purpose I/O pin that can be controlled using
G1 F1500           ; Set feedrate to 1500mm/min
G1 X50 Y25.3 E22.4 ; Move and extrude
94.

M106 in Teacup Firmware

Additionally to the above, Teacup Firmware uses

G1 F1500           ; Set feedrate to 1500mm/min
G1 X50 Y25.3 E22.4 ; Move and extrude
44 to control general devices. It supports the additional
N123 [...G Code in here...] *71
10 parameter, which is an zero-based index into the list of heaters/devices in config.h.

Example
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
25

Turn on device #3 at full speed/wattage.

Note: When turning on a temperature sensor equipped heater with

G1 F1500           ; Set feedrate to 1500mm/min
G1 X50 Y25.3 E22.4 ; Move and extrude
44 and
G1 F1500                 ; Feedrate 1500mm/min
G1 X50 Y25.3 E22.4 F3000 ; Accelerate to 3000mm/min
99 at the same time, temperature control will override the value given in
G1 F1500           ; Set feedrate to 1500mm/min
G1 X50 Y25.3 E22.4 ; Move and extrude
44 quickly.

Note well: The ambiguous text in the note above needs to be reworded by someone who knows the actual functioning. Below is my interpretation based on language use, not practical experience or code inspection.

Note: If

G1 F1500                 ; Feedrate 1500mm/min
G1 X50 Y25.3 E22.4 F3000 ; Accelerate to 3000mm/min
99 is (or becomes) active on a heater (or other device) with a feedback sensor it will correct any
G1 F1500           ; Set feedrate to 1500mm/min
G1 X50 Y25.3 E22.4 ; Move and extrude
44 initiated control output value change in the time it takes for the PID (of other feedback) loop to adjust it back to minimum error. It may not be easy to observe a change in the temperature (process value) due to this brief change in the control value

M107: Fan Off

Deprecated in Teacup firmware and in RepRapFirmware. Use

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
018 instead.

M108: Cancel Heating

Breaks out of an

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
044 or
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
045 wait-for-temperature loop, continuing the print job. Use this command with caution! If cold extrusion prevention is enabled (see
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
046) and the temperature is too low, this will start "printing" without extrusion. If cold extrusion prevention is disabled and the hot-end temperature is too low, the extruder may jam.

This command was introduced in Marlin 1.1.0. As with other emergency commands [e.g.,

G1 F1500           ; Set feedrate to 1500mm/min
G1 X50 Y25.3 E22.4 ; Move and extrude
21] this requires the host to leave space in the command buffer, or the command won't be executed until later.

Recent versions of Marlin introduce

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
048, which overcomes the buffer limitation by watching the incoming serial stream. Commands M108, M112, M410, and M876 can all be intercepted by the emergency parser, so it is recommended to enable this feature.

M108: Set Extruder Speed (BFB)

Sets speed of extruder motor. (Deprecated in FiveD firmware, see

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
049)

M109: Set Extruder Temperature and Wait

Parameters
N123 [...G Code in here...] *71
70 Use fan for cooling (Only Prusa)
N123
62 minimum target temperature, waits until heating
N123
61 maximum target temperature, waits until cooling (Sprinter)
N123
61 accurate target temperature, waits until heating and cooling (Marlin and MK4duo)
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
054 tool number (RepRapFirmware and Klipper), optional
N123 [...G Code in here...] *71
91 use extruder fan to speed up cooling (if not heating)Example
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
26
M109 in Teacup

Not needed. To mimic Marlin behaviour, use M104 followed by M116.

M109 in Marlin, MK4duo, Sprinter (ATmega port), RepRapFirmware, Prusa

Set extruder heater temperature in degrees celsius and wait for this temperature to be achieved.

Example
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
27

RepRapFirmware also supports the optional

N123
46 parameter (as generated by slic3r) to specify which tool the command refers to (see below).

M109 in Sprinter (4pi port)

Parameters:

N123 [...G Code in here...] *71
00 (optional), set target temperature value. If not specified, waits for the temperature set by M104.
N123
89 (optional), sets target temperature range maximum value.

Example
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
28

If you have multiple extruders, use

N123
46 or
N123 [...G Code in here...] *71
10 parameter to specify which extruder you want to set/wait.

Another way to do this is to use G10.

M109 in MakerBot
Example
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
29

Sets the target temperature for the current build platform. S is the temperature to set the platform to, in degrees Celsius. T is the platform to heat.

M109 in Klipper

According to the documentation, Klipper will wait for the specified temperature to settle, i.e. it will wait until it goes back down in case it overshoots. Klipper also supports the optional

N123
46 parameter to specify which tool the command refers to (see above).

M110: Set Current Line Number

Parameters
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
062 Line numberExample
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
30

This example sets the current line number to 123. Thus the expected next line after this command will be 124.

M111: Set Debug Level

Parameters
N123
83 Debug module1
N123
62 Debug on/offExamples
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
31

Enable or disable debugging features in the firmware. The implementation may look different per firmware.

Notes

1This parameter is only available in RepRapFirmware.

2Prusa fimrware use D-codes/commands for debugging.

M111 in RepRapFirmware

RepRapFirmware allows debugging to be set for each module. If the optional 'P' parameter is not specified, debugging will be enabled for all modules. For a list of modules, send

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
065.

M111 in Repetier

Set the level of debugging information transmitted back to the host to level 6. The level is the OR of three bits:

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
32

Thus 6 means send information and errors, but don't echo commands. (This is the RepRap default.)

For firmware that supports ethernet and web interfaces

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
066 will turn web debug information on without changing any other debug settings, and
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
067 will turn it off. Web debugging usually means that HTTP requests will be echoed to the USB interface, as will the responses.

M112: Full (Emergency) Stop

Example
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
33

Any moves in progress are immediately terminated, then RepRap shuts down. All motors and heaters are turned off. It can be started again by pressing the reset button on the master microcontroller. See also

G1 F1500           ; Set feedrate to 1500mm/min
G1 X50 Y25.3 E22.4 ; Move and extrude
23 and
G1 F1500           ; Set feedrate to 1500mm/min
G1 X50 Y25.3 E22.4 ; Move and extrude
20.

Please note while many systems termed this an Emergency Stop, this terminology is regulated in many regions with specific requirements behind its use. Marlin 2.0.x has renamed this to Full Stop. RepRapFirmware has indicated an intention to make a similar change as well. This stop function is NOT implemented in a Category 0 or 1 stop fashion or with fail-safe hardware compliying with PLd or better. The function as implemented is a category 2 software stop with no redundancies.

M113: Set Extruder PWM

Example
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
34

Set the PWM for the currently-selected extruder. On its own this command sets RepRap to use the on-board potentiometer on the extruder controller board to set the PWM for the currently-selected extruder's stepper power. With an S field:

M113 S0.7

it causes the PWM to be set to the

N123 [...G Code in here...] *71
00 value (70% in this instance).
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
071 turns the extruder off, until an
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
049 command other than
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
071 is sent.

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.

Usage
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
074Parameters
N123
62 keepalive interval to setExamples
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
35

M114: Get Current Position

Example
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
36

This causes the RepRap machine to report its current X, Y, Z and E coordinates to the host.

For example, the machine returns a string such as:

ok C: X:0.00 Y:0.00 Z:0.00 E:0.00

In Marlin first 3 numbers is the position for the planner. The other positions are the positions from the stepper function. This helps for debugging a previous stepper function bug.

X:0.00 Y:0.00 RZ:0.00 LZ:0.00 Count X:0.00 Y:0.00 RZ:41.02 LZ:41.02

M115: Get Firmware Version and Capabilities

ParametersThis command can be used without any additional parameters.
N123
87 (RepRapFirmware 3 only) Expansion board number (typically the CAN address) for which the firmware version is requested, default 0 (i.e. main board)
N123
83 Electronics type1
N123 [...G Code in here...] *71
87 Report the Prusa version number2
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
079 Check the firmware version provided2Examples
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
37

Request the Firmware Version and Capabilities of the current microcontroller The details are returned to the host computer as key:value pairs separated by spaces and terminated with a linefeed.

sample data from firmware:

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
38

This

G1 F1500           ; Set feedrate to 1500mm/min
G1 X50 Y25.3 E22.4 ; Move and extrude
84 code is inconsistently implemented, and should not be relied upon to exist, or output correctly in all cases. An initial implementation was committed to svn for the FiveD Reprap firmware on 11 Oct 2010. Work to more formally define protocol versions is currently (October 2010) being discussed. See M115_Keywords for one draft set of keywords and their meanings. See the
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
081 command for a more comprehensive report on machine capabilities supported by RepRapFirmware.

Notes

1This parameter is supported only in RepRapFirmware and can be used tell the firmware about the hardware on which it is running. If the

N123 [...G Code in here...] *71
10 parameter is present then the integer argument specifies the hardware being used. The following are currently supported:

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
39

2These parameters are only supported in Prusa Firmware. Parameter

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
079 will check 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.

sample data

G1 F1500           ; Set feedrate to 1500mm/min
G1 X50 Y25.3 E22.4 ; Move and extrude
84:

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
40

sample data

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
085

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
41

sample data on display for 30s or user interaction

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
086

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
42

M116: Wait

ParametersThis command can be used without any additional parameters.1
N123
83 Tool number
N123
56 Heater number
N123
88 Chamber numberExamples
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
43

Wait for all temperatures and other slowly-changing variables to arrive at their set values if no parameters are specified. See also

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
044.

Notes

1Most implementations don't support any parameters, but RepRapFirmware version 1.04 and later supports an optional 'P' parameter that is used to specify a tool number. If this parameter is present, then the system only waits for temperatures associated with that tool to arrive at their set values. This is useful during tool changes, to wait for the new tool to heat up without necessarily waiting for the old one to cool down fully.

Recent versions of RepRapFirmware also allow a list of the heaters to be specified using the 'H' parameter, and if the 'C' parameter is present, this will indicate that the chamber heater should be waited for.

M117: Get Zero Position

Example
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
44

This causes the RepRap machine to report the X, Y, Z and E coordinates in steps not mm to the host that it found when it last hit the zero stops for those axes. That is to say, when you zero X, the x coordinate of the machine when it hits the X endstop is recorded. This value should be 0, of course. But if the machine has drifted (for example by dropping steps) then it won't be. This command allows you to measure and to diagnose such problems. (E is included for completeness. It doesn't normally have an endstop.)

M117: Display Message

Example
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
45

This causes the given message to be shown in the status line on an attached LCD. The above command will display Hello World. If RepRapFirmware is used and no LCD is attached, this message will be reported on the web interface.

Notes

In Prusa Firmware it is also used to display internal messages on LCD.1

M118: Echo message on host

Use this code to print a visible message to the host console, preceded by 'echo:'.

Parameters
int cs = 0;
for(i = 0; cmd[i] != '*' && cmd[i] != NULL; i++)
   cs = cs ^ cmd[i];
cs &= 0xff;  // Defensive programming...
34 (RepRapFirmware only) Message targets(s): 0 = generic [default], 1 = USB, 2 = LCD, 3 = HTTP, 4 = Telnet
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
092 (RepRepFirmware only) Message to sendExample (Marlin)
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
46Example (RepRapFirmware)
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
47

M118: Negotiate Features

Example
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
48

This M-code is for future proofing. NO firmware or hostware supports this at the moment. It is used in conjunction with

G1 F1500           ; Set feedrate to 1500mm/min
G1 X50 Y25.3 E22.4 ; Move and extrude
84's FEATURES keyword.

See Protocol_Feature_Negotiation for more info.

M119: Get Endstop Status

Example
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
49

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.

In redeem,

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
094 can also be used to invert end stops.

Example
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
50

This will invert end stop X1 (Inverted means switch is connected in Normally Open state (NO))

M120: Push

Example
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
51

Push the state of the RepRap machine onto a stack. Exactly what variables get pushed depends on the implementation (as does the depth of the stack - a typical depth might be 5). A sensible minimum, however, might be

  • Current feedrate
  • Whether moves are relative or absolute
  • Whether extrusion is relative or absolute

RepRapFirmware calls this automatically when a macro file is run. In addition to the variables above, it pushes the following values on the stack:

  • Whether the units are inches or mm
  • Whether or not volumetric extrusion is in use

M121: Pop

Example
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
52

Recover the last state pushed onto the stack.

M120: Enable endstop detection

M121: Disable endstop detection

M122: Firmware dependent

M122: Diagnose (RepRapFirmware)
ParametersBmmm Expansion board number for which diagnostics are requested, default 0 which means main boardPnnn Optional parameter to specify what diagnostics are required. Caution: some values of P will crash the firmware deliberately to test error handling! See the Duet3D wiki for more details."DSF" Immediate DSF diagnostics (RRF3/Duet3 only with attached SBC)
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
095 - LPC and STM32 Port Only Outputs the configuration of all the pins allocated by the firmware and board.txtExampleM122

Sending an

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
096 causes the RepRap to transmit diagnostic information, for example via a USB serial link.

If RepRapFirmware is used and debugging is enabled for the Network module, this will also print LWIP stats to the host via USB.

M122: Set Software Endstop (MK4duo)

Disabled or Enabled Software Endstop M122 S<0/1>

M122: Debug Stepper drivers (Marlin)

Get diagnostic info about L6470 or Trinamic stepper drivers having a UART or SPI interface.

With Trinamic drivers there are some extra parameters, and depending on the configuration either basic or detailed information will be reported. Use parameters

N123 [...G Code in here...] *71
42,
N123 [...G Code in here...] *71
43,
N123 [...G Code in here...] *71
04, etc. to limit the report only to the specified steppers, otherwise all steppers are reported. Pass
N123 [...G Code in here...] *71
46 to re-initialize the drivers. Use parameter
N123 [...G Code in here...] *71
00 to sample at regular intervals. The
N123 [...G Code in here...] *71
10 parameter can be used to set the sample interval in milliseconds.

Example
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
53

M123: Firmware dependent

M123: Tachometer value (RepRap, Prusa & Marlin)

Sending a

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
103 causes the RepRap to transmit filament tachometer values from all extruders.

Sending a

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
103 is used in Prusa firmware to report fan speeds and fan pwm values.1

Sending a

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
103 is used in Marlin firmware to report only extruders fans speeds and pwm values.2

Usage
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
54Parameters2
int cs = 0;
for(i = 0; cmd[i] != '*' && cmd[i] != NULL; i++)
   cs = cs ^ cmd[i];
cs &= 0xff;  // Defensive programming...
54 autoreport every n seconds (0 to disable)Prusa firmware output1
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
107
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
108
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
109
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
110Examples1
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
55Examples2
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
56
M123: Endstop Logic (MK4duo)
Parameters
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
111 X Logic
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
112 Y Logic
int cs = 0;
for(i = 0; cmd[i] != '*' && cmd[i] != NULL; i++)
   cs = cs ^ cmd[i];
cs &= 0xff;  // Defensive programming...
55 Z Logic
G1 F1500                 ; Feedrate 1500mm/min
G1 X50 Y25.3 E22.4 F3000 ; Accelerate to 3000mm/min
06 X2 Logic
G1 F1500                 ; Feedrate 1500mm/min
G1 X50 Y25.3 E22.4 F3000 ; Accelerate to 3000mm/min
11 Y2 Logic
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
116 Z2 Logic
int cs = 0;
for(i = 0; cmd[i] != '*' && cmd[i] != NULL; i++)
   cs = cs ^ cmd[i];
cs &= 0xff;  // Defensive programming...
34 Probe Logic
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
118 Door LogicExamples
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
57

M124: Firmware dependent

M124: Immediate motor stop

Immediately stops all motors.

M124: Set Endstop Pullup
Parameters
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
111 X Pullup on/off
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
112 Y Pullup on/off
int cs = 0;
for(i = 0; cmd[i] != '*' && cmd[i] != NULL; i++)
   cs = cs ^ cmd[i];
cs &= 0xff;  // Defensive programming...
55 Z Pullup on/off
G1 F1500                 ; Feedrate 1500mm/min
G1 X50 Y25.3 E22.4 F3000 ; Accelerate to 3000mm/min
06 X2 Pullup on/off
G1 F1500                 ; Feedrate 1500mm/min
G1 X50 Y25.3 E22.4 F3000 ; Accelerate to 3000mm/min
11 Y2 Pullup on/off
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
116 Z2 Pullup on/off
int cs = 0;
for(i = 0; cmd[i] != '*' && cmd[i] != NULL; i++)
   cs = cs ^ cmd[i];
cs &= 0xff;  // Defensive programming...
34 Probe Pullup on/off
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
118 Door Pullup on/offExamples
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
58

M126: Open Valve

Example
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
59

Open the extruder's valve (if it has one) and wait 500 milliseconds for it to do so.

M126 in MakerBot
Example
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
60

Enables an extra output attached to a specific toolhead (e.g. fan)

M127: Close Valve

Example
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
61

Close the extruder's valve (if it has one) and wait 400 milliseconds for it to do so.

M127 in MakerBot
Example
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
62

Disables an extra output attached to a specific toolhead (e.g. fan)

M128: Extruder Pressure PWM

Example
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
63

PWM value to control internal extruder pressure.

G1 F1500           ; Set feedrate to 1500mm/min
G1 X50 Y25.3 E22.4 ; Move and extrude
37 is full pressure.

M129: Extruder pressure off

Example
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
64

In addition to setting Extruder pressure to 0, you can turn the pressure off entirely. P400 will wait 100ms to do so.

M130: Set PID P value

Parameters
N123
83 heater number
N123
62 proportional (Kp)Example
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
65

Teacup can control multiple heaters with independent PID controls. For the default shown at https://github.com/Traumflug/Teacup_Firmware/blob/master/config.default.h, heater 0 is the extruder (P0), and heater 1 is the bed (P1).

Teacup's PID proportional units are in pwm/255 counts per quarter C, so to convert from counts/C, you would divide by 4. Conversely, to convert from count/qC to count/C, multiply by 4. In the above example, S=8 represents a Kp=8*4=32 counts/C.

M131: Set PID I value

Parameters
N123
83 heater number
N123
62 integral (Ki)Example
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
66

Teacup's PID integral units are in pwm/255 counts per (quarter C*quarter second), so to convert from counts/qCqs, you would divide by 16. Conversely, to convert from count/qCqs to count/Cs, multiply by 16. In the above example, S=0.5 represents a Ki=0.5*16=8 counts/Cs.

M132: Set PID D value

Parameters
N123
83 heater number
N123
62 derivative (Kd)Example
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
67

Teacup's PID derivative units are in pwm/255 counts per (quarter degree per 2 seconds), so to convert from counts/C, you would divide by 4. Conversely, to convert from count/qC to count/C, multiply by 8. In the above example, S=24 represents a Kd=24*8=194 counts/(C/s).

M132 in MakerBot
Example
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
68

Loads the axis offset of the current home position from the EEPROM and waits for the buffer to empty.

M133: Set PID I limit value

Parameters
N123
83 heater number
N123
62 integral limit (Ki)Example
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
69

Teacup's PID integral limit units are in quarter-C*quarter-seconds, so to convert from C-s, you would multiply by 16. Conversely, to convert from qC*qs to C*s, divide by 16. In the above example, S=264 represents an integral limit of 16.5 C*s.

M133 in MakerBot

Wait for the toolhead to reach its target temperature.

Parameters
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
136 : Extruder to wait for
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
137 : Time limit, in secondsExample
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
70

M134: Write PID values to EEPROM

Example
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
71
M134 in MakerBot
Example
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
72

Instruct the machine to wait for the platform to reach its target temperature. T is the platform to wait for. P if present, sets the time limit.

M135: Set PID sample interval

Parameters
N123
62 Heat sample time in secondsExample
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
73

Set the PID to measure temperatures and calculate the power to send to the heaters every 300ms.

M135 in MakerBot
Example
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
74

Instructs the machine to change its toolhead. Also updates the State Machine's current tool_index. T is the toolhead for the machine to switch to and the new tool_index for the state machine to use.

M136: Print PID settings to host

Example
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
75

M140: Set Bed Temperature (Fast)

Parameters
N123
83 Bed heater index1
N123
56 Heater number1
N123 [...G Code in here...] *71
17 Tool number2
N123
62 Active/Target temperature
N123
61 Standby temperature1 2Example
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
76

Set the temperature of the build bed to 55oC and return control to the host immediately (i.e. before that temperature has been reached by the bed).

Notes

1 These parameters are only supported in RepRapFirmware. RepRapFirmware allows the bed heater to be switched off if the absolute negative temperature (-273.15) is passed as target temperature. In this case the current bed temperature is not affected:

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
77

2 These parameters are only supported in MK4duo for Idle temperature

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
78

There is an optional R field that sets the bed standby temperature:

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
144.

Recent versions of RepRapFirmware also provide an optional 'H' parameter to set the hot bed heater number. If no heated bed is present, a negative value may be specified to disable it.

M141: Set Chamber Temperature (Fast)

Parameters
N123
83 Chamber index1
N123
56 Heater number1
N123 [...G Code in here...] *71
17 Tool number2
N123
62 Active/Target temperature
N123
61 Standby temperature1 2Examples
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
79

Set the temperature of the chamber to 30oC and return control to the host immediately (i.e. before that temperature has been reached by the chamber).

Notes

1 These parameters are only supported in RepRapFirmware and work just like in M140.

2 These parameters are only supported in MK4duo and work just like in M140.

M142: Firmware dependent

M142: Holding Pressure
Example
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
80

Set the holding pressure of the bed to 1 bar.

The holding pressure is in bar. For hardware which only has on/off holding, when the holding pressure is zero, turn off holding, when the holding pressure is greater than zero, turn on holding.

M142: Set Cooler Temperature (Fast)
Parameters
N123 [...G Code in here...] *71
17 Tool number
N123
62 Active/Target temperature
N123
61 Standby temperatureExamples
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
81

Set the temperature of the cooler

M143: Maximum heater temperature

Parameters
N123
68 Heater number (RepRapFirmware 1.17 and later, default 1 which is normally the first hot end)
N123 [...G Code in here...] *71
00 Maximum temperatureExamples
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
82

The default maximum temperature for all heaters was 300°C prior to RepRapFirmware version 1.13, and 262°C from 1.13 onwards. From RepRapFirmware 1.17 onwards, the default maximum temperatures are 262C for extruders and 125C for the bed.

When the temperature of the heater exceeds this value, countermeasures will be taken.

M144: Bed Standby

ParametersPnn Bed heater number, default 0Sn 0 = set bed heater to standby (default), 1 = set bad heater activeExample
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
83

Switch the bed heater to its standby temperature.

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
155 turns it back to its active temperature.

M146: Set Chamber Humidity

Parameters
N123
61 Relative humidity in percentExample
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
84

Set the relative humidity of the chamber to 60% and return control to the host immediately (i.e. before that humidity has been reached by the chamber).

M149: Set temperature units

Parameters
N123 [...G Code in here...] *71
70 Flag to treat temperature as degrees Celsius
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
158 Flag to treat temperature as KelvinExample
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
85

It affects the

N123 [...G Code in here...] *71
00 or
N123
89 values in the codes
G1 F1500                 ; Feedrate 1500mm/min
G1 X50 Y25.3 E22.4 F3000 ; Accelerate to 3000mm/min
99,
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
044,
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
163,
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
164,
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
165,
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
045 and
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
167 The default is
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
168.

M150: Set LED color

Parameters
N123
61 Red component
G1 F1500           ; Set feedrate to 1500mm/min
G1 X50 Y25.3 E22.4 ; Move and extrude
17 Green component
N123
87 Blue component
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
172 White component (Marlin)
N123
83 Brightness (0-255) (Marlin, also RepRapFirmware 2.03 and later)
N123 [...G Code in here...] *71
10 Set full brightness (Marlin)
N123
62 (RepRapFirmware) Number of individual LEDs to set to these colours
G0 X12               ; move to 12mm on the X axis
G0 F1500             ; Set the feedrate to 1500mm/min
G1 X90.6 Y13.8 E22.4 ; Move to 90.6mm on the X axis and 13.8mm on the Y axis while extruding 22.4mm of material
00 (RepRapFirmware) Following command action. F0 (default) means this is the last command for the LED strip, so the next M150 command starts at the beginning of the strip. F1 means further M150 commands for the remainder of the strip follow this one.
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
111 (RepRapFirmware) LED type: X0 (default) = DotStar, X1 = NeoPixel. This parameter is remembered from one call to the next, so it only needs to be given once.
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
178 (RepRapFirmware) Brightness, 0-31 (alternative to P 0-255)
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
179 (RepRapFirmware) Use specified SPI frequency (in Hz) instead of default frequency. This parameter is only processed if X parameter also present. When using NeoPixels, only frequencies between about 2.5MHz and 4MHz will work.Example
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
86Example (RepRapFirmware)
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
87

Set BlinkM, Neopixel, and/or other LED light color and intensity with RGBW component values from 0 to 255. Some LCD controllers use this interface for a backlight. Firmware may override the set color to indicate the current printer status.

RepRapFirmware uses this command to control DotStar or NeoPixel LED strips on controllers that provide a connector for this purpose. When using NeoPixel strips there is a firmware-dependent maximum number of LEDs in the strip supported determined by the size of the DMA buffer.

Notes

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

M154: Auto Report Position

Hosts normally monitor printer position by sending

G1 F1500           ; Set feedrate to 1500mm/min
G1 X50 Y25.3 E22.4 ; Move and extrude
89 every couple of seconds. This adds more serial traffic and fails if the command queue is full.
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
181 reduces traffic by setting the firmware to report the 'projected' position at regular intervals. This behavior is disabled by default for best compatibility with existing hosts. If the firmware supports
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
181 the output of
G1 F1500           ; Set feedrate to 1500mm/min
G1 X50 Y25.3 E22.4 ; Move and extrude
84 will report the
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
184 capability.

Usage
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
185 : Set the auto-report interval in seconds. Set the interval to 0 to disable.

M155: Automatically send temperatures

Parameters
N123
62 enable sending temperatures = 1, disable = 0
N123
62 Interval in seconds between auto-reports. S0 to disable. (Marlin) Prusa has a Maximum: 2551
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
188 Activate auto-report function (bit mask). Default is temperature.1C bitmap1
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
189
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
190
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
191
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
192
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
193
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
194
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
195
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
196Examples
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
88

Hosts normally monitor printer temperatures by sending

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
006 every couple of seconds. This not only adds serial traffic but it will fail whenever the command queue is full.
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
198 addresses these problems by telling the firmware to automatically report temperatures at regular intervals. This behavior is disabled by default for best compatibility with existing hosts. If the firmware supports
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
198 the output of
G1 F1500           ; Set feedrate to 1500mm/min
G1 X50 Y25.3 E22.4 ; Move and extrude
84 will report the
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
201 capability:

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
89

Prusa Firmware 3.10.0+ also adds capabilities:

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
90

M160: Number of mixed materials

Example
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
91

This command has been superseded by the tool definition command

N123 [...G Code in here...] *71
05 (see below).

Set the number of materials, N, that the current extruder can handle to the number specified. The default is 1.

When N >= 2, then the E field that controls extrusion requires N values separated by colons ":" after it like this:

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
92

The second line moves straight to the point (90.6, 13.8) extruding a total of 22.4mm of filament. The mix ratio for the move is 0.1:0.1:0.1:0.7.

The third line moves back 20mm in X extruding 42.4mm of filament.

The fourth line has no physical effect.

M163: Set weight of mixed material

Parameters
N123
62 extruder number
N123
83 weight

Set weight for this mixing extruder drive.
See Repetier Color Mixing for more informations.

M164: Store weights

Parameters
N123
62 virtual extruder number
N123
83 store to eeprom (P0 = no, P1 = yes)

Store weights as virtual extruder S.

M165: Set multiple mix weights

Parameters
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
207
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
208 Mix factor for extruder stepper 1
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
209 Mix factor for extruder stepper 2
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
210 Mix factor for extruder stepper 3
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
211 Mix factor for extruder stepper 4
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
212 Mix factor for extruder stepper 5
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
213 Mix factor for extruder stepper 6
  • Set multiple mix factors for a mixing extruder.
  • Factors that are left out will be set to 0.
  • All factors together must add up to 1.0.

M190: Wait for bed temperature to reach target temp

Parameters
N123
62 minimum target temperature, waits until heating
N123
61 accurate target temperature, waits until heating and cooling (Marlin and Prusa)Example
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
93

Wait for the bed temperature to reach 60 degrees, printing out the temperatures once per second.

M191: Wait for chamber temperature to reach target temp

Example
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
94

Set the temperature of the build chamber to 60 °C and wait for the temperature to be reached.

Parameters
N123
62 minimum target temperature, waits until heating
N123
61 accurate target temperature, waits until heating and cooling (Marlin)

M192: Wait for Probe Temperature

Use

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
218 to dwell until the probe is at or above a given temperature.

M200: Set filament diameter

Volumetric Extrusion is a firmware mode (and an option you can set in some slicers) wherein all extrusion amounts are specified as a volume —using cubic millimeters or inches (i.e., mm3 or in3)— instead of a linear distance. This makes it possible to use the same G-code with any filament diameter.

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
219 tells the firmware what the filament diameter is, and (if non-zero) to enable Volumetric Extrusion.

Send

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
219 without parameters to get the current Volumetric Extrusion state and filament diameters.

Note that slicer-commanded retraction amounts must also be specified in mm3 since the E axis is interpreted as a volume. However, when using Firmware Retraction (

N123 [...G Code in here...] *71
02 /
G1 F1500                 ; Feedrate 1500mm/min
G1 X50 Y25.3 E22.4 F3000 ; Accelerate to 3000mm/min
73) the retractions specified by
N123 [...G Code in here...] *71
07 are still set in linear units.

Parameters (Marlin)
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
224 Set the filament diameter in current units. If non-zero, enable Volumetric Extrusion.
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
225 Select the target extruder. If omitted, the active extruder.
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
226 Enable or Disable Volumetric Extrusion (without modifying the filament diameter).
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
227 Set the Maximum Extrusion Volume in mm3 per second. (Ignores units set by
N123
40.) Use
int cs = 0;
for(i = 0; cmd[i] != '*' && cmd[i] != NULL; i++)
   cs = cs ^ cmd[i];
cs &= 0xff;  // Defensive programming...
89 for no limit.Examples (Marlin)
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
95Parameters (RepRapFirmware)
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
230 Set filament diameter to aaa for extruder 1, bbb for extruder 2, etc. In RepRapFirmware 3.4 and earlier, if any of aaa, bbb etc. are zero then Volumetric Extrusion is disabled for that extruder.
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
231 Set filament diameter for all extruders.
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
226 Enable or disable volumetric extrusion for this input channel (RepRapFirmware 3.5 and later)Examples (RepRapFirmware)
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
96

M201: Set max acceleration

Parameters
N123
51 Acceleration for X axis in units/s2
N123
52 Acceleration for Y axis in units/s2
N123
53 Acceleration for Z axis in units/s2
N123
54 Acceleration for the active or specified extruder in units/s2Example
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
97

Set the acceleration that axes can do in units/s2.

The

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
237 command is intended to define the machine's physical limits. Slicers should use the
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
238 command to define accelerations for a job and leave
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
237 settings to the user.

RepRapFirmware specific: Multiple colon-separated E values can be provided, so that different extruders can use different accelerations. If a single E value is provided, that value is applied to all extruders. The values must be provided in mm/sec^2 even if G20 has been used to set units to inches. M201 without parameters reports the current settings.

M201.1: Set reduced acceleration for special move types

Parameters
N123
51 Acceleration for X axis in units/s2
N123
52 Acceleration for Y axis in units/s2
N123
53 Acceleration for Z axis in units/s2
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
243 Acceleration for the extruders in units/s2Example
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
98

Set the acceleration that axes should use for special types of move that should be done using reduced acceleration.

RepRapFirmware specific: these values are used for probing moves (because some types of Z probe can be triggered by high acceleration at the start of the move) and for moves that involve stall detection endstops (because high acceleration can bring the motor close to stalling). If a single E value is provided, that value is applied to all extruders. The values must be provided in mm/sec^2 even if G20 has been used to set units to inches. M201.1 without parameters reports the current settings.

M202: Set max travel acceleration

Set max travel acceleration in units/s^2 for travel moves (

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
244). Unused in Marlin!!

M203: Firmware dependent

M203: Set maximum feedrate
Parameters
N123
51 Maximum feedrate for X axis
N123
52 Maximum feedrate for Y axis
N123
53 Maximum feedrate for Z axis
N123
54 Maximum feedrate for extruder drives
N123
78 (RepRapFirmware) Minimum feed rate (optional)Example
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
99

Sets the maximum feedrates that your machine can do in mm/min. (Marlin uses mm/sec).

This command is intended to define the machine limits. Slicers should not generate M203 commands, instead they should use the F parameter on G0, G1 etc. command to specify the requested speeds.

M203 (Repetier): Set temperature monitor

Set temperature monitor to

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
250. Repetier Firmware only.

M204: Firmware dependent

M204: Set default acceleration
Parameters (RepRapFimware)
N123
83 Acceleration for printing moves
N123 [...G Code in here...] *71
17 Acceleration for travel movesExample
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
00

Accelerations set with

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
238 apply to the move as a whole based on the type of move. Use
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
237 to set limits for each axis individually. Both of these limits will be applied during printing.

Parameters (MK4duo)
N123
83 Acceleration for printing moves
G1 F1500                 ; Feedrate 1500mm/min
G1 X50 Y25.3 E22.4 F3000 ; Accelerate to 3000mm/min
16 Acceleration for travel moves
N123
61 Acceleration for Retraction for Tools with T codeExample
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
01

Other firmwares:

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
258 Set Acceleration for normal moves in units/s2
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
259 Set Acceleration for retract/recover moves in units/s2
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
260 Set Minimum Segment Time to prevent planner starvation.

Marlin notes: Since version 1.0.2-1 the

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
238 options are:

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
262 Set Acceleration for Printing moves. (i.e., Any XYZ motion plus E.)
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
263 Set Acceleration for Retract moves. (i.e., E-axis only moves.)
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
259 Set Acceleration for Travel moves. (i.e., without E movement)Example

Set the acceleration for printing movements to 800mm/s^2, for travels to 3000mm/s^2 and for retracts to 9000mm/s^2.

N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
02
M204 (Repetier): Set PID values
Usage
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
03

Set one or more PID parameters. Values are 100 * real value.

M205: Firmware dependent

M205: Advanced settings
Sprinter / MarlinMinimum travel speed =
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
265
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
266
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
267Sprinter / Marlin Example
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
04

Smoothieware uses a different algorithm: [1]

X[xy junction deviation] Z[z junction deviation] S[minimum planner speed].Z junction deviation only applies to z only moves0 disables junction deviation for Z-1 uses global junction deviationSmoothie example
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
05
M205 (Repetier): EEPROM Report

Output EEPROM settings. Repetier Firmware only.

M206: Firmware dependent

M206: Offset axes
Parameters
N123
51 X axis offset
N123
52 Y axis offset
N123
53 Z axis offsetExample
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
06

The values specified are added to the endstop position when the axes are referenced. The same can be achieved with a

G0 X12               ; move to 12mm on the X axis
G0 F1500             ; Set the feedrate to 1500mm/min
G1 X90.6 Y13.8 E22.4 ; Move to 90.6mm on the X axis and 13.8mm on the Y axis while extruding 22.4mm of material
60 right after homing (
N123
38,
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
273).

With Marlin firmware, the current values can read from the machine with a bare

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
274 command and be saved to EEPROM using the
G0 X12               ; move to 12mm on the X axis
G0 F1500             ; Set the feedrate to 1500mm/min
G1 X90.6 Y13.8 E22.4 ; Move to 90.6mm on the X axis and 13.8mm on the Y axis while extruding 22.4mm of material
07 command. (See also
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
276: Babystepping)

A similar command is

N123 [...G Code in here...] *71
02, aligning these two is subject to discussion.

With Marlin 1.0.0 RC2 a negative value for z lifts(!) your printhead.

In builds of RepRapFirmware that support CNC workplace coordinates, using this command is equivalent to using G10 L2 P1 to set the coordinate offsets for workplace 1.

M206 (Repetier): Set EEPROM value

Set a Repetier Firmware EEPROM value.

Parameters
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
278 Value type
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
279 Value position
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
280 An integer value
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
281 A float valueExample
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
07

M207: Firmware dependent

M207: Set retract length
Parameters
N123
62 positive length to retract, in mm
N123
61 positive or negative additional length to un-retract, in mm (RepRapFirmware only)
N123
55 retraction feedrate, in mm/min
N123 [...G Code in here...] *71
17 feedrate for un-retraction if different from retraction, mm/min (RepRapFirmware 1.16 and later only)
N123
53 additional zlift/hopExample
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
08

Set the retract length used by the

N123 [...G Code in here...] *71
02 and
G1 F1500                 ; Feedrate 1500mm/min
G1 X50 Y25.3 E22.4 F3000 ; Accelerate to 3000mm/min
73 commands. Units are in mm regardless of
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
219 setting.

Machinekit uses different parameters and speed units for

N123 [...G Code in here...] *71
07. Use
N123 [...G Code in here...] *71
10 to set retract length in mm. Use
G1 F1500                 ; Feedrate 1500mm/min
G1 X50 Y25.3 E22.4 F3000 ; Accelerate to 3000mm/min
31 to set retract velocity in mm/s. For firmware retraction Machinekit uses
N123 [...G Code in here...] *71
32 and
N123 [...G Code in here...] *71
29 in place of
N123 [...G Code in here...] *71
02 and
G1 F1500                 ; Feedrate 1500mm/min
G1 X50 Y25.3 E22.4 F3000 ; Accelerate to 3000mm/min
73.

M207 Calibrate Z axis with Z max endstop
Example
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
09

After placing the tip of the nozzle in the position you expect to be considered Z=0, issue this command to calibrate the Z axis. It will perform a z axis homing routine and calculate the distance traveled in this process. The result is stored in EEPROM as z_max_length. For using this calibration method the machine must be using a Z MAX endstop.

This procedure is usually more reliable than mechanical adjustments of a Z MIN endstop.

M207 (Repetier): Set jerk without saving to EEPROM

Repetier Firmware only. Change the maximum instantaneous speed change ("jerk") values, but don't store the change in EEPROM.

Since Repetier 0.91 December 2013 [2] (if not earlier)

Parameters
N123
51 Temporarily set XY jerk in mm/s
N123
53 Temporarily set Z jerk in mm/s
N123
54 Temporarily set Extruder jerk in mm/sExample
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
10

M208: Firmware dependent

M208: Set unretract length
Parameters
N123
62 positive length surplus to the
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
301, in mm
N123
55 feedrate, in mm/sec

Sets the "recover" (aka "unretract") length.

M208 (RepRapFirmware): Set axis max travel
Parameters
N123
62 0 = set axis maximum (default), 1 = set axis minimum
N123
51 X axis limit
N123
52 Y axis limit
N123
53 Z axis limitExampleM208 X200 Y200 Z90 ; set axis maximaM208 X-5 Y0 Z0 S1 ; set axis minima

The values specified set the software limits for axis travel in the specified direction. The axis limits you set are also the positions assumed when an endstop is triggered.

M209: Enable automatic retract

With automatic retract detection, G-code generated by slicers without

N123 [...G Code in here...] *71
02/
G1 F1500                 ; Feedrate 1500mm/min
G1 X50 Y25.3 E22.4 F3000 ; Accelerate to 3000mm/min
73 support can take advantage of Firmware Retraction. The firmware converts E-only moves into retract/recover moves, using the firmware's tuned lengths and feedrates in place of the original E moves.

Example
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
11

The

N123 [...G Code in here...] *71
00 parameter turns Automatic Retract Detection on (1) or off (0).

M210: Set homing feedrates

Example
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
12

Set the feedrates used for homing to the values specified in mm per minute.

M211: Disable/Enable software endstops

The boolean value S 1=enable or 0=disable controls state of software endstop.

The boolean value X, Y or Z 1=max endstop or 0=min endstop selects which endstop is controlled.

Example
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
13

Disables X,Y,Z max endstops

Example
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
14

Enables X min endstop

Example
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
15

Prints current state of software endstops.

M212: Set Bed Level Sensor Offset

This G-Code command is known to be available in the newer versions of PrintrBot's branch of Marlin. It may not be available in other firmware.

Example
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
16

Set the Z home to 0.2 mm lower than where the sensor says Z home is. This is extremely useful when working with printers with hard-to-move sensors, like the PrintrBot Metal Plus.

PrintrBot suggests that the user make minor (0.1-0.2) adjustments between attempts and immediately executes

G0 X12               ; move to 12mm on the X axis
G0 F1500             ; Set the feedrate to 1500mm/min
G1 X90.6 Y13.8 E22.4 ; Move to 90.6mm on the X axis and 13.8mm on the Y axis while extruding 22.4mm of material
07 &
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
311 after setting this.

M217: Toolchange Parameters

If arguments are given, sets tool-change retract and prime length (mm), prime feedrate (mm/min), retract feedrate (mm/min), and park position/raise (mm) or Z raise (mm): SPRXYZ. XY arguments require SINGLENOZZLE_SWAP_PARK. If no arguments are given, reports current values. Currently used to set the

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
312 tool-change options in Marlin 2.0 and up. May be extended for other tool-changing systems in the future.

M218: Set Hotend Offset

Sets hotend offset (in mm): TXY.

Example
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
17Notes

In Prusa Firmware this G-code is only active if

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
313 is higher then 1 in the source code. On Original i3 Prusa MK2/s MK2.5/s MK3/s it is not active.1

M220: Set speed factor override percentage

Parameters
N123
62 Speed factor override percentage (0..100 or higher)Example
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
18

Sets the speed factor override percentage.

M221: Set extrude factor override percentage

Parameters
N123
62 Extrude factor override percentage (0..100 or higher), default 100%
G1 F1500                 ; Feedrate 1500mm/min
G1 X50 Y25.3 E22.4 F3000 ; Accelerate to 3000mm/min
96 Extruder drive number (RepRapFirmware only), default 0
N123 [...G Code in here...] *71
17 Extruder drive number (Prusa Firmware only), default 0 if not set.1Example
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
19

Sets extrude factor override percentage. In the case of RepRapFirmware and Prusa Firmware, sets the extrusion factor percentage for the specified extruder drive only.

M220: Turn off AUX V1.0.5

M221: Turn on AUX V1.0.5

M222: Set speed of fast XY moves

M223: Set speed of fast Z moves

M224: Enable extruder during fast moves

M225: Disable on extruder during fast moves

M226: G-code Initiated Pause

Example
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
20

Initiates a synchronous pause (pauses after all previous commands from the same stream have been completed). That is, program execution is stopped and the printer waits for user interaction. This matches the behaviour of

G1 F1500           ; Set feedrate to 1500mm/min
G1 X50 Y25.3 E22.4 ; Move and extrude
20 in the NIST RS274NGC G-code standard and
G1 F1500           ; Set feedrate to 1500mm/min
G1 X50 Y25.3 E22.4 ; Move and extrude
23 in Marlin firmware.

M226: Wait for pin state

Parameters
N123
83 pin number
N123
62 pin stateExample
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
21

Wait for a pin to be in some state.

M227: Enable Automatic Reverse and Prime

Example
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
22

P and S are steps.

"Reverse and Prime" means, the extruder filament is retracted some distance when not in use and pushed forward the same amount before going into use again. This shall help to prevent drooling of the extruder nozzle. Teacup firmware implements this with

G1 F1500           ; Set feedrate to 1500mm/min
G1 X50 Y25.3 E22.4 ; Move and extrude
33/
G1 F1500           ; Set feedrate to 1500mm/min
G1 X50 Y25.3 E22.4 ; Move and extrude
43.

M228: Disable Automatic Reverse and Prime

Example
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
23

See also

G1 F1500                 ; Feedrate 1500mm/min
G1 X50 Y25.3 E22.4 F3000 ; Accelerate to 3000mm/min
76.

M229: Enable Automatic Reverse and Prime

Example
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
24

N123 [...G Code in here...] *71
10 and
N123 [...G Code in here...] *71
00 are extruder screw rotations. See also
G1 F1500                 ; Feedrate 1500mm/min
G1 X50 Y25.3 E22.4 F3000 ; Accelerate to 3000mm/min
76.

M230: Disable / Enable Wait for Temperature Change

Example
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
25

int cs = 0;
for(i = 0; cmd[i] != '*' && cmd[i] != NULL; i++)
   cs = cs ^ cmd[i];
cs &= 0xff;  // Defensive programming...
04 Disable wait for temperature change
int cs = 0;
for(i = 0; cmd[i] != '*' && cmd[i] != NULL; i++)
   cs = cs ^ cmd[i];
cs &= 0xff;  // Defensive programming...
03 Enable wait for temperature change

M231: Set OPS parameter

N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
26

M232: Read and reset max. advance values

M240: Trigger camera

Example
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
27

Triggers a camera to take a photograph. (Add to your per-layer G-code.)

Notes

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

M240: Start conveyor belt motor / Echo off

Example
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
27

The conveyor belt allows to start mass production of a part with a reprap.

Echoing may be controlled in some firmwares with

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
330.

M241: Stop conveyor belt motor / echo on

Example
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
29

Echoing may be controlled in some firmwares with

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
330.

M245: Start cooler

Example
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
30

used to cool parts/heated-bed down after printing for easy remove of the parts after print

M246: Stop cooler

Example
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
31

M250: Set LCD contrast

Example
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
32

Sets LCD contrast C(value 0..63), if available.

M256: Set LCD brightness

Example
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
33

Set the LCD brightness B(value 0..255), if available.

M251: Measure Z steps from homing stop (Delta printers)

Examples
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
34

(This is a Repetier-Firmware only feature.)

M260: i2c Send Data

Buffer and send data over the i2c bus. Use

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
332 to set the address from 0-127. Add up to 32 bytes to the buffer with each
N123 [...G Code in here...] *71
67. Send and reset the buffer with
N123 [...G Code in here...] *71
00.

Parameters (Marlin, MK4duo)Ann I2C addressBnn Byte to buffer or sendS If present, sends the bytes that have been bufferedExamples
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
35Parameters (RepRapFirmware)Ann I2C addressBnn:nn:nn... Bytes to sendSnn Number of bytes to receive (optional, RepRapFirmware 2.02 and later)Examples
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
36

RepRapFirmware does not use the S parameter, instead the address and all the bytes to send are specified in a single command.

M261: i2c Request Data

Request data (synchronously) from an i2c slave device. This command in basic form simply relays the received data to the host.

ParametersAnn I2C addressBnn How many bytes to requestSnn (Marlin 2.0.9.3) Style of output: 0 = Raw (default), 1 = Bytes (hex), 2 = 1-2 byte (integer), 3 = Bytes (decimal)Example
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
37

Both

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
335 and
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
336 are commands demonstrating use of the i2c bus (TWIBus class) in Marlin Firmware. Developers and vendors can make Marlin an i2c master device by enabling
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
337, and Marlin can act as a slave device by setting
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
338 from 8-127. This class can be used to divide up processing responsibilities between multiple instances of Marlin running on multiple boards. For example, one board might control a Z axis with 4 independent steppers to create a self-leveling system, or a second board could drive the graphical display while the first board handles printing.

M280: Set servo position

Set servo position absolute.

Parameters
N123
83 Servo index
N123
62 Angle or microseconds
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
341 Invert polarity (RepRapFirmware only)Example
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
38

Marlin and RepRapFirmware treat

N123 [...G Code in here...] *71
00 values below 200 as angles, and 200 or greater as the pulse width in microseconds.

In RepRapFirmware, the servo index is the same as the pin number for the

G1 F1500           ; Set feedrate to 1500mm/min
G1 X50 Y25.3 E22.4 ; Move and extrude
94 command. See https://duet3d.com/wiki/Using_servos_and_controlling_unused_I/O_pins for details.

RepRapFirmware supports the optional I1 parameter, which if present causes the polarity of the servo pulses to be inverted compared to normal for that output pin. The

N123 [...G Code in here...] *71
46 parameter is not remembered between
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
345 commands (unlike the
N123 [...G Code in here...] *71
46 parameter in
G1 F1500           ; Set feedrate to 1500mm/min
G1 X50 Y25.3 E22.4 ; Move and extrude
44 commands), so if you need inverted polarity then you must include I1 in every
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
345 command you send.

Duet 0.8.5 M280 P value to Expansion Port Pin MappingPNameExpansion Port PinUse M307 H# A-1 C-1 D-1 before using these pins3PC23_PWML6214PC22_PWML5225PC21_PWML423

On the Duet 0.6, pin 18 is controlled by heater 2. On the 0.8.5, pin 18 is controlled by heater 6, but is also shared with fan1. In order to use this pin, the fan must be disabled (

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
349). See Using servos and controlling unused I/O pins

Notes

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

M281: Set Servo Angles

Set the angles for a servo's deployed (or selected) and stowed (or unselected) states. To activate this command in Marlin enable the

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
350 option.

Parameters
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
351 - Servo Index
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
352 - Deployed / Selected Angle
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
353 - Stowed / Unselected AngleExample
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
39

M282: Detach Servo

Detach servo. This disables the servo until its next move. To activate this command in Marlin enable the

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
354 option.

Parameters
N123
83 Servo indexExample
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
40

M290: Babystepping

Parameters (RepRapFirmware)
N123
62 Amount to baby step Z in mm. Positive values raise the head, negative values lower it.
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
357 Amount to baby step other axes in mm (optional, supported in later RepRapFirmware versions)
N123
53 Synonym for S (RepRapFirmware 1.21 and later)
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
359 (Optional, RepRapFirmware 1.21 and later) R1 = relative (add to any existing babystep amount, the default), R0 = absolute (set babystepping offset to the specified amount)Examples
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
41Parameters (Repetier)
N123
53 Amount to baby step in mm. Positive values raise the head, negative values lower it.Examples
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
42Additional Parameters (Marlin 1.1.7 and later)
N123
51 Amount to babystep X in current units. (Requires
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
362)
N123
52 Amount to babystep Y in current units. (Requires
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
362)
N123
53 Amount to babystep Z in current units. Synonym for '
N123 [...G Code in here...] *71
00' parameter.Example
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
43

This command tells the printer to move the axis (or axes) transparently to the motion system. This is like physically moving the axes by force, but much nicer to the machine.

In RepRapFirmware

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
276 with no parameters reports the accumulated baby stepping offset. Marlin doesn't track accumulated babysteps.

In RepRapFirmware 1.19 and earlier, the babystepping offset is reset to zero when the printer is homed or the bed is probed. In RepRapFirmware 1.21 and later, homing and bed probing don't reset babystepping, but you can reset it explicitly using M290 R0 S0.

Note: If the

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
368 option is used in Marlin, this command also affects the Z probe offset (as set by
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
369) and that offset will be saved to EEPROM.

M291: Display message and optionally wait for response

Parameters
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
370 The message to display, which must be enclosed in double quotation marks. If the message itself contains a double quotation mark, use two double quotation marks to represent it.
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
371 Optional title for the message box. Must be enclosed in double quotation marks too.
int cs = 0;
for(i = 0; cmd[i] != '*' && cmd[i] != NULL; i++)
   cs = cs ^ cmd[i];
cs &= 0xff;  // Defensive programming...
54 Message box mode (defaults to 1)
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
054 Timeout in seconds, only legal for S=0 and S=1. The message will be cancelled after this amount of time, if the user does not cancel it before then. A zero or negative value means that the message does not time out (it may still be cancelled by the user if it has a Close button). In RepRapFirmware, the default timeout for messages that do not require acknowledgement is 10 seconds.
int cs = 0;
for(i = 0; cmd[i] != '*' && cmd[i] != NULL; i++)
   cs = cs ^ cmd[i];
cs &= 0xff;  // Defensive programming...
55 0 = no special action, 1 = display Z jog buttons alongside the message to allow the user to adjust the height of the print headExamples
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
44

This command provides a more flexible alternative to M117, in particular messages that time out, messages that suspend execution until the user acknowledges them, and messages that allow the user to adjust the height of the print head before acknowledging them.

Allowed message box modes include:

N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
45

The combination S0 T0 is not permitted, because that would generate a message box with no close button and that never times out, which would lock up the user interface.

Duet Web Control 2.0.3 and later supports HTML in the message body.

M292: Acknowledge message

Parameters
int cs = 0;
for(i = 0; cmd[i] != '*' && cmd[i] != NULL; i++)
   cs = cs ^ cmd[i];
cs &= 0xff;  // Defensive programming...
34 Whether the current operation shall be cancelled. Only legal if M291 was called with S=3 (optional)

This command is sent by the user interface when the user acknowledges a message that was displayed because of a M291 command with parameter S=2 or S=3.

M300: Play beep sound

Parameters
N123
62 frequency in Hz
N123
83 duration in milliseconds
G1 F1500                 ; Feedrate 1500mm/min
G1 X50 Y25.3 E22.4 F3000 ; Accelerate to 3000mm/min
16 volume in rage 0 - 1Example
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
46

Play beep sound, use to notify important events like the end of printing. R2C2 electronics.

If an LCD device is attached to RepRapFirmware, a sound is played via the add-on touch screen control panel. Else the web interface will play a beep sound.

Notes

1In Prusa Firmware the defaults are 100Hz and 1000ms, so that

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
379 without parameters will beep for a second.

2Klipper does not support

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
379 by default, however it can be easily added as a G-code macro

M301: Set PID parameters

Parameters
N123
56 heater number (Smoothie uses 'S', Redeem uses 'E')
N123
83 proportional (Kp)
N123
78 integral (Ki)
G1 F1500                 ; Feedrate 1500mm/min
G1 X50 Y25.3 E22.4 F3000 ; Accelerate to 3000mm/min
96 derivative (Kd)Examples
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
47

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

MK4duo

H[heaters] H = 0-5 Hotend, H = -1 BED, H = -2 CHAMBER, H = -3 COOLER

Marlin

Hot end only; see

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
385 for bed PID. H is the heater number, default 1 (i.e. first extruder heater).

RepRapFirmware 1.15 onwards

In RepRapFirmware 1.15 and later the M301 is supported as described above, but it is not normally used. Instead the heater model is defined by M307 or found by auto tuning, and the firmware calculates the PID parameters from the model. An M301 command can be used in config.g after the M307 command for that heater to override the firmware-computed PID parameters.

RepRapFirmware 1.09 to 1.14 inclusive
  • N123
    
    68 Is the heater number, and is compulsory. H0 is the bed, H1 is the first hot end, H2 the second etc.
  • N123 [...G Code in here...] *71
    
    10 Interprets a negative P term as indicating that bang-bang control should be used instead of PID (not recommended for the hot end, but OK for the bed heater).
  • N123 [...G Code in here...] *71
    
    46 Integral value
  • N123 [...G Code in here...] *71
    
    86 Derivative value
  • N123
    
    46 Is the approximate additional PWM (on a scale of 0 to 255) needed to maintain temperature, per degree C above room temperature. Used to preset the I-accumulator when switching from heater fully on/off to PID.
  • N123 [...G Code in here...] *71
    
    00 PWM scaling factor, to allow for variation in heater power and supply voltage. Is designed to allow a correction to be made for a change in heater power and/or power supply voltage without having to change all the other parameters. For example, an S factor of 0.8 means that the final output of the PID controller should be scaled to 0.8 times the standard value, which would compensate for a heater that is 25% more powerful than the standard one or a supply voltage that is 12.5% higher than standard.
  • N123 [...G Code in here...] *71
    
    68 Wind-up. Sets the maximum value of I-term, must be high enough to reach 245C for ABS printing.
  • N123 [...G Code in here...] *71
    
    67 PID Band. Errors larger than this cause heater to be on or off.

An example using all of these would be:

N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
48
Smoothie

int cs = 0;
for(i = 0; cmd[i] != '*' && cmd[i] != NULL; i++)
   cs = cs ^ cmd[i];
cs &= 0xff;  // Defensive programming...
03 is 0 for the hotend, and 1 for the bed, other numbers may apply to your configuration, depending on the order in which you declare temperature control modules.

Other implementations

W: Wind-up. Sets the maximum value of I-term, so it does not overwhelm other PID values, and the heater stays on. (Check firmware support - Sprinter, Marlin?)

Example
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
49
Teacup

See

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
395,
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
396,
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
397,
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
398 for Teacup's codes for setting the PID parameters.

M302: Allow cold extrudes

Parameters
N123
62 Cold extrude minimum temperature (also in RepRapFirmware 2.02 and later)
N123
83 Cold extrude allow state (RepRapFirmware)
N123
61 Cold retraction minimum temperature (RepRapFirmware 2.02 and later)Examples (RepRapFirmwre)
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
50Examples (Others)
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
51

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.

Notes

1RepRapFirmware uses the

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
402 parameter instead of
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
403, and for
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
046 with no parameters it will report the current cold extrusion state.

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 (E-1). Send the appropriate code and wait for the output to update the firmware.

Hot end usage:

N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
52

Bed usage (repetier, not sure whether cycles work here):

N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
53

Bed usage (others):

N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
54Example
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
55

Smoothie's syntax, where

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
405 is the first temperature control module (usually the hot end) and
N123 [...G Code in here...] *71
98 is the second temperature control module (usually the bed):

N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
56

In RepRapFirmware, this command computes the process model parameters (see

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
407), which are in turn used to calculate the PID constants. H is the heater number, P is the PWM to use (default 0.5), and S is the maximum allowable temperature (default 225). Tuning is performed asynchronously. Run
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
408 with no parameters to see the current tuning state or the last tuning result.

Example
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
57Notes

In Marlin Firmware you can add the

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
409 parameter to apply the PID results to current settings upon completion.

M304: Set PID parameters - Bed

Parameters
N123
83 proportional (Kp)
N123
78 integral (Ki)
G1 F1500                 ; Feedrate 1500mm/min
G1 X50 Y25.3 E22.4 F3000 ; Accelerate to 3000mm/min
96 derivative (Kd)Examples
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
58

Sets Proportional, Integral and Derivative values for bed. RepRapFirmware interprets a negative P term as indicating that bang-bang control should be used instead of PID. In RepRapFirmware, this command is identical to

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
413 except that the
N123
68 parameter (heater number) defaults to zero.

See also PID Tuning.

M304 in RepRapPro version of Marlin: Set thermistor values

In the RepRapPro version of Marlin ( https://github.com/reprappro/Marlin )

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
385 is used to set thermistor values (as
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
416 is in later firmwares). RRP Marlin calculates temperatures on the fly, rather than using a temperature table.
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
385 Sets the parameters for temperature measurement.

Example
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
59

This tells the firmware that for heater 1 (

N123
68 parameter: 0 = heated bed, H = first extruder), the thermistor beta (
N123 [...G Code in here...] *71
67 parameter) is 4200, the thermistor series resistance (
N123
89 parameter) is 4.8Kohms, the thermistor 25C resistance (
N123
46 parameter) is 100Kohms. All parameters other than H are optional. If only the
N123
68 parameter is given, the currently-used values are displayed. They are also displayed within the response to
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
423.

M305: Set thermistor and ADC parameters

Parameters
N123
83 Heater number, or virtual heater number
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
425 Heater name (optional, RepRapFirmware only)
N123 [...G Code in here...] *71
17 (for thermistor sensors) Thermistor resistance at 25oC
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
427 (for MAX31856-based thermocouple sensors) The thermistor type letter, default K
N123
87 Beta value, or the reciprocal of the Steinhart-Hart thermistor model B coefficient
N123
88 Steinhart-Hart C coefficient (MK4duo and RepRapFirmware 1.17 and later), default 0
N123
61 Series resistor value
N123
92 ADC low offset correction, default 0
N123
56 ADC high offset correction, default 0
N123
51 Heater ADC channel, or thermocouple or PT100 or current loop adapter channel, defaults to the same value as the
N123 [...G Code in here...] *71
10 parameter
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
435 (where nn is 50 or 60) If the sensor interface uses a MAX31856 thermocouple chip or MAX31865 PT100 chip, this is the local mains frequency. Readings will be timed to optimise rejection of interference at this frequency.Example
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
60

Sets the parameters for temperature measurement. The example above tells the firmware that for heater 1 (

N123 [...G Code in here...] *71
10 parameter: 0 = heated bed, 1 = first extruder) the thermistor 25C resistance (
N123
46 parameter) is 100Kohms, the thermistor series resistance (
N123
89 parameter) is 1Kohms, the thermistor beta (
N123 [...G Code in here...] *71
67 parameter) is 4200. All parameters other than P are optional. If only the
N123 [...G Code in here...] *71
10 parameter is given, the existing values are displayed.

Example
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
61

The H correction affects the reading at high ADC input voltages, so it has the greatest effect at low temperatures. The L correction affects the reading at low input voltages, which correspond to high temperatures.

The

N123 [...G Code in here...] *71
42 parameter tells the firmware to use the thermistor input corresponding to a different heating channel. RepRapFirmware also allow an external SPI thermocouple interface (such as the MAX31855) or PT100 interface (MAX31865) to be configured. MAX31855 thermocouple channels are numbered from 100, MAX31856 thermocouple channels are numbered from 150, PT100 channels from 200 and current loop channels from 300. Channel 1000 is the CPU temperature indication, 1001 is the temperature of the hottest stepper motor driver on the main board, and 1001 is the temperature of the hottest drivers on the expansion board.

In the above example, the ADC high end correction (

N123
68 parameter) is 14, the ADC low end correction (
N123 [...G Code in here...] *71
93 parameter) is -11, and thermistor input #2 is used to measure the temperature of heater #1.

M306: Set home offset calculated from toolhead position

Example
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
62

The values specified are added to the calculated end stop position when the axes are referenced. The calculated value is derived from the distance of the toolhead from the current axis zero point.

The user would typically place the toolhead at the zero point of the axis and issue the

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
444 command.

This value can be saved to EEPROM using the

G0 X12               ; move to 12mm on the X axis
G0 F1500             ; Set the feedrate to 1500mm/min
G1 X90.6 Y13.8 E22.4 ; Move to 90.6mm on the X axis and 13.8mm on the Y axis while extruding 22.4mm of material
07 command (as
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
274 value).

Implemented in Smoothieware

M307: Set or report heating process parameters

Parameters
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
447 Heater number (0 is usually the bed heater)
N123
86 gAin, expressed as ultimate temperature rise obtained in degC divided by the PWM fraction. For example, if G=180 then at 50% PWM the ultimate temperature rise would be 90C.
N123
88 dominant time Constant of the heating process in seconds
G1 F1500                 ; Feedrate 1500mm/min
G1 X50 Y25.3 E22.4 F3000 ; Accelerate to 3000mm/min
96 Dead time in secondsFour optional additional parameters help control the heating process
N123
55 PWM frequency to use (not supported in RepRapFirmware 3, use M950 instead).
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
452 selects Bang-bang control instead of PID if non-zero. Default at power-up is 0 for extruder heaters, 1 for bed and chamber heaters.
N123
62 maximum PWM to be used used with this heater on a scale of 0 to 1. Default 1.0.
G1 F1500                 ; Feedrate 1500mm/min
G1 X50 Y25.3 E22.4 F3000 ; Accelerate to 3000mm/min
16 VIN supply voltage at which the A parameter was calibrated (RepRapFirmware 1.20 and later). This allows the PID controller to compensate for changes in supply voltage. A value of zero (the default) disables compensation for changes in supply voltage.Examples
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
63

Each heater and its corresponding load may be approximated as a first order process with dead time, which is characterised by the gain, time constant and dead time parameters. The model can used to calculate optimum PID parameters, using different values for the heating or cooling phase and the steady state phase. It is also used to better detect heater faults. In future it may be used to calculate feed-forward terms to better respond to changes in the load. Normally these model parameters are found by auto tuning - see

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
408.

RepRapFirmware 1.16 and later allow the PID controller for a heater to be disabled by setting the

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
332,
N123 [...G Code in here...] *71
70, and
N123 [...G Code in here...] *71
86 parameters to -1. This frees up the corresponding heater control pin for use as a general purpose I/O pin to use with the M42 or M280 command. In RepRapFirmware 3, M950 should be used to free up the pin instead.

M308: Set or report sensor parameters

Common Parameters
int cs = 0;
for(i = 0; cmd[i] != '*' && cmd[i] != NULL; i++)
   cs = cs ^ cmd[i];
cs &= 0xff;  // Defensive programming...
54 Sensor number
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
460 The name of the control board pin that this sensor uses. For thermistors it is the thermistor input pin name. For sensors connected to the SPI bus it is the name of the output pin used as the chip select.
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
461 The sensor and interface type, e.g. "thermistor", "pt1000", "rtdmax31865", "max31855", "max31856", "linear-analog", "dht22-temp", "dht22-humidity", "current-loop-pyro"
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
462 Sensor name (optional), displayed in the web interfaceAdditional parameters for thermistors
N123 [...G Code in here...] *71
17 (for thermistor sensors) Thermistor resistance at 25oC
N123
87 Beta value, or the reciprocal of the Steinhart-Hart thermistor model B coefficient
N123
88 Steinhart-Hart C coefficient, default 0
N123
61 Series resistor value
N123
92 ADC low offset correction, default 0 (ignored if the hardware supports automatic ADC gain and offset calibration)
N123
56 ADC high offset correction, default 0 (ignored if the hardware supports automatic ADC gain and offset calibration)Additional parameters for PT1000 sensors
N123
61 Series resistor value
N123
92 ADC low offset correction, default 0 (ignored if the hardware supports automatic ADC gain and offset calibration)
N123
56 ADC high offset correction, default 0 (ignored if the hardware supports automatic ADC gain and offset calibration)Additional parameters for MAX31856-based thermocouple sensors
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
427 The thermistor type letter, default K
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
435 (where nn is 50 or 60) The local mains frequency. Readings will be timed to optimise rejection of interference at this frequency.Additional parameters for MAX31865-based PT100 sensors
N123
61 Series resistor value
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
435 (where nn is 50 or 60) The local mains frequency. Readings will be timed to optimise rejection of interference at this frequency.Additional parameters for linear analog sensors
G0 X12               ; move to 12mm on the X axis
G0 F1500             ; Set the feedrate to 1500mm/min
G1 X90.6 Y13.8 E22.4 ; Move to 90.6mm on the X axis and 13.8mm on the Y axis while extruding 22.4mm of material
00 F0 = unfiltered (fast response), F1 = filtered (slower response, but noise reduced and ADC oversampling used to increase resolution)
N123
92 The temperature or other value when the ADC output is zero
N123
56 The temperature or other value when the ADC output is full scale

This code replaces M305 in RepRapFirmware 3. In earlier versions of RepRapFirmware, sensors only existed in combination with heaters, which necessitated the concept of a "virtual heater" to represent a sensor with no associated heater (e.g. MCU temperature sensor). RepRapFirmware 3 allows sensors to be defined independently of heaters. The association between heaters and sensors is defined using M950.

M308 can be used in the following ways:

N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
64

Sensor type names obey the same rules as pin names, i.e. case is not significant, neither are hyphen and underscore characters.

M309: Set or report heater feedforward

ParametersPn Tool numberSaaa:bbb:ccc... Feedforward coefficients. The number of coefficients provided must equal the number of heaters configured for the tool when it was created (see M563).

If the P parameter is not provided, the current tool is assumed. If the S parameter is not provided, the existing coefficients are reported.

The units of S are PWM fraction (on a scale of 0 to 1) per mm/sec of filament forward movement.

M310: Temperature model settings

Usage
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
479  ; report values
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
480  ; autotune C+R values
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
481  ; force model self-test state
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
482  ; set 0=disable 1=enable
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
483  ; set resistance at index
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
484  ; set power, capacitance
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
485  ; set beeper, warning and error threshold
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
486  ; set ambient temperature correctionParameters
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
332 autotune C+R values
N123 [...G Code in here...] *71
91 force model self-test state (0=off 1=on) during autotune using current values
N123
62 set 0=disable 1=enable
N123
78 resistance index position (0-15)
N123
61 resistance value at index (K/W; requires :
N123
78)
N123
83 power (W)
N123
88 capacitance (J/K)
N123
87 beep and warn when reaching warning threshold 0=disable 1=enable (default: 1)
N123
54 error threshold (K/s; default in variant)
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
172' warning threshold (K/s; default in variant)
N123 [...G Code in here...] *71
17 ambient temperature correction (K; default in variant)

Prusa Firmware for MK3S/+, MK2.5/S only!

M320: Activate autolevel (Repetier)

Usage
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
499
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
500Parameters
N123
62 if greater than 0, activate and store persistently in EEPROMExamples
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
65

Parameter

N123
62 is optional.

(Repetier only)

M321: Deactivate autolevel (Repetier)

Usage
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
503
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
504Parameters
N123
62 if greater than 0, deactivate and store persistently in EEPROMExamples
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
66

Parameter

N123
62 is optional.

(Repetier only)

M322: Reset autolevel matrix (Repetier)

Usage
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
507
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
508Parameters
N123
62 if greater than 0, also reset the matrix values saved EEPROMExamples
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
67

Parameter

N123
62 is optional.

(Repetier only)

M323: Distortion correction on/off (Repetier)

Usage
int cs = 0;
for(i = 0; cmd[i] != '*' && cmd[i] != NULL; i++)
   cs = cs ^ cmd[i];
cs &= 0xff;  // Defensive programming...
94
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
512
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
513Parameters
N123
62 0 (disable correction) or 1 (enable correction)
N123
83 1 (store correction state persistently in EEPROM)Examples
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
68

(Repetier only) Controls distortion correction feature after having set it up using

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
516

M340: Control the servos

(Repetier only ,Marlin see M280)

M340 PS/ ServoID = 0..3 pulseInUs = 500..2500

Servos are controlled by a pulse width normally between 500 and 2500 with 1500ms in center position. 0 turns servo off.

M350: Set microstepping mode

Sets microstepping mode.

Warning: Steps per unit remains unchanged; except that in RepRapFirmware the steps/mm will be adjusted automatically.

Usage
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
517ParametersNot all parameters need to be used, but at least one should be used. As with other commands, RepRapFirmware reports the current settings if no parameters are used.
G0 X12               ; move to 12mm on the X axis
G0 F1500             ; Set the feedrate to 1500mm/min
G1 X90.6 Y13.8 E22.4 ; Move to 90.6mm on the X axis and 13.8mm on the Y axis while extruding 22.4mm of material
20 Set stepping mode for all drivers (not supported by RepRapFirmware)
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
519 Set stepping mode for the X axis
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
178 Set stepping mode for the Y axis
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
521 Set stepping mode for the Z axis
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
522 Set stepping mode for Extruder 0 (for RepRapFirmware use
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
523 etc. for multiple extruders)
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
524 Set stepping mode for Extruder 1 (not supported by RepRapFirmware, see above)
G0 X12               ; move to 12mm on the X axis
G0 F1500             ; Set the feedrate to 1500mm/min
G1 X90.6 Y13.8 E22.4 ; Move to 90.6mm on the X axis and 13.8mm on the Y axis while extruding 22.4mm of material
15 Enable (nn=1) or disable (nn=0) microstep interpolation mode for the specified drivers, if they support it (RepRapFirmware only)Modes (nn)1 = full step2 = half step4 = quarter step8 = 1/8 step16 = 1/16 step64 = 1/64 step128 = 1/128 step256 = 1/256 stepExamples
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
69

M351: Toggle MS1 MS2 pins directly

Example
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
70

M355: Turn case lights on/off

Examples
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
71


Every call or change over LCD menu sends a state change for connected hosting software like:

N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
72

M360: Report firmware configuration

Target

This command helps hosting software to detect configuration details, which the user would need to enter otherwise. It should reduce configuration time considerably if supported.

Example
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
73Response
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
74

SCARA calibration codes (Morgan)

In order to ease calibration of Reprap Morgan, the following M-codes are used to set the machine up

M360: Move to Theta 0 degree position

The arms move into a position where the Theta steering arm is parallel to the top platform edge. The user then calibrates the position by moving the arms with the jog buttons in software like pronterface until it is perfectly parallel. Using

G1 F1500           ; Set feedrate to 1500mm/min
G1 X50 Y25.3 E22.4 ; Move and extrude
89 will then display the calibration offset that can then be programmed into the unit using
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
274 (Home offset) X represents Theta.

Smoothieware:

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
528 will take the current position as parallel to the platform edge, and store the offset in the homing trim offset (M666) No further user interaction is needed.

M361: Move to Theta 90 degree position

Theta move to 90 degrees with platform edge. User calibrates by using jog arms to place exactly 90 degrees. Steps per degree can then be read out by using

G1 F1500           ; Set feedrate to 1500mm/min
G1 X50 Y25.3 E22.4 ; Move and extrude
89, and programmed using
G1 F1500                 ; Feedrate 1500mm/min
G1 X50 Y25.3 E22.4 F3000 ; Accelerate to 3000mm/min
64. X represents Theta. Program Y (Psi) to the same value initially. Remember to repeat
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
531 after adjusting steps per degree.

Smoothieware:

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
528 will accept the current position as 90deg to platform edge. New steps per angle is calculated and entered into memory (M92) No further user interaction is required, except to redo
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
531.

M362: Move to Psi 0 degree position

Arms move to Psi 0 degree. Check only after other Theta calibrations

M363: Move to Psi 90 degree position

Arms move to Psi 90 degree. Check only after other Theta calibrations

M364: Move to Psi + Theta 90 degree position

Move arms to form a 90 degree angle between the inner and outer Psi arms. Calibrate by moving until angle is exactly 90 degree. Read out with

G1 F1500           ; Set feedrate to 1500mm/min
G1 X50 Y25.3 E22.4 ; Move and extrude
89, and calibrate value into Home offset
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
274. Psi is represented by Y.

Smoothieware:

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
536 will accept the current position as 90deg between arms. The offset is stored as a trim offset (M666) and no further user interaction is required except to save all changes via
G0 X12               ; move to 12mm on the X axis
G0 F1500             ; Set the feedrate to 1500mm/min
G1 X90.6 Y13.8 E22.4 ; Move to 90.6mm on the X axis and 13.8mm on the Y axis while extruding 22.4mm of material
07.

M365: SCARA scaling factor

Adjust X Y and Z scaling by entering the factor. 100% scaling (default) is represented by 1

M366: SCARA convert trim

Executing this command translates the calculated trim values of the SCARA calibration to real home offsets. This prevents the home and trim movement after calibration.

M370: Morgan manual bed level - clear map

Clear the map and prepare for calibration

Usage
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
538
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
539

Without parameters is defaults to

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
540 (25 calibration points) When specifying parameters, uneven numbers are recommended.

M371: Move to next calibration position

Move to the next position for calibration. User moves the bed towards the hotend until it just touches

M372: Record calibration value, and move to next position

The position of the bed is recorded and the machine moves to the next position. Repeat until all positions programmed

M373: End bed level calibration mode

End calibration mode and enable z correction matrix. Does not save current matrix

M374: Save calibration grid

Saves the calibration grid.

Parameters
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
541 (Smoothieware only) Extension of the grid file
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
542 (RepRapFirmware only) Name of the file to save to
N123 [...G Code in here...] *71
04 (Smoothieware only) Also save the
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
274 Z homing offset into the grid fileUsage (Smoothieware)
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
75Usage (RepRapFirmware)
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
76

In Smoothieware, without parameters this saves the grid into the default grid file that gets loaded at boot. The optional parameter specifies the extension of the grid file - useful for special grid files such as for a special print surface like a removable print plate. Addition of Z will additionally save the

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
545 homing offset into the grid file.

In RepRapFirmware, this saves the grid parameters and height map into the specified file, or the default file

int cs = 0;
for(i = 0; cmd[i] != '*' && cmd[i] != NULL; i++)
   cs = cs ^ cmd[i];
cs &= 0xff;  // Defensive programming...
21 if no filename was specified. To load the height map automatically at startup, use command
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
547 in the config.g file.

M375: Display matrix / Load Matrix

Displays the bed level calibration matrix (Marlin), or loads the grid matrix file (Smoothieware and RepRapFirmware)

Parameters
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
541 (Smoothieware only)
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
542 (RepRapFirmware only)Usage
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
77

Without parameters loads default grid, and with specified extension or specified filename attempts to load the specified grid. If not available will not modify the current grid. In Smoothieware, if Z was saved with the grid file, it will load the saved Z with the grid.

M376: Set bed compensation taper

Parameters
N123
56 Height (mm) over which to taper off the bed compensationExample
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
78

This command specifies that bed compensation should be tapered off over the specified height, so that no bed compensation is applied at and above that height. If H is zero or negative then no tapering is applied, so compensation is performed throughout the entire print.

If the firmware does not adjust the extrusion amount to compensate for the changing layer height while tapering is being applied, you will get under- or over-extrusion. Using a large taper height will reduce this effect. For example, if the taper height is 50 times the largest bed height error, then under- or over-extrusion will be limited to 2%.

M380: Activate solenoid

Example
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
79

Activates solenoid on active extruder.

M381: Disable all solenoids

Example
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
80

M400: Wait for current moves to finish

Example
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
81

Finishes all current moves and and thus clears the buffer. That's identical to

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
551 for Teacup printers.

M401: Deploy Z Probe

ParametersP Probe number, default 0 (RepRapFirmware)S Set BLTouch HS Mode (Marlin 2.0.9.3+ with
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
552 enabled.)H Report current BLTouch HS Mode (Marlin 2.0.9.4+ with
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
552 enabled.)Example
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
82

Deploy the z-probe (if present). In RepRapFirmware this command runs the macro file sys/deployprobe#.g (where # is the probe number) if it exists, otherwise it runs sys/deployprobe.g if it exists.

M402: Stow Z Probe

ParametersP (RepRapFirmware only) Probe number, default 0Example
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
83

Raise z-probe if present. In RepRapFirmware this runs macro file sys/retractprobe#.g (where # is the probe number) if it exists, otherwise sys/retractprobe.g if it exists.

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

Parameters
N123
67 Extruder number
N123 [...G Code in here...] *71
91 Filament type

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.

M404: Filament width and nozzle diameter

Parameters
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
062 Filament width (in mm)
G1 F1500                 ; Feedrate 1500mm/min
G1 X50 Y25.3 E22.4 F3000 ; Accelerate to 3000mm/min
96 Nozzle diameter (in mm)1Examples
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
84

Enter the nominal filament width (3mm, 1.75mm) or will display nominal filament width without parameters.

Notes

1While Marlin only accepts the 'N' parameter, RepRapFirmware further allows to specify the nozzle diameter (in mm) via the 'D 'parameter. This value is used to properly detect the first layer height when files are parsed or a new print is being started.

M405: Filament Sensor on

Example
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
85

Turn on Filament Sensor extrusion control. Optional Dto set delay in centimeters between sensor and extruder.

M406: Filament Sensor off

Example
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
86

Turn off Filament Sensor extrusion control.

M407: Display filament diameter

Example
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
87

Displays measured filament diameter. In RepRapFirmware,

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
558 does the same as
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
559.

M408: Report JSON-style response

Parameters
N123
62 Response type
N123
61 Response sequence numberExample
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
88

Report a JSON-style response by specifying the desired type using the 'S' parameter. The following response types are supported:

  • Type 0 is a short-form response, similar to the response used by older versions of the web interface.
  • Type 1 is like type 0 except that static values are also included.
  • Type 2 is similar to the response provided by the web server for Duet Web Control.
  • Type 3 is an extended version of type 2 which includes some additional parameters that aren't expected to change very frequently.
  • Type 4 is an extended version of type 2 which may be used to poll for current printer statistics.
  • Type 5 reports the current machine configuration.

Here is an example of a typical type 0 response:

N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
89

The response is set as a single line with a newline character at the end. The meaning of the fields is:

N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
90

The type 1 response comprises these fields plus some additional ones that do not generally change and therefore do not need to be fetched as often. The extra fields include:

N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
91

The fields may be in any order in the response. Other implementations may omit fields and/or add additional fields.

For a more detailed comparison of type 2 - 5, see RepRap_Firmware_Status_responses.

PanelDue currently uses only

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
562 and
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
563.

M409: Query object model

Parameters
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
564 Key string, default empty
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
565 Flags string, default emptyExamples
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
92

The key string is just the path to the Object Model (OM) variables wanted, with the following extensions:

  • An element that is an array may be followed by either [number] to select just one element, or by [] to select all elements and report the results as an array
  • The path may be preceded by # in which case the path must refer to an array and just the number of array elements is returned

An empty key string selects the entire object model.

The flags string may include one or more of the following:

N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
93

The response is a JSON object of the following form:

{"key":"key","flag'":"flags","result":object-value}

The key and flags fields are as provided in the M409 command. If the key string is malformed or refers to a property that does not exist in the object model, the result field is null.

RepRapFirmware on network-enabled electronics also provides the same functionality via the rr_model call to the HTTP API.

M410: Quick-Stop

This command does a quick stop of all stepper motors and aborts all moves in the planner. This command is only intended for emergency situations, and due to the instant stop the actual stepper positions may be shifted. Note that if `EMERGENCY_PARSER` is disabled, the response may be delayed while the command buffer is being queued. If a print job is in progress, it will continue, so it is important to suspend the print job before using this command.

M412: Disable Filament Runout Detection

Enable or disable filament runout detection. When filament sensors are enabled, the firmware responds to a filament runout by running the configured G-code (usually

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
566 Filament Change). When filament runout detection is disabled, no action will be taken on filament runout.

Usage:

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
567

If no 'S' parameter is given, this command reports the current state of filament runout detection.

Examples
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
568 Enable filament runout detection
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
569 Disable filament runout detection
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
570 Report the current filament runout detection state

M413: Power-Loss Recovery

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

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
571 option must be enabled.

This feature operates without a power-loss detection circuit by writing to the recovery file periodically (e.g., once per layer), or if a

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
572 is configured then it will write the recovery info only when a power-loss is detected. The latter option is preferred, since constant writing to the SD card can shorten its life, and the print will be resumed where it was interrupted rather than repeating the last layer. (Future implementations may allow use of the EEPROM or the on-board SD card.)

Usage:

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
573

If no 'S' parameter is given, this command reports the current state of Power-loss Recovery.

Examples
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
574 Enable power-loss recovery
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
575 Disable power-loss recovery
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
576 Report the current power-loss recovery state

M415: Host Rescue

The host rescue G-code is essential to enabling host software to recover from a lost connection or power loss. With this solution the firmware stores the last received coordinate and current position in EEPROM. Once the host reconnects, the firmware reports this recovery information. From the last-received coordinate the host can determine the last line that was processed. Firmware should move the extruder to a parking position if commands stop arriving during an active print job (with heaters still on). Once the host starts sending new commands the firmware should restore the last position. Host and firmware developers can work together to optimize this solution.

If the firmware supports this solution it should announce it with the capability:

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
577

Examples
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
578 Enable host rescue system
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
579 Disable host rescue system
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
580 Set Z position as if homed
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
581 Report rescue state

Every call to M415 reports the state. Answers are

RESCUE_STATE: OFF

Nothing stored. Print finished.

RESCUE_STATE: LX:121.97 LY:143.33 LZ:3.30 LE:1.84 LT:0 X:0.00 Y:240.00 Z:13.30 E:1.84

Print was interrupted. Coordinates with leading L are last received positions, LT is active extruder. Normal coordinates are current position and can be omitted, if the move did not finish due to power loss.

On a power loss the firmware should respond with

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
582 as early as possible to give host time to flush log as it is likely host will also go down very soon.

Support is available in Repetier-Firmware 1.0.4 or higher. Repetier-Server 0.91.0 is the first to use this concept and can be used to validate implementation.

M416: Power loss

Host tells firmware that it will loose power. This is the solution in case a connected host has a power loss detection and firmware does not. Firmware should return the message

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
582 and do whatever firmware is supposed to do in that case. In combination with host rescue it should store positions, disable heaters, go to park position.

M420: Set RGB Colors as PWM (MachineKit)

Usage:

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
584

Example
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
94

Set the color of your RGB LEDs that are connected to PWM-enabled pins. Note, the Green color is controlled by the

N123
67 value instead of the G value due to the G code being a primary code that cannot be overridden.

In Marlin

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
586 is Enable/Disable Mesh Leveling (with current values) S1=enable S0=disable

M420: Leveling On/Off/Fade (Marlin)

Enable/Disable Bed Leveling (using the current stored grid or mesh).

Usage
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
587Examples
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
95

Marlin 1.1.0 adds the

N123 [...G Code in here...] *71
04 parameter to set the "fade" height. This requires the
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
589 option.

When the

N123 [...G Code in here...] *71
04 fade height value is set non-zero, bed compensation will gradually reduce up to the given height, and cease completely above that height.

M421: Set a Mesh Bed Leveling Z coordinate

Set a single Z coordinate in the Mesh, Bilinear or UBL Leveling grid. Requires

N123 [...G Code in here...] *71
79 or
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
592 or
N123 [...G Code in here...] *71
99.

I & J are the index for the X and Y axis respectively.

Usage
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
594 to set an absolute value to a mesh point

or

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
595 to offset a mesh point by a specified value

M422: Set a G34 Point

Set a single XY coordinate to be used by

G0 X12               ; move to 12mm on the X axis
G0 F1500             ; Set the feedrate to 1500mm/min
G1 X90.6 Y13.8 E22.4 ; Move to 90.6mm on the X axis and 13.8mm on the Y axis while extruding 22.4mm of material
06 for Z Stepper Alignment.

Usage
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
597

M423: X-Axis Twist Compensation

Reset, set, or report X-Axis Twist Compensation data that will be used by subsequent

N123 [...G Code in here...] *71
74 commands to compensate for a twisted X-axis.

Parameters
N123
89 Flag to reset the X-twist data to configured defaults.
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
600 Zero-based index into the X-twist data array. (
N123 [...G Code in here...] *71
04 is also required)
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
602 An offset value to set. (
N123 [...G Code in here...] *71
42 is also required)
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
604 Set the starting X position.
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
605 Set the X spacing distance.Usage
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
606 to report the current X-twist data to the host console.
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
607 to reset X-twist data to the configured defaults.
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
608 to set an offset value.
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
609 to set the X-start position and X-spacing distance.

M424: Global Z Offset

Set or report the global Z offset for the leveling mesh. The command

N123 [...G Code in here...] *71
74 will set this automatically to an average mesh value to allow for "leveling fade" with a biased mesh. In Marlin this feature requires the
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
611 option.

Parameters
N123 [...G Code in here...] *71
04 New global offset value to apply.Usage
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
613 to report the current global mesh Z offset.
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
614 to set the global mesh Z offset.

M425: Backlash Correction

Parameters
N123
55 Enable/disable/fade-out backlash correction (0.0 = none to 1.0 = 100%)
N123
62 Distance over which backlash correction is spread1 (mm)
N123
51 Set the backlash distance on X (mm; 0 to disable)
N123
52 Set the backlash distance on Y (mm; 0 to disable)
N123
53 Set the backlash distance on Z (mm; 0 to disable)
N123 [...G Code in here...] *71
42 Use measured value for backlash on X (if available)
N123 [...G Code in here...] *71
43 Use measured value for backlash on Y (if available)
N123 [...G Code in here...] *71
04 Use measured value for backlash on Z (if available)Examples (Marlin)
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
96Notes

1 In Marlin, backlash compensation works by adding extra steps to one or more segments after a motor direction reversal. With smoothing off, this can cause blemishes on the print. Enabling smoothing will cause those extra steps to be spread over multiple segments, minimizing artifacts.

M450: Report Printer Mode

Usage
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
623Example
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
97

Printers can be used for different task by exchanging the toolhead. Depending on the tool, a different behavior of some commands can be expected. This command reports the current working mode. Possible answers are:

PrinterMode:FFFPrinterMode:LaserPrinterMode:CNC

M451: Select FFF Printer Mode

Usage
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
624Example
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
98

Switches to FFF mode for filament printing.

M452: Select Laser Printer Mode

Usage
G1 F1500           ; Set feedrate to 1500mm/min
G1 X50 Y25.3 E22.4 ; Move and extrude
35Example
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
99

Switches to laser mode. This mode enables handling of a laser pin and makes sure that the laser is only activated during

N123
48 moves if laser was enabled or E is increasing.
N123
36 moves should never enable the laser.
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
628/
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
629 can be used to enable/disable the laser for moves.

M453: Select CNC Printer Mode

Usage
G1 F1500           ; Set feedrate to 1500mm/min
G1 X50 Y25.3 E22.4 ; Move and extrude
34Parameters (RepRapFirmware only)
  • Snnn (optional) Spindle index, defaults to 0. Duet 2 supports 4 spindles max
  • Pfff:rrr Logical pin numbers used to drive the spindle motor in clockwise and counterclockwise directions. Omit the ":rrr" part if the spindle turns clockwise only.
  • In Invert (I1) or don't invert (I0, default) the output polarity
  • Rnnn Spindle RPM that is achieved at full PWM. Used to convert the S parameter in M3 and M4 commands to a PWM value.
  • Fnnn (optional) The PWM frequency to use
  • Tnnn (optional) Assign spindle to a tool allowing better control in DWC
Example
(Home some axes)
G28 (here come the axes to be homed) X Y
00

Switches to CNC mode. In this mode

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
628/
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
632/
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
629 control the pins defined for the milling device.

Notes for RepRapFirmware: By default, no output is assigned to the spindle motor. Logical pin numbers for the P parameters are as defined for the M42 and M208 commands. If you wish to assign a heater or fan output to control the spindle motor as in the above example, you must first disable the corresponding heater (see M307) or fan (see M106).

M460: Define temperature range for thermistor-controlled fan

Usage
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
634Example
(Home some axes)
G28 (here come the axes to be homed) X Y
01

If the firmware has a thermistor controlled fan defined, you can set at which temperature the fan starts and from which temperature on it should run with maximum speed.

M470: Create Directory on SD-Card

Parameters
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
635 Name of directory to createUsage
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
636Example
(Home some axes)
G28 (here come the axes to be homed) X Y
02

This will create a new directory on the SD-Card. If not otherwise specified the default root should be the first/internal SD-Card.

M471: Rename File/Directory on SD-Card

Parameters
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
425 Name of existing file/directory
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
638 New name of file/directory
G1 F1500                 ; Feedrate 1500mm/min
G1 X50 Y25.3 E22.4 F3000 ; Accelerate to 3000mm/min
96 Setting this to 1 will delete an existing file that matches the T parameter valueUsage
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
640Example
(Home some axes)
G28 (here come the axes to be homed) X Y
03

Rename or move a file or directory. Using the D parameter can delete a file with the target name. Renaming or moving across directories is possible though not from one SD-Card to another.

M486: Cancel Object

The

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
641 G-code provides an interface to identify objects on the print bed and cancel them. Basic usage: Use
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
642 to tell the firmware how many objects there are, so it can provide an LCD interface. (Otherwise the firmware counts them up in the first layer.) In every layer of your G-code, you must preface each object's layer slice with
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
643 to indicate which object is being printed. The index should be zero-based. To cancel the first object, use
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
644; to cancel the 5th object use
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
645; and so on. The "current" object is canceled with
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
646.

G-codes associated with the canceled objects are no longer printed. Firmware supports this feature by ignoring G0-G3/G5 moves in XYZ while updating F and keeping the E coordinate up-to-date without extruding.

Slicers should number purge towers and other global features with a negative index (or other flag) to distinguish them from regular print objects, since it is important to preserve color changes, purge towers, and brims.

Host software (such as OctoPrint) may be able to cancel individual objects through a plugin, and in this case they should not use M486 P to cancel objects (although doing so should cause no harm).

Usage
(Home some axes)
G28 (here come the axes to be homed) X Y
04M486 implementation in RepRapFirmwareIf the GCode file being printed contains object label comments (e.g. using the "Label objects" option in PrusaSlicer) then it is not necessary to use M486 S commands to indicate which object is being printed. Objects on the build plate will be numbered from 0 in the order in which their labels first appear in the file.If you do use M486 S commands in the GCode file instead of object label comments, then RepRapFirmware provides an optional A parameter to the M486 S command to allow objects to be named. The name of each object need only be specified once.M486 without parameters lists the names and approximate locations of known objects on the build plate. For the benefit of user interfaces, this information may also be retrieved from the object model using M409.

M500: Store parameters in non-volatile storage

Example
(Home some axes)
G28 (here come the axes to be homed) X Y
05

Save current parameters to EEPROM, SD card or other non-volatile storage.

In Redeem any parameters set through G/M-codes which is different than what is read from the config files, are stored back to the local config. For instance setting stepper current and microstepping through

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
647 and
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
648 followed by
G0 X12               ; move to 12mm on the X axis
G0 F1500             ; Set the feedrate to 1500mm/min
G1 X90.6 Y13.8 E22.4 ; Move to 90.6mm on the X axis and 13.8mm on the Y axis while extruding 22.4mm of material
07 will update /etc/redeem/local.cfg.

M501: Read parameters from EEPROM

Parameters
N123
62 Enable auto-save (only RepRapFirmware)Example
(Home some axes)
G28 (here come the axes to be homed) X Y
06

Set the active parameters to those stored in the EEPROM, SD card or other non-volatile storage. This is useful to revert parameters after experimenting with them.

RepRapFirmware versions prior to 1.17 allows "S1" to be passed, which forces parameters to be automatically saved to EEPROM when they are changed.

In RepRapFirmware 1.17 and later, the parameters are saved in file sys/config-override.g on the SD card.

M502: Restore Default Settings

Example
(Home some axes)
G28 (here come the axes to be homed) X Y
07

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 with

G0 X12               ; move to 12mm on the X axis
G0 F1500             ; Set the feedrate to 1500mm/min
G1 X90.6 Y13.8 E22.4 ; Move to 90.6mm on the X axis and 13.8mm on the Y axis while extruding 22.4mm of material
07 to reboot with default settings.

M503: Report Current Settings

Examples
(Home some axes)
G28 (here come the axes to be homed) X Y
08

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

G1 F1500                 ; Feedrate 1500mm/min
G1 X50 Y25.3 E22.4 F3000 ; Accelerate to 3000mm/min
64 command.

RepRapFirmware outputs the content of the configuration file, but note that it may be truncated if it is too long.

Examples
(Home some axes)
G28 (here come the axes to be homed) X Y
09

This command checks the contents of EEPROM for correct version, size, and checksum and reports the result.

M505: Firmware dependent

M505: Clear EEPROM and RESET Printer

This command erase all EEPROM and reset the board.

M505: Set configuration file folder
ParametersP"name" ; name of folder, default path is /sys/ if it is a relative pathExampleM505 P"experimental" ; change config file path from /sys/ to /sys/experimental/

Following this command, files that would normally be fetched from /sys/ (for example, homing files and system macro files in RepRapFirmware) are fetched from the specified folder instead. Any such files that are already being executed will continue to run.

This command can be used to allow multiple configurations to be maintained easily. In RepRapFirmware the file /sys/config/g can contain just these two lines:

(Home some axes)
G28 (here come the axes to be homed) X Y
10

The first line changes the config file folder to /sys/config1 and the second one executes file config.g in that folder. To select an alternative configuration, only the first line needs to be edited.

M509: Force language selection

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

M510: Lock Machine

Lock the machine. When the machine is locked a passcode is required to unlock it. Use

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
653 with your passcode to unlock the machine. In Marlin this feature is enabled with the
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
654 option.

M511: Unlock Machine with Passcode

Check the given passcode and unlock the machine if it is correct. Otherwise, delay for a period of time before allowing another attempt. In Marlin this feature is enabled with the

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
654 option.

ParametersP"passcode" ; a numeric passcode to try

M512: Set Passcode

Check the given passcode (

N123 [...G Code in here...] *71
10) and if it is correct clear the passcode. If
N123 [...G Code in here...] *71
00 is given, set a new passcode. In Marlin this feature is enabled with the
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
658 option.

ParametersP"oldpass" ; the current numeric passcodeS"newpass" ; a new numeric passcode

M524: Abort SD Printing

Example
(Home some axes)
G28 (here come the axes to be homed) X Y
11

If an SD print is in progress, this command aborts the print, just as if you had selected "Stop print" from the LCD menu.

M530: Enable printing mode

Example
(Home some axes)
G28 (here come the axes to be homed) X Y
12

This command tells the firmware that a print has started (

int cs = 0;
for(i = 0; cmd[i] != '*' && cmd[i] != NULL; i++)
   cs = cs ^ cmd[i];
cs &= 0xff;  // Defensive programming...
04) or ended (
int cs = 0;
for(i = 0; cmd[i] != '*' && cmd[i] != NULL; i++)
   cs = cs ^ cmd[i];
cs &= 0xff;  // Defensive programming...
03). The
N123 [...G Code in here...] *71
93 parameter sets the number of layers.
int cs = 0;
for(i = 0; cmd[i] != '*' && cmd[i] != NULL; i++)
   cs = cs ^ cmd[i];
cs &= 0xff;  // Defensive programming...
89 denotes unknown layer count. This enables the firmware to switch into a special print display mode to show print progress. Firmware should indicate the presence of this feature by responding to
G1 F1500           ; Set feedrate to 1500mm/min
G1 X50 Y25.3 E22.4 ; Move and extrude
84 with an additional line:

(Home some axes)
G28 (here come the axes to be homed) X Y
13Notes

1In MK4duo this command starts print counters for statistics. It also turns off a 30-minute timer for the heaters. If the timer reaches 30, turn off all the heaters.

M531: Set print name

Example
(Home some axes)
G28 (here come the axes to be homed) X Y
14

Sets the name of the currently printed object. Should follow

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
664 for correct display.

M532: Set print progress

Example
(Home some axes)
G28 (here come the axes to be homed) X Y
15

Sets the print progress (X = 0..100) and currently printed layer (L). Should be send every 0.1% progress change on every layer change.

M540: Set MAC address

Parameters
N123
83 The MAC addressExamples
(Home some axes)
G28 (here come the axes to be homed) X Y
16

Sets the MAC address of the RepRap. This should be done before any other network commands. The MAC address is six one-byte hexadecimal numbers separated by colons. The 0x prefix is optional in later firmware revisions.

All devices running on the same network shall all have different MAC addresses. For your printers, changing the last digit is sufficient.

This command is only needed when using older electronics that doesn't provide a unique MAC address, for example Duet 0.6 and Duet 0.8.5.

M540 in Marlin: Enable/Disable "Stop SD Print on Endstop Hit"

Parameters
N123
62 state, S1=enable, S0=disableExample
(Home some axes)
G28 (here come the axes to be homed) X Y
17Notes

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

M550: Set Name

Parameters
N123
83 Machine nameExample
(Home some axes)
G28 (here come the axes to be homed) X Y
18

Sets the name of the RepRap to (in this case) Godzilla. The name can be any string of printable characters except ';', which still means start comment.

M551: Set Password

Parameters
N123
83 PasswordExample
(Home some axes)
G28 (here come the axes to be homed) X Y
19

On machines that need a password to activate them, set that password. The code 'P' is not part of the password. Note that as this is sent in clear it does not (nor is it intended to) offer a very high level of security. But on machines that are (say) on a network, it prevents idle messing about by the unauthorised. The password can contain any printable characters except ';', which still means start comment.

Note for RepRapFirmware: If the specified password differs from the default one (i.e. reprap), the user will be asked to enter it when a connection is established via HTTP or Telnet. For FTP, the password must always be passed explicitly.

M552: Set IP address, enable/disable network interface

Parameters
N123
78 (Optional) Number of the network interface to manage (defaults to 0)
N123
83 IP address, 0.0.0.0 means acquire an IP address using DHCP
N123
62 (optional) -1 = reset network interface, 0 = disable networking, 1 = enable networking as a client, 2 = enable networking as an access point (WiFi-enabled electronics only)
N123
61 (optional, RepRapFirmware 1.17 and earlier only) HTTP port, default 80Example
(Home some axes)
G28 (here come the axes to be homed) X Y
20

Sets the IP address of the machine to (in this case) 192.168.1.14. If the

N123 [...G Code in here...] *71
00 parameter is not present then the enable/disable state of the network interface is not changed.

In RepRapFirmware 1.18 and later the HTTP port address is set using the

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
674 command, so the
N123
89 parameter of this command is no longer supported.

M552 with no parameters reports the current network state and IP address.

M553: Set Netmask

Parameters
N123
78 (Optional) Number of the network interface to manage (defaults to 0)
N123
83 Net maskExample
(Home some axes)
G28 (here come the axes to be homed) X Y
21

Sets the network mask of the RepRap machine to (in this case) 255.255.255.0. A restart may be required before the new network mask is used. If no 'P' field is specified, this echoes the existing network mask configured.

Recent RepRapFirmware versions allow the IP configuration to be changed without a restart.

M554: Set Gateway and/or DNS server

Parameters
N123
78 (Optional) Number of the network interface to manage (defaults to 0)
N123
83 Gateway
N123
62 (Optional) DNS server (only supported by DSF 3.3 with DuetPi system config plugin)Example
(Home some axes)
G28 (here come the axes to be homed) X Y
22

Sets the Gateway IP address of the RepRap machine to (in this case) 192.168.1.1. A restart may be required before the new gateway IP address is used. If no 'P' field is specified, this echoes the existing Gateway IP address configured.

Recent RepRapFirmware versions allow the IP configuration to be changed without a restart.

M555: Set compatibility

Parameters
N123
83 Emulation typeExample
(Home some axes)
G28 (here come the axes to be homed) X Y
23

For firmware that can do it, the firmware is set to a mode where its input and (especially) output behaves exactly like other established firmware. The value of the 'P' argument is:

M556: Axis compensation

Parameters
N123
62 Height of the measured distances
N123
51 Deviation in X direction
N123
52 Deviation in Y direction
N123
53 Deviation in Z direction
N123
83 Apply XY compensation to Y axis instead of X (defaults to 0, requires RRF 3.2-b4 or newer)Example
(Home some axes)
G28 (here come the axes to be homed) X Y
24

Image denoting how to determine the S parameter for G-code M556

Though with care and adjustment a RepRap can be set up with its axes at right-angles to each other within the accuracy of the machine, who wants to bother with care and adjustment when the problem can be solved by software? This tells software the tangents of the angles between the axes of the machine obtained by printing then measuring a test part. The

N123 [...G Code in here...] *71
00 parameter (100 here) is the length of a triangle along each axis in mm. The X, Y and Z figures are the number of millimeters of the short side of the triangle that represents how out of true a pair of axes is. The X figure is the error between X and Y, the Y figure is the error between Y and Z, and the Z figure is the error between X and Z. Positive values indicate that the angle between the axis pair is obtuse, negative acute.

M557: Set Z probe point or define probing grid

Parameters to define
N123
39 probe points (Cartesian/CoreXY printers only, no longer supported in RepRapFirmware)
N123
83 Probe point number
N123
51 X coordinate
N123
52 Y coordinateExample
(Home some axes)
G28 (here come the axes to be homed) X Y
25Parameters to define
N123 [...G Code in here...] *71
74 probe grid (all values in mm)
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
693 Minimum and maximum X coordinates to probe
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
694 Minimum and maximum Y coordinates to probe
N123
61 Radius to probe
G0 X12               ; move to 12mm on the X axis
G0 F1500             ; Set the feedrate to 1500mm/min
G1 X90.6 Y13.8 E22.4 ; Move to 90.6mm on the X axis and 13.8mm on the Y axis while extruding 22.4mm of material
20 or
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
697 Probe point spacing
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
137 or
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
699 Number of probe points in each direction (RepRapFirmware 2.02 and later) - use instead of specifying the spacingExamples
(Home some axes)
G28 (here come the axes to be homed) X Y
26

Set the points at which the bed will be probed to compensate for its plane being slightly out of horizontal.

The first form defines the points for for

N123
39 bed probing. The
N123 [...G Code in here...] *71
10 value is the index of the point (indices start at 0) and the
N123 [...G Code in here...] *71
42 and
N123 [...G Code in here...] *71
43 values are the position to move extruder 0 to to probe the bed. An implementation should allow a minimum of three points (P0, P1 and P2). This just records the point coordinates; it does not actually do the probing. See G32. Defining the probe points in this way is no longer supported by RepRapFirmware, you should define them in a bed.g file instead.

The second form defines the grid for

N123 [...G Code in here...] *71
74 bed probing. For Cartesian printers, specify minimum and maximum
N123 [...G Code in here...] *71
42 and
N123 [...G Code in here...] *71
43 values to probe and the probing interval. For Delta printers, specify the probing radius. If you define both, the probing area will be the intersection of the rectangular area and the circle. There is a firmware-dependent maximum number of probe points supported, which may be as low as 100.

M558: Set Z probe type

Parameters
N123
83 Z probe type
N123
55 Feed rate (i.e. probing speed, mm/min)
N123
56 Dive height (mm)
N123
78 Invert (I1) or do not invert (I0) the Z probe reading (RepRapFirmware 1.16 and later)
N123
61 Z probe recovery time after triggering, default zero (seconds) (RepRapFirmware 1.17 and later)1
N123 [...G Code in here...] *71
17 Travel speed to and between probe points (mm/min)
N123
86 Maximum number of times to probe each point, default 1 (RepRapFirmware 1.21 and later)
N123
62 Tolerance when probing multiple times, default 0.03 (RepRapFirmware 1.21 and later)
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
452 B1 turns off all heaters during probing moves and during the probe recovery time (RepRapFirmware 1.21 and later)Obsolete parameters
N123
51 If nonzero, use probe for homing X axis (RepRapFirmware 1.19 and earlier only)
N123
52 If nonzero, use probe for homing Y axis (RepRapFirmware 1.19 and earlier only)
N123
53 If nonzero, use probe for homing Z axis (RepRapFirmware 1.19 and earlier only)Example
(Home some axes)
G28 (here come the axes to be homed) X Y
27

A Z probe may be a switch, an IR proximity sensor, or some other device. This selects which to use:

P0 indicates that no Z probe is presentP1 indicates an unmodulated IR probe, or any other probe type that emulates an unmodulated IR probe (probe output is an analog signal that rises with decreasing nozzle height above the bed). If there is a control signal to the probe, it is driven high when the probe type is P1P2 specifies a modulated IR probe, where the modulation is commanded directly by the main board firmware using the control signal to the probeP3 selects an alternative Z probe similar to P1 but the control signal to the probe lowP4 selects a switch for bed probing (on the Duet, this must be connected to the E0 endstop pins)P5 (from RepRapFirmware 1.14) selects a switch or a digital output device to the In pin of the Z-probe connectorP6 is as P4 but the switch is connected to and alternative connector (on the Duet series, the E1 endstop connector)P7 is as P4 but the switch is connected to and alternative connector (on the Duet series, the Z endstop connector)P8 is as P5 but the signal is unfiltered for faster responseP9 is as P5 but the probe is deployed and retracted at every probe point. This is intended for BLTouch.

Related codes: G29, G30, G31, G32, M401, M402.

M559: Upload configuration file

Example
(Home some axes)
G28 (here come the axes to be homed) X Y
28

If the RepRap supports it, this uploads a file that is run on re-boot to configure the machine. This file usually is a special G Code file. After sending

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
719, the file should be sent, ending with an
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
720 (q.v.).

M560: Upload web page file

Example
(Home some axes)
G28 (here come the axes to be homed) X Y
29For RepRaps that have web support and that can be driven by a web browser, this uploads the file that is the control page for the RepRap. After sending
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
721 the file (usually an HTML file) should be sent, terminated by the string. Clearly that string cannot exist in the body of the file, but can be put on the end to facilitate this process. This should not be too serious a restriction...

M561: Set Identity Transform

Example
(Home some axes)
G28 (here come the axes to be homed) X Y
30

This cancels any bed-plane fitting as the result of probing (or anything else) and returns the machine to moving in the user's coordinate system.

M562: Reset temperature fault

Parameters
N123
83 Heater numberExample
(Home some axes)
G28 (here come the axes to be homed) X Y
31

Reset a temperature fault on heater/sensor 2. If the RepRap has switched off and locked a heater because it has detected a fault, this will reset the fault condition and allow you to use the heater again. Obviously to be used with caution. If the fault persists it will lock out again after you have issued this command. P0 is the bed; P1 the first extruder, and so on.

Later versions of RepRapFirmware support M562 without the P parameter, which will reset all heater faults.

M563: Define or remove a tool

Parameters
N123
83 Tool number
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
425 Tool name (optional)
G1 F1500                 ; Feedrate 1500mm/min
G1 X50 Y25.3 E22.4 F3000 ; Accelerate to 3000mm/min
96 Extruder drive(s)
N123
56 Heater(s)
N123
55 Fan(s) to map the print cooling fan to (RepRapFirmware 1.16 and later)
N123
51 Axis or axes to map X movement to (RepRapFirmware 1.16 and later)
N123
52 Axis or axes to map Y movement to
N123
92 Drive to use for filament mapping. By default RRF will use the first and only extruder drive if this parameter is not specified (supported by RRF >= 2.02)Examples
(Home some axes)
G28 (here come the axes to be homed) X Y
32

Tools are usually (though not necessarily) extruders. The 'P' field specifies the tool number. Tool numbers can have any positive integer value and 0. The 'D' field specifies the drive(s) used by the tool - in the first example drives 0, 2 and 3. Drive 0 is the first drive in the machine after the movement drives (usually X, Y and Z). If there is no 'D' field the tool has no drives. The 'H' field specifies the tool's heaters - in the first example heaters 1 and 3. Heater 0 is usually the hot bed (if any) so the first extruder heater is usually 1. If there is no H field the tool has no heaters.

Tools are driven using multiple values in the 'E' field of

N123
48 commands, each controlling the corresponding drive in the 'D' field above, as follows:

(Home some axes)
G28 (here come the axes to be homed) X Y
33

The first line moves straight to the point (90.6, 13.8) extruding a total of 2.24mm of filament from both drives 0 and 2 and 15.98mm of filament from drive 3. The second line moves back 20mm in X extruding 42.4mm of filament from drive 3.

Alternatively, if the slicer does not support generating

N123
48 commands with multiple values for the extrusion amount, the
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
733 command can be used to define a tool mix ratio.

Normally an

N123 [...G Code in here...] *71
05 command is immediately followed by a
N123 [...G Code in here...] *71
02 command to set the tool's offsets and temperatures.

It is permissible for different tools to share some (or all) of their drives and heaters. So, for example, you can define two tools with identical hardware, but that just operate at different temperatures.

The X mapping option is used to create tools on machines with multiple independent X carriages. The additional carriages are set up as axes U, V etc. (see

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
736) and the X mapping option in
N123 [...G Code in here...] *71
05 defines which carriage or carriages are used.

If you use the

N123 [...G Code in here...] *71
05 command with a
N123 [...G Code in here...] *71
10 value for a tool that has already been defined, that tool is redefined using the new values you provide.

RepRapFirmware supports an additional form of the

N123 [...G Code in here...] *71
05 command. The command:

(Home some axes)
G28 (here come the axes to be homed) X Y
34

means add 1 (the value of the

N123 [...G Code in here...] *71
00 parameter) to all tool numbers found in the remainder of the current input stream (e.g. the current file if the command is read from a file on the SD card), or until a new
N123 [...G Code in here...] *71
05 command of this form is executed. The purpose of this is to provide compatibility between systems in which tool numbers start at 1, and programs such as slic3r that assume tools are numbered from zero.

Recent versions of RepRapFirmware allow the deletion of existing tools if

N123 [...G Code in here...] *71
05 is called in this way:

(Home some axes)
G28 (here come the axes to be homed) X Y
35

M564: Limit axes

Parameters
N123
56 H1 = forbid movement of axes that have not been homed, H0 = allow movement of axes that have not been homed (RepRapFirmware 1.21 and later)
N123
62 S1 = limit movement within axis boundaries, S0 = allow movement outside boundariesExampleM564 S0 H0

Allow moves outside the print volume and before homing, or not. If the S parameter is 0, then you can send G codes to drive the RepRap outside its normal working volume, and it will attempt to do so. Likewise if the H parameter is 0 you can move the head or bed along axes that have not been homed. The default behaviour is S1 H1. On some types of printer (e.g. Delta and SCARA), movement before homing is prohibited regardless of the H parameter.

M565: Set Z probe offset

Example
(Home some axes)
G28 (here come the axes to be homed) X Y
36

Set the offset from the extruder tip to the probe position. The

N123 [...G Code in here...] *71
42,
N123 [...G Code in here...] *71
43, and
N123 [...G Code in here...] *71
04 values are the delta between the extruder and the actual trigger position of the probe. If the probe trigger point is below the extruder (typical) the Z offset will be negative. This just records the point offset; it does not actually do the probing. See
N123
39.

M566: Set allowable instantaneous speed change

Parameters
N123
51 Maximum instantaneous speed change of the X axis (mm/min)
N123
52 Maximum instantaneous speed change of the Y axis
N123
53 Maximum instantaneous speed change of the Z axis
N123
54 Maximum instantaneous speed change of the extruder drivesExample
(Home some axes)
G28 (here come the axes to be homed) X Y
37

Sets the maximum allowable speed change (sometimes called 'jerk speed') of each motor when changing direction.

The model files and gcode files used by repraps generally render circles and other curves shapes as a sequence of straight line segments. If the motors were not allowed any instantaneous speed change, they would have to come to a stop at the junction between each pair of line segments. By allowing a certain amount of instantaneous speed change, printing speed can be maintained when the angle between the two line segments is small enough.

If you set these

N123 [...G Code in here...] *71
42 and
N123 [...G Code in here...] *71
43 values too low, then the printer will be slow at printing curves. If they are too high then the printer may be noisy when cornering and you may suffer ringing and other print artefacts, or even missed steps.

On very old versions of RepRapFirmware (prior to 1.09), these were also the minimum speeds of each axis.

M567: Set tool mix ratios

Parameters
N123
83 Tool number
N123
54 Mix ratiosExample
(Home some axes)
G28 (here come the axes to be homed) X Y
38

This example sets the mix ratio for tool 2 (the

N123 [...G Code in here...] *71
10 value). When mixing is then turned on (see
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
759), only single
N123
67 values need to be sent on a
N123
48 command (any extra
N123
67 values will be ignored, but are not illegal):

(Home some axes)
G28 (here come the axes to be homed) X Y
39

This will move to X=20 extruding a total length of filament of 1.3mm. The first drive of tool 2 will extrude 0.1*1.3mm, the second 0.2*1.3mm and so on. The ratios don't have to add up to 1.0 - the calculation done is as just described. But it is best if they do.

See also

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
759.

M568: Tool settings

ParametersPnnn Tool number. If this parameter is not provided, the current tool is assumed.Rnnn Standby temperature(s)Snnn Active temperature(s)Fnnn Spindle RPM, always positiveAn Required heater state: 0 = off, 1 = standby temperature(s), 2 = active temperature(s)ExamplesM568 P1 R140 S205 ; set standby and active temperatures for tool 1M568 P0 F5200 ; set spindle RPM for tool 0M568 P2 A1 ; set tool 2 heaters to their standby temperatures

RepRapFirmware will report the tool parameters if only the tool number is specified.

The R value is the standby temperature in °C that will be used for the tool, and the S value is its operating temperature. If you don't want the tool to be at a different temperature when not in use, set both values the same.

Temperatures set with M568 do not wait for the heaters to reach temp before proceeding. In order to wait for the temp use a M116 command after the M568 to wait for temps to be reached.

M568: Turn off/on tool mix ratios (obsolete meaning in old RepRapFirmware versions)

This command is obsolete. When using a tool defined as a mixing extruder, RepRapFirmware applies the mix ratio defined by M567 whenever only one E parameter is provided in G1 commands. When multiple colon-separated E values are provided in the G1 command, they will be used as the individual amounts to extrude.

M569: Stepper driver control

Parameters
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
137 Motor driver number
int cs = 0;
for(i = 0; cmd[i] != '*' && cmd[i] != NULL; i++)
   cs = cs ^ cmd[i];
cs &= 0xff;  // Defensive programming...
54 Direction of movement of the motor(s) attached to this driver: 0 = backwards, 1 = forwards (default 1)
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
359 Driver enable polarity: 0 = active low, 1 = active high (default 0)
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
136 Minimum driver step pulse width and interval in microseconds (RepRapFirmware 1.14 and later)
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
768 Minimum driver step pulse width, step pulse interval, direction-to-step setup time and step-to-direction hold time, in microseconds (RepRapFirmware 1.21 and later)
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
769 Stepper driver mode (RepRapFirmware 2.0 and later): 0=constant off time, 1=random off time, 2=spread cycle, 3=stealthChop, 4=closed loop
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
435 (firmware 2.02 and later) Off-time in the chopper control register, 1 to 15
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
524 (firmware 2.02 and later) Blanking time (tbl) in the chopper control register, 0 to 3. See the TMC driver datasheet.
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
772 or
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
773 (firmware 2.02 and later) Hysteresis start, end and decrement values in the chopper control register. See the TMC driver datasheet for the meaning.
N123
88 Custom chopper control register value (RepRapFirmware 2.0 and later). Do not change this value without having a good understanding of the stepper driver driver chip!
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
775 (firmware 2.02 and later) t_high parameter for those stepper driver chips that support it (e.g. TMC2208, 2224). Send M569 P# (where # is the driver number) with no additional parameters to see how this translates into mm/sec. See also the V parameter.
G1 F1500                 ; Feedrate 1500mm/min
G1 X50 Y25.3 E22.4 F3000 ; Accelerate to 3000mm/min
16 (firmware 2.02 and later) tpwmthrs parameter for those stepper driver chips that support it (e.g. TMC2208, 2224). This is the interval in clock cycles between 1/256 microsteps below which the drivers will switch from stealthChop to to spreadCycle mode. Only applies when the driver is configured in stealthChop mode. Typical value are from 100 (high speed) to 4000 (low speed). Send M569 P# (where # is the driver number) with no additional parameters to see how this translates into axis speed in mm/sec.Example
(Home some axes)
G28 (here come the axes to be homed) X Y
40Notes

All parameters except P are optional. For any parameter that is not provided, the corresponding value will not be changed.

The T parameters are intended for use with external stepper drivers. Currently, RepRapFirmware only remembers the highest

N123
46 parameters seen in any M569 command, and applies those values to all drivers for which any nonzero
N123
46 parameters were specified.

The modes (D parameter) supported by various stepper driver chips are:

TMC2130, TMC2160, TMC5160: modes 0,1,2,3 (Duet 3 EXP1HCL board also supports mode 4)TMC2660: modes 0,1,2TMC2208/2209/2224: modes 2,3 (mode 3 is stealthChop2)

Some versions of RepRapFirmware prior to 1.14 also provided

N123 [...G Code in here...] *71
42,
N123 [...G Code in here...] *71
43,
N123 [...G Code in here...] *71
04 and
N123
67 parameters to allow the mapping from axes and extruders to stepper driver numbers to be changed. From 1.14 onward, this functionality is provided by M584 instead.

M569.1: Stepper driver closed loop configuration

Parameters
int cs = 0;
for(i = 0; cmd[i] != '*' && cmd[i] != NULL; i++)
   cs = cs ^ cmd[i];
cs &= 0xff;  // Defensive programming...
34 or
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
784 Motor driver number, or board address and driver number
int cs = 0;
for(i = 0; cmd[i] != '*' && cmd[i] != NULL; i++)
   cs = cs ^ cmd[i];
cs &= 0xff;  // Defensive programming...
54 Mode: 0=open loop (default), 1=closed loop (requires an encoder to be selected, see the T parameter)
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
054 Encoder type: 0=none, 1=linear quadrature encoder on axis, 2=quadrature encoder on motor shaft, 3=AS5047D encoder on motor shaft, 4=TLI5012B encoder on motor shaft
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
787 Encoder counts per mm (linear encoder) or per rotation (rotary encoder). Only used if the encoder type is 1 or 2.
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
788 Proportional constant
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
789 Integral constant
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
790 Derivative constant
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
447 Minimum holding current as a percentage of the configured current when operating in closed loop mode

Supported by RepRapFirmware on boards using closed loop drivers. Switching between open loop and closed loop modes is done using M569.

M569.2: Read or write any stepper driver register

Parameters
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
137 Motor driver number
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
793 Register number, 0-127
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
794 Value to write (optional)Example
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
795

If the V parameter is not provided, this command reads the specified register and returns the value of that register. If the V parameter is provided, that value is written to the specified register.

WARNING! Use of M569.2 to write stepper driver registers may result in damage to the stepper drivers, for example from excessive motor current or insufficient blanking time.

M569.3: Read Motor Driver Encoder

This causes the RepRap machine to report its current motor encoder positions to the host in units of arc degrees (1/360'ths of turns), relative to some reference position that you set with the

N123 [...G Code in here...] *71
00 parameter.

Before the first call with the

N123 [...G Code in here...] *71
00 parameter, the reference is unknown and arbitrary.

Parameters
int cs = 0;
for(i = 0; cmd[i] != '*' && cmd[i] != NULL; i++)
   cs = cs ^ cmd[i];
cs &= 0xff;  // Defensive programming...
34 or
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
784 Motor driver number, or board address and driver number. Several (remote) drivers may be specified, separated by colon. No more than number of visible axes, as specified by
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
800 parameter, are allowed.
N123 [...G Code in here...] *71
00 Sets an encoder reference point. Current and subsequent
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
802 calls returns numbers that are relative to the
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
803 call.

If

N123 [...G Code in here...] *71
10 is not supplied, an error is returned.

A maximum of four CAN-connected drivers can be reached with

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
805 counting from machine boot. CAN addresses that fail to respond don't count towards this maximum.

Examples
(Home some axes)
G28 (here come the axes to be homed) X Y
41

Error: M569: missing parameter 'P'

(Home some axes)
G28 (here come the axes to be homed) X Y
42

Error: M569.3: Message not received

(Home some axes)
G28 (here come the axes to be homed) X Y
43

[-155.28, -4089.60, 6842.04, 0.00, ],

(Home some axes)
G28 (here come the axes to be homed) X Y
44

[0.00, -4089.60, 6842.04, -155.28, ],

(Home some axes)
G28 (here come the axes to be homed) X Y
45

[0.00, 0.00, 0.00, 0.00, ],

(Home some axes)
G28 (here come the axes to be homed) X Y
46

Error: M569.3: Max CAN addresses we can reference is 4. Can't reference board 49.

Notes

1 Planned for RepRapFirmware 3.4.

M569.4: Set Motor Driver Torque Mode

Tell one or more motor drivers to apply a specified torque regardless of position.

Parameters
int cs = 0;
for(i = 0; cmd[i] != '*' && cmd[i] != NULL; i++)
   cs = cs ^ cmd[i];
cs &= 0xff;  // Defensive programming...
34 or
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
784 Motor driver number, or board address and driver number. Can also be a colon separated list of driver numbers.
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
054 Where n is the mode/torque to apply in units of Nm. Newer Hangprinters might use units of N.

If

N123 [...G Code in here...] *71
10 or
N123
46 parameter is missing, then no action is taken. The driver is put back into position mode by requesting a torque smaller than 0.0001 Nm.

Examples
(Home some axes)
G28 (here come the axes to be homed) X Y
47

Error: M569: missing parameter 'P'

(Home some axes)
G28 (here come the axes to be homed) X Y
48

Error: M569: missing parameter 'T'

(Home some axes)
G28 (here come the axes to be homed) X Y
49

0.001000 Nm,

(Home some axes)
G28 (here come the axes to be homed) X Y
50

pos_mode, pos_mode,

Notes

Hangprinter's "torque mode" is implemented as a ReprapFirmware macro that depends on M569.4.

Practical torques for tightening lines in daily use tend to lie between 0.1 Nm and 0.001 Nm for a Hangprinter.

1 Planned for RepRapFirmware 3.4.

M569.5: Collect Data from Closed-loop Driver

Parameters
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
784 Motor CAN board address and driver number

Remaining details TBD.

M569.6: Execute Closed-loop Driver Tuning Move

Parameters
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
784 Motor CAN board address and driver number

Remaining details TBD.

M569.7: Configure motor brake port

Parameters
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
784 Motor CAN board address (if applicable) and driver number
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
814 Port name of the brake control port. The port must be on the same CAN board as the driver. The CAN address does not need to be specified in the port name, but if it is then it must be the same as the driver address.Example
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
815

When the motor driver is enabled, the specified output port will be turned on at the same time to release the brake. When the motor driver is disabled, the output port will be turned off. Idle current mode does not count as disabled.

M569.8: Read Axis Force

Parameters
int cs = 0;
for(i = 0; cmd[i] != '*' && cmd[i] != NULL; i++)
   cs = cs ^ cmd[i];
cs &= 0xff;  // Defensive programming...
34 or
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
784 Motor driver number, or board address and driver number. Can also be a colon separated list of driver numbers.

The readouts are in units of Newtons.

Example

M569.8 P40.0:41.0:42.0:43.0 [3.52, -0.60, 7.24, -5.84, ],

M569.9: Sets the driver sense resistor and maximum current

Parameters
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
137 or
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
819 Motor driver number.
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
820 Driver sense resistor value in Ohms.
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
821 Driver max current value in Amps.Example
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
822

M570: Configure heater fault detection

Parameters for RepRapFirmware 1.14 and earlier
N123
62 Heater timeout (in seconds)Example
(Home some axes)
G28 (here come the axes to be homed) X Y
51

After a heater has been switched on, wait 120 seconds for it to get close to the set temperature. If it takes longer than this, raise a heater fault.

Parameters for RepRapFirmware 1.15e and later
N123
56 Heater number
N123
83 Time in seconds for which a temperature anomaly must persist on this heater before raising a heater fault (default 5 seconds)
N123 [...G Code in here...] *71
17 Permitted temperature excursion from the setpoint for this heater (default 10C)
N123
62 Time in seconds after a heater fault is raised after which the print will be abandoned, default 10 minutes (RepRapFirmware 1.20 and later)Example
(Home some axes)
G28 (here come the axes to be homed) X Y
52

Warning! Heating fault detection is provided to reduce the risk of starting a fire if a dangerous fault occurs, for example if the heater cartridge or thermistor falls out of the heater block. You should not increase the detection time or permitted temperature excursion without good reason, because doing so will reduce the protection.

M571: Set output on extrude

Parameters
N123
62 Output value
N123
55 Output PWM frequency (RepRapFirmware 1.17 and later)
N123
83 Logical pin number (RepRapFirmware 1.17 and later), defaults to the FAN0 output until
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
831 with a
N123 [...G Code in here...] *71
10 parameter has been seenExample
(Home some axes)
G28 (here come the axes to be homed) X Y
53

This turns the controlled pin output on whenever extrusion is being done, and turns it off when the extrusion is finished. The output could control a fan or a stirrer or anything else that needs to work just when extrusion is happening. It also can be used to control a laser beam. The

N123 [...G Code in here...] *71
00 parameter sets the value of the PWM to the output. 0.0 is off; 1.0 is fully on.

In RepRapFirmware 1.17 and later you can use the

N123 [...G Code in here...] *71
10 parameter to change the pin used and you can also set the PWM frequency. Pin numbers are the same as in the M42 and
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
345 commands. The pin you specify must not be in use for anything else, so if it is normally used as a heater you must disable the heater first using
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
407, or if it is used for a fan you must disable the fan using M106 with the I-1 parameter.

M572: Set or report extruder pressure advance

Parameters
G1 F1500                 ; Feedrate 1500mm/min
G1 X50 Y25.3 E22.4 F3000 ; Accelerate to 3000mm/min
96 Extruder number
N123
62 Pressure advance amount (in seconds)Example
(Home some axes)
G28 (here come the axes to be homed) X Y
54

This sets the pressure advance coefficient (

N123 [...G Code in here...] *71
00 parameter) for the specified extruder (
N123 [...G Code in here...] *71
86 parameter).

Pressure advance causes the extruder drive position to be advanced or retarded during printing moves by an additional amount proportional to the rate of extrusion. At the end of a move when the extrusion rate is decreasing, this may result in the extruder drive moving backwards (i.e. retracting). Therefore, if you enable this feature, you may need to reduce the amount of retraction you use in your slicing program to avoid over-retraction.

With Bowden extruders, an

N123 [...G Code in here...] *71
00 value between 0.1 and 0.5 usually gives the best print quality. Direct drive extruders typically work best with lower values such as 0.05.

Older versions of RepRapFirmware used the

N123 [...G Code in here...] *71
10 parameter to specify the drive number, instead of using D to specify the extruder number.

M573: Report heater PWM

Parameters
N123
83 Heater numberExample
(Home some axes)
G28 (here come the axes to be homed) X Y
55

This gives a running average (usually taken over about five seconds) of the PWM to the heater specified by the P field. If you know the voltage of the supply and the resistance of the heater this allows you to work out the power going to the heater. Scale: 0 to 1.

In RepRapFirmware 3.3.0 and later the heater PWM can be queried from the Object Model instead.

M574: Set endstop configuration

ParametersXnnn Switch position for X axisYnnn Switch position for Y axisZnnn Switch position for Z axisSnnn Endstop type: 0 = active low endstop input, 1 = active high endstop input, 2 = Z probe, 3 = motor load detectionExampleM574 X1 Y2 Z0 S1  ; X endstop at low end, Y endstop at high end, no Z endstop, all active high

This defines the position of endstop sensor that the printer has for each axis: 0 = none, 1 = low end, 2 = high end. The optional S parameter defines whether the endstop input is active high (S1, the default), low (S0), or the axes listed use the Z probe for homing that axis (S2), or motor stall detection (S3). A normally-closed endstop switch wired in the usual way produces an active high output (S1). If different axes use different types of endstop sensing, you can use more than one M574 command.

On delta printers the XYZ parameters refer to the towers, and the endstops should normally all be high end (i.e. at the top of the towers).

The S2 and S3 options are supported in RepRapFirmware 1.20 and later.

In RepRapFirmware 1.16 and earlier, the M574 command with E parameter was used to specify whether a Z probe connected to the E0 endstop input produces an active high (S1) or active low (S0) output. In RepRapFirmware 1.17 and later, use the I parameter of the M558 command instead.

M575: Set serial comms parameters

Parameters
N123
83 Serial channel number
N123
87 Baud rate (optional)
N123
62 Protocol (optional)Example
(Home some axes)
G28 (here come the axes to be homed) X Y
56

This sets the communications parameters of the serial comms channel specified by the

N123 [...G Code in here...] *71
10 parameter.
int cs = 0;
for(i = 0; cmd[i] != '*' && cmd[i] != NULL; i++)
   cs = cs ^ cmd[i];
cs &= 0xff;  // Defensive programming...
83 specifies the main serial interface (typically a USB port, or serial-over-USB), while
int cs = 0;
for(i = 0; cmd[i] != '*' && cmd[i] != NULL; i++)
   cs = cs ^ cmd[i];
cs &= 0xff;  // Defensive programming...
84 specifies an auxiliary serial port (for example, the port used to connect a PanelDue) and P2 specifies a second auxiliary port if there is one.

The

N123 [...G Code in here...] *71
67 parameter is the required baud rate (this parameter is typically ignored if the port is a true USB port).

The

N123 [...G Code in here...] *71
00 parameter is a bitmap of protocol features. Bit 0 if set specifies that only commands that include a valid checksum or CRC should be accepted from this comms channel. Bit 1 if set specifies that responses should be sent in raw mode (default is to send them as JSON). Bit 2 if set specifies that only commands with a valid CRC should be accepted (this overrides bit 0).

If either the B or the S parameter is missing, the previous value will be retained, or a default used if the port has not previously been configured using M575. If both are missing then the existing values are reported.

M576: Set SPI comms parameters

Parameters
N123
62 Maximum delay between full SPI transfers (in ms, defaults to 25ms)
N123
55 Maximum delay between full SPI transfers when a file is open (in ms, defaults to 5ms)
N123
83 Number of events required to skip the delay (defaults to 4)Example
(Home some axes)
G28 (here come the axes to be homed) X Y
57

This sets the communications parameters of the SPI channel. Supported in RRF 3.4 and later in SBC mode.

M577: Wait until endstop is triggered

Parameters
N123
62 Desired endstop level
N123
51 Select X axis endstop
N123
52 Select Y axis endstop
N123
53 Select Z axis endstop
N123
54 Select extruder drive endstopExample
(Home some axes)
G28 (here come the axes to be homed) X Y
58

Wait for an endstop switch to be pressed. The example above will wait until the first extruder endstop is triggered.

The following trigger types may be used using the 'S' parameter:

0: Endstop not hit 1: Low endstop hit 2: High endstop hit 3: Near endstop (only Z probe)

M578: Fire inkjet bits

Parameters
N123
83 Inkjet head number
N123
62 Bit patternExample
(Home some axes)
G28 (here come the axes to be homed) X Y
59

This fires inkjet head 3 (the P field) using the bit pattern specified by the S field. The example shown would fire bits 101. If the

N123 [...G Code in here...] *71
10 parameter is ommitted inkjet 0 is assumed.

This is a version of the M700 command used by the Inkshield, but unfortunately M700 is already taken so cannot be used for that in the standard.

M579: Scale Cartesian axes

Parameters
N123
51 Scale factor for X axis
N123
52 Scale factor for Y axis
N123
53 Scale factor for Z axisExample
(Home some axes)
G28 (here come the axes to be homed) X Y
60

On a Cartesian RepRap you can get prints exactly the right size by tweaking the axis steps/mm using the M92 G Code above. But this does not work so easily for Delta and other RepRaps for which there is cross-talk between the axes. This command allows you to adjust the X, Y, and Z axis scales directly. So, if you print a part for which the Y length should be 100mm and measure it and find that it is 100.3mm long then you set Y0.997 (= 100/100.3).

M580: Select Roland

Parameters
N123
61 Whether Roland mode should be activated
N123
83 Initial text to send to the Roland controllerExample
(Home some axes)
G28 (here come the axes to be homed) X Y
61

This is not really anything to do with RepRap, but it is convenient. The little Roland mills are very widely available in hackerspaces and maker groups, but annoyingly they don't speak G Codes. As all RepRap firmware includes a G-Code interpreter, it is often easy to add functions to convert G Codes to Roland RML language. M580 selects a Roland device for output if the R field is 1, and returns to native mode if the

N123
89 field is 0. The optional
N123 [...G Code in here...] *71
10 string is sent to the Roland if
N123
89 is 1. It is permissible to call this repeatedly with
N123
89 set to 1 and different strings in the
N123 [...G Code in here...] *71
10 field to communicate directly with a Roland.

M581: Configure external trigger

Parameters
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
136 Logical trigger number to associate the endstop input(s) with, from zero up to a firmware-specific maximum (e.g. 9 for RepRapFirmware)
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
874 Selects endstop input(s) to monitor
N123 [...G Code in here...] *71
10 Reserved, may be used in future to allow general I/O pins to cause triggers
N123 [...G Code in here...] *71
00 Whether trigger occurs on a rising edge of that input (S1, default), falling edge (S0), or ignores that input (S-1). By default, all triggers ignore all inputs.
N123 [...G Code in here...] *71
70 Condition: whether to trigger at any time (C0, default) or only when printing a file from SD card (C1)Example
(Home some axes)
G28 (here come the axes to be homed) X Y
62

When

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
878 is executed, if the
N123
46 parameter is present but the other parameters are omitted, the trigger inputs and edge polarities for that trigger number are reported. Otherwise, the specified inputs and their polarities are added to the conditions that cause that trigger. Using
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
880 with no
N123 [...G Code in here...] *71
42,
N123 [...G Code in here...] *71
43,
N123 [...G Code in here...] *71
04 or
N123
67 parameters sets the trigger back to ignoring all inputs.

In RepRapFirmware, trigger number 0 causes a full (emergency) stop as if

G1 F1500           ; Set feedrate to 1500mm/min
G1 X50 Y25.3 E22.4 ; Move and extrude
21 had been received. Trigger number 1 causes the print to be paused as if
G1 F1500           ; Set feedrate to 1500mm/min
G1 X50 Y25.3 E22.4 ; Move and extrude
74 had been received. Any trigger number # greater then 1 causes the macro file
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
887 to be executed. Polling for further trigger conditions is suspended until the trigger macro file has been completed. RepRapFirmware does not wait for all queued moves to be completed before executing the macro, so you may wish to use the
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
888 command at the start of your macro file. If several triggers are pending, the one with the lowest trigger number takes priority.

M582: Check external trigger

ParametersT Trigger number to pollExample
(Home some axes)
G28 (here come the axes to be homed) X Y
63

Triggers set up by the M581 command are normally activated only when the specified inputs change state. This command provides a way of causing the trigger to be executed if the input is at a certain level. For each of the inputs associated with the trigger, the trigger condition will be checked as if the input had just changed from the opposite state to the current state.

For example, if you use M581 to support an out-of-filament sensor, then M582 allows you to check for out-of-filament just before starting a print.

M584: Set drive mapping

Parameters
N123
51 Driver number(s) for X motor(s)
N123
52 Driver number(s) for Y motor(s)
N123
53 Driver number(s) for Z motor(s)
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
892 Driver number(s) for additional axes U, V, W, A, B and C (UVW RepRapFirmware 1.16 and later; ABC RepRapFirmware 1.19 and later)
N123
54 Driver number(s) for E motor(s)
N123
83 Number of visible axes, defaults to the total number of axes configured.ExampleM584 X0 Y1 Z2:3 E4:5:6 ; Driver 0 controls the X motor, 1 controls Y, 2 and 3 control Z motors, 4 and 5 control E motors

Assigning a drive using

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
736 does not remove its old assignment. Therefore, if you assign a drive that defaults to being an extruder drive, you should also assign the extruder drives explicitly as in the above example. Failure to do so may result in unexpected behaviour.

You can use

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
736 to create additional axes - for example, to represent additional carriages on a machine with multiple independent X carriages. Additional axes must be created in the order UVWABC. You can hide some of the last axes you create using the P parameter. Hidden axes have no homing buttons or jog controls in the user interface.

On the Duet WiFi and Duet Ethernet, if you configure multiple drivers for an axis, either all of them must be TMC2660 drivers on the Duet or a Duet expansion board, or none of them must be. This is to facilitate dynamic microstepping and other features of the TMC2660.

M585: Probe Tool

In machines with a tool probe this probes the currently selected tool against it and corrects the offsets set by the G10 command (q.v.).

Parameter must be only one of
N123
51
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
898
N123
53

Where the absolute value of

N123
28 is the radius of the tool plus the radius of the probe in that direction. So
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
901 will set the X offset of a 1mm diameter tool against a 2mm diameter probe, etc. If the value of
N123
28 is positive the tool is moved in the positive direction towards the probe until it touches. If it is negative, the tool moves the other way.

So the process should be:

Set the values as closely as known in the
N123 [...G Code in here...] *71
02 command.Move to a position slightly offset from the probe then execute
N123 [...G Code in here...] *71
01s in X, Y and Z in the tool selection macro to set them precisely.

After this, the

N123 [...G Code in here...] *71
02 command on its own can be used to report the values.

M586: Configure network protocols

Parameters
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
137 Protocol: 0 = HTTP or HTTPS, 1 = FTP or SFTP, 2 = Telnet or SSH (which of the two choices depends on the
N123
46 parameter)
G0 X12               ; move to 12mm on the X axis
G0 F1500             ; Set the feedrate to 1500mm/min
G1 X90.6 Y13.8 E22.4 ; Move to 90.6mm on the X axis and 13.8mm on the Y axis while extruding 22.4mm of material
20 0 = disable this protocol, 1 = enable this protocol
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
793 TCP port number to use for the specified protocol. Ignored unless S = 1. If this parameter is not provided then the default port for that protocol and TLS setting is used.
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
136 0 = don't use TLS, 1 = use TLS. Ignored unless
N123 [...G Code in here...] *71
00 = 1. If this parameter is not provided, then TLS will be used if the firmware supports it and a security certificate has been configured. If
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
912 is given but the firmware does not support TLS or no certificate is available, then the protocol will not be enabled and an error message will be returned.
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
913 Set or reset allowed site for cross-orgin HTTP requests (RRF > 3.2-b4.1)

M586 with no

N123 [...G Code in here...] *71
00 parameter reports the current support for the available protocols.

RepRapFirmware 1.18 and later enable only HTTP (or HTTPS if supported) protocol by default. If you wish to enable FTP and/or Telnet, enable them using this command once or twice in config.g.

M587: Store WiFi host network in list, or list stored networks

Parameters
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
915 Network SSID
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
916 Network password
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
917 (optional) IP address to use when connected to this network. If zero or not specified then an IP address will be acquired via DHCP.
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
918 (optional) Gateway IP address to use when connected to this network.
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
919 (optional) Netmask to use when connected to this network
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
920 (optional, supported only by DuetPi + DSF v3.3 or newer) DNS server to use
N123
88 (supported only by DuetPi + DSF v3.3 or newer) Country code for the WiFi adapter, only required if not set before

If a password or SSID includes space or semicolon characters then it must be enclosed in double quotation marks. For security, do not use this command in the config.g file, or if you do then remove it after running it once so that the network password is not visible in the file.

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
922 with no parameters lists all stored SSIDs, but not the stored passwords.

M588: Forget WiFi host network

Parameters
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
915 SSID to remove from the networks list

The specified SSID will be removed from the networks list and the associated password cleared out of EEPROM. If the SSID is given as * then all stored networks will be forgotten.

M589: Configure access point parameters

Parameters
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
915 The SSID that the WiFi interface should use when it is commanded to run as an access point
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
916 The WiFi password
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
917 The IP address to use

Note: WPA2 security will be used by default.

M590: Report current tool type and index

Report the current tool type, which may be "Extruder," "Picker," "Laser," "Foam Cutter," "Milling," or any others implemented by the machine. Also report the tool index, such as "0x01" for the second extruder.

Example
(Home some axes)
G28 (here come the axes to be homed) X Y
64

M591: Configure filament monitoring

This configures filament sensing for the specified extruder. The sensor may be a simple filament presence detector, or a device that measures movement of filament, or both. The action on detecting a filament error is firmware-dependent, but would typically be to run a macro and/or to pause the print and display a message.

ParametersCnn Which input the filament sensor is connected to. On Duet electronics: 0=X endstop input, 1=Y endstop input, 2=Z endstop input, 3=E0 endstop input etc.Dnn Extruder drive number (0, 1, 2...),Pnn Type of sensor: 0=none, 1=simple sensor (low signal when filament present), 2=simple sensor (high signal when filament present), 3=Duet3D rotating magnet sensor, 4=Duet3D rotating magnet sensor with microswitch, :Snn S0 = disable filament monitoring, S1 = enable filament monitoring. Calibration data may be collected while printing even when filament monitoring is disabled.

5=Duet3D laser filament monitor, 6=Duet3D laser filament monitor with microswitch, 7=pulse-generating sensor

Additional parameters for Duet3D laser filament monitorRaa:bb Allow the filament movement reported by the sensor to be between aa% and bb% of the commanded values; if it is outside these values and filament monitoring is enabled, the print will be pausedEnn minimum extrusion length before a commanded/measured comparison is done, default 3mmAdditional parameters for Duet3D rotating magnet filament monitorLnn Filament movement per complete rotation of the sense wheel, in mmR, E As for Duet3D laser filament monitorAdditional parameters for a pulse generating filament monitorLnn Filament movement per pulse in mmR, E As for Duet3D laser filament monitorExamplesM591 D0 C3 P5 S1 R70:130 L24.8 E6.0  ; Duet3D laser sensor for extruder drive 0 is connected to E0 endstop input, 24.8mm/rev, 70% to 130% tolerance, 6mm detection lengthM591 D1  ; display filament sensor parameters for extruder drive 1

Note: RepRapFirmware 1.19 and 1.20 also supported filament monitors via M591, but some of the parameters were different.

M592: Configure nonlinear extrusion

ParametersDnn Extruder drive number (0, 1, 2...)Annn A coefficient in the extrusion formula, default zeroBnnn B coefficient in the extrusion formula, default zeroLnnn Upper limit of the nonlinear extrusion compensation, default 0.2T nnn Reserved for future use, for the temperature at which these values are validExampleM592 D0 A0.01 B0.0005 ; set parameters for extruder drive 0M592 D0 ; report parameters for drive 0

Most extruder drives use toothed shafts to grip the filament and drive it through the hot end. As the extrusion speed increases, so does the back pressure from the hot end, and the increased back pressure causes the amount of filament extruded per step taken by the extruder stepper motor to reduce. This may be because at high back pressures, each tooth compresses and skates over the surface of the filament for longer before it manages to bite. See forum post http://forums.reprap.org/read.php?262,802277 and the graph at http://forums.reprap.org/file.php?262,file=100851,filename=graph.JPG for an example.

Nonlinear extrusion compensates for this effect. The amount of extrusion requested is multiplied by (1 + MIN(L, A*v + B*v^2)) where v is the requested extrusion speed (calculated from the actual speed at which the move will take place) in mm/sec.

Nonlinear extrusion is not applied to extruder-only movements such as retractions and filament loading.

M593: Configure Dynamic Acceleration Adjustment

ParametersFnnn Frequency of ringing to cancel in Hz. Zero or negative values disable the feature.ExampleM593 F40.5

This is an experimental feature of RepRapFirmware. By default, Dynamic Acceleration Adjustment (DAA) is disabled. If it is enabled, then acceleration and deceleration rates will be adjusted separately per-move to cancel out ringing at the specified frequency. Any acceleration values set using M204 will be saved but ignored until DAA is disabled, but acceleration limits set by M201 will still be honoured.

DAA is most useful to avoid exciting low-frequency ringing, for which S-curve acceleration is ineffective and may make the ringing worse. High-frequency ringing is better countered by using S-curve acceleration.

To measure the ringing frequency, take a print that exhibits ringing on the perimeters (for example a cube), preferably printed single-wall or external-perimeters-first. Divide the speed at which the outer perimeter was printed (in mm/sec) by the distance between adjacent ringing peaks (in mm), measured away from the corner so that the head has reached the full printing speed.

Cartesian and CoreXY printers will typically have different frequencies of ringing for the X and Y axes. In this case it is is usually best to aim to cancel the lower ringing frequency, because the higher frequency will be less strongly excited. If the frequencies are not much different, in a moving-bed cartesian printer you could reduce the higher ringing frequency by adding mass to that axis. Note that X axis ringing causes artefacts predominantly on the Y face of the test cube, and vice versa.

M594: Enter/Leave Height Following mode

ParametersPn P1 = enter height following mode, P0 = leave height following mode

Height following mode allows the Z position of the tool to be controlled by a PID controller using feedback from a sensor. See also M951.

If a movement command (e.g. G1) explicitly mentions the Z axis while height following mode is active, existing moves in the pipeline will be allowed to complete and the machine allowed to come to a standstill. Then height following mode will be terminated and the new move executed.

M595: Set movement queue length

ParametersPnn Maximum number of moves held in the movement queue. RepRapFirmware uses this value to determine how many DDA objects to allocate.Snn (optional) Number of pre-allocated per-motor movement objects. If the number of pre-allocated objects is insufficient, RepRapFirmware will attempt to allocate additional omnes dynamically when they are needed.

Different features of motion control firmware may have competing demands on microcontroller RAM. In particular, operations that use many short segments (e.g. laser rastering) need longer movement queues than typical 3D printing, but have fewer motors to control. This command allows the movement queue parameters to be adjusted so that the queue can be lengthened if necessary, or kept short if a long movement queue is not needed and there are other demands on RAM.

M595 without any parameters reports the length of the movement queue and the number of per-motor movement objects allocated.

M596: Select movement queue number

ParametersPnn Movement queue number. Queues are numbered 0 (the default queue), 1, ...

This command is supported in RepRapFirmware builds that can execute moves on different axis systems asynchronously, for example for concurrent printing of two or more different objects. It specifies that subsequent GCode commands from this input channel should be routed to the specified movement queue and the tool associated with that queue.

The number of available queues is firmware-dependent but will typically be 2. Before using a movement queue other than queue 0 it may be necessary to use M595 to increase the length of that queue, because the default length of movement queues other than the primary one may be quite short.

At the start of a file print, queue 0 is selected automatically.

If M596 is used without the P parameter, it reports the current motion system number for the input channel that the command was received on.

M597: Collision avoidance

ParametersX,Y...aaa First axis identifier and valueU,V...bbb Second axis identifier and valueExampleM597 V0 Y23.5

This configuration command is intended for use in systems having multiple tool heads that can be moved independently and asynchronously. The axis letters must be different from each other, so must the values of aaa and bbb. Normally, aaa will be zero and bbb will be positive. The command specifies that the machine position of the axis with the higher value must always be at least the difference in values greater than the position of the other axis. In the above example, the position of the Y axis must always be at least 23.5mm greater than the position of the V axis.

When Y and V are driven by independent motion systems and executing moves independently, in any block of GCode between synchronisation points, using this example the minimum of all Y coordinates inside the block (including the initial Y coordinate) must be at least 23.5mm greater than the maximum of the all V coordinates inside the block. If this is not the case, the job will be aborted prior to starting the first move that would cause the conflict.

M600: Set line cross section

Example
(Home some axes)
G28 (here come the axes to be homed) X Y
65

Sets the cross section for a line to extrude in velocity extrusion mode. When the extruder is enabled and movement is executed the amount of extruded filament will be calculated to match the specified line cross section.

M600: Filament change pause

Pause for filament change.

Parameters
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
927
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
928
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
929
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
930
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
931
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
932 Automatically (only Prusa Firmware with MMU connected)1
G0 X12               ; move to 12mm on the X axis
G0 F1500             ; Set the feedrate to 1500mm/min
G1 X90.6 Y13.8 E22.4 ; Move to 90.6mm on the X axis and 13.8mm on the Y axis while extruding 22.4mm of material
37 (no return) Don't return to the previous position after filament changeExample
(Home some axes)
G28 (here come the axes to be homed) X Y
66

In SmoothieWare:

The variable "after_suspend_gcode" is run after

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
566.

For example:

after_suspend_gcode G91_G0E-5_G0Z10_G90_G0X-50Y-50 # gcode to run after suspend, retract then get head out of way

In RepRapFirmware,

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
566 causes macro file filament-change.g to be run if it exists, otherwise it falls back to pause.g. The parameters in the
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
566 command are ignored.

Notes

In Prusa Firmware this command is also used when the Filament Runout Sensor triggers. To prevent filament blobs it will raise to 25 mm if it has been triggered below 25 mm layer height. Default are X=211 mm, Y=0 mm, Z=2 mm, E=-2 mm, L=-80 mm1

M601: Pause print

Pauses print on Prusa i3 MK2/s,MK2.5/s,MK3/s.

M602: Resume print

Resumes print on Prusa i3 MK2/s,MK2.5/s,MK3/s.

M603: Stop print (Prusa i3)

Stop print on Prusa i3 MK2/s, MK2.5/s, and MK3/s.

M603: Configure Filament Change

This command configures Filament Change behavior in Marlin Firmware and in Prusa mini firmware under development.

Parameters
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
937 Select extruder to configure, active extruder if not specified (not used yet)
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
938 Retract distance for removal, for the specified extruder.
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
939 Extrude distance for insertion, for the specified extruder.

M605: Set dual x-carriage movement mode

Set Dual X-Carriage movement mode.

Parameters
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
940 Mode (see below)
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
941 Optional X offset for Mode 2
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
942 Optional temperature difference for Mode 2Example
(Home some axes)
G28 (here come the axes to be homed) X Y
67

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
943: Full control mode. The slicer has full control over x-carriage movement
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
944: Auto-park mode. The inactive head will auto park/unpark without slicer involvement
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
945: Duplication mode. The second extruder will duplicate the first with nnn millimeters x-offset and an optional differential hotend temperature of
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
946 degrees. E.g., with "
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
947" the second extruder will duplicate the first with a spacing of 100mm in the x direction and 2 degrees hotter.

RepRapFirmware does not implement M605 because it supports dual carriage mode, duplication mode, auto park, different temperatures etc. using the

N123 [...G Code in here...] *71
05 tool definition command and the tool change macro files.

M650: Set peel move parameters

This command is sent by nanoDLP to set the parameters for the peel move used after curing a layer. RepRapFirmware 2.02 ignores it. If using RepRapFirmware 2.03 or later you can create a empty file M650.g to cause it to be ignored.

M651: Execute peel move

This command is sent by nanoDLP to execute a peel move after curing a layer. RepRapFirmware 2.02 executes macro /sys/peel-move.g in response to this command. For RepRapFirmware 2.03 and later, create a macro file M651.g containing the commands required to execute the peel move.

M665: Set delta configuration

Parameters
N123
92 Diagonal rod length
N123
61 Delta radius
N123
62 Segments per second1
N123
87 Safe probing radius2,3
N123
56 Delta height defined as nozzle height above the bed when homed after allowing for endstop corrections 2
N123
51 X tower position correction2,4
N123
52 Y tower position correction2,4
N123
53 Z tower position correction2,4
N123
86 X tower diagonal rod trim.1 (Marlin 2.0.6+)
N123
87 Y tower diagonal rod trim.1 (Marlin 2.0.6+)
N123
88 Z tower diagonal rod trim.1 (Marlin 2.0.6+)Examples
(Home some axes)
G28 (here come the axes to be homed) X Y
68

Set the delta calibration variables. (See the discussion page for notes on this implementation.)

Notes

1Only supported on Marlin.

2Only supported in RepRapFirmware and Marlin 1.1.0.

3 In Marlin 1.1.0 sets the radius on which the probe points are taken for the delta auto calibration routine G33 as well as for the manual LCD calibration menu.

4X, Y and Z tower angular offsets from the ideal (i.e. equilateral triangle) positions, in degrees, measured anti-clockwise looking down on the printer. In Marlin 1.1.0 X,Y and Z tower angular offsets will be rotated so the Z tower angular offset is zero.

M666: Set delta endstop adjustment

Parameters
N123
51 X axis endstop adjustment
N123
52 Y axis endstop adjustment
N123
53 Z axis endstop adjustment
N123
86 X bed tilt in percent1
N123
87 Y bed tilt in percent1Example
(Home some axes)
G28 (here come the axes to be homed) X Y
69

Sets delta endstops adjustments.

In RepRapFirmware and Repetier, positive endstop adjustments move the head closer to the bed when it is near the corresponding tower. In Marlin and Smoothieware, negative endstop corrections move the head closer to the bed when it is near the corresponding tower.

In Marlin, only negative endstop corrections are allowed. From version 1.1.0 onward positive endstops are allowed to be entered but the endstops will be normalized to zero or negative and the residue will be subtracted from the delta height defined in M665.

In Repetier the endstop corrections are expressed in motor steps. In other firmwares they are expressed in mm.

1RepRapFirmware 1.16 and later.

M667: Select CoreXY mode

Parameters
N123
62 CoreXY mode
N123
51 X axis scale factor (RepRapFirmware 2.02 and earlier)
N123
52 Y axis scale factor (RepRapFirmware 2.02 and earlier)
N123
53 Z axis scale factor (RepRapFirmware 2.02 and earlier)Example
(Home some axes)
G28 (here come the axes to be homed) X Y
70

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
969 selects Cartesian mode (unless the printer is configured as a delta using the
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
970 command). Forward motion of the X motor moves the head in the +X direction. Similarly for the Y motor and Y axis, and the Z motor and Z axis. This is the default state of the firmware on power up.

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
971 selects CoreXY mode. Forward movement of the X motor moves the head in the +X and +Y directions. Forward movement of the Y motor moves the head in the -X and +Y directions.

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
972 selects CoreXZ mode. Forward movement of the X motor moves the head in the +X and +Z directions. Forward movement of the Z motor moves the head in the -X and +Z directions.

RepRapFirmware 2.03 and earlier support additional parameters X, Y and Z may be given to specify factors to scale the motor movements by for the corresponding axes. For example, to specify a CoreXZ machine in which the Z axis moves 1/3 of the distance of the X axis for the same motor movement, use M667 S2 Z3. The default scaling factor after power up is 1.0 for all axes. In RepRapFirmware 2.03 and later, this functionality is moved to the movement matrix that you can define or alter using the M669 command.

To change the motor directions, see the M569 command.

M668: Set Z-offset compensations polynomial

Polynomial compensation is an experimental method to compensate for geometric distortion of a delta machine Z-plane. After the bed is compensated with the set of G30 points, there remains error. This method fits a 6th degree polynomial with independent origins for each order to the residual error data (using a simulated annealing technique on the host). The polynomial is communicated and controlled through

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
973. Because the polynomial takes many floating point operations to compute each point, the firmware builds a grid of values, and used bi-linear interpolation to adjust the actual Z-axis offset error estimate.

For the polynomial used, 40 parameters are specified. The

N123 [...G Code in here...] *71
46 parameter allows the coefficients to be loaded a few at a time, which limits the size of the G-code string. The index starts with 1, not with 0.

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
975 sets the polynomial parameters starting at index x, if index present and != 0.

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
976 recomputes the grid based on the current parameters.

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
977 turns off or on the polynomial compensation.

Typical usage
(Home some axes)
G28 (here come the axes to be homed) X Y
71

Which sets the list, computes the interpolation grid, and then enables compensation.

M669: Set kinematics type and kinematics parameters

ParametersKnnn Kinematics type: 0 = Cartesian, 1 = CoreXY, 2 = CoreXZ, 3 = linear delta, 4 = serial SCARA, 5 = CoreXYU, 6 = Hangprinter, 7 = polar, 8 = CoreXYUV, 9 = linear delta + Z axis, 10 = rotary delta, 11 = MarkForged, 12 = reserved for Collinear Tripteron

Selects the specified kinematics, then uses the other parameters to configure it. If the K parameter is missing then the other parameters are used to update the configuration data for the current kinematics. If no parameters are given then the current kinematics and configuration parameters are reported

Parameters for generalised Cartesian kinematics (including CoreXY, CoreXZ, MarkForged, CoreXYU etc.)Xnnn, Ynnn, Znnn, Unnn etc. (optional) Movement matrix coefficients. For example.
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
978 tells the firmware that to move the X axis one unit, the first motor must be moved 1 unit in the forwards direction, the second motor 1 unit in the reverse direction, and the third motor not at all. Using these coefficients, you can specify the kinematics equations for any printer with up to 10 axes for which the movement of each axis is a linear combination of the movements of the individual motors. If these parameters are omitted, the defaults for the specified kinematics (K parameter) will be used.Parameters for serial SCARA kinematicsPnnn Proximal arm length (mm)Dnnn Distal arm length (mm)Annn:nnn Proximal arm joint movement minimum and maximum angles, in degrees anticlockwise seen from above relative to the X axisBnnn:nnn Proximal-to-distal arm joint movement minimum and maximum angles, in degrees anticlockwise seen from above relative to both arms in lineCnnn:nnn:nnn Crosstalk factors. The first component is the proximal motor steps to equivalent distal steps factor, the second is the proximal motor steps to equivalent Z motor steps factor, and the third component is the distal motor steps to equivalent Z motor steps factor.Snnn Segments per second if smooth XY motion is approximated by means of segmentationTnnn Minimum segment length (mm) if smooth XY motion is approximated by means of segmentationXnnn X offset of bed origin from proximal jointYnnn Y offset of bed origin from proximal jointExamples
(Home some axes)
G28 (here come the axes to be homed) X Y
72

The minimum and maximum arm angles are also the arm angles assumed by the firmware when the homing switches are triggered. The P, D, A and B parameters are mandatory. The C and F parameters default to zero, and the segmentation parameters default to firmware-dependent values.

Parameters for Polar kinematicsRaaa:bbb Minimum and maximum radius in mm. If only one value it given it will be used as the maximum radius, and the minimum radius will be assumed to be zero.
Hnnn Radius in mm at which the homing switch is triggered during a homing move. If this parameter is not present, the homing switch is assumed to trigger at the minimum radius.
Fnnn Maximum turntable speed in degrees per secondAnnn Maximum turntable acceleration in degrees per second per secondSnnn, Tnnn As for serial SCARA kinematics

M670: Set IO port bit mapping

ParametersPnn:nn:nn... List of logical port numbers that bits 0, 1, 2... controlTnnn port switching time advance in milliseconds

RepRapFirmware 1.19 and later provides an optional P parameter on the G1 command to allow I/O ports to be set to specified states for the duration of the move. The argument to the P parameter is a bitmap giving the required state of each port. The M669 command specifies the mapping between the bits of that argument and logical port numbers. Optionally, the T parameter can be used to advance the I/O port switching a short time before the corresponding move begins.

M671: Define positions of Z leadscrews or bed leveling screws

ParametersXnn:nn:nn... List of between 2 and 4 X coordinates of the leadscrews that drive the Z axis or the bed leveling screwsYnn:nn:nn... List of between 2 and 4 Y coordinates of the leadscrews that drive the Z axis or the bed leveling screwsSnn Maximum correction to apply to each leadscrew in mm (optional, default 1.0)Pnnn Pitch of the bed leveling screws (not used when bed leveling using independently-driven leadscrews). Defaults to 0.5mm which is correct for M3 bed leveling screws.ExampleM671 X-15.0:100.0:215.0 Y220.0:-20.0:220.0  ; Z leadscrews are at (-15,220), (100,-20) and (215,220)

Informs the firmware of the positions of the leadscrews used to raise/lower the bed or gantry. The numbers of X and Y coordinates must both be equal to the number of drivers used for the Z axis (see the M584 command). This allows the firmware to perform bed leveling by adjusting the leadscrew motors individually after bed probing.

For machines without multiple independently-driven Z leadscrews, this command can be used to define the positions of the bed leveling screws instead. Then bed probing can be used to calculate and display the adjustment required to each screw to level the bed. The thread pitch (P parameter) is used to translate the height adjustment needed to the number of turns of the leveling screws.

M672: Program Z probe

ParametersSnn:nn:nn... Sequence of 8-bit unsigned values to send to the currently-selected Z probeExampleM671 S50:205

This command is for sending configuration data to programmable Z probes such as the Duet3D delta effector. The specified command bytes are sent to the probe. The Duet3D probe stores the configuration data in non-volatile memory, so there is no need to send this command every time the probe is used.

M673: Align plane on rotary axis

ParametersU,V,W,A,B,C Rotary axis letter on which the plane is mountedPnnn Factor to multiply the correction angle (degrees) with (defaults to 1)ExampleM673 A

This code is intended to align a plane that is mounted on a rotary axis. To make use of this code it is required to take two probe points via G30 P first. Supported in RepRapFirmware 2.02 and later.

M674: Set Z to center point

This code is intended to determine the Z center point of a stash that is mounted on a rotary axis. This code is yet to be implemented.

M675: Find center of cavity

ParametersX,Y,Z Axis to probe onFnnnn Probing feedrateRnnn Distance to move away from the lower endstop before the next probing move startsExampleM675 X R2 F1200

This code is intended to find the center of a cavity that can be measured using the configured axis endstop. If using a Z probe for this purpose, make sure the endstop type for the corresponding axis is updated before this code is run. Once this code starts, RepRapFirmware will move to the lower end looking for an endstop to be triggered. Once it is triggered, the lower position is saved and the axis maximum is probed. As soon as both triggers have been hit, the center point is calculated and the machine moves to the calculated point.

M700: Level plate

Example
(Home some axes)
G28 (here come the axes to be homed) X Y
73

Script to adjust the plate level.

M701: Load filament

Initiate a filament load. This command can be used without any additional parameters.

Parameters
G0 X12               ; move to 12mm on the X axis
G0 F1500             ; Set the feedrate to 1500mm/min
G1 X90.6 Y13.8 E22.4 ; Move to 90.6mm on the X axis and 13.8mm on the Y axis while extruding 22.4mm of material
20 Filament to load (RepRapFirmware)
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
136 Tool to load (Marlin)
G1 F1500                 ; Feedrate 1500mm/min
G1 X50 Y25.3 E22.4 F3000 ; Accelerate to 3000mm/min
26 Length to use for load (Marlin)
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
521 Z raise to perform (Marlin)With no parameters
  • RepRapFirmware will report the name of the loaded filament (if any).
  • Marlin Firmware initiates a Filament Load.
Examples
(Home some axes)
G28 (here come the axes to be homed) X Y
74

RepRapFirmware 1.19 and later implement a filament management mechanism to load and unload different materials. This code may be used to load a material for the active tool, however be aware that this code will work only for tools that have exactly one extruder assigned. When called RepRapFirmware will...

  1. Run the macro file "load.g" in the subdirectory of the given material (e.g. /filaments/PLA/load.g)
  2. Change the filament name of the associated tool, so it can be reported back to Duet Web Control

M702: Unload filament

Initiate a filament unload. This command can be used without any additional parameters. In contrast to

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
983 this code is intended to unload the previously loaded filament from the selected tool.

Parameters
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
188 Unload the (current) filament only if the MMU is used (Prusa Firmware)
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
136 Tool to load (Marlin)
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
986 Length to use for unload (Marlin)
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
521 Z raise to perform (Marlin)

In response to

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
988 RepRapFirmware will do the following:

  1. Run the macro file "unload.g" in the subdirectory of the given material (e.g.
    G92 E0
    G28
    G1 F1500
    G1 X2.0 Y2.0 F3000
    G1 X3.0 Y3.0
    
    989)
  2. Change the filament name of the current tool, so it can be reported back to Duet Web Control
Examples
(Home some axes)
G28 (here come the axes to be homed) X Y
75

M703: Configure Filament

  1. In RepRapFirmware this code is used to apply the configuration of a previously loaded filament (see M701). All it does is run
    G92 E0
    G28
    G1 F1500
    G1 X2.0 Y2.0 F3000
    G1 X3.0 Y3.0
    
    990 which may contain codes to set parameters like extrusion factor, retraction distances and temperatures. If no filament is assigned to the current tool, this code will not generate a warning.

If the filaments feature is used, it is recommended to put this code into

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
991 to ensure the right filament parameters are set. Supported in RepRapFirmware 2.02 and newer.

This gcode is in development by Prusa Research related to Filament and MMU settings/operations and will be updated as soon as possible.

This gcode is in development by Prusa Research related to Filament and MMU settings/operations and will be updated as soon as possible.

This gcode is in development by Prusa Research related to Filament and MMU settings/operations and will be updated as soon as possible.

This gcode is in development by Prusa Research related to Filament and MMU settings/operations and will be updated as soon as possible.

This gcode is in development by Prusa Research related to Filament and MMU settings/operations and will be updated as soon as possible.

This gcode is in development by Prusa Research related to Filament and MMU settings/operations and will be updated as soon as possible.

M710: Firmware dependent

M710: Controller Fan settings
ParametersWith no parameters, report current settings.
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
992 Turn Auto Mode on or off.
N123
62 Set the Active Speed (0-255) used when motors are enabled.
N123
78 Set the Idle Speed (0-255) used when motors are disabled.
G1 F1500                 ; Feedrate 1500mm/min
G1 X50 Y25.3 E22.4 F3000 ; Accelerate to 3000mm/min
96 Set the Idle Duration (seconds) to keep the fan running after motors are disabled.
N123
89 Reset to defaults.Example
(Home some axes)
G28 (here come the axes to be homed) X Y
76
M710: Erase the EEPROM and reset the board

This command only exists in a defunct bq fork of Marlin Firmware.

Example
(Home some axes)
G28 (here come the axes to be homed) X Y
77

M750: Enable 3D scanner extension

Example
(Home some axes)
G28 (here come the axes to be homed) X Y
78

This code may be used as an OEM extension to enable scanner functionality in the firmware. After a regular start of RepRapFirmware, the 3D scan extension is disabled by default, but if additional scanner components are attached, this code may be used to enable certain OEM functions.

M751: Register 3D scanner extension over USB

Example
(Home some axes)
G28 (here come the axes to be homed) X Y
79

When a 3D scanner board is attached to the USB port, this code is used to turn on communication between the 3D printing and the scanner board. If the USB connection is removed while the 3D scanner configuration is active, the firmware will disable it again and restore the default communication parameters.

M752: Start 3D scan

Parameters
N123
62: Length/degrees of the scan
N123
61: Resolution (new in RRF 2.0) [optional, defaults to 100]
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
062: Scanner mode (new in RRF 2.0) [optional, 0=Linear (default), 1=Rotary]
N123
83: Filename for the scanExample
(Home some axes)
G28 (here come the axes to be homed) X Y
80

Instruct the attached 3D scanner to initiate a new 3D scan and to upload it to the board's SD card (i.e. in the "scans" directory). Before the SCAN command is sent to the scanner, the macro file "scan_pre.g" is executed and when the scan has finished, the macro file "scan_post.g" is run. Be aware that both files must exist to avoid error messages.

M753: Cancel current 3D scanner action

Example
(Home some axes)
G28 (here come the axes to be homed) X Y
81

Instruct the attached 3D scanner to cancel the current operation. Cancelling uploads is not supported.

M754: Calibrate 3D scanner

ParametersNnnn Calibration mode (0=linear [default], 1=rotary)Example
(Home some axes)
G28 (here come the axes to be homed) X Y
82

Calibrates the attached 3D scanner. Before the calibration is performed by the external scanner, "calibrate_pre.g" is run and when it is complete, "calibrate_post.g" is executed.

M755: Set alignment mode for 3D scanner

Parameters
N123
83 Whether to turn on (> 0) or off (<= 0) the alignment featureExamples
(Home some axes)
G28 (here come the axes to be homed) X Y
83

Sends the ALIGN ON/OFF command the attached 3D scanner. Some devices turn on a laser when this command is received. If the 'P' parameter is missing, equal to, or less than 0, the alignment feature is turned off. Depending on whether the alignment is turned on or off, either align_on.g or align_off.g is executed before the ALIGN command is sent to the scanner.

M756: Shutdown 3D scanner

Example
(Home some axes)
G28 (here come the axes to be homed) X Y
84

Sends the SHUTDOWN command the attached 3D scanner.

M800: Fire start print procedure

1 only in bq-Marlin Firmware

Example
(Home some axes)
G28 (here come the axes to be homed) X Y
85

M801: Fire end print procedure

1 only in bq-Marlin Firmware

Example
(Home some axes)
G28 (here come the axes to be homed) X Y
86

M808: Set or Goto Repeat Marker

The

N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
002 command is used in a G-code file to set a Repeat Marker beginning at the start of the following line. For an SD print, the firmware will save a marker with the file's byte position and the count given by the
N123 [...G Code in here...] *71
93 parameter. To set an infinite loop use
int cs = 0;
for(i = 0; cmd[i] != '*' && cmd[i] != NULL; i++)
   cs = cs ^ cmd[i];
cs &= 0xff;  // Defensive programming...
89. To terminate an infinite loop from the host,
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
005 will cancel all current loops.

The

N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
006 command (no parameters) will cause G-code processing to loop back to the previous Repeat Marker as many times as specified. Ideally, each instance of
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
007 should have a corresponding
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
006.

The number of nested

N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
007 commands is limited to the depth set in the firmware. To enable this feature in Marlin, define
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
010. Hosts should look for
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
011. At this time the feature only applies to printing direct from media and otherwise
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
006 is ignored, so host developers are free to come up with their own approach to these codes with no nesting limit and make it work with any old firmware.

Example
(Home some axes)
G28 (here come the axes to be homed) X Y
87

RepRapFirmware processes M808 as follows:

- M808 S{ccc} translates into while ccc followed by block begin. ccc must yield true or false. For more on while-loops and expressions in RepRapFirmware, see https://duet3d.dozuki.com/Wiki/GCode_Meta_Commands.- M808 Lnn is equivalent to M808 S{nn == 0 || iterations < nn}.- M808 without S or L parameter ends the block.- As usual, predefined constant iterations reports the number of completed iterations of the innermost loop.- M808 without S or L parameter when not inside a loop, or any M808 command in an input stream other than a SD print file, gives rise to an error message.
M808 in Marlin 2.0.8
(Home some axes)
G28 (here come the axes to be homed) X Y
88

M810-M819: G-code macros stored in memory or flash not filename

Use the M810-M819 commands to set and execute 10 distinct G-code “macros.” Put anything after the command to define its macro. To run the macro just send M810-M819 by itself. Multiple commands in one macro are separated by the pipe character (‘|’).1 only in bq-Marlin Firmware. to run macro type M810-M819 with no comments.


Define Macro to do some moves and make a beep We use M815 but M810-M19 can be used.

Example

N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
013

To run macro

N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
014

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

N123
38. This value may also be used by
N123 [...G Code in here...] *71
74 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).

This setting is saved in the EEPROM by M500 and restored by

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
311. The default (as reset by
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
018) is set by the
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
019 setting in Configuration.h.

Note that in Marlin 1.1.0 and later

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
369 sets the value literally as given, while Marlin 1.0.2 negates the absolute value.

The examples below will set the Z-probe Z offset to -4 mm (below the nozzle):

M851 in Marlin 1.0.2
(Home some axes)
G28 (here come the axes to be homed) X Y
89
M851 in Marlin 1.1.0
(Home some axes)
G28 (here come the axes to be homed) X Y
90
M851 in Marlin 2.0.0
(Home some axes)
G28 (here come the axes to be homed) X Y
91
M851 in MK4duo 4.3.25
(Home some axes)
G28 (here come the axes to be homed) X Y
92
M851 in RepRapFirmware 2.02 and later

M851 Znn is implemented for backwards compatibility with other firmwares. It sets the Z probe trigger in the same way as G31 Z-nn (note the sign reversal). It also flags the Z-probe G31 parameters as to be saved in config-override.g if the M500 command is used.

M860 Wait for Probe Temperature

Parameters
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
821 Target temperatureNotes

In Prusa Firmware this command will wait for the PINDA thermistor to reach a target temperature.

M861 Set Probe Thermal Compensation

Parameters
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
022 Print current EEPROM offset values
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
023 Set factory default values
N123 [...G Code in here...] *71
04 Set all values to 0 (effectively disabling PINDA temperature compensation)
N123 [...G Code in here...] *71
00 Microsteps
N123 [...G Code in here...] *71
46 Table indexExample
(Home some axes)
G28 (here come the axes to be homed) X Y
93

Results

(Home some axes)
G28 (here come the axes to be homed) X Y
94Notes

In Prusa Firmware this command will set / read the PINDA temperature compensation offsets.

M862: Print checking

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

M862.1: Check nozzle diameter
Parameters
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
027 nnnn = Nozzle diameter 0.25 /0.40 /0.60
G1 F1500                 ; Feedrate 1500mm/min
G1 X50 Y25.3 E22.4 F3000 ; Accelerate to 3000mm/min
31 Current nozzle diameter

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

Example messages
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
029 Printer nozzle diameter differs from the G-code. Continue?
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
030 Printer nozzle diameter differs from the G-code. Please check the value in settings. Print cancelled.
M862.2: Check model code
Parameters
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
027 nnnn = Prusa model
G1 F1500                 ; Feedrate 1500mm/min
G1 X50 Y25.3 E22.4 F3000 ; Accelerate to 3000mm/min
31 Current model

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

Accepted printer type identifiers and their numeric counterparts:

(Home some axes)
G28 (here come the axes to be homed) X Y
95Example messages
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
029 G-code sliced for a different printer type. Continue?
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
030 G-code sliced for a different printer type. Please re-slice the model again. Print cancelled.
M862.3: Model name
Parameters
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
035 nnnn = Prusa model name
G1 F1500                 ; Feedrate 1500mm/min
G1 X50 Y25.3 E22.4 F3000 ; Accelerate to 3000mm/min
31 Current model name

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

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

N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
037Example messages
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
029 G-code sliced for a different printer type. Continue?
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
030 G-code sliced for a different printer type. Please re-slice the model again. Print cancelled.
M862.4: Firmware version
Parameters
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
027 nnnn = Prusa firmware version
G1 F1500                 ; Feedrate 1500mm/min
G1 X50 Y25.3 E22.4 F3000 ; Accelerate to 3000mm/min
31 Current firmware version

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

Example messages
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
029 G-code sliced for a newer firmware. Continue?
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
030 G-code sliced for a newer firmware. Please update the firmware. Print cancelled.
M862.5: Gcode level
Parameters
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
027 nnnn = Gcode level
G1 F1500                 ; Feedrate 1500mm/min
G1 X50 Y25.3 E22.4 F3000 ; Accelerate to 3000mm/min
31 Current Gcode level

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

Example messages
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
029 G-code sliced for a different level. Continue?
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
030 G-code sliced for a different level. Please re-slice the model again. Print cancelled.

M871: PTC Configuration

N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
048 allows you to modify the Z adjustments corresponding to temperatures.

Parameters
N123 [...G Code in here...] *71
67 Set the Z adjustment for bed temperature
N123 [...G Code in here...] *71
10 Set the Z adjustment for probe temperature
N123
67 Set the Z adjustment for extruder temperatureExamples
(Home some axes)
G28 (here come the axes to be homed) X Y
96

M876: Dialog handling

Parameters
N123
83 signal support for dialog creation on the host = 1, disable = 0
N123
62 select dialog option nnn (0 based)Example
(Home some axes)
G28 (here come the axes to be homed) X Y
97

N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
054 allows selecting an option of a prompt on a connected host created by the firmware through the corresponding action commands, see G-code#Action_commands. The S parameter is the 0-based index of the chosen option - 0 for the first option provided by the firmware, 1 for the second and so on.

Example: A prompt with three options defined via the firmware and completed by the host by selecting the second option ("Home X/Y and pause print")

(Home some axes)
G28 (here come the axes to be homed) X Y
98

To indicate the availability of this function,

G1 F1500           ; Set feedrate to 1500mm/min
G1 X50 Y25.3 E22.4 ; Move and extrude
84 will add an extra line:

(Home some axes)
G28 (here come the axes to be homed) X Y
99

so hosts know about the presence of the function.

M890 Run User Gcode

Parameters
N123
62 select 1 - 5 User Gcode defined in configuration.Example
N123
00

M900 Set Linear Advance Scaling Factors

Sets the advance extrusion factors for Linear Advance. If any of the

N123
89,
N123 [...G Code in here...] *71
68,
N123
68, or
N123 [...G Code in here...] *71
86 parameters are set to zero the ratio will be computed dynamically during printing.

Parameters
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
061 Advance K factor
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
062 Set ratio directly (overrides WH/D)
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
063
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
064
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
065 Set ratio from WH/DExamples
N123
01

Requires enabling the

N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
066 feature in Marlin 1.1.

The K factor in the M900 command supported by early versions of Marlin is related to the S factor in the long-established M572 command supported by RepRapFirmware by the following formula:

N123
02

More recent versions of Marlin appear to have removed the steps/mm dependency, so now K = S.

M905: Set local date and time

Parameters
N123
83 Current date in the format YYYY-MM-DD
N123
62 Current time in the format HH:MM:SSExample
N123
03

Updates the machine's local date and time or reports them if no parameters are specified. The time should be specified in 24-hours format as in "13:45" instead of 1:45PM.

M906: Set motor currents

Parameters
N123
51 X drive motor current
N123
52 Y drive motor current
N123
53 Z drive motor current
N123
54 E drive(s) motor current(s)
N123
78 Motor idle current in percent (0..100)Example
N123
04

Sets the currents to send to the stepper motors for each axis. The values are the peak current per phase in milliamps.

The

N123 [...G Code in here...] *71
46 parameter is the percentage of normal that the motor currents should be reduced to when the printer becomes idle but the motors have not been switched off. The default value is 30%. On delta printers in particular you may need to increase it to e.g. 60% to prevent the carriages from dropping when the current is reduced to the idle value.

M907: Set digital trimpot motor

Set digital trimpot motor current using axis codes (

N123 [...G Code in here...] *71
42,
N123 [...G Code in here...] *71
43,
N123 [...G Code in here...] *71
04,
N123
67,
N123 [...G Code in here...] *71
67,
N123 [...G Code in here...] *71
00). In Repetier, it sets the current in Percent. In Redeem, it sets the current in Amps (whereas
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
647 uses milliamps).

M908: Control digital trimpot directly

M908 PS

Notes

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

M909: Set microstepping

Example
N123
05

Set the microstepping value for each of the steppers. In Redeem this is implemented as powers of 2 so…

N123
06

M910: Set decay mode

Example
N123
07

Set the decay mode for each stepper controller The decay mode controls how the current is reduced and recycled by the H-bridge in the stepper motor controller. It varies how the implementations are done in silicone between controllers. Typically you have an on phase where the current flows in the target current, then an off phase where the current is reversed and then a slow decay phase where the current is recycled.

M910: TMC2130 init

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

M911: Configure auto save on loss of power ("power panic")

Parameters
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
082 Auto save threshold in volts. The print will be stopped automatically and resume parameters saved if the voltage falls below this value. Set to around 1V to 2V lower than the voltage that appears at the Duet VIN terminals at full load. A negative or zero value disables auto save.
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
083 Resume threshold in volts. Must be greater than the auto save voltage. Set to a high value to disable auto resume.
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
084 G-Code commands to run when the print is stopped.ExampleM911 S19.8 R22.0 P"M913 X0 Y0 G91 M83 G1 Z3 E-5 F1000"

When the supply voltage falls below the auto save threshold while a print from SD card is in progress, all heaters will be turned off, printing will be stopped immediately (probably in the middle of a move), the position saved, and the specified command string executed. You should typically do the following in the command string:

  • If possible, use M913 to reduce the motor current in order to conserve power. For example, on most printers except deltas you can probably set the X and Y motor currents to zero.
  • Retract a little filament and raise the head a little. Ideally the retraction should happen first, but depending on the power reserve when low voltage is detected, it may be best to do both simultaneously.

M911 with no parameters displays the current enable/disable state, and the threshold voltages if enabled.

Note: RepRapFirmware 1.19 used different parameters. You are recommended to upgrade to version 1.20 or later if you wish to use this "power panic" functionality.

M911: Set TMC2130 holding currents

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

M912: Set electronics temperature monitor adjustment

Parameters
N123
83 Temperature monitor channel, default 0
N123
62 Value to be added to the temperature reading in degCExample
N123
08

Many microcontrollers used to control 3D printers have built-in temperature monitors, but they normally need to be calibrated for temperature reading offset. The

N123 [...G Code in here...] *71
00 parameter specifies the value that should be added to the raw temperature reading to provide a more accurate result.

M912: Set TMC2130 running currents

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

M913: Set motor percentage of normal current

Parameters
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
874 Percentage of normal current to use for the specified axis or extruder motor(s)Example
N123
09

This allows motor currents to be set to a specified percentage of their normal values as set by

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
647. It can be used (for example) to reduce motor current during course homing, to make homing quieter or to reduce the risk of damage to endstops, to reduce motor current when using sensorless endstops (motor stall detection), and to reduce current while loading filament to guard against the possibility of feeding too much filament. Use
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
090 again with the appropriate parameters set to 100 to restore the normal currents.

M913: Print TMC2130 currents

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

M914: Set/Get Expansion Voltage Level Translator

Parameters
N123 [...G Code in here...] *71
00 Expansion voltage signal level, must be 3 or 5Example
N123
10

M914: Set TMC2130 normal mode

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

M915: Configure motor stall detection

ParametersPnnn:nnn:... Drive number(s) to configureX,Y,Z,U,V,W,A,B,C Axes to configure (alternative to using the P parameter)Snnn Stall detection threshold (-64 to +63, values below -10 not recommended)Fn Stall detection filter mode, 1 = filtered (one reading per 4 full steps), 0 = unfiltered (default, 1 reading per full step)Hnnn (optional) Minimum motor full steps per second for stall detection to be considered reliable, default 200Tnnn (optional) Coolstep control register, 16-bit unsigned integerRn Action to take on detecting a stall from any of these drivers: 0 = no action (default), 1 = just log it, 2 = pause print, 3 = pause print, execute macro file /sys/rehome.g, and resume printExamplesM915 P0:2:3 S10 F1 R0M915 X Y S5 R2

This sets the stall detection parameters and optionally the low-load current reduction parameters for TMC2660, TMC2130 or similar driver chips. Use either the P parameter to specify which driver number(s) you want to configure, or the axis names of the axes that those motors drive (the parameters will then be applied to all the drivers associated with any of those axes).

If any of the S, F, T and R parameters are absent, the previous values for those parameters associated with the specified drivers will continue to be used. If all the parameters are absent, the existing settings for the specified drives will be reported.

See the Trinamic TMC2660 and TMC2130 datasheets for more information about the operation and limitations of motor stall detection.

M915: Set TMC2130 silent mode

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

M916: Resume print after power failure

ParametersnoneExampleM916

If the last print was not completed and resume information has been saved (either because the print was paused or because of a power failure), then the heater temperatures, tool selection, head position, mix ratio, mesh bed compensation height map etc. are restored from the saved values and printing is resumed.

RepRapFirmware also requires macro file /sys/resurrect-prologue.g to be present on the SD card before you can use M915. This file is executed after the heater temperatures have been set, but before waiting for them to reach the assigned temperatures. You should put commands in this file to home the printer as best as you can without disturbing the print on the bed. To wait for the heaters to reach operating temperature first, use command M116 at the start of the file.

M916: Set TMC2130 Stallguard sensitivity threshold

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

M917: Set motor standstill current reduction

ParametersX,Y,Z,E Percentage of normal current to use when the motor is standing still or moving slowly, default 100ExampleM917 X70 Y70 Z80 E70:70

Some motor drivers (e.g. TMC2660) allow higher motor currents to be used while the motor is moving than when it is at standstill. This command sets the percentage of the current set by M906 that is to be used when the motor is stationary but not idle, or moving very slowly.

Standstill current reduction is not the same as idle current reduction. The standstill current must be high enough to produce accurate motion at low speeds; whereas the idle current (set using the I parameter in the M906 command) needs only to be high enough to hold the motor position sufficiently so that when the current is restored to normal, the position is the same as it was before the current was reduced to idle.

M917: Set TMC2130 PWM amplitude offset (pwm_ampl)

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

M918: Configure direct-connect display

This command is used to tell RepRapFirmware about a directly-connected dumb LCD or similar display.

ParametersP Directly-connected display type: 0 = none (default), 1 = 128x64 pixel mono graphics display using ST7920 controller, 2 = 128x64 mono display using ST7567 controllerE The number of pulses generated by the rotary encoder per detent. Typical values are 2 and 4. Negative values (e.g. -2 and -4) reverse the encoder direction.F (optional, supported in RRF 2.03 and later) SPI clock frequency in Hz, default 2000000 (i.e. 2MHz)C (optional, supported in RRF 3.2 and later) Display contrast, in range 0 to 100. Only used with ST7567-based displays. ST7920-based displays usually have a contrast potentiometer instead.R (optional, supported in RRF 3.2 and later) Display resistor ratio, in range 1 to 7. Only used with ST7567-based displays. The default value of 6 is suitable for the Fysetc Mini 12864 display. Some other displays need 3.ExampleM918 P1 E2

M918: Set TMC2130 PWM amplitude gradient (pwm_grad)

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

M928: Start SD logging

Example
N123
11

Stop SD logging with

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
720.

M929: Start/stop event logging to SD card

ParametersP"filename" The name of the file to log to. Only used if the S1 parameter is used. A default filename will be used if this parameter is missing.Sn S1 = start logging, S0 = stop loggingExampleM929 P"eventlog.txt" S1  ; start logging to file eventlog.txtM929 S0  ; stop logging

When event logging is enabled, important events such as power up, start/finish printing, most error messages and (if possible) power down will be logged to the SD card. Each log entry is a single line of text, starting with the date and time if available, or the elapsed time since power up if not. If the log file already exists, new log entries will be appended to the existing file.

M950: Create heater, fan or GPIO/servo device

ParametersDn SD card slot number (RRF 3.4 on Duet 3 MB6HC only - the only value supported is 1)Enn LED strip number (RRF 3.5 and later)Fnn Fan numberHnn Heater numberJnn GP input numberPnn or Snn GPIO or Servo number (the only difference is the default PWM frequency)Rnn Spindle number *RRF 3.3 and later)C"name" Pin name(s) and optional inversion status. Pin name "nil" frees up the pin. A leading '!' character inverts the output. A leading '^' character enables the pullup resistor. The '^' and '!' characters may be placed in either order.Qnn (optional) For fans and heaters: PWM frequency in Hz. For LED strips: clock frequency in Hz.Tnn Temperature sensor number, required when creating a heater; or LED strip type when creating an LED portKaaa:bbb:ccc (optional, for spindles only, RRF 3.5 and later) Optional PWM values (0..1) for spindle control (max [aaa] - or - min, max [aaa:bbb] - or - min, max, idle [aaa:bbb:ccc])ExamplesM950 H1 C"out1" Q100 T1 ; create heater 1 using temperature sensor 1M950 H2 C"nil" ; disable heater 2 and free up the associated pinM950 H2 C"1.out0" T2 ; create heater 2 using pin out0 on expansion board 1 and temperature sensor 2M950 F3 C"heater2" Q100 ; Fan 3 is connected to heater 2 pin, PWM at 100HzM950 P0 C"exp.heater3" ; create GPIO port 0 attached to heater 3 pin on expansion connectorM950 F2 C"!fan2+^pb6" ; Fan 2 uses the Fan2 output, but we are using a PWM fan so the output needs to be inverted, also we are using PB6 as a tacho input with pullup resistor enabledM950 D1 C"spi.cs0+spi.cs2" ; on Duet 3 MB6HC support external SD card using pins spi.cs0 and spi.cs2 for the CS and Card Detect pins respectively

M950 is used to create heaters, fans, LED strip ports and GP in and out ports and to assign pins to them. Each M950 command assigns a pin or pins to a single device. So every M950 command must have exactly one of the D, E, F, H, J, P or S parameters.

If a M950 command has C and/or Q parameters, then the pin allocation and/or frequency of any existing device will be changed accordingly. Otherwise, the current configuration will be reported.

When using M950 to create a heater, you must first use M308 to define a temperature sensor to control that heater, and specify its number in the T parameter of the M950 command.

M951: Set height following mode parameters

ParametersSnn or Hnn Sensor numberPnn.n Proportional factor, in mm per sensor unitInn.n Integral factor, in mm per sensor unit per secondDnn.n Derivative factor, in mm per rate of change of sensor units (change in sensor unit per second)Fnn.n (optional) Sample and correction frequency (Hz), default 5HzZnn.n:nn.n Minimum and maximum permitted Z values

Height following mode allows the Z position of the tool to be controlled by a PID controller using feedback from a sensor. See also M594.

If commanding the motors to increase Z causes the sensor value to increase, then all of P, I and D must be positive. If commanding the motors to increase Z causes the sensor value to decrease, then all of P, I and D must be negative.

M952: Set CAN expansion board address and/or normal data rate

ParametersBn Existing CAN address of expansion board to be changed, 1 to 125.An New CAN address of that expansion board, 1 to 125.Sn.n Requested bit rate in Kbits/second (1K = 1000)T0.n Fraction of the bit time between the bit start and the sample point (optional)J0.n Maximum jump time as a fraction of the bit time (optional)ExampleM952 B120 A11  ; change the CAN address of expansion board 101 to 11M952 B11 S500  ; change the CAN bit rate or expansion board 11 to 500kbps

Some CAN-connected expansion boards are too small to carry address selection switches. Such boards default to a standard address, which can be changed using this command.

This command can also be used to change the normal data rate, for example if the printer has CAN bus cables that are too long to support the standard data rate (1Mbits/sec in RepRapFirmware). All boards in the system on the same CAN bus must use the same CAN data rate. The procedure for changing the data rate is:

  • Use M952 to change the data rate on all the expansion boards, one at a time. After changing the data rate on each expansion board, you will no longer be able to communicate with it, and you may need to power it down or disconnect it from the CAN bus to prevent it interfering with subsequent CAN communications.
  • Change the data rate of the main board last. Then the main board should be able to communicate with all the expansion boards again.

M953: Set CAN-FD bus fast data rate

ParametersSn.n Requested bit rate in Kbits/second (1K = 1000). Ignored if it is lower than the bit rate for the negotiation phase.T0.n Fraction of the bit time between the bit start and the sample point (optional)J0.n Maximum jump time as a fraction of the bit time (optional)Caa:bb Transceiver delay compensation offset and minimum, in nanoseconds (optional)ExampleM953 S4000 T0.6 J0.2

This command allows the bandwidth of the CAN bus to be optimised, by increasing the data rate during transmission of CAN-FD data packets using the BRS (bit rate switch) feature. The maximum speed supported by CAN-FD is 8Mbits/sec but the practical limit depends on the cable length, cable quality, number of devices on the bus and CAN interface hardware used. The rate specified will be rounded down to the nearest achievable rate.

The optional C parameter allows fine-tuning of the transmitter delay compensation. The first parameter is the offset added to the measured transmitter delay. The optional second value, which must be greater than the first, is the minimum delay compensation applied. Glitches seen by the receiver while the transceiver delay is being measured will be ignored if they would result in a transceiver delay compensation lower than this value. When CAN is implemented on Microchip SAME5x and SAMC21 processors, these values are converted from nanoseconds into time quanta and stored in the TDCO and TDCF fields of the transceiver delay compensation register.

M954: Configure as CAN expansion board

ParametersAnn CAN address to use (required)

This command is used to reconfigure the board it is executed on as a CAN-connected expansion board. It would typically be the only command in the config.g file. When it is executed, the board changes its CAN address to the one specified in the A parameter, stops sending CAN time sync messages, and responds to requests received via CAN just like a regular expansion board. A few GCode commands can still be executed locally for diagnostic purposes, for example M111 and M122.

M955: Configure Accelerometer

Parameters (provisional)Pnn or Pbb.nn Accelerometer to use (required)Inn Accelerometer orientationSnnn Sample rate (Hz)Rnn Resolution (bits), typically 8, 10 or 12

This command configures an accelerometer.

The P parameter selects which accelerometer to use and is mandatory. To use an accelerometer on a CAN-connected expansion board, use the form Pboard-address.device-number for example P22.0.

If none of the other parameters are provided, the current configuration of the specified accelerometer is reported. Otherwise the configuration of that accelerometer is adjusted according to the I, S, and R parameters. These configuration settings persist until they are changed.

The I (orientation) parameter tells the firmware which of the 24 possible orientations the accelerometer chip is in relative to the printer axes. It is expressed as a 2-digit number. The first digit specifies which machine direction the Z axis of the accelerometer chip (usually the top face of the chip) faces, as follows: 0 = +X, 1 = +Y, 2 = +Z, 4 = -X, 5 = -Y, 6 = -Z. The second digit expresses which direction the X axis of the accelerometer chip faces, using the same code. If the accelerometer chip axes line up with the machine axis, the orientation is 21. This is the default orientation if no orientation has been specified.

The S and R parameters control how the accelerometer is programmed. The R parameter is ignored unless the S parameter is also provided. If S is provided but R is missing, a default resolution is used. The sensor resolution will be adjusted to be no greater than the value of the R parameter (or the minimum supported resolution if greater), then the sensor sampling rate will be adjusted to a value supported at that resolution that is close to the S parameter. The actual rate and resolution selected can be found by using M955 with just the P parameter.

M956: Collect accelerometer data and write to file

ParametersPnn or Pbb.nn Accelerometer to use (required)Snnn Number of samples to collect (required)X and/or Y and/or Z Machine axes to collect data for. If no axes are specified, data is collected for all three axes.An (required) 0 = activate immediately, 1 = activate just before the start of the next move, 2 = activate just before the start of the deceleration segment of the next moveKn (optional, default 0) Skip the specified number of moves before activating (use with A1 or A2)

This command causes the specified number of accelerometer samples to be collected and saved to a .csv file on the SD card.

The P parameter selects which accelerometer to use and is mandatory. To use an accelerometer on a CAN-connected expansion board, use the form Pboard-address.device-number for example P22.0.

M957: Raise event

ParametersE"type" Event type nameDnn Device number to which the event relates, optionally including the CAN address of the board concernedPnn (optional) additional data about the event (unsigned integer)Bnn (optional) CAN address that the event should appear to originate fromS"text" (optional) Short text string to be appended to the event message

This command is used to raise an event internally as if the event had actually occurred, and execute any related handler macro for that event. Its main use is to test event handler macros.

The event type names are firmware-dependent. In RepRapFirmware they are: heater_fault, driver_error, filament_error, driver_warning, driver_stall and mcu_temperature_warning.

The meaning of the device number depends on the event type. For a driver error it is the local driver number. For a heater fault it is the heater number. For a filament error it is the extruder number.

The meaning of the optional additional parameter also depends on the event type. For example, for a driver error it is the driver status.

M995: Calibrate Touch Screen

Parameters
N123
62 Firmware module number(s), default 0
N123
87 Expansion board address, default 0 (i.e. main controller board)Example
N123
12

This command triggers a firmware update if the necessary files are present on the SD card. In RepRapFirmware on the Duet series, module numbers are as follows:

0 - main firmware. The firmware filename depends on the controller electronics, e.g.sys/RepRapFirmware.bin (Duet 06/085), sys/Duet2CombinedFirmware (Duet WiFi/Ethernet), sys/DuetMaestroFirmware.bin (Duet Maestro). File sys/iap.bin (Duet), sys/iap4e.bin (Duet WiFi/Ethernet) or sys/iap4s.bin (Duet Maestro) must also be present.

1 - WiFi module firmware, filename sys/DuetWiFiServer.bin

2 - Reserved (on Duet WiFi running RepRapFirmware 1.18 and earlier, was web server file system)

3 - Duet WiFi main boards: put the WiFi module into bootloader mode so that firmware can be uploaded directly via its serial port. Duet 3 expansion boards: update the bootloader (RepRapFirmware 3.2 and later).

4 - Updates the firmware on an attached PanelDue v3 or later touch screen (supported in RRF 3.2 and later)

M998: Request resend of line

Parameters
N123
83 Line numberExample
N123
13

Request a resend of line 34. In some implementations the input-handling code overwrites the incoming G Code with this when it detects, for example, a checksum error. Then it leaves it up to the G-code interpreter to request the resend.

M999: Restart after being stopped by error

ParametersThis command can be used without any additional parameters.
N123
83 Reset flags1
N123
87 CAN address of the board to reset (RRF only)2Example
N123
14

Restarts the firmware using a software reset.

Notes

1The dc42 fork of RepRapFirmware not only resets the board but also puts the board into firmware upload mode if parameter PERASE is present. 2Starting from RRF 3.3 this parameter may be set to -1 to reboot the attached SBC (DuetPi + SBC)

Other commands

G: List all G-codes

Example
N123
15

Print a list of all implemented G-codes in the firmware with description to the host.
(Note: this has been implemented in Redeem, and so is only a proposal.)

M: List all M-codes

Example
N123
16

Print a list of all implemented M-codes in the firmware with description to the host.
(Note: this has been implemented in Redeem, and so is only a proposition)

T: Select Tool

ParametersThis command can be used without any additional parameters.
N123
83: Bitmap of all the macros to be run (only RRF 1.17b or later)Tool numberExample
N123
17

Select tool (or in older implementations extruder) number 1 to build with.

The sequence followed is:

  1. Set the current tool to its standby temperatures specified by
    N123 [...G Code in here...] *71
    
    02 (see above),
  2. Set the new tool to its operating temperatures specified by
    N123 [...G Code in here...] *71
    
    02 and wait for all temperatures to stabilise,
  3. Apply any X, Y, Z offset for the new tool specified by
    N123 [...G Code in here...] *71
    
    02,
  4. Use the new tool.

Selecting a non-existent tool (100, say) just does Step 1 above1. That is to say it leaves all tools in their standby state. You can, of course, use the

N123 [...G Code in here...] *71
02 command beforehand to set that standby temperature to anything you like.

Note that you may wish to move to a parking position before executing a T command in order to allow the new extruder to reach temperature while not in contact with the print. It is acceptable for the firmware to apply a small offset [by convention (-1mm x tool-number) in Y] to the current position when the above sequence is entered to allow temperature changes to take effect just away from the parking position. Any such offset must, of course, be undone when the procedure finishes.

If the Z value changes in the offsets and the tool moves up, then the Z move is made before the X and Y moves. If Z moves down, X and Y are done first.

Some firmware (Such as Prusa i3 Printers with MMU) also support the

N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
103 (recommended) and
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
104(depricated)2 commands to prompt the user to select a tool (or a filament in the case of the MultiMaterial Unit) on the printer's menu. Then the
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
105 command actually loads the selected filament.

Some implementations (e.g. RepRapFirmware) allow you to specify tool-change G Code macros3. There are normally three specified (any of which can contain no commands if desired) that execute in this order:

  1. Actions to do with the old tool before it is released - macro name:
    N3 T0*57 ; This is a comment
    N4 G92 E0*67
    ; So is this
    N5 G28*22
    
    106 where N is the tool number;
  2. (Old tool is released);
  3. Actions to do with the new tool before it is selected - macro name:
    N3 T0*57 ; This is a comment
    N4 G92 E0*67
    ; So is this
    N5 G28*22
    
    107 where N is the tool number;
  4. (New tool is selected); and
  5. Actions to do with the new tool after it is selected - macro name:
    N3 T0*57 ; This is a comment
    N4 G92 E0*67
    ; So is this
    N5 G28*22
    
    108 where N is the tool number.

With such implementations there is no wait for temperature stabilisation. That can be achieved by an

N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
109 in any of the macros, of course. However be aware that recent RepRapFirmware versions does NOT run any tool change macros if the axes are not homed.

After a reset tools will not start heating until they are selected. You can either put them all at their standby temperature by selecting them in turn, or leave them off so they only come on if/when you first use them. The

G1 F1500           ; Set feedrate to 1500mm/min
G1 X50 Y25.3 E22.4 ; Move and extrude
23,
G1 F1500           ; Set feedrate to 1500mm/min
G1 X50 Y25.3 E22.4 ; Move and extrude
20, and
G1 F1500           ; Set feedrate to 1500mm/min
G1 X50 Y25.3 E22.4 ; Move and extrude
21 commands turn them all off. You can, of course, turn them all off with the
G1 F1500           ; Set feedrate to 1500mm/min
G1 X50 Y25.3 E22.4 ; Move and extrude
20 command, then turn some back on again. Don't forget also to turn on the heated bed (if any) if you use that trick.

Tool numbering may start at 0 or 1, depending on the implementation. Some implementations (those that use the

N123 [...G Code in here...] *71
05 command to define tools) allow the user to specify tool numbers, so with them you can have tools 17, 99 and 203 if you want. Negative numbers are not allowed.

Notes

1 For RepRapFirmware, selecting a non-existent tool also removes any X/Y/Z offset applied for the old tool.

2

N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
104 was the original form of the command, but it was changed to
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
103 when it was realized that the question mark character caused problems when printing through octoprint. This change was implemented in Prusa firmware 3.5.0.

3 Under special circumstances, the execution of those macro files may not be desired. RepRapFirmware 1.17b or later supports an optional

N123 [...G Code in here...] *71
10 parameter to specify which macros shall be run. If absent then all the above macros will be run. Otherwise pass a bitmap of all the macros to be executed. The bitmap of this value consists of tfree=1, tpre=2 and tpost=4.

D: Debug codes

NOTE: These D codes are not compatible with the Gcode spec ( NIST Gcode spec, initially written for CNC, which Reprap initially messed up, after what the CNC side of Reprap has spent years trying to get Reprap back to respecting it ), and will make life hell for those building machines that do more than just 3D printing, or controllers that support this, as well as possibly cause other issues. I see this is from Prusa, and I know these guys are really cool about Open-Source, so I'm sure they care a lot about respecting standards and other projects as well, so I'm certain they'll fix this as soon as they see there is an issue. Thankfully this is very easy to fix, just change from D1 to Mxxx D1, where you find a Mxxx Gcode that is currently free and start using it. In Gcode, only M, G and T are keywords, D is a parameter, you can't make it a keyword without messing everything up. I'm sure for your subset of using Gcode, that's probably just fine, but it's not for the rest of us, and the whole point of adding things to this page, is for others to use it if they want/can/need, and the way it currently is ( breaking a standard ), this can't be used by others. Links:

This note by: -- [email protected]

Debug codes are not active by defalut and must be defined in source code.

D-1: Endless Loop
---
D0: Reset
This command will reset the board
N123 [...G Code in here...] *71
67: Bootloader
D1: Clear EEPROM and RESET
This command will clear the EEPROM and reset the board
D2: Read/Write RAM
ParametersThis command can be used without any additional parameters. It will read the entire RAM.
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
119: Address (x0000-x1fff)
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
120: Count (1-8192)
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
121: Data (hex)NotesThe hex address needs to be lowercase without the 0 before the xCount is decimalThe hex data needs to be lowercase
D3: Read/Write EEPROM
ParametersThis command can be used without any additional parameters. It will read the entire EEPROM.
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
119: Address (x0000-x0fff)
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
120: Count (1-4096)
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
121: Data (hex)NotesThe hex address needs to be lowercase without the 0 before the xCount is decimalThe hex data needs to be lowercase
D4: Read/Write PIN
To read the digital value of a pin you need only to define the pin number.Parameters
N123
83: Pin (0-255)
G0 X12               ; move to 12mm on the X axis
G0 F1500             ; Set the feedrate to 1500mm/min
G1 X90.6 Y13.8 E22.4 ; Move to 90.6mm on the X axis and 13.8mm on the Y axis while extruding 22.4mm of material
00: Function in/out (0/1)
G0 X12               ; move to 12mm on the X axis
G0 F1500             ; Set the feedrate to 1500mm/min
G1 X90.6 Y13.8 E22.4 ; Move to 90.6mm on the X axis and 13.8mm on the Y axis while extruding 22.4mm of material
01: Value (0/1)
D5: Read/Write FLASH
ParametersThis command can be used without any additional parameters. It will read the 1kb FLASH.
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
119: Address (x00000-x3ffff)
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
120: Count (1-8192)
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
121: Data (hex)
N123
67: EraseNotesThe hex address needs to be lowercase without the 0 before the xCount is decimalThe hex data needs to be lowercase
D6: Read/Write external FLASH
Reserved
D7: Read/Write Bootloader
Reserved
D8: Read/Write PINDA
Parameters
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
022: Read PINDA temperature shift values
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
023: Reset PINDA temperature shift values to default
N123
83: Pinda temperature [C]
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
135: Z Offset [mm]
D9: Read/Write ADC
Parameters
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
136: ADC channel index
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
137: Heater 0 temperature
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
341: Heater 1 temperature
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
139: Bed temperature
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
140: PINDA temperature
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
141: PWR voltage
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
142: Ambient temperature
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
143: BED voltage
N123 [...G Code in here...] *71
87: Value to be written as simulated
D10: Set XYZ calibration = OK
Writes current time in the log file.
D20: Generate an offline crash dump
Generate a crash dump for later retrival.Usage
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
145Parameters
N123
67: Perform an emergency crash dump (resets the printer).NotesA 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
Output the complete crash dump (if present) to the serial.Usage
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
147NotesThe starting address can vary between builds, but it's always at the beginning of the data section.
D22: Clear crash dump state
Clear an existing internal crash dump.Usage
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
148
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
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
149Parameters
N123
67: Perform an emergency crash dump (resets the printer).
N123
89: Disable online dumps.
D80: Bed check
This command will log data to SD card file "mesh.txt".Parameters
N123
67: Dimension X (default 40)
N123 [...G Code in here...] *71
91: Dimension Y (default 40)
N123
44: Points X (default 40)
N123
68: Points Y (default 40)
N123 [...G Code in here...] *71
46: Offset X (default 74)
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
157: Offset Y (default 34)
D81: Bed analysis
This command will log data to SD card file "wldsd.txt".Parameters
N123
67: Dimension X (default 40)
N123 [...G Code in here...] *71
91: Dimension Y (default 40)
N123
44: Points X (default 40)
N123
68: Points Y (default 40)
N123 [...G Code in here...] *71
46: Offset X (default 74)
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
157: Offset Y (default 34)
D106: Print measured fan speed for different pwm values
D2130: Trinamic stepper controller
Reserved
D9125: PAT9125 filament sensor
This command can be used without any additional parameters. It will read the PAT9125 values.Parameters
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
022: Print values
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
023: Print values
N123
89: Resolution. Not active in code
N123 [...G Code in here...] *71
42: X values
N123 [...G Code in here...] *71
43: Y values
N123 [...G Code in here...] *71
93: Activate filament sensor log

Proposed EEPROM configuration codes

Background: Every 3D printer has parameters that need to be persistent but also easily tunable, such as extrusion steps-per-mm and various planner values. Some of these parameters are hardcoded in firmware so that a user has to modify, recompile, and re-flash the firmware for certain adjustments, while others can be modified with an M-code and stored to the EEPROM or other persistent storage.

Current implementations:

Marlin and Sprinter use G-codes
G0 X12               ; move to 12mm on the X axis
G0 F1500             ; Set the feedrate to 1500mm/min
G1 X90.6 Y13.8 E22.4 ; Move to 90.6mm on the X axis and 13.8mm on the Y axis while extruding 22.4mm of material
07-
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
423 to save, load, reset, and report the settings mirrored in EEPROM. Note that the
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
423 command reports settings that may not have been saved to EEPROM yet.Teacup uses G-codes
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
395-
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
174 to set, read, and save PID values.Repetier Firmware uses
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
274 to set a stored value (using an ID number) and
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
176 to report settings.RepRapFirmware uses the
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
177 file on the SD card for settings storage.
G0 X12               ; move to 12mm on the X axis
G0 F1500             ; Set the feedrate to 1500mm/min
G1 X90.6 Y13.8 E22.4 ; Move to 90.6mm on the X axis and 13.8mm on the Y axis while extruding 22.4mm of material
07 saves some values to that file,
G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
311 re-loads settings from this file, and
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
018 loads the "factory settings" values from
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
181, ignoring
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
177.

Please see the RFC M-codes for EEPROM config proposed by AlexRa in March of 2011. There is currently no working implementation of the proposed commands.

Replies from the RepRap machine to the host computer

All communication is in printable ASCII characters.

Messages sent back to the host computer are terminated by a newline.

The basic protocol responses look like this:

xx [line number to resend] [T:93.2 B:22.9] [C: X:9.2 Y:125.4 Z:3.7 E:1902.5] [Some debugging or other information may be here]

N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
183 can be one of:

  • N3 T0*57 ; This is a comment
    N4 G92 E0*67
    ; So is this
    N5 G28*22
    
    184 - The RepRap machine is ready to receive the next line from the host.
  • N3 T0*57 ; This is a comment
    N4 G92 E0*67
    ; So is this
    N5 G28*22
    
    185 or
    N3 T0*57 ; This is a comment
    N4 G92 E0*67
    ; So is this
    N5 G28*22
    
    186 - There was a communication error and the RepRap machine is requesting a resend of the line in question. The line is specified either as
    G0 X12               ; move to 12mm on the X axis
    G0 F1500             ; Set the feedrate to 1500mm/min
    G1 X90.6 Y13.8 E22.4 ; Move to 90.6mm on the X axis and 13.8mm on the Y axis while extruding 22.4mm of material
    
    37 or
    N3 T0*57 ; This is a comment
    N4 G92 E0*67
    ; So is this
    N5 G28*22
    
    188. Examples:
    N3 T0*57 ; This is a comment
    N4 G92 E0*67
    ; So is this
    N5 G28*22
    
    189,
    N3 T0*57 ; This is a comment
    N4 G92 E0*67
    ; So is this
    N5 G28*22
    
    190,
    N3 T0*57 ; This is a comment
    N4 G92 E0*67
    ; So is this
    N5 G28*22
    
    191
  • N3 T0*57 ; This is a comment
    N4 G92 E0*67
    ; So is this
    N5 G28*22
    
    192 or
    N3 T0*57 ; This is a comment
    N4 G92 E0*67
    ; So is this
    N5 G28*22
    
    193 or
    N3 T0*57 ; This is a comment
    N4 G92 E0*67
    ; So is this
    N5 G28*22
    
    194 (Repetier Firmware) - There was an error. Common communication errors such as
    N3 T0*57 ; This is a comment
    N4 G92 E0*67
    ; So is this
    N5 G28*22
    
    195 or
    N3 T0*57 ; This is a comment
    N4 G92 E0*67
    ; So is this
    N5 G28*22
    
    196,
    N3 T0*57 ; This is a comment
    N4 G92 E0*67
    ; So is this
    N5 G28*22
    
    197 or
    N3 T0*57 ; This is a comment
    N4 G92 E0*67
    ; So is this
    N5 G28*22
    
    198,
    N3 T0*57 ; This is a comment
    N4 G92 E0*67
    ; So is this
    N5 G28*22
    
    199 or
    N3 T0*57 ; This is a comment
    N4 G92 E0*67
    ; So is this
    N5 G28*22
    
    200 are recoverable and should immediately be followed by a resend. Other non-fatal errors commonly include
    N3 T0*57 ; This is a comment
    N4 G92 E0*67
    ; So is this
    N5 G28*22
    
    201 and several SD related errors such as
    N3 T0*57 ; This is a comment
    N4 G92 E0*67
    ; So is this
    N5 G28*22
    
    202,
    N3 T0*57 ; This is a comment
    N4 G92 E0*67
    ; So is this
    N5 G28*22
    
    203,
    N3 T0*57 ; This is a comment
    N4 G92 E0*67
    ; So is this
    N5 G28*22
    
    204,
    N3 T0*57 ; This is a comment
    N4 G92 E0*67
    ; So is this
    N5 G28*22
    
    205,
    N3 T0*57 ; This is a comment
    N4 G92 E0*67
    ; So is this
    N5 G28*22
    
    206,
    N3 T0*57 ; This is a comment
    N4 G92 E0*67
    ; So is this
    N5 G28*22
    
    207,
    N3 T0*57 ; This is a comment
    N4 G92 E0*67
    ; So is this
    N5 G28*22
    
    208,
    N3 T0*57 ; This is a comment
    N4 G92 E0*67
    ; So is this
    N5 G28*22
    
    209 and
    N3 T0*57 ; This is a comment
    N4 G92 E0*67
    ; So is this
    N5 G28*22
    
    210. Any other errors indicate a hardware fault that will make the RepRap machine shut down immediately after it has sent this message. They should be considered fatal by hosts.
  • N3 T0*57 ; This is a comment
    N4 G92 E0*67
    ; So is this
    N5 G28*22
    
    211 - The RepRap machine's command buffers are empty and it is waiting for the next line from the host.
  • N3 T0*57 ; This is a comment
    N4 G92 E0*67
    ; So is this
    N5 G28*22
    
    212 - The RepRap machine is busy for some reason and currently cannot receive or process commands through the serial interface from a connected host. Possible reasons are: `processing` (the RepRap machine is busy with processing some lengthy command, like homing, heatup or auto leveling),
    N3 T0*57 ; This is a comment
    N4 G92 E0*67
    ; So is this
    N5 G28*22
    
    213 (the RepRap machine is paused and awaiting an action by the user via its built in controller unit, e.g. clicking the button),
    N3 T0*57 ; This is a comment
    N4 G92 E0*67
    ; So is this
    N5 G28*22
    
    214 (the RepRap machine is paused and waiting for input from the user via its built in controller unit, e.g. selecting a menu option). Examples:
    N3 T0*57 ; This is a comment
    N4 G92 E0*67
    ; So is this
    N5 G28*22
    
    215,
    N3 T0*57 ; This is a comment
    N4 G92 E0*67
    ; So is this
    N5 G28*22
    
    216.

The T: and B: values are the temperature of the currently-selected extruder and the bed respectively, and are only sent in response to

G92 E0
G28
G1 F1500
G1 X2.0 Y2.0 F3000
G1 X3.0 Y3.0
006. If such temperatures don't exist (for example for an extruder that works at room temperature and doesn't have a sensor) then a value below absolute zero (-273oC) is returned.

C: means that coordinates follow. Those are the X: Y: etc values. These are only sent in response to

G1 F1500           ; Set feedrate to 1500mm/min
G1 X50 Y25.3 E22.4 ; Move and extrude
89 and
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
219.

The RepRap machine may also send lines that look like this:

// This is some debugging or other information on a line on its own. It may be sent at any time.

Such lines will always be preceded by //.

The most common response is simply:

N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
184

When the machine boots up it sends the string

N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
221

once to the host before sending anything else. This should not be replaced or augmented by version numbers and the like.

G1 F1500           ; Set feedrate to 1500mm/min
G1 X50 Y25.3 E22.4 ; Move and extrude
84 (see above) requests those.

Originally, every line sent by RepRap to the host computer except the start line was supposed to have a two-character prefix (one of

N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
184,
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
185,
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
192 or
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
226). The machine should never send a line without such a prefix. These days, firmwares generally do not adhere to this rule and thus it should be considered obsolete.

N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
227 are lines sent from the host to the RepRap machine,
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
228 are lines sent from the RepRap machine to the host.

N123
18

Action commands

The current versions of Pronterface and OctoPrint can interpret special commands sent by the firmware of the form:

N123
19

Other hosts simply ignore or echo this output from the firmware.

The available Host Action Commands are:

  • N3 T0*57 ; This is a comment
    N4 G92 E0*67
    ; So is this
    N5 G28*22
    
    221: Tell the host to start the currently selected print job. (OctoPrint 1.5.0+)
  • N3 T0*57 ; This is a comment
    N4 G92 E0*67
    ; So is this
    N5 G28*22
    
    230: Tell the host to pause the print job.
  • N3 T0*57 ; This is a comment
    N4 G92 E0*67
    ; So is this
    N5 G28*22
    
    231: Tell the host to resume the print job.
  • N3 T0*57 ; This is a comment
    N4 G92 E0*67
    ; So is this
    N5 G28*22
    
    232: Tell the host to disconnect from the printer.
  • N3 T0*57 ; This is a comment
    N4 G92 E0*67
    ; So is this
    N5 G28*22
    
    233: Tell the host to abort the current job.
  • N3 T0*57 ; This is a comment
    N4 G92 E0*67
    ; So is this
    N5 G28*22
    
    234: Tell the host that an extruder's filament is out or jammed. Host should issue a pause and can offer better help to the user. For backwards-compatibility it should be followed by the
    N3 T0*57 ; This is a comment
    N4 G92 E0*67
    ; So is this
    N5 G28*22
    
    230 action.
  • N3 T0*57 ; This is a comment
    N4 G92 E0*67
    ; So is this
    N5 G28*22
    
    236: Tell the host that a printer-controlled print job was paused. (OctoPrint 1.3.9+)
  • N3 T0*57 ; This is a comment
    N4 G92 E0*67
    ; So is this
    N5 G28*22
    
    237: Tell the host that a printer-controlled print job was resumed. (OctoPrint 1.3.9+)
  • N3 T0*57 ; This is a comment
    N4 G92 E0*67
    ; So is this
    N5 G28*22
    
    238: Display a "
    N123 [...G Code in here...] *71
    
    74 Probing Retrying" alert. (Lulzbot Cura 3.6+)
  • N3 T0*57 ; This is a comment
    N4 G92 E0*67
    ; So is this
    N5 G28*22
    
    240: Cancel the print job and display a "
    N123 [...G Code in here...] *71
    
    74 Probing Failed" alert. (Lulzbot Cura 3.6+)
  • N3 T0*57 ; This is a comment
    N4 G92 E0*67
    ; So is this
    N5 G28*22
    
    242: The SD card was inserted. Hosts should update internal state as needed. (OctoPrint 1.6.0+)
  • N3 T0*57 ; This is a comment
    N4 G92 E0*67
    ; So is this
    N5 G28*22
    
    243: The SD card was ejected. Hosts should update internal state as needed. (OctoPrint 1.6.0+)
  • N3 T0*57 ; This is a comment
    N4 G92 E0*67
    ; So is this
    N5 G28*22
    
    244: The SD card was updated. Hosts should update internal state as needed. (OctoPrint 1.6.0+)

Action commands can also be sent by the firmware to have the host show alerts and prompts for user feedback. The following commands are supported by OctoPrint 1.3.9 or later with the "Action Command Prompt support" plugin enabled.

  • N3 T0*57 ; This is a comment
    N4 G92 E0*67
    ; So is this
    N5 G28*22
    
    245: Start a user prompt dialog that displays
    N3 T0*57 ; This is a comment
    N4 G92 E0*67
    ; So is this
    N5 G28*22
    
    246 to the user.
  • N3 T0*57 ; This is a comment
    N4 G92 E0*67
    ; So is this
    N5 G28*22
    
    247: Define a dialog choice with the associated
    N3 T0*57 ; This is a comment
    N4 G92 E0*67
    ; So is this
    N5 G28*22
    
    246.
  • N3 T0*57 ; This is a comment
    N4 G92 E0*67
    ; So is this
    N5 G28*22
    
    249: Same as
    N3 T0*57 ; This is a comment
    N4 G92 E0*67
    ; So is this
    N5 G28*22
    
    247.
  • N3 T0*57 ; This is a comment
    N4 G92 E0*67
    ; So is this
    N5 G28*22
    
    251: Tell the host to prompt the user with the defined dialog.
  • N3 T0*57 ; This is a comment
    N4 G92 E0*67
    ; So is this
    N5 G28*22
    
    252: Tell the host to close the dialog (e.g., the choice was made from the printer's own UI).

After showing a user dialog the host should wait for feedback and send the user's selection back to the firmware with

N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
253 as described in G-Code#M876:_Dialog_handling. On connection (or whenever the functionality is enabled in the host) the host can tell the firmware that it supports host dialogs by sending
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
254.

For more detailed examples of

N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
255 action command dialogs, see OctoPrint's documentation.

Further notes

RepRapFirmware responds to some commands with a reply string in JSON format, terminated by a newline. This allows later firmware revisions to include additional information without confusing clients (e.g. PanelDue) that do not expect it, and to make responses self-describing so that the client will not be confused if responses are delayed or lost. The commands affected are:

  • N3 T0*57 ; This is a comment
    N4 G92 E0*67
    ; So is this
    N5 G28*22
    
    256 (now deprecated in favor of
    G92 E0
    G28
    G1 F1500
    G1 X2.0 Y2.0 F3000
    G1 X3.0 Y3.0
    
    081)
  • N3 T0*57 ; This is a comment
    N4 G92 E0*67
    ; So is this
    N5 G28*22
    
    258 (now deprecated in favor of
    G92 E0
    G28
    G1 F1500
    G1 X2.0 Y2.0 F3000
    G1 X3.0 Y3.0
    
    081)
  • N3 T0*57 ; This is a comment
    N4 G92 E0*67
    ; So is this
    N5 G28*22
    
    260
  • N3 T0*57 ; This is a comment
    N4 G92 E0*67
    ; So is this
    N5 G28*22
    
    261
  • G92 E0
    G28
    G1 F1500
    G1 X2.0 Y2.0 F3000
    G1 X3.0 Y3.0
    
    081

Proposal for sending multiple lines of G-code

So far, this is a proposal, open for discussion.

Problem to solve

When using Marlin firmware or emulating Marlin, each line of G-code sent from the host to the controller is answered with an

N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
184 before the next line can be sent without locking communications up. This slows down communication and limits the number of commands-per-second that can be sent to the control board, and the USB stack on the host and the serial interface driver on the Arduino also add their own latencies (up to 10 milliseconds). This is not a problem for other controller electronics using native USB such as the Duet, because the standard serial-over-USB drivers provide flow control, so the host software can be configured not to wait for the
N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22
184.

For more details on this proposal, some suggested solutions and comments, please see GCODE_buffer_multiline_proposal

Alternatives to G-code

Main article: Firmware/Alternative#alternatives to G-code

Several people have suggested using STEP-NC or some other control language; or perhaps designing a completely new control language.

How to convert C Program into software?

Steps in Converting C Program to Executable Program.
Create / Edit : First of all, we need to create a C program for execution. ... .
Compile : After creating or editing source code we need to compile it by using compiler. ... .
Link : Object files are not executable file so in order to make executable file we use linker..

Does C compile to machine code?

The C programming language is what is referred to as a compiled language. In other words, C programs are implemented by compilers, which translate source code into machine-readable code (more on that later).

What are three 3 ways to convert a high

A high level language to machine code can be done by.
A. Interpreter Coding..
B. Chip..
C. Linker..
D. Compiler..

What converts program code into machine language?

A compiler is a special program that translates a programming language's source code into machine code, bytecode or another programming language. The source code is typically written in a high-level, human-readable language such as Java or C++.