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

Gcode can also be stored in files on SD cards. A file containing RepRap Gcode usually has the extension .g, .gco or .gcode.
Files for BFB/RapMan have the extension .bfb.
Gcode 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 GCode 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 Gcode(s) are implemented in any given firmware, there are little tables attached to the command descriptions, like this one:

There is some support for the Gcode. 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 Gcode automatically, so there's no need to send the command. An example is power supply on/off Gcode (M80/M81) in the Teacup firmware.

???

It is unknown if the firmware supports this Gcode. You may want to test this yourself before using it in production.

The firmware deprecated this Gcode. The firmware author(s) should amend the deprecated Gcode on this page with workarounds (if needed) and the last supported firmware version that will accept this Gcode.

For the technically minded, Gcode line endings are Unix Line Endings (\n), but will accept Windows Line Endings (\r\n), 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 Gcode 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 (X175) or fractionals (X17.62), but selecting extruder number 2.76 would make no sense. In this description, the numbers in the fields are represented by nnn 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.

Letter

Meaning

Gnnn

Standard GCode command, such as move to a point

Mnnn

RepRap-defined command, such as turn on a cooling fan

Tnnn

Select tool nnn. In RepRap, a tool is typically associated with a nozzle, which may be fed by one or more extruders.

Snnn

Command parameter, such as time in seconds; temperatures; voltage to send to a motor

Pnnn

Command parameter, such as time in milliseconds; proportional (Kp) in PID Tuning

Xnnn

A X coordinate, usually to move to. This can be an Integer or Fractional number.

Ynnn

A Y coordinate, usually to move to. This can be an Integer or Fractional number.

Znnn

A Z coordinate, usually to move to. This can be an Integer or Fractional number.

U,V,W

Additional axis coordinates (RepRapFirmware)

Innn

Parameter - X-offset in arc move; integral (Ki) in PID Tuning

Jnnn

Parameter - Y-offset in arc move

Dnnn

Parameter - used for diameter; derivative (Kd) in PID Tuning

Hnnn

Parameter - used for heater number in PID Tuning

Fnnn

Feedrate in mm per minute. (Speed of print head movement)

Rnnn

Parameter - used for temperatures

Qnnn

Parameter - not currently used

Ennn

Length of extrudate. This is exactly like X, Y and Z, but for the length of filament to consume.

Nnnn

Line number. Used to request repeat transmission in the case of communications errors.

*nnn

Checksum. Used to check for communications errors.

Case sensitivity

The original NIST GCode 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-insensitive

RepRapFirmware version 1.19 and later (except within quoted strings)

Firmwares that are known to be case-sensitive

RepRapFirmware 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, many 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 ABCxyz;" 123 to the WiFi network list, use command:

M587 S"MYROUTER" P"ABCxyz;"" 123"

or if you can't send lowercase characters:

M587 S"MYROUTER" P"ABC'X'Y'Z;"" 123"

Comments

Gcode 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 GCode 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 Gcode to your printer, as this saves bandwidth.

Checking

The RepRap firmware checks the line number and the checksum.
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 GCode 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:

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: G0-G3 and G28-G32. The Teacup Firmware buffers also some setting commands: G20, G21, G90 and G91. All other G, M or T 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.

However, in the above example, we set a feedrate of 1500 mm/m, then do the same move, but accelerating to 3000 mm/m. 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 G0 or G1 to send an E 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 S parameter in this way, as damage may occur if you assume incorrectly. In RepRapFirmware, using the S1 or S2 parameter on a delta printer causes the XYZ 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 S1.

2In the RS274NGC Spec, G0 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 G1 is Controlled Move, which was used to move between the current point in space and the new point as precise as possible.

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

4RepRapFirmware provides an additional 'R1' parameter to tell the machine to go back to the coordinates a print was previously paused at. If this parameter is used and the code contains axis letters, an offset will be added to the pause coordinates (e.g. G1 R1 Z5).

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.

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

(sets the offset for tool (or in older implementations extrude head) 2 to the X, Y, and Z values specified)

G10 P1 R140 S205

(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 R value is the standby temperature in oC 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. 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 M585.

Notes

1Marlin uses G10/G11 for executing a retraction/unretraction move. The RepRapPro version of Marlin supports G10 for tool offset. Smoothie uses G10 for retract and G10 Ln for setting workspace coordinates.

2It's usually a bad idea to put a non-zero Z 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.

5Tool offsets are applied after any X axis mapping has been performed. Therefore if for example you map X to U in your M563 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.

This mode applies to G2/G3 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 G2/G3 arcs involving the Z plane.

These commands are supported in Marlin 1.1.4 and later with ARC_SUPPORT and CNC_WORKSPACE_PLANES enabled.

G26: Mesh Validation Pattern

The G26 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 G26 command prints a single layer pattern over the entire print bed, giving a clear indication of how accurately every mesh point is defined. G26 can be used to determine which areas of the mesh are less-than-perfect and how much to adjust each mesh point.

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

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 X, Y, and Z parameters act only as flags. Any coordinates given are ignored. For example, G28 Z10 results in the same behavior as G28 Z. Delta printers cannot home individual axes, but must always home all three towers, so the X Y Z parameters are simply ignored on these machines.

Marlin firmware (version 1.1.0 and later) provides an option called Z_SAFE_HOMING 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 homeall.g is processed. For individual axes the homex.g, homey.g, or homez.g file will be used. On Delta printers, G28 command will always home all three towers by processing the homedelta.g file, regardless of any XYZ parameters.

Because the behavior of G28 is unspecified, it is recommended not to automatically include G28 in your ending GCode. 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 G0 or G1.

Notes

1 MK4duo has a B parameter that tells the printer to return to the coordinates it was at before homing.

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

G29 Auto Bed Leveling (Marlin)

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 PROBE_MANUALLY option allows all forms of Auto Bed Leveling to be used without a probe. The procedure is similar to that of MESH_BED_LEVELING (see below). Begin the process with G29 to move the nozzle to the first point. Adjust the Z axis using G1 or your host software. Send G29 again to move to the next point and repeat until all points have been sampled.

Parameters

P Set the size of the grid that will be probed (P x P points). Not supported by non-linear delta printer bed leveling. Example: G29 P4

S Set the XY travel speed between probe points (in units/min)

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

V Set the verbose level (0-4). Example: G29 V3

T Generate a Bed Topology Report. Example: G29 P5 T 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.

F Set the Front limit of the probing grid

B Set the Back limit of the probing grid

L Set the Left limit of the probing grid

R Set the Right limit of the probing grid

Global Parameters

E By default G29 will engage the Z probe, test the bed, then disengage. Include E or E1 to engage/disengage the Z probe for each sample. (This has no effect for fixed probes.)

G29 Unified Bed Leveling (Marlin)

Marlin firmware (version 1.1.0 and later) includes the AUTO_BED_LEVELING_UBL 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 G26 Mesh Tuning feature.

A Activate Activate the Unified Bed Leveling system. (i.e., M420 S1)
D Disable Disable the Unified Bed Leveling system. (i.e., M420 S0)
B# Business Do Manual Probing in 'Business Card' mode.
H# Height Height to raise the nozzle after each Manual Probe of the bed.
C Continue Continue, Constant, or Current Location, depending on Phase.
E Every Stow the probe after every sampled point.
F# Fade Fade leveling compensation gradually, until it ceases at the given height.
I# Invalidate Invalidate a specified number of Mesh Points (X and Y).
J# Grid Do a grid (planar) leveling of the current Mesh using a grid with n points on a side.
K# Kompare Compare (diff) current Mesh with stored Mesh #, replacing current Mesh with the result.
L Load Load Mesh from the previously activated location in the EEPROM.
L# Load Load Mesh from the specified location in the EEPROM.
S Store Store the current Mesh in the Activated area of the EEPROM. Also save all settings.
S # Store Store the current Mesh at the specified area in EEPROM, set as the Activated area.
S -1 Store Store the current Mesh as a print-out suitable to be fed back into the system.
O Map Display the Mesh Map Topology.
P0 Phase 0 Zero Mesh Data and turn off the Mesh Compensation System.
P1 Phase 1 Invalidate the Mesh and do Automatic Probing to generate new Mesh data.
P2 Phase 2 Probe unpopulated areas of the Mesh (those that couldn't be auto-probed).
P3 Phase 3 Fill unpopulated Mesh points with a fixed value. No 'C' for "smart fill" extrapolation.
P4 Phase 4 Fine tune the Mesh. ** Delta Mesh Compensation requires an LCD panel. **
P5 Phase 5 Find Mean Mesh Height and Standard Deviation.
P6 Phase 6 Shift Mesh height. All Mesh points are adjusted by the amount specified with 'C'.
Q Test Load specified Test Pattern to help check system operation.
R # Repeat Repeat the command the specified number of times. Default: grid points X * Y.
T 3-Point Perform a 3-Point Bed Leveling on the current Mesh.
U Unlevel Perform a probe of the outer perimeter to assist in physically leveling the bed.
W What? Print a report of Unified Bed Leveling stored data.
X # The X location for the command
Y # The Y location for the command
Z Zero Do a single probe to set the Z Height of the nozzle.
Z # Zero Raise/lower the entire Mesh to conform with the specified difference (plus zprobe_zoffset).

G29 Manual Bed Leveling (Marlin)

Marlin firmware (version 1.0.2 and later) also provides a MESH_BED_LEVELING 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

G29 S1 ; Move to the first point and wait for a measurement
G29 S2 ; Store the current Z, move to the next point
G29 S3 Xn Yn Zn.nn ; Modify the Z height of a single point

G29 Auto Bed Leveling (Repetier-Firmware)

Repetier firmware since v0.91 supports G29 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 G32 instead with firmware 0.92.8 and above.

S0 Default value. Z bed heights are calculated at the measured points, relative to current Z position before issuing G29.

S1 Same as S0, except printer immediately moves to Z maximum position (Z max endstop required!), and calculates new Z maximum height. You must first issue G28 Z to home to Z maximum position before issuing G29 Snnn for this to work correctly, or the printer height will be invalid.

S2 Same as S1, except new calculated Z height is also stored to EEPROM.

G29 Auto Bed Leveling (RepRapFirmware)

RepRapFirmware:

S0 (default if no S parameter) Probe the bed, save the height map in a file on the SD card, and activate bed compensation. The default folder for the height map file is /sys and the default file name is heightmap.csv.

S1 Load the height map from file and activate bed compensation. The default folder and filename as for S0.

G30 ; Probe the bed at the current XY position. When the probe is triggered, set the Z coordinate to the probe trigger height.
G30 S-1 ; Probe the bed at the current XY position. When the probe is triggered, do not adjust the Z coordinate.
G30 P0 X20 Y50 Z-99999 ; Probe the bed at X20 Y50 and save the XY coordinates and the height error as point 0
G30 P3 X180 Y180 Z-99999 S4 ; Probe the bed at X180 Y180, save the XY coordinates and the height error as point 3 and calculate 4-point compensation or calibration
G30 P3 X180 Y180 Z-99999 S-1 ; As previous example but just report the height errors

In its simplest form probes bed at current XY location.

RepRapFirmware supports additional behaviour: if a Pn field is specified the probed X, Y, and Z values are saved as point n on the bed for calculating the offset plane or for performing delta printer calibration. If X, Y, or Z values are specified (e.g. G30 P1 X20 Y50 Z0.3) then those values are used instead of the machine's current coordinates. A silly Z 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. G30 P1 Z0.3 S) the bed plane is computed for compensation and stored. The combination of these options allows for the machine to be moved to points using G1 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 GCode file for automatic execution.

RepRapFirmware uses the value of the S 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 H 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 Z parameter of the G31 command in the config.g file. When you probe using G30 and the probe triggers, the firmware will assume that the nozzle is at the nominal trigger height plus the value you have in the H parameter.

1MK4duo Firmware support an optional parameter for Autocalibration Delta.

Usage

G30 Xnnn Ynnn Znnn Annn E R I D T S U

Parameters

Xnnn X coordinate

Ynnn Y coordinate

Znnn Z coordinate

Annn A Autocalibration width nnn precision

E Adjust Endstop

R Adjust Endstop & Delta Radius

I Adjust Tower

D Adjust Diagonal Rod

T Adjust Tower Radius

Sn Stows the probe if 1 (default=1)

Un <bool> with a non-zero value will apply the result to current zprobe_zoffset

Tnnn (RepRapFirmware 1.17 and later) Z probe type to which these parameters apply, defaults to the current Z probe type as defined by M558 P parameter

Examples

G31 P500 Z2.6
G31 X16.0 Y1.5

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: G31 P312 Z0.7) this will set the Z height to 0.7mm when the Z-probe value reaches 312 when a G28 Z0 (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 G31 Z0.7 will tell the RepRap machine that it is at a height of 0.7mm when the probe is triggered.

In RepRapFirmware, separate G31 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 G31 command, or use the T parameter.

In Repetier, G31 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 Z parameter is correct, default is current bed temperature) and 'C' (temperature coefficient of Z parameter in mm/oC, default zero) can be set for the alternative (ultrasonic) sensor. This is useful for probes that are affected by temperature. This facility is deprecated and likely to be removed in a future version of RepRapFirmware.

G32: Probe Z and calculate Z plane

G32 ; Probe and calculate
G32 Snnn ; Each firmware has its own parameters
G32 Snnn Pnnn ; Refer to their specific documentation

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

This command probes the bed at 3 or more pre-defined points (see M557) and updates transformation matrix for bed leveling compensation.

Parameters

Snnn Store transformation matrix after probing1

Examples

G32
G32 S2

RepRapFirmware executes macro file bed.g if present instead of using the M557 coordinates.

Notes

1Currently only Repetier firmware v0.92.8 and higher have working support for an optional Snnn parameter. The numeric value sets the behavior that occurs immediately after point probe and transformation matrix calculation. These are the values for Reprapfirmware:

S0 Default value. Transformation matrix is updated in RAM but is not stored to EEPROM. Z bed height not calculated.

S1 Transformation matrix is updated in RAM but is not stored to EEPROM. Printer immediately moves to Z maximum position (Z max endstop required!), and calculates new Z maximum height. You must first issue G28 to home to Z maximum position before issuing G32 Snnn for this to work correctly, or the printer height will be invalid.

S2 Same as S1, except transformation matrix and Z max heights are also stored to EEPROM.

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, G29) or by tilting the bed with motors.

Parameters

Snnn Bed leveling method

Pnnn Bed correction method

The values for Snnn and Pnnn are as follows:

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

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

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

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

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

When used with no parameters, G33 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 G28 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 M323.

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

The z-offset (M212) is set by making a probe and a paper test at the centre (P-1) (Marlin 2.0.x);

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

G33

G33 Pn T Cx.xx Fn Vn E

Parameters

Pn Number of probe points: n*n (n= -1 -> 10), when P is omitted the default set in Configuration.h is used.

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

Cx.xx 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.

Fn Force to run at least n iterations (n=1-30) and take the best result

G91: Set to Relative Positioning

All coordinates from now on are relative to the last position. Note: RepRapFirmware latest revision firmware uses M83 to set the extruder to relative mode: extrusion is NOT set to relative by ReprapFirmware on G91: only X,Y and Z are set to relative. By contrast, Marlin (for example) DOES also set extrusion to relative on a G91 command, as well as setting X, Y and Z.

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.

G93: Feed Rate Mode (Inverse Time Mode) (CNC specific)

G93 is Inverse Time Mode. In inverse time feed rate mode, an F word means the move should be completed in (one divided by the F number) minutes.
For example, if the F number is 2.0, the move should be completed in half a minute.

When the inverse time feed rate mode is active, an F word must appear on every line which has a G1, G2, or G3 motion, and an F word on a line that does not have G1, G2, or G3 is ignored. Being in inverse time feed rate mode does not affect G0 (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.

G100 X Y Z ; set floor for argument passed in. Number ignored and may be absent.
G100 R5 ; Add 5 to radius. Adjust to be above floor if necessary
G100 R0 ; Set radius based on current z measurement. Moves all axes to zero

G130: Set digital potentiometer value

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.

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 M1, M112.

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 macro file stop.g before everything is turned off. Apart from that, RepRapFirmware (v1.09n-ch) accepts an extra 'H' parameter, whose value must be non-zero, to keep all heaters active. This is what Duet Web Control v1.07 sends to cancel a paused print.

Notes

1Not available in RepRapFirmware, but as a work-around G4 can be run before M0.

2Only available on Marlin.

M1: Sleep or Conditional stop

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 M0, M112.

The Marlin Firmware does the same as M0.

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 sleep.g is run before all heaters and drives are turned off.

RepRapFirmware interprets this code only if a Roland mill has been configured.

In Repetier-Firmware in laser mode you need S0..S255 to set laser intensity. Normally you use S255 to turn it on full power for moves. Laser will only fire during G1/G2/G3 moves and in laser mode (M452).

Note that some firmwares list file names in upper case, but - when sent to the M23 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 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".

M24: Start/resume SD print

The machine prints from the file selected with the M23 command. If the print was previously paused with M25, printing is resumed from that point. To restart a file from the beginning, use M23 to reset it, then M24.

When this command is used to resume a print that was paused, RepRapFirmware runs macro file resume.g prior to resuming the print.

{"err":0,"size":457574,"height":4.00,"layerHeight":0.25,"filament":[6556.3],"generatedBy":"Slic3r 1.1.7 on 2014-11-09 at 17:11:32"}

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, all other values are in mm. The fields may appear in any order, and additional fields may be present.

If the file name parameter is not supplied and a file on the SD card is currently being printed, then information for that file is returned including additional field "fileName". This feature is used by the web interface and by PanelDue, so that if a connection is made when a file is already being printed, the name and other information about that file can be shown.

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

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 M114 command, q.v.).

See also M240 and M241 below.

M41: Loop

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:

When you press the reset button,

When the build material runs out (if your RepRap is set up to detect this), and

M42: Switch I/O pin

M42 switches a general purpose I/O pin. Use M42 Px Sy 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 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:

M43: Stand by on material exhausted

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.

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.

M73: Set build percentage

Instruct the machine that the build has progressed to the specified percentage. The machine is expected to display this on it's interface board. If the percentage is exactly 0, then a Build Start Notification is sent. If the percentage is exactly 100, then a Build End notification is sent.

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, M84 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.

Notes

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

Allows programming of steps per unit (usually mm) for motor drives. These values are reset to firmware defaults on power on, unless saved to EEPROM if available (M500 in Marlin) or in the configuration file (config.g in RepRapFirmware). Very useful for calibration.

RepRapFirmware will report the current steps/mm if you send M92 without any parameters.

M98: Call Macro/Subprogram

Runs the macro in the file mymacro.g. In conventional G Codes for CNC machines the P 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 GCode file that is executed by the G98 call. That GCode file does not need to end with an M99 (return) as the end-of-file automatically causes a return. Macro calls cannot usually be nested or be recursive; i.e. you can't call a macro from a macro, although RepRapFirmware explicitly supports this.

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 on RepRapFirmware as well.

Allows programming of axis hysteresis. Mechanical pulleys, gears and threads can have hysteresis when they change direction. That is, a certain number of steps occur before movement occurs. You can measure how many mm are lost to hysteresis and set their values with this command. Every time an axis changes direction, these extra mm will be added to compensate for the hysteresis.

M104: Set Extruder Temperature

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). Duet-dc42 and other firmware also supports the optional T parameter (as generated by slic3r) to specify which tool the command applies to. See also M109.

This is deprecated because temperatures should be set using the G10 and T commands (q.v.).

M104 in Teacup Firmware

In Teacup Firmware, M104 can be additionally used to handle all devices using a temperature sensor. It supports the additional P parameter, which is a zero-based index into the list of sensors in config.h. For devices without a temp sensor, see M106.

Example

M104 P1 S100

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

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

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

Notes

1These parameters are only supported by RepRapFirmware, which returns a JSON-formatted response if parameter S2 or S3 is specified. Additionally, parameter Rnn may be provided, where nn is the sequence number of the most recent G-code response that the client has already received. M105 S2 is equivalent to M408 S0, and M105 S3 is equivalent to M408 S2. Usage of these forms of M105 is deprecated, please use M408 instead.

Bnnn Blip time - fan will be run at full PWM for this number of seconds when started from standstill1

Hnn:nn:nn... Select heaters monitored when in thermostatic mode1

Rnnn Restore fan speed to the value it has when the print was paused1

Tnnn Set thermostatic mode trigger temperature1

Example

M106 S127

Examples (RepRapFirmware)

M106 P1 I1 S87
M106 P1 T45 H1:2
M106 P2 B0.1 L0.05

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). M106 S0 turns the fan off. In some implementations like RepRapFirmware the PWM value may alternatively be specified as a real fraction: M106 S0.7.

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 2 fans.

M106 in RepRapFirmware

If an S 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 F parameter in the M563 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 R2 parameter (see below).

If no S parameter is given but the R1 parameter is used, the fan speed when the print was last paused will be set. If the R2 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 T and H 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 H parameter is at or above the trigger temperature set by the T parameter, and off otherwise. Thermostatic mode can be disabled using parameter H-1.

The B 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 L 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 I 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 I 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 M42.

M106 in Teacup Firmware

Additionally to the above, Teacup Firmware uses M106 to control general devices. It supports the additional P parameter, which is an zero-based index into the list of heaters/devices in config.h.

Example

M106 P2 S255

Turn on device #3 at full speed/wattage.

Note: When turning on a temperature sensor equipped heater with M106 and M104 at the same time, temperature control will override the value given in M106 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 M104 is (or becomes) active on a heater (or other device) with a feedback sensor it will correct any M106 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

M108: Cancel Heating (Marlin)

Breaks out of an M109 or M190 wait-for-temperature loop, continuing the print job. Use this command with caution! If cold extrusion prevention is enabled (see M302) 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., M112] this requires the host to leave space in the command buffer, or the command won't be executed until later.

For firmware that supports ethernet and web interfaces M111 S9 will turn web debug information on without changing any other debug settings, and M111 S8 will turn it off. Web debugging usually means that HTTP requests will be echoed to the USB interface, as will the responses.

M112: Emergency Stop

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 M0 and M1.

M113: Set Extruder PWM

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 S value (70% in this instance). M113 S0 turns the extruder off, until an M113 command other than M113 S0 is sent.

This M115 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 M408 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 P parameter is present then the integer argument specifies the hardware being used. The following are currently supported:

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

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

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

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.

M120: Push

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, and

Whether moves (and separately extrusion) are 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:

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.

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.

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

M132 X Y Z A B

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

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

Example

M133 T0 P500

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

M140: Set Bed Temperature (Fast)

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). There is an optional R field that sets the bed standby temperature: M140 S65 R40.

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 affected1:

M140 S-273.15

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.

M143: Maximum heater temperature

H Heater number (RepRapFirmware 1.17 and later, default 1 which is normally the first hot end)

S Maximum temperature

Examples

M143 S275 ; set the maximum temperature of the hot-end to 275°C
M143 H0 S125 ; set the maximum bed temperature to 125C

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.

Hosts normally monitor printer temperatures by sending M105 every x seconds. This not only adds traffic, but also only works while printer is not blocked by waiting commands. So frequency more depends on frequency you can send new commands and creates extra traffic. As a solution, firmware can be told to automatically send temperatures every second. This function is disabled by default for best compatibility with existing hosts. To indicate the availability of this function, M115 will add an extra line:

M200 D1.75:3.0:1.75 ; set extruder 0 to 1.75mm, extruder 1 to 3.0mm and all remaining extruders to 1.75mm

Volumetric extrusion is an option you can set in some slicers whereby all extrusion amounts are specified in mm3 (cubic millimetres) of filament instead of mm of filament. This makes the gcode independent of the filament diameter, potentially allowing the same gcode to run on different printers. The purpose of the M200 command is to inform the firmware that the gcode input files have been sliced for volumetric extrusion, and to provide the filament diameter so that the firmware can adjust the requested extrusion amount accordingly.

Sending M200 without parameters reports the current volumetric extrusion state and (where appropriate) filament diameter for each extruder.

Note that if you use slicer-commanded retraction, the retraction amounts must be specified in mm3 too. If instead you use firmware retraction, then the firmware retraction amounts specified using the M207 command are still interpreted as mm.

Other firmwares:

Without parameters loads default grid, and with specified extension attempts to load the specified grid. If not available will not modify the current grid.
If Z was saved with the grid file, it will load the saved Z with the grid.

Question: what does a firmware do with filament diameter? Has this an effect on how much an E command moves the extruder motor? --Traumflug 11:34, 14 October 2012 (UTC) Yes, Marlin uses this to set a 'volumetric_multiplier' by which the E-steps of a move are scaled in the planner. DaveX (talk) 16:44, 12 April 2014 (PDT)
Smoothie implements the same thing as Marlin --Arthurwolf (talk) 05:23, 10 November 2014 (PST)

Sets the acceleration that axes can do in units/second^2 for print moves. For consistency with the rest of G Code movement this should be in units/(minute^2), but that gives really silly numbers and one can get lost in all the zeros. So for this we use seconds.

Use M201 to set per-axis accelerations and extruder accelerations. RepRapFirmware applies the M204 accelerations to the move as a whole, and also applies the limits set by M201 to each axis and extruder.

M207: Calibrate z axis by detecting z max length

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.

M226: Gcode Initiated Pause

Initiates a pause in the same way as if the pause button is pressed. That is, program execution is stopped and the printer waits for user interaction. This matches the behaviour of M1 in the NIST RS274NGC G-code standard and M0 in Marlin firmware.

M227: Enable Automatic Reverse and Prime

"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 M101/M103.

M261: i2c Request Data

Request data from an i2c slave device. This command simply relays the received data to the host.

Parameters

Ann I2 address

Bnn How many bytes to request

Example

M261 A99 B5 ; Request 5 bytes from Address 99

Both M260 and M261 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 EXPERIMENTAL_I2CBUS, and Marlin can act as a slave device by setting I2C_SLAVE_ADDRESS 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.

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 I parameter is not remembered between M280 commands (unlike the I parameter in M106 commands), so if you need inverted polarity then you must include I1 in every M280 command you send.

Duet 0.8.5 M280 P value to Expansion Port Pin Mapping

P

Name

Expansion Port Pin

Use M307 H# A-1 C-1 D-1 before using these pins

3

PC23_PWML6

21

4

PC22_PWML5

22

5

PC21_PWML4

23

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 (M106 P1 I-1). See Using servos and controlling unused I/O pins

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 BABYSTEP_ZPROBE_OFFSET option is used in Marlin, this command also affects the Z probe offset (as set by M851) and that offset will be saved to EEPROM.

M291: Display message and optionally wait for response

P"message" 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.

R"message" Optional title for the message box. Must be enclosed in double quotation marks too.

Sn Message box mode (defaults to 1)

Tn 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). In RepRapFirmware, the default timeout for messages that do not require acknowledgement is 10 seconds.

Zn 0 = no special action, 1 = display Z jog buttons alongside the message to allow the user to adjust the height of the print head

Examples

M291 P"Please do something and press OK when done" S2
M291 P"This message will be closed after 10 seconds" T10

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:

0. No buttons are displayed (non-blocking)
1. Only "Close" is displayed (non-blocking)
2. Only "OK" is displayed (blocking, send M292 to resume the execution)
3. "OK" and "Cancel" are displayed (blocking, send M292 to resume the execution or M292 P1 to cancel the operation in progress)

Marlin

Hot end only; see M304 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

H Is the heater number, and is compulsory. H0 is the bed, H1 is the first hot end, H2 the second etc.

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

I Integral value

D Derivative value

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

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

W Wind-up. Sets the maximum value of I-term, must be high enough to reach 245C for ABS printing.

B PID Band. Errors larger than this cause heater to be on or off.

An example using all of these would be:

M301 H1 P20 I0.5 D100 T0.4 S1 W180 B30

Smoothie

S0<code> 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

M301 W125

Teacup

See <code>M130, M131, M132, M133 for Teacup's codes for setting the PID parameters.

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:

M303 S<temperature> C<cycles>

Bed usage (repetier, not sure whether cycles work here):

M303 P1 S<temperature>

Bed usage (others):

M303 E-1 C<cycles> S<temperature>

Example

M303 C8 S175

Smoothie's syntax, where E0 is the first temperature control module (usually the hot end) and E1 is the second temperature control module (usually the bed):

M303 E0 S190

In RepRapFirmware, this command computes the process model parameters (see M307), 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 M303 with no parameters to see the current tuning state or the last tuning result.

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 M301 except that the H parameter (heater number) defaults to zero.

M304 in RepRapPro version of Marlin: Set thermistor values

In the RepRapPro version of Marlin ( https://github.com/reprappro/Marlin ) M304 is used to set thermistor values (as M305 is in later firmwares). RRP Marlin calculates temperatures on the fly, rather than using a temperature table. M304 Sets the parameters for temperature measurement.

Example

M304 H1 B4200 R4800 T100000

This tells the firmware that for heater 1 (H parameter: 0 = heated bed, H = first extruder), the thermistor beta (B parameter) is 4200, the thermistor series resistance (R parameter) is 4.8Kohms, the thermistor 25C resistance (T parameter) is 100Kohms. All parameters other than H are optional. If only the H parameter is given, the currently-used values are displayed. They are also displayed within the response to M503.

Xnnn Heater ADC channel, or thermocouple or PT100 or current loop adapter channel, defaults to the same value as the P parameter

Fnn (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

M305 P1 T100000 R1000 B4200

Sets the parameters for temperature measurement. The example above tells the firmware that for heater 1 (P parameter: 0 = heated bed, 1 = first extruder) the thermistor 25C resistance (T parameter) is 100Kohms, the thermistor series resistance (R parameter) is 1Kohms, the thermistor beta (B parameter) is 4200. All parameters other than P are optional. If only the P parameter is given, the existing values are displayed.

Example

M305 P1 T100000 R1000 B4200 H14 L-11 X2

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 X 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 (H parameter) is 14, the ADC low end correction (L parameter) is -11, and thermistor input #2 is used to measure the temperature of heater #1.

M307: Set or report heating process parameters

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

Cnnn dominant time Constant of the heating process in seconds

Dnnn Dead time in seconds

Four optional additional parameters help control the heating process

Fnnn PWM frequency to use.

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

Snnn maximum PWM to be used used with this heater on a scale of 0 to 1. Default 1.0.

Vnnn 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 disables compensation for changes in supply voltage.

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 (including using different values for the heating or cooling phase and the steady state phase), to better detect heater faults, and to calculate feed-forward terms to better respond to changes in the load. Normally these model parameters are found by auto tuning - see M303.

RepRapFirmware 1.16 and later allow the PID controller for a heater to be disabled by setting the A, C, and D 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.

Bnn Set stepping mode for Extruder 1 (not supported by RepRapFirmware, see above)

Inn Enable (nn=1) or disable (nn=0) microstep interpolation mode for the specified drivers, if they support it (RepRapFirmware only)

Modes (nn)

1 = full step

2 = half step

4 = quarter step

8 = 1/8 step

16 = 1/16 step

64 = 1/64 step

128 = 1/128 step

256 = 1/256 step

Examples

M350 S16 ; reset all drivers to the default 1/16 micro-stepping - not supported by RepRapFirmware
M350 Z1 ; set the Z-axis' driver to use full steps
M350 E4 B4 ; set both extruders to use quarter steps - Marlin/Repetier
M350 E4:4:4 ; set extruders 0-2 to use quarter steps - RepRapFirmware

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 M114 will then display the calibration offset that can then be programmed into the unit using M206 (Home offset) X represents Theta.

Smoothieware: M360 P0 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 M114, and programmed using M92. X represents Theta. Program Y (Psi) to the same value initially. Remember to repeat M360 after adjusting steps per degree.

Smoothieware: M360 P0 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 M360.

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 M114, and calibrate value into Home offset M206. Psi is represented by Y.

Smoothieware: M364 P0 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 M500.

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 M206 Z homing offset into the grid file.

In RepRapFirmware, this saves the grid parameters and height map into the specified file, or the default file heightmap.csv if no filename was specified. To load the height map automatically at startup, use command M375 in the config.g file.

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.

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

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.

The response is set as a single line with a newline character at the end. The meaning of the fields is:

status: I=idle, P=printing from SD card, S=stopped (i.e. needs a reset), C=running config file (i.e starting up), A=paused, D=pausing, R=resuming from a pause, B=busy (e.g. running a macro), F=performing firmware update
heaters: current heater temperatures, numbered as per the machine (typically, heater 0 is the bed)
active: active temperatures of the heaters
standby: standby temperatures of the heaters
hstat: status of the heaters, 0=off, 1=standby, 2=active, 3=heater fault. Heater 0 is normally the bed heater, heaters 1, 2.. are the extruder heaters.
pos: the X, Y and Z (and U, V, W if present) axis positions of the current tool (if a tool is selected), or of the print head reference point if no tool is selected
extr: the positions of the extruders
sfactor: the current speed factor (see M220 command)
efactor: the current extrusion factors (see M221 command), one value per extruder
tool: the selected tool number. A negative number typically means no tool selected.
probe: the Z-probe reading
fanPercent: the speeds of the controllable fans, in percent of maximum
fanRPM: the print cooling fan RPM
homed: the homed status of the X, Y and Z axes (and U, V, W if they exist), or towers on a delta. 0=axis has not been homed so position is not reliable, 1=axis has been homed so position is reliable.
fraction_printed: the fraction of the file currently being printed that has been read and at least partially processed.
message: the message to be displayed on the screen (only present if there is a message to display)
timesLeft: an array of the estimated remaining print times (in seconds) calculated by different methods. These are currently based on the proportion of the file read,
the proportion of the total filament consumed, and the proportion of the total layers already printed. Only present if a print from SD card is in progress.
seq: the sequence number of the most recent non-trivial G-code response or error message. Only present if the R parameter was provided and the current sequence number is greater than that.
resp: the most recent non-trivial G-code response or error message. Only present if the R parameter was provided and the current sequence number is greater.

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:

myName: the name of the printer
firmwareName: the name of the firmware, e.g. "RepRapFirmware", "Smoothieware" or "Repetier"
geometry: one of "cartesian", "delta", "corexy, "corexz" etc.
axes: the number of axes
volumes: the number of SD card slots available
numTools: the number of available tools numbered contiguously starting from 0

The fields may be in any order in the response. Other implementations may omit fields and/or add additional fields.

Set the color of your RGB LEDs that are connected to PWM-enabled pins. Note, the Green color is controlled by the <code>E value instead of the G value due to the G code being a primary code that cannot be overridden.

M450: Report Printer Mode

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:

M452: Select Laser Printer Mode

Switches to laser mode. This mode enables handling of a laser pin and makes sure that the laser is only activated during G1 moves if laser was enabled or E is increasing. G0 moves should never enable the laser. M3/M5 can be used to enable/disable the laser for moves.

M500: Store parameters in non-volatile storage

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 M906 and M907 followed by M500 will update /etc/redeem/local.cfg.

M502: Revert to the default "factory settings."

This command resets all tunable parameters to their default values, as set in the firmware. This doesn't reset any parameters stored in the EEPROM, so it must be followed with M500 if you want to do that.

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

RepRapFirmware outputs the content of the configuration file, but note that it may be truncated if it is too long.

M530: Enable printing mode

This command tells the firmware that a print has started (S1) or ended (S0). The L parameter sets the number of layers. L0 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 M115 with an additional line:

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.

M551: Set Password

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.

M553: Set Netmask

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

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.

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

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 G32 bed probing. The P value is the index of the point (indices start at 0) and the X and Y 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 deprecated in RepRapFirmware, you should define them in a bed.g file instead.

The second form defines the grid for G29 bed probing. For Cartesian printers, specify minimum and maximum X and Y 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.

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 present. P1 gives 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 P1. P2 specifies a modulated IR probe, where the modulation is commanded directly by the main board firmware using the control signal to the probe. P3 selects an alternative Z probe by driving the control signal to the probe low. P4 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 (normally closed) for bed probing between In and Gnd pins of the Z-probe connector (Duet 0.8.5 and Duet WiFi). P6 is as P4 but the switch is connected to and alternative connector (on the Duet series, the E1 endstop connector).

The X, Y and Z parameters specify whether each axis uses the Z probe for homing or not. If the parameter is nonzero, the Z probe is used for homing that axis. If the parameter is zero, the endstop switch for that axis is used for homing instead. See also G31 and G32.

Notes

1This parameter used to specify the Z probe channel in RepRapFirmware, but it has been superceded by the functionality of "M115 Px". With older firmware versions and a Duet 0.7/0.85, this parameter should be 1.

M559: Upload configuration file

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 M559, the file should be sent, ending with an M29 (q.v.).

M560: Upload web page file

For 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 M560 the file (usually an HTML file) should be sent, terminated by the string

<!-- **EoF** -->

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

M562: Reset temperature fault

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.

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 G1 commands, each controlling the corresponding drive in the 'D' field above, as follows:

G1 X90.6 Y13.8 E2.24:2.24:15.89
G1 X70.6 E0:0:42.4

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 G1 commands with multiple values for the extrusion amount, the M567 command can be used to define a tool mix ratio.

Normally an M563 command is immediately followed by a G10 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 M584) and the X mapping option in M563 defines which carriage or carriages are used.

If you use the M563 command with a P 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 M563 command. The command:

M563 S1

means add 1 (the value of the S 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 M563 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 M563 is called in this way:

M563 P1 D-1 H-1

M564: Limit axes

Allow moves outside the print volume, 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. User beware... If you set the S parameter to 1 then the RepRap will not think outside the box. The default behaviour is S = 1.

M565: Set Z probe offset

Set the offset from the extruder tip to the probe position. The X, Y, and Z 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 G32.

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 X and Y 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

This example sets the mix ratio for tool 2 (the P value). When mixing is then turned on (see M568), only single E values need to be sent on a G1 command (any extra E values will be ignored, but are not illegal):

G1 X20 E1.3

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.

Set the control value for the drive specified by P that sends it forwards to the given value in the S field. After sending the example, sending a 1 to X (drive 0) will make it go forwards, sending a 0 will make it go backwards. Obviously to be used with extreme caution...

Notes

1RepRapFirmware 1.14 and later support the T parameter, to allow the step pulse width and interval to be lengthened for those drivers that need it. If no T parameter is given, then the step pulse width and interval are guaranteed to be suitable for the on-board drivers. Currently, RepRapFirmware only remembers the highest T parameter seen in any M569 command, and applies that value to all drivers for which any nonzero T parameter was specified.

Some versions of RepRapFirmware prior to 1.14 also provide X, Y, Z and E 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.

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

Hnnn Heater number

Pnnn Time in seconds for which a temperature anomaly must persist on this heater before raising a heater fault (default 5 seconds)

Tnnn Permitted temperature excursion from the setpoint for this heater (default 10C)

Snnn 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

M570 H1 P4 T15

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.

Pnnn Logical pin number (RepRapFirmware 1.17 and later), defaults to the FAN0 output until M571 with a P parameter has been seen

Example

M571 P3 F200
M571 S0.5

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 S 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 P parameter to change the pin used and you can also set the PWM frequency. Pin numbers are the same as in the M42 and M280 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 M307, or if it is used for a fan you must disable the fan using M106 with the I-1 parameter.

This sets the pressure advance coefficient (S parameter) for the specified extruder (D parameter). Supported by RepRapFirmware-dc42, -ch and -dn.

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 S value between 0.1 and 0.2 usually gives the best print quality.

Older versions of RepRapFirmware used the P parameter to specify the drive number, instead of using D to specify the extruder number.

M573: Report heater PWM

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.

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.

This sets the communications parameters of the serial comms channel specified by the P parameter. P0 specifies the main serial interface (typically a USB port, or serial-over-USB), while P1 specifies an auxiliary serial port (for example, the port used to connect a PanelDue). The B parameter is the required baud rate (this parameter is typically ignored if the port is a true USB port). The S parameter is a bitmap of features. The lowest bit, if set, specifies that only commands that include a valid checksum should be accepted from this comms channel.

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

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 R field is 0. The optional P string is sent to the Roland if R is 1. It is permissible to call this repeatedly with R set to 1 and different strings in the P field to communicate directly with a Roland.

M581: Configure external trigger

Tnn Logical trigger number to associate the endstop input(s) with, from zero up to a firmware-specific maximum (e.g. 9 for RepRapFirmware)

X, Y, Z, E Selects endstop input(s) to monitor

P Reserved, may be used in future to allow general I/O pins to cause triggers

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

C Condition: whether to trigger at any time (C0, default) or only when printing a file from SD card (C1)

Example

M581 E1:2 S1 T2 C1 ; invoke trigger 2 when a rising edge is detected on the E1 or E2 endstop input and a file is being printed from SD card

When M581 is executed, if the T 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 S-1 with no X, Y, Z or E parameters sets the trigger back to ignoring all inputs.

In RepRapFirmware, trigger number 0 causes an emergency stop as if M112 had been received. Trigger number 1 causes the print to be paused as if M25 had been received. Any trigger number # greater then 1 causes the macro file sys/trigger#.g 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 M400 command at the start of your macro file. If several triggers are pending, the one with the lowest trigger number takes priority.

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.

This allows you, for example, to turn on a DC motor (see the M42 command) then wait until a switch connected to Pin Pnnn gives the value Sn.

If the R field is present, then the system waits until the value on analog Pnnn is reached. In this case the S value is used as a tolerance, so M583 P8 R0.7 S0.01 would wait until the analog value on Pin 8 was between 0.69 and 0.71.

Assigning a drive using M584 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 M584 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

Xnnn

Y-nnn

Znnn

Where the absolute value of nnn is the radius of the tool plus the radius of the probe in that direction. So M585 X1.5 will set the X offset of a 1mm diameter tool against a 2mm diameter probe, etc. If the value of nnn 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 G10 command.

Move to a position slightly offset from the probe then execute M585s in X, Y and Z in the tool selection macro to set them precisely.

After this, the G10 command on its own can be used to report the values.

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

Tnn 0 = don't use TLS, 1 = use TLS. Ignored unless S = 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 T1 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.

M586 with no S 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

Inn.nn.nn.nn (optional) IP address to use when connected to this network. If zero or not specified then an IP address will be acquired via DHCP.

Jnn.nn.nn.nn (optional) Gateway IP address to use when connected to this network.

Knn.nn.nn.nn (optional) Netmask to use when connected to this network

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.

M587 with no parameters lists all stored SSIDs, but not the stored passwords.

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.

Snn Sensitivity, for those sensor types that need it. For the Duet3D rotating magnet sensor this is the mm of filament movement per complete rotation of the sense wheel. For the Duet3D laser sensor this is a constant close to +1.0 or -1.0. For a pulse-generating sensor it is the amount of filament movement in mm per pulse.

Rnn Tolerance as a percentage of the commanded extrusion amount. A negative value puts the firmware in calibration mode.

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.

T nnn Reserved for future use, for the temperature at which these values are valid

Example

M592 D0 A0.01 B0.0005 ; set parameters for extruder drive 0

M592 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 is an experimental feature in RepRapFirmware to compensate 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.

M600: Set line cross section

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.

M605 S0: Full control mode. The slicer has full control over x-carriage movement
M605 S1: Auto-park mode. The inactive head will auto park/unpark without slicer involvement
M605 S2 [Xnnn] [Rmmm]: Duplication mode. The second extruder will duplicate the first with nnn millimeters x-offset and an optional differential hotend temperature of mmm degrees. E.g., with "M605 S2 X100 R2" the second extruder will duplicate the first with a spacing of 100mm in the x direction and 2 degrees hotter.

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.

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.

M667 S0 selects Cartesian mode (unless the printer is configured as a delta using the M665 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.

M667 S1 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.

M667 S2 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.

M667 S3 selects CoreYZ mode. Forward movement of the Y motor moves the head in the +Y and +Z directions. Forward movement of the Z motor moves the head in the -Y and +Z directions.

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.

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 M668. 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 I 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.

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 serial SCARA kinematics

Pnnn 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 axis

Bnnn:nnn Proximal-to-distal arm joint movement minimum and maximum angles, in degrees anticlockwise seen from above relative to both arms in line

Cnnn: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 segmentation

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 kinematics

Raaa: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.

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.

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

Snn:nn:nn... Sequence of 8-bit unsigned values to send to the currently-selected Z probe

Example

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

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 the firmware does the following:

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

If this code is called without any parameters, RepRapFirmware will report the name of the loaded filament (if any).