GCodes are a widely used machine control language. They are human readable and editable. This page describes the RepRapFirmware supported GCodes. RepRapFirmware follows the philosophy of "GCode everywhere", in essence the users or external program's interaction with the firmware should be through GCodes. There are GCodes for all supported control and configuration inputs along with status and debugging information.
RepRapFirmware GCodes were originally based on the information from the RepRap wiki GCode page. There are some GCodes listed on that page that are not implemented in RepRapFirmware. More details can be found on the GCodes not implemented page.
A typical piece of GCode sent to a machine running RepRapFirmware might look like this (The meaning of these codes (and more) is explained below on this page.)
G10 P0 S195 R175 T0 G1 X100 Y100 Z0.3 F3000 G1 X100.4 Y99.3 E0.23 F600 ...many 1000s more lines...
A design philosophy of RepRapFirmware is "GCode everywhere" what this means is explained in this sub section
The GCode can originate from a number of sources:
In all cases the GCode could
A key difference from other 3d printer firmwares is not employing a separate command set (other than GCodes) to configure the printer. To that end RepRapFirmware has a large collection of configuration GCodes that allow the behaviour of the machine to be controlled. For some examples of when these GCodes are employed have a look at these wiki pages:
The advantage of "GCode everywhere" is the same commands can be send from any of the GCode sources, and originate from the user, a UI, macro or file and it will generate the same response from the firmware. This greatly improves the ease and power of firmware configuration and operation.
This section explains the elements that make up a GCode command.
The general rule on command order in config.g is: don't try to change the parameters of anything that you haven't already created and doesn't exist by default.
For example:
GCode comments begin at a semicolon, and end at the end of the line:
T0 ; This is a comment G92 E0 ;So is this G28
In CNC mode only (M453), comments can be enclosed in a single pair of parentheses, e.g. (comment)
. Comments cannot include double or nested parentheses, e.g. (comment (a bit more comment))
, and they must start and end on the same line. This complies with NIST Gcode interpreter guidelines.
G28 (here come the axes to be homed) X Y
Comments and white space will be ignored by RepRapFirmware when executing the GCode.
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 3.01 and later, instead of a number you may use an expression enclosed in braces, for example {2+2}. See GCode Meta Commands for details of the supported expression types.
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 |
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 |
A,B,C | Additional axis coordinates in some commands, used for various purposes in others |
Dnnn | Parameter - used for diameter; derivative (Kd) in PID Tuning; drive number; or additonal axis |
Innn | Parameter - X-offset in arc move; integral (Ki) in PID Tuning |
Jnnn | Parameter - Y-offset in arc move |
K n | Typically used for Z probe number |
Hnnn | Parameter - usually used for a heater number |
Fnnn | Feedrate in mm per minute. (Speed of print head movement) |
Rnnn | Parameter - used for temperatures |
Qnnn | Parameter - usually a frequency |
Ennn | Length of filament to move through the extruder. This is exactly like X, Y and Z, but for the length of filament to consume. Where a tool has more than one extruder drive then Ennn:nnn:nnn etc is supported to allow for the individual morement of each to be controlled directly |
Nnnn | Line number. Used to request repeat transmission in the case of communications errors. Optional |
*nnn | Checksum. Used to check for communications errors. Optional |
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.
RepRapFirmware version 1.19 and later is case-insensitive, except for characters within quoted strings. RepRapFirmware version 1.18 and earlier accept only uppercase letters for command and parameter letters.
In RepRapFirmware, quoted strings are permitted anywhere a string parameter is expected. 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"
This is an optional feature that is seldom used as GCode files are normally printed from the on-board SD card.
Example: N123
If present, the line number should be the first field in a line. For GCode stored in files on SD cards the line number is usually omitted.
If checking is supported, the firmware expects line numbers to increase by 1 each line, and if that doesn't happen it is flagged as an error. But you can reset the count using M110 (see below).
Example: *71
If present, the checksum should be the last field in a line, but before a comment. For GCode stored in files on SD cards the checksum is usually omitted.
If checking is supported, the RepRap firmware checks the checksum against a locally-computed value and, if they differ, requests a repeat transmission of the line of the given number.
Example: N123 [...G Code in here...] *71
The firmware checks the line number and the checksum.
You can leave both of these out - RepRapFirmware 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. See this forum thread for an example of usage, in this case sending GCode to the PanelDue port without disabling checksums.
The checksum "cs" for a GCode string "cmd" (including its line number) is computed by xor-ing the bytes in the string up to and not including the * character as follows:
int cs = 0; for(i = 0; cmd[i] != '*' && cmd[i] != NULL; i++) cs = cs ^ cmd[i]; cs &= 0xff; // Defensive programming...
and the value is appended as a decimal integer to the command after the * character.
Checksums provide poor protection against data corruption. RRF 3.4 and later allow a 16-bit CRC to be used instead.
In RepRapFirmware 3.01 and later, if the line begins with a recognised keyword (optionally preceded by N and a line number, and/or space or tab characters) then that whole line of GCode is interpreted as a meta-command. Recognised keywords are:
abort echo elif else global if set var while
See GCode Meta Commands for details of these commands.
A line that does not start with one of these keywords must start with command letter G, M or T or be empty apart from white space and comments. Exception: when in CNC or Laser mode, if a line does not start with a G, M or T command but nevertheless has other fields, and the previous line that included a command was a G0, G1, G2 or G3 command, then the previous command will be repeated with values from the new fields. This is to support GCode generated for CNC machines.
RepRapFirmware allows multiple G- and M-commands to be included in a single line. Each occurrence of G or M on the line that is preceded by a space or tab character and is not inside a quoted string or a meta command starts a new command. In RRF 3.2 and later, the space or tab character is not required.
Important: a command that invokes a macro file (such as G28, G29, G32 and M98) must be the last command in that line of GCode, because any following commands on the same line will not be executed. A T (tool change) command must be on a line by itself.
RepRapFirmware stores regular G0, G1, G2 and G3 movement commands in a 'move queue' internally for execution, equivalent to a look-ahead buffer. These commands are acknowledged when they are placed in the queue. This means that there is no appreciable delay before a command is acknowledged unless the move queue is full, and that sequences of line segments can be plotted without coming to a stop between one and the next.
Some non-movement commands are also queued when executed from a job file or a macro, in a 'deferred command queue'. This operates in parallel to the 'move queue', and together the two queues operate as a single logical queue, and generally can be considered as one queue.
Non-movement commands behave like this:
As soon as one of these commands is received it is acknowledged and stored locally in the queue. If the queue is full, then the acknowledgement is delayed until space for storage in the queue is available. PC host programs rely on this for flow control when the controller electronics does not support device level flow control.
Notes
{ }
then the command is not queued because the value of the OM expression is liable to change, and there isn't a suitable context to evaluate it in if it were to be queued.0:/gcodes/0123456789/012.gcodecounts as 30 characters
As a general rule, any G or M command can be sent at any time. This means all settings can be changed 'on the fly', i.e. while printing. This does not take into account logical considerations, or individual pre-requisites for individual commands. For example, sending new values for M566 'jerk', M201 'acceleration', or M203 'max speed' while printing is a great way to tune these values. However, while it is theoretically possible to change M563 'define a tool' while printing, it's probably not a good idea.
For a list of GCodes that may be found in other firmwares/CNC control software which are not implemented in RepRapFirmware, see GCodes not implemented.
In RepRapFirmware 2.03 and later, you can create custom GCodes, so long as the GCode is not already implemented. If you try to execute a G- or M-command that RRF does not implement, it will execute a system macro of that name if it exists. For example, if you send G40 then it will execute /sys/G40.g if it exists; and if you send M5000 then it will execute /sys/M5000.g if it exists.
In RRF 3.4 and later this extends to G- and M-commands with fractional numbers, for example if you send M55.6 then RRF will look for file "0:/sys/M55.6.g".
The maximum length of a gcode command including the command itself and all parameters is 256 characters.
Same as G1 except as follows:
See 'G1: Controlled linear' move for usage.
RRF2.02 and later, RRF3
RRF2.01 and earlier
1Where a tool has more than one extruder drive then Ennn:nnn:nnn etc is supported to allow for the individual movement of each to be controlled directly. This overrides the extruder mix ratio set with M567
Very important! If you use M452 to put your machine into Laser mode, when upgrading firmware from 2.01 or earlier to 2.02 or later you must replace all S parameters in G0/G1 commands in homing files etc. by H parameters. This is because S is now used to control laser power, for compatibility with programs that generate GCode files for laser cutters.
G0 X12 ; (move to 12mm on the X axis) G0 F1500 ; (Set the feedrate to 1500mm/minute) G1 X90.6 Y13.8 E22.4 ; (Move to 90.6mm on the X axis and 13.8mm on the Y axis while extruding 22.4mm of material) G1 E10:10:5:0:0 F300 ; with a tool that has 5 extruder drives, extrude 10mm on drive 0, 10mm on drive 1, 5mm on drive 2 and 0mm on drive 3 and 4.
RepRapFirmware treats G0 and G1 in the same way except as follows:
The meaning of the H parameter is as follows:
The meaning of the S parameter has changed over successive versions of RepRapFirmware. It currently sets the laser power when M452 Laser mode is set, but was also used for homing behaviour. See below.
In RRF 3.x:
RRF 3, G0/G1 H parameter BEFORE and AFTER M452 Laser Mode. | |
---|---|
Parameter | Meaning |
G1 Xnnn Ynnn Znnn H0 (default) | Ignore endstops while moving but apply axis limits. Don't allow movement if the axis has not previously been homed unless M564 has been used to allow it. |
G1 Xnnn Ynnn Znnn H1 | Sense endstops while moving (ignoring the axis limits) and stop when the endstop is hit. On Delta, Scara and Polar machines, axis letters refer to individual motors. |
G1 Xnnn Ynnn Znnn H2 | Ignore endstops and axis limits while moving. Also ignore if axis has not been homed. On Delta, Scara, Polar and Core XY machines axis letters refer to individual towers (delta) or individual joint motors (scara) or A/B motors (CoreXY). |
G1 Xnnn Ynnn Znnn H3 | Sense endstops while measuring axis length, setting the appropriate M208 limit to the measured position at which the endstop switch triggers. |
G1 Xnnn Ynnn Znnn H4 | Sense endstops while moving, update the current position at which the endstop switch triggers (supported in RRF 3.2 and later). |
RRF 3, G0/G1 S parameter BEFORE M452 Laser Mode. | |
---|---|
S parameter is ignored |
RRF 3, G0/G1 S parameter AFTER M452 Laser Mode. | |
---|---|
S parameter sets laser power with range of 0-255. |
In RRF 3.5.0-beta3 and later:
To increase the speed of raster engraving, raster clustering mode has been implemented. A single G1 move is split up into equal portions by multiple values in the S parameter, eg G1 X50 S100:50:25:50:100
would move 50mm and change the laser power every 10mm. This allows more commands to fit in the command buffer, to keep speed up. Laser cutter software such as Lightburn supports raster clustering.
In RRF 2.02 to 2.05.1:
RRF 2.02 to 2.05.1, G0/G1 H parameter BEFORE and AFTER M452 Laser Mode. | |
---|---|
Parameter | Meaning |
G1 Xnnn Ynnn Znnn H0 | Ignore endstops while moving. |
G1 Xnnn Ynnn Znnn H1 | Sense endstops while moving (ignoring the axis limits). On Delta (only), axis letters refer to individual towers. |
G1 Xnnn Ynnn Znnn H2 | Ignore endstops while moving. Also ignore if axis has not been homed. On Delta and Core XY, axis letters refer to individual towers. |
G1 Xnnn Ynnn Znnn H3 | Sense endstops while measuring axis length, setting the appropriate M208 limit to the measured position at which the endstop switch triggers. |
RRF 2.02 to 2.05.1, G0/G1 S parameter BEFORE M452 Laser Mode. | |
---|---|
Parameter | Meaning |
G1 Xnnn Ynnn Znnn S0 | Ignore endstops while moving. |
G1 Xnnn Ynnn Znnn S1 | Sense endstops while moving. On Delta (only), axis letters refer to individual towers. |
G1 Xnnn Ynnn Znnn S2 | Ignore endstops while moving. Also ignore if axis has not been homed. On Delta and CoreXY, axis letters refer to individual towers. |
G1 Xnnn Ynnn Znnn S3 | Sense endstops while measuring axis length, and set the appropriate M208 limit to the measured position at which the endstop switch triggers. |
RRF 2.02 to 2.05.1, G0/G1 S parameter AFTER M452 Laser Mode. | |
---|---|
S parameter sets laser power with range of 0 to 255. |
In RRF 2.01 and earlier:
RRF_2.01 and earlier, G0/G1 S parameter | |
---|---|
Parameter | Meaning |
G1 Xnnn Ynnn Znnn S0 | Ignore endstops while moving. |
G1 Xnnn Ynnn Znnn S1 | Sense endstops while moving. On Delta (only), axis letters refer to individual towers. |
G1 Xnnn Ynnn Znnn S2 | Ignore endstops while moving. Also ignore if axis has not been homed. On Delta and CoreXY, axis letters refer to individual motors. |
G1 Xnnn Ynnn Znnn S3 | Sense endstops while measuring axis length, and set the appropriate M208 limit to the measured position at which the endstop switch triggers. |
G1 F1500 G1 X50 Y25.3 E22.4
In the above example, we set the feedrate to 1500mm/minute on line 1, then move to 50mm on the X axis and 25.3mm on the Y axis while extruding 22.4mm of filament between the two points.
G1 F1500 G1 X50 Y25.3 E22.4 F3000
However, in the above example, we set a feedrate of 1500mm/minute on line 1, then do the move described above accelerating to a feedrate of 3000 mm/minute as it does so. The extrusion will accelerate along with the X and Y movement, so everything stays synchronized.
Feedrate is treated 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 such a way that ensures that everything moves smoothly together, and the right volume of material is extruded at all points. The feedrate specified may not be reached due to a lower feedrate limit being configured, or the move being too short for the axis to accelerate and decelerate in time.
For CNC users especially: RRF has a default minimum movement speed of 0.5mm/sec. In firmware 2.03 and later this can be changed using the I ('i') parameter of the M203 command.
The firmware keeps track of the exact number of microsteps sent to each movement axis using a 32-bit signed integer microstep counter, this limits the maximum absolute move and axis length to (2^31 - 1) microsteps. This does not apply to extruder drives. The firmware multiplies the requested axis position (after adding any offsets) by the steps/mm to get the required microstep position and the microstep counter accumulates across multiple moves, as the axis position increases it increments, as it decreases it decrements. The maximum size of the microstep counter is only an issue for situations where an axis needs to accommodate one or more moves or an overall axis length that would overflow the counter (i.e. an extremely long axis, or an extremely high resolution axis). In typical uses this is not a concern, for example on a standard linear axis using 160 microsteps/mm an axis of over 13km is supported. In cases where the microstep counter is not sufficient (e.g. a very high resolution rotary axis moving for a very long time) G92 can be used to set the origin to a new point on the axis and thus reset the counter.
In a similar manner, if the requested axis position gets very large then accuracy will suffer, because it is held and calculated as a 32-bit float.
Clockwise arc move. Supported by RRF 1.18 and later in FDM mode, RRF 1.20 and later in CNC mode, and RRF 2.01 and later in Laser mode.
See 'G3: Controlled Arc Move' for usage.
Counter-clockwise arc move. Supported by RRF 1.18 and later in FDM mode, RRF 1.20 and later in CNC mode, and RRF 2.01 and later in Laser mode.
Either the R parameter must be provided, or at least one of I and J must be provided. To draw a complete circle, define the position of the centre using I and/or J and make X and Y the same as the current X and Y coordinates.
1Where a tool has more than one extruder drive then Ennn:nnn:nnn etc is supported to allow for the individual movement of each to be controlled directly. This overrides the extruder mix ratio set with M567
G2 X90.6 Y13.8 I5 J10 E22.4 ; (Move in a Clockwise arc from the current point to point (X=90.6,Y=13.8), with a center point at (X=current_X+5, Y=current_Y+10), extruding 22.4mm of material between starting and stopping) G3 X90.6 Y13.8 I5 J10 E22.4 ; (Move in a Counter-Clockwise arc from the current point to point (X=90.6,Y=13.8), with a center point at (X=current_X+5, Y=current_Y+10), extruding 22.4mm of material between starting and stopping) G2 X100 Y50 R200 ; (draw a clockwise arc with radius 200 from the current position to X=100 Y=50)
G1 X50 Y0 G2 X60 Y0 J10
Pause the machine for a period of time.
G4 P200 ; wait for 200 milliseconds
In this case, sit still doing nothing for 200 milliseconds. The state of the machine, for example the bed and extruder temperatures, will still be preserved and controlled during the delay.
Note that this use of G10 may be deprecated in a future version of RRF, although it will remain available for a substantial time. It will be replaced with M568 which can already be used for temperature setting in firmware 3.3beta2 and later.
This form of the G10 command is recognised by having a P combined with at least an R or S parameter.
The tool must be created with M563 before it is referenced with this command.
G10 P1 R140 S205 ; set standby and active temperatures for tool 1
Remember that any parameter that you don't specify will automatically be set to the last value for that parameter.
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.
Temperatures set with G10 do not wait for the heaters to reach temp before proceeding. In order to wait for the temp use a M116 command after the G10 to wait for temps to be reached.
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 .
This form of the G10 command is recognised by having either or both of the L and P parameters. Supported on the Duet 2 series and later Duets.
Modes
1Tool 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.
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 independent carriages. When all the tools are in the machine at once they should all be positioned at the same Z height to avoid a lower tool colliding with the object while a higher tool is printing.
Tool offsets are given as the offset of the nozzle relative to the print head reference point, so the signs are opposite to what you might expect because tool offsets are subtracted from the required printing locations during printing.
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.
See also M585.
Tool Offset Examples
G10 P2 X17.8 Y-19.3 Z0.0 ; sets the offset for tool 2 to the X, Y, and Z values specified G10 L1 P2 X17.8 Y-19.3 Z0.0 ; sets the offset for tool 2 to the X, Y, and Z values specified
Coordinate Offset Example
Suppose the current machine coordinates are X110 Y110 Z20
and you want to make this the origin (i.e. X0 Y0 Z0
) of the second coordinate system (accessible via G55) then there are two options:
G10 L2 P2 X110 Y110 Z20
G10 L20 P2 X0 Y0 Z0
The first example will set offsets to be subtracted from the current machine coordinates.
The second example will set the coordinates of the current position in the specified coordinate system directly.
If this command refers to any axes other than X, Y and Z then it must appear later in config.g than the M584 command that creates those additional axes.
This form of the G10 command is recognised by having no parameters.
G10
G11
Supported from RepRapFirmware 3.3beta1.
Parameters: none
The active plane determines how the tool path of an arc (G2 or G3) is interpreted.
Supported from RepRapFirmware 3.3beta1.
See 'G17: Select XY plane for arc moves' for usage.
Supported from RepRapFirmware 3.3beta1.
See 'G17: Select XY plane for arc moves' for usage.
G20 ; set units to inches
Units from this command onwards are in inches. Note that this is only intended to affect G0, G1 and other commands commonly found in GCode files that represent objects to print. Specifically G20 only affects: G0 to G3, G10 and G92. So you should use metric values in config.g when configuring the printer and then change to inches with G20 at the end of it if the GCodes you want to send to move the machine are expressed in inches by default.
G21 ; set units to millimeters
Units from this command onwards are in millimeters. This is the default.
This command can be used without any additional parameters.
Restrictions
This command may not be used within a homing file.
G28 ; Home all axes G28 XZ ; Home the X and Z axes
The X and Z parameters in this example 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 if the Firmware is in Delta mode.
The purpose of homing is to move the specified axes in such a way as to establish a known position for them, for example by moving an axis motor until an endstop switch is triggered. Homing an axis normally leaves it in a fixed position, however this position needs not be the zero position.
The way in which each axis is homed is completely configurable using the homing macro files, which specify what actions are taken. Execution of the G28 command is as follows:
For Cartesian printers that use a Z probe to home Z instead of an endstop it is sensible to setup the homeall.g with the XY axes to home first, then move the carriage to a safe position –usually the middle of the bed– where it can safely probe downward to home Z. For an example see Configuring RepRapFirmware for a Cartesian printer.
Neither homeall.g nor any other homing file may itself contain a G28 command, however it may use a M98 command to invoke another homing file.
Because the behaviour of G28 can be complex, it is recommended to consider the printer actions carefully before including G28 in your ending GCode. On a Cartesian or CoreXY it could result in colliding with the printed object. An alternative to move the carriage at the completion of a print is to use G0 or G1.
This command uses a probe to measure the bed height at 4 or more points to determine its tilt and overall flatness. It then enables mesh bed compensation so that the nozzle will remain parallel to the bed. The printer must be homed with G28 before using this command.
G29 S0 ; Probe the bed, save height map to "heightmap.csv" and enable mesh bed compensation G29 S3 P"usual.csv" ; Save the current height map to file "usual.csv" G29 S2 ; Disable mesh bed compensation G29 S1 P"usual.csv" ; Load height map file "usual.csv" and enable mesh bed compensation G29 S4 P"probePoints.csv" ; Load probe points file "probePoints.csv"
G29 S4 P"probePoints.csv"
.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, just report the machine height at which the probe was triggered. G30 S-2 ; Probe the bed at the current XY position. When the probe is triggered, adjust the Z offset of the current tool to make the current position Z=0. G30 S-3 ; Probe the bed and set the Z probe trigger height to the height it stopped at (supported in RRF 2.03 and later)
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
Caution: the XY coordinates are permitted to be outside the normal printable bed area! This is intentional, because some printers (e.g. delta printers) benefit from probing areas not used for printing.
G30 without a P parameter
This probes the bed starting at the current height. Depending on the value of the S parameter (0, -1, -2 or -3) it can be used to home the Z axis, to measure the Z probe trigger height, to adjust the Z offset of the current tool, or to adjust the Z probe trigger height.
G30 with a P parameter
This is used for operations that are performed after the printer has been homed and that require the height error at more than one probe point to be measured. These operations are typically performed in the bed.g file, with a G30 line for each probe point. With a Z parameter of -9999 or lower, the head moves to the specified XY coordinates and the dive height (set using the H parameter in the M558 command), and probes the bed.
For example, a bed.g for a Cartesian/CoreXY machine probing 3 points might be:
G28 ; home G30 P0 X20 Y190 Z-99999 ; probe point 0 near a leadscrew G30 P1 X180 Y190 Z-99999 ; probe point 1 near a leadscrew G30 P2 X100 Y10 Z-99999 S3 ; probe point 2 near a leadscrew and calibrate 3 motors
The P parameter is the probe point number for each G30 command. It should start at P0 and increase sequentially for each additional probe point.
The S parameter on the last G30 command in the sequence indicates that a complete set of points has been probed and instructs the firmware what sort of calibration to perform.
NOTE: From RepRapFirmware version 1.09 to 3.01-RC4, the number of factors may be 3, 4 or 5 when doing old-style auto bed compensation on a Cartesian or CoreXY printer. This form of bed compensation has been removed in RRF 3.01-RC5 and later.
If a "normal" Z parameter is given instead of -9999 or lower, then the bed is not probed, but instead that value is used as if the Z probe had triggered at that height.
The H parameter is an optional 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. For example, when doing delta calibration, it can account for the change in trigger height caused by effector tilt, if the vertical offset caused by the tilt has been measured.
The K parameter is applicable to all G30 commands. It is the Z probe number, default 0. It is not remembered between G30 commands, it always defaults to 0.
Using a Scanning Z Probes as a normal Z probe is supported in RRF 3.5.0-rc.3 and later.
1 X,Y,U,V,W,A,B,C...nnn offsets of the Z probe relative to the print head (i.e. the position when the empty tool is selected) can be specified. This allows you to calculate your probe coordinates based on the geometry of the bed, without having to correct them for Z probe X,Y,U,V,W,A,B,C...nnn offset.
2 Optional parameter 'S' specifies the temperature in °C at which the specified Z parameter is correct. The default is current temperature. In RRF3 you must specify which temperature sensor to use in the 'H' parameter.
3 Optional parameter 'T' specifies one, or two, temperature coefficients of the Z parameter, default zero. This is useful for probes that are affected by temperature.
G31 Z1.2 T0.02 S20 H2
when sensor 2 measures 26C would calculate trigger height as 1.2 + 0.02x6x6 = 1.92mmG31 Z1.2 T0.03:0.02 S20 H2
when sensor 2 measures 26C would calculate trigger height as 1.2 + 0.03x6 + 0.02x6x6 = 2.1mm1 X 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. 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.
2 Optional parameter 'S' specifies the temperature in °C at which the specified Z parameter is correct. The default is current temperature. In RRF3 you must specify which temperature sensor to use in the 'H' parameter.
3 Optional parameter 'C' specifies one, or two (RRF v3.2), temperature coefficients of the Z parameter, default zero. This is useful for probes that are affected by temperature.
G31 Z1.2 C0.02 S20 H2
when sensor 2 measures 26C would calculate trigger height as 1.2 + 0.02x6x6 = 1.92mmG31 Z1.2 C0.03:0.02 S20 H2
when sensor 2 measures 26C would calculate trigger height as 1.2 + 0.03x6 + 0.02x6x6 = 2.1mm1 X 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. 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.
2 Optional parameter 'S' specifies the temperature in °C at which the specified Z parameter is correct. The default is current temperature. In RRF2 the bed temperature reading is used.
3 Optional parameter 'C' specifies the temperature coefficient of the Z parameter, default zero. This is useful for probes that are affected by temperature. When the parameter is specified, it is the variation in Z parameter height with the change in sensor temperature in mm/°C. The parameter is applied to the difference between current measured temperature and calibration temperature 'S'. For example, G31 Z1.2 C0.02 S20
when the bed measures 26C would calculate trigger height as 1.2 + 0.02x6x6 = 1.92mm
4 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.
G31 P500 Z2.6 G31 X16.0 Y1.5
; RRF 3.3 and later example of probe with thermistor and temperature compensation M558 P8 C"io2.in" H1 F1000 T6000 A3 ; Prusa PindaV2 Endstop M308 S2 P"temp2" A"Pinda V2" Y"thermistor" T100000 B3950 ; Prusa PindaV2 Thermistor G31 P500 X23 Y5 Z1.1 S21 H2 T0.02 ; Nozzle offset - Smooth Sheet
A G31 command to set Z probe parameters must come after the M558 command that defines the Z probe.
It must also come after M584 if it references any axes beyond X and Y (RRF >=3.3beta2).
In RRF 3.3 and later any parameters will be passed to macro file bed.g.
G32 ; execute macro bed.g
The firmware executes macro file bed.g. This macro normally uses G30 commands to probe the bed and then perform auto calibration of a delta printer (see Calibrating a delta printer), or perform bed levelling by moving the Z leadscrews independently, or display the manual corrections needed to the bed levelling screws.
For more detail on using G32 for automatic Delta calibration see: Calibrating a delta printer
For more detail on using G32 for automatic leveling of a cartesian or CoreXY see: Bed levelling using multiple independent Z motors
For more detail on using G32 for manual bed leveling assistant see: Using the manual bed levelling assistant
Probe toward workpiece, stop on contact, signal error if failure. Supported in RepRapFirmware 3 and later.
Modes
Conditions considered an error (for G38.2 and G38.4)
G38.x Straight Probe will perform a probing move in a straight line with the currently active or selected (Pnnn) probe. It will either move towards an obstacle (usually a workpiece) and stop on contact or move away from an obstacle until the probe loses contact.
Note: for probing away the probe used does not have to be inverted. This command will take care of that.
Feedrate used for this move is the configured feedrate of the used probe (see M558 Fnnn).
Probe toward workpiece, stop on contact Supported in RepRapFirmware 3 and later.
See 'G38.2: Straight Probe' for usage.
Probe away from workpiece, stop on loss of contact, signal error if failure. Supported in RepRapFirmware 3 and later.
See 'G38.2: Straight Probe' for usage.
Probe away from workpiece, stop on loss of contact. Supported in RepRapFirmware 3 and later.
See 'G38.2: Straight Probe' for usage.
Supported on the Duet 2 and later Duets only.
G53 G1 X50 Y50 Z20 ; these moves are in machine coordinates G1 X100 Y100 Z20 ; these moves, on the line after G53, are in the currently selected coordinate system
G53 causes all coordinates in movement commands on the remainder of the current line of GCode to be interpreted as machine coordinates, ignoring any coordinate offset of the workplace coordinate system currently in use, and also ignoring any tool offsets. G53 is not modal and must be programmed on each line on which it is intended to be active. On the following line without G53, the coordinate system reverts to the currently selected coordinate system.
See the NIST GCode Interpreter Version 3 standard for more details.
Selects coordinate system 1. Supported on the Duet 2 and later Duets only.
G54 selects coordinate system 1, G55 selects coordinate system 2 etc. up to G59 which selects coordinate system 6. G59.1 selects coordinate system 7, G59.2 selects system 8 and G59.3 selects system 9.
Initially, coordinate system 1 is in use, and all coordinate systems have zero offset from the machine coordinates. To set coordinate system offsets, use the G10 command with the L2 parameter.
See the NIST GCode Interpreter Version 3 standard for more details.
Selects coordinate system 2. Supported on the Duet 2 and later Duets only.
See 'G54: Select coordinate system' for usage.
Selects coordinate system 3. Supported on the Duet 2 and later Duets only.
See 'G54: Select coordinate system' for usage.
Selects coordinate system 4. Supported on the Duet 2 and later Duets only.
See 'G54: Select coordinate system' for usage.
Selects coordinate system 5. Supported on the Duet 2 and later Duets only.
See 'G54: Select coordinate system' for usage.
Selects coordinate system 6. Supported on the Duet 2 and later Duets only.
See 'G54: Select coordinate system' for usage.
Selects coordinate system 7. Supported on the Duet 2 and later Duets only.
See 'G54: Select coordinate system' for usage.
Selects coordinate system 8. Supported on the Duet 2 and later Duets only.
See 'G54: Select coordinate system' for usage.
Selects coordinate system 9. Supported on the Duet 2 and later Duets only.
See 'G54: Select coordinate system' for usage.
Supported in firmware 1.21 and later.
RepRapFirmware for Duets generally provides slots 0 thru 5. When a print is paused the coordinates are saved to slot 1 automatically, and at the start of a tool change the coordinates are saved to slot 2 automatically. The remaining slots are free to use for any purpose. Use G0 or G1 with the appropriate R parameter to move the current tool to a saved position.
Note: Do not use G60 in pause.g . It is not needed as the co-ordinates are saved in slot 1 automatically. Using it in pause.g can lead to issues with restoring the primary and secondary motion system correctly in RRF 3.5.1
Rotates the coordinate system in the current plane as selected by G17, G18 or G19. You may either specify the coordinates of the two axes of the selected plan (e.g. X and Y if using the default XY plane or after G17) or you may specify A and B coordinates.
RepRapFirmware implements G68 for the XY plane only. Coordinate rotation is not applied if any of the following is true:
Note: if G68 coordinate rotaton is in effect and you use one of G54 thru G59.3 to switch to a different workplace coordinate system, the rotation origin will move in line with the origin of the workplace coordinate system.
This cancels any coordinate rotation that was set up by G68.
All coordinates from now on are absolute, relative to the origin of the machine.
All coordinates from now on are relative to the last position.
G92 X10 E90
Allows manual specification of the axis positions by setting the current user position to the values given. The machine position is updated as necessary taking into account tool offsets and workplace coordinate offsets. The example above would set the machine's X user coordinate to 10, and the extruder coordinate to 90. No physical motion will occur. In RepRapFirmware, a G92 without coordinates does nothing.
CNC specific. Supported from firmware version 3.5
G93
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, F2.0 means the move should be completed in a half a minute.
CNC specific. Supported from firmware version 3.5
G94
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.
M0
The effect of M0 depends on the state of the machine.
Note: From RRF 3.5b1, When a print file completes normally then file stop.g is run automatically even if the print file did not end with a M0 command.
See also M1 - sleep or conditional stop, M112 - emergency stop.
M1
The effect of M1 depends on the state of the machine.
G and M codes can still be sent, the first of which will wake it up again. See also M0 - stop or unconditional stop, M112 - emergency stop.
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.
M2
This command terminates the current job. At present, it behaves just like M0.
Supported in v3.5-b1 and later.
Supported in RepRapFirmware version 1.20 and later when the device mode is set to CNC mode (for CNC mode, see M453).
Supported in RepRapFirmware version 2.01 and later when the device mode is set to CNC and laser mode (for laser mode, see M452).
Supported in RepRapFirmware version 3.5 and later when the device mode is set to CNC, laser and FFF mode (for FFF mode, see M451).
M3 S4000 ; CNC mode, turn on spindle at speed of 4000 RPM, clockwise M3 S255 ; laser mode, set laser power to full on
M3 S255
, then subsequent G1 moves will use that setting without needing an S parameter. Alternatively set the laser power with the first G1 S command, and subsequent G1 commands will use that setting, until either an M3 S0
, G1 S0
or M5
is sent.M3 S255
, then subsequent G1 moves will use that setting without needing an S parameter. Alternatively set the laser power with the first G1 S command, and subsequent G1 commands will use that setting, until either an M3 S0
or M5
is sent.Supported in RepRapFirmware version 1.20 and later when the device mode is set to CNC mode (for CNC mode, see M453).
Supported in RepRapFirmware version 3.5 and later when the device mode is set to CNC and FFF mode (for FFF mode, see M451).
M4 S4000 ; turn on spindle at speed of 4000 RPM, counterclockwise
Supported in RepRapFirmware version 1.20 and later when the device mode is set to CNC mode (for CNC mode, see M453).
Supported in RepRapFirmware version 2.01 and later when the device mode is set to CNC and laser mode (for laser mode, see M452).
Supported in RepRapFirmware version 3.5 and later when the device mode is set to CNC, laser and FFF mode (for FFF mode, see M451).
M5 ; turn off spindle/laser
M5
(or M3 S0
or G1 S0
) will turn off the laser, and subsequent G1 commands (without an S parameter) will not fire the laser until another M3 S# or G1 S# command is sent.M5
(or M3 S0
or G1 S0
) will turn off the laser, and subsequent G1 commands (without an S parameter) will not fire the laser until another M3 S# or G1 S# command is sent.Available in RepRapFirmware 3.3beta2 and later.
M17 M17 X E0
Enables all axis and extruder motors when used without parameters. Motors can also be enabled selectively. For example, M17 X E0:2 will enable the X, extruder 0 and extruder 2 motors. Use this command to energise a motor for stealthChop tuning, followed by a short pause eg G4 P100 to allow the driver to establish the motor parameters.
M18 ; Disable all axis and extruder motors M18 X E0:2 ; Disable X, extruder 0 and extruder 2 motors.
M20 ; lists all files in the default folder of the internal SD card (0:/gcodes) M20 S2 P"/gcodes/subdir" ; lists all files in the gcodes/subdir folder of the internal SD card, using JSON format M20 P"1:/" ; lists all files on the secondary (PanelDue) SD card's root
If Marlin compatibility is enabled, a file list response is encapsulated:
Begin file list: Traffic cone.g frog.gcode calibration piece.g End file list ok
If RepRapFirmware emulates no firmware compatibility, a typical response looks like:
GCode files: "Traffic cone.g","frog.gcode","calibration piece.g"
RepRapFirmware always returns long filenames in the case in which they are stored.
If the S2 parameter is used 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". Example:
M20 S2 P"/gcodes" {"dir":"/gcodes","first":0,"next":0,"files":["4-piece-1-2-3-4.gcode","Hinged_Box.gcode","Hollow_Dodecahedron_190.gcode","*Calibration pieces"]}
Returned value "first" is the number of files that were skipped (as specified in the R parameter), and "next" is the number to skip next time to retrieve the next block of filenames. If "next" is zero then there are no more filenames.
The S3 parameter is similar to S2 but includes "type", "name", "size", "date", e.g.
M20 S3 R23 { "dir": "0:/gcodes/", "first": 23, "files": [ { "type": "f", "name": "Hinged_Box.gcode", "size": 179638, "date": "2022-11-09T18:56:02" }, { "type": "f", "name": "frog.gcode.gcode", "size": 612786, "date": "2022-11-09T14:06:32" } ], "next": 0 }
The specified SD card is initialized.
M21 M21 P1
In SBC mode and RRF v3.4 or newer this code may be used to mount block devices or remote endpoints using the mount command.
0:/gcodes/remote
, optional if the device node is already present in /etc/fstab)M21 P"192.168.1.222:3D" S"0:/gcodes/remote" T"nfs" M21 P"//192.168.1.222/3D" S"0:/gcodes/remote" T"cifs" O"user=myUser,password=myPass" M21 P"curlftpfs#ftp://192.168.1.222:/3D" S"0:/gcodes/remote" T"fuse" O"user=myUser:myPass" ; requires curlftpfs package
The specified SD card is released, so further (accidental) attempts to read from it are guaranteed to fail.
M22 M22 P1
In SBC mode and v3.4 or newer this code may be used to unmount block devices or remote endpoints using the mount command.
M22 P"0:/gcodes/remote"
M23 filename.gco
The file specified as filename.gco is selected ready for printing. RepRapFirmware supports long filenames as well as 8.3 format.
Full paths, including all directories and subdirectories are limited to 120 characters.
e.g.;
0:/gcodes/0123456789/012.gcode
counts as 30 characters
M24
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, the macro file resume.g is run prior to resuming the print.
M25
The machine pauses printing at the current position within the file. To resume printing, use M24. Do not use this code to pause the print in the currently printing GCode file, use M226 instead. M226 is intended for use in the GCode file being printed, for example to pause after a particular layer has completed. So it waits until all the moves in the queue have been completed. M25 is intended for use from a different source of GCodes than the current print from SD card (like the web interface console, PanelDue or Macro).
M25 attempts to execute as quickly as possible and follows the following logic:
That means the longest it will take to pause is 1 move + 2 seconds. In most situations pause occurs much quicker than that.
After movement is halted as described above but prior to the pause operation completing, the macro file pause.g is run. This allows the head to be moved away from the print, filament to be retracted, etc.
Note that if a pause is commanded while a macro is being executed, the pause will be deferred until the macro has completed.
M26 S49315
Set the file offset in bytes from the start of the SD card file selected by M23. The offset must correspond to the start of a GCode command.
M27
Reports the number of bytes processed in this format, which can be processed by Pronterface:
SD printing byte 2134/235422
If no file is being printed, only this message is reported:
Not SD printing.
M28 filename.gco
File specified by filename.gco is created (or overwritten if it exists) on the SD card and all subsequent commands sent to the machine are written to that file.
M29
File opened by M28 command is closed, and all subsequent commands sent to the machine are executed as normal.
M30 filename.g M30 "filename.g"
filename.g is deleted.
M32 filename.g M32 "filename.g"
It can be used when printing from SD card and does the same as M23 and M24.
M36 "filename.g" M36
Returns information in JSON format for the specified SD card file (if a filename was provided) or for the file currently being printed. A sample response is:
{"err":0,"size":436831,"fileName":"EscherLizardModified.gcode","lastModified":"2017-09-21T16:58:07","height":5.20,"layerHeight":0.20,"printTime":660,"simulatedTime":1586,"filament":[1280.7],"generatedBy":"Simplify3D(R) Version 4.0.0"}
The "err" field is zero if successful, nonzero if the file was not found or an error occurred while processing it. The "size" field should always be present if the operation was successful. The presence or absence of other fields depends on whether the corresponding values could be found by reading the file. The "filament" field is an array of the filament lengths required from each spool. The size is in bytes, the times are in seconds, all other values are in mm. "printTime" is the printing time estimated by the slicer, "simulationTime" is the time measured when the print was simulated by the firmware. The fields may appear in any order, and additional fields may be present. Versions of RepRapFirmware prior to 3.4 do not provide the "fileName" field if information for a specific file was requested.
RepRapFirmware 3.4 and later also return information about thumbnail images embedded in the GCode file via an additional JSON field "thumbnails". A sample value for this field is:
"thumbnails":[{"width":32,"height":32,"fmt":"qoi","offset":103,"size":2140},{"width":220,"height":220,"fmt":"qoi","offset":2384,"size":25464}]
The "fmt" field denotes the encoding of the thumbnail and is one of "png", "qoi" or "jpeg". The "thumbnails" field is omitted entirely if there are no thumbnails embedded in the GCode file.
This command is used to return the data for a thumbnail image in a GCode file. The offset value should be either the offset of the start of data for a thumbnail as returned by the M36 command, or the value returned in the "next" field by a previous M36.1 command. The response is in JSON format.
M36.1 P"/gcodes/EscherLizardModified.gcode" S103
Sample response:
{fileName":"EscherLizardModified.gcode","offset":103,"data":"cW9pZgAAACA....AAAAB","next":0,err": 0}
The "fileName" and "offset" values are as given in the command. "data" is part or all of the base64-encoded thumbnail data starting at that offset. "next" is zero if there is no more data for that thumbnail, otherwise not all the thumbnail data was returned and "next" is the byte offset in the file of the rest of the thumbnail data. "err" is 0 if the command was successful, otherwise "err" is nonzero and the other fields may or may not be present.
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 P"MyModel.g" ; run file MyModel.g in simulation mode and update the simulated time stored in the file M37 S2 ; set the simulation mode to debug
M37 P"file.gcode" runs the specified file in normal simulation mode and displays the calculated job time when complete.
M37 Sn where n is nonzero enters simulation mode n. n=1 selects debug mode, n=2 selects normal simulation mode, n=3 selects partial simulation mode. All G and M codes will not be acted on, but the time they would take to execute will be calculated if the mode is 1 or 2.
M37 S0 exits 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).
Used to compute a hash of a file on the SD card and returns a hexadecimal string which is the SHA1 of the file.
M38 gcodes/myfile.g
If the file cannot be found, then the string "Cannot find file" is returned instead.
Supported in ReprapFirmware 1.21 and later.
This command returns information about the SD card in the specified slot in the requested format.
M39 ; report information for SD card 0 in plain text format M39 P1 S2 ; report information for SD card 1 in JSON format
; example output from RRF 3.3 M39 SD card in slot 0: capacity 3.97Gb, free space 3.81Gb, speed 20.00MBytes/sec, cluster size 32kb M39 S2 {"SDinfo":{"slot":0,"present":1,"capacity":3965190144,"free":3807379456,"speed":20000000,"clsize":32768}}
In the JSON response, capacity, free space and cluster size are in bytes. and interface speed is in bytes/second.
M950 P0 C"exp.heater3" Q500 ; allocate GPIO port 0 to heater3 on expansion connector, 500Hz ... M42 P0 S0.5 ; set 50% PWM on GPIO port 0
M42 switches a general purpose I/O pin which is defined by M950. Use M42 Px Sy to set pin x to value y. The S field may be in the range 0.0-1.0 or >1.0-255. 0 is off in both cases.
M42 P3 I1 S0.5 F500 ; set Heater 3 pin to 50% PWM at 500Hz, inverted
M42 switches a general purpose I/O pin. Use M42 Px Sy to set pin x to value y. The S field may be in the range 0.0-1.0 or >1.0-255. 0 is off in both cases.
In RRF 2.x, the 'P' pin number reference is an internal firmware reference named "digital pin" which It maps on different connector pins depending the hardware. See Controlling unused IO pins for all the unused pin mappings in RRF 2.x.
For Duet 0.8.5 and 0.6, along with pre 1.16 versions of RepRapFirmware, see the RepRap GCode dictionary M42 entry.
See also
M73 is generated by some slicers, to inform the firmware about the state of the print so that it can provide a better estimate of the remaining print time.
M80 ; sets pin in the power on state M80 C"pson" ; allocates the pin and sets the pin in the power on state. M80 C"!pson" ; inverts the PS_ON output for Meanwell power supplies
Turns on the ATX power supply from standby mode to fully operational mode using the power supply control pin on the External 5V header. If a deferred power down command was set up using M81 S1 then it is cancelled.
In RRF 3.4.0 and later, M80 will do nothing unless you have previously allocated a pin to control power using either M80 or M81 with C parameter. This would normally be done in the config.g file.
M81 C"pson" ; allocate the PS_ON pin to power control but leave power off M81 ; turn power off immediately M81 S1 ; turn power off when all thermostatic fans have turned off M81 D30 S1 ; turn power off after 30 seconds or when all thermostatic fans have turned off, whichever happens later (RRF 3.5)
Turns off the ATX power supply. Counterpart to M80. A deferred power down command (M81 S1) that has not yet happened can be cancelled using M80.
In RRF 3.4 and later, M81 will have no effect unless a power control pin has previously been assigned using M80 or M81 with the C parameter. This would normally be done in the config.g file.
M82 ; absolute extrusion mode
Makes the extruder interpret extrusion as absolute positions.
It is strongly recommended to use relative extrusion, not absolute extrusion. This is especially true for multi tool systems.
move.virtualEPos
. This counter is also set by G92 E"nn" so G92 E0 sets it to 0. This behaviour is there to allow old slicers and other clients which do not understand multiple tool machines to work with absolute extrusion mode. It does not work well with multiple tools, hence why relative extrusion mode is recommended. The virtual E position is reset when a print is started.M82 ; set to absolute mode
M114
Response (abridged):
.. E:0.000 E0:0.0 ..
Note the virtual extruder and Extruder E0 are both at 0 as no movement has been commanded yet. Commanding a move:
G1 E10 F300
M114
Response (abridged):
.. E:10.000 E0:10.0 ..
Both counters show the movement.
Now resetting the Virtual E position to 0, followed by a further move:
G92 E0
G1 E11 F300
M114
Response (abridged):
.. E:11.000 E0:21.0 ..
So the virtual E position has incremented form 0 to 11, but the E0 counter was not reset by G92 E0, so has continued to count up from 10, so is now at 21.
M82 ; set to absolute mode
M114
Response (abridged):
.. E:0.000 E0:0.0 E1:0.0 E2:0.0 ..
Note the virtual extruder and Extruder E0,E1 and E2 are all at 0 as no movement has been commanded yet. Commanding a move with T0 selected
G1 E10 F300
M114
Response (abridged):
.. E:10.000 E0:10.0 E1:0.0 E2:0.0 ..
Both the Virtual extruder and the E0 counters show the movement.
Switching to T2 (no extrusion in the tool change commands in this example), then commanding another movement:
G1 E5 F300
M114
Response
.. E:5.000 E0:10.0 E1:0.0 E2:-5.0 ..
This shows the issue with using absolute extrusion with multiple tools. The virtual extruder was on 10, so in absolute mode the command to move to 5 is a retraction of 5mm. so its updated form 10 to 5, and the selected extruder (E2) moves back from 0 to -5.
It is possible to work around this by resetting the virtual extruder position using G92 E0 before each tool change. Alternatively if its state is needed to be maintained then saving the virtual position into a separate global variable for each tool as part of the tfreeN.g tool change macros and then restoring it in the tpostN.g tool change macros should allow this, however in most cases its better to use M83
M83 ; relative extrusion mode
Makes the extruder interpret extrusion values as relative positions.
Deprecated in RRF 3.6.0-beta.2 and later. Use M18 to disable motors, and M906 T# to set idle timeout
M84 ; Disable all motors M84 S10 ; Set idle time out to 10 seconds M84 E0:1:2:3:4 ; Disable specific motors
Stops the idle hold on all axis and extruder, effectively disabling the specified motor, or all motors, the same as M18. Be aware that by disabling idle hold during printing, you will get quality issues.
Also used to set the idle timeout for all motors. For example, M84 S10
will idle the stepper motors after 10 seconds of inactivity. The idle current is set by the M906 I parameter.
M84 S10
will idle the stepper motors after 10 seconds of inactivity.M84 S0
does NOT mean "never idle hold" (ie motors stay on all the time, at full current), and S0 is an invalid setting. The correct way to set no idle hold (ie motors are 'always on') is to use M906 I parameter to set the idle hold to the required level, eg M906 I100
.If this command refers to any axes other than X, Y and Z then it must be later in config.g than the M584 command that creates those additional axes.
M92 X80 Y80 Z80 M92 E420:500
Allows programming of steps per mm for motor drives. These values are reset to those set in config.g on power on, unless saved with M500. It will report the current steps/mm if you send M92 without any parameters.
RepRapFirmware does not support individual motor settings where an axis has multiple motors connected to different stepper drivers. The first parameter specified will be used for all motors on the axis. You should use identical motors on any axis that has more than one motor to avoid unexpected behaviour.
Example: If you have two motors on your Z axis, physically connected to Z and E0 stepper drivers, configured with M584 Z2:3, set M92 Z80, not M92 Z80:80
RepRapFirmware uses floating point maths so it is possible to use floating point numbers for steps/mm.
M98 P"mymacro.g" ; Runs the macro in the file mymacro.g M98 P"macro.g" S100 Y"string" ; Runs macro.g, passes the values for parameters S and Y to the macro
; within macros M98 R1 ; macro can be paused from this point onwards
M99
Returns from an M98 call, this is not required to return from the end of a macro and the macro naturally returns at the end of file.
RepRapFirmware closes the currently active macro file. If a nested macro is being run, RepRapFirmware goes up one stack level.
Supported as part of compatibility with Simplify3D firmware retraction commands.
Same behaviour as G11 (unretract)
Must select "Generate M101, M102, M103" in Simplify3D.
Supported as part of compatibility with Simplify3D firmware retraction commands. Command is accepted and ignored as it serves no function in RRF.
Must select "Generate M101, M102, M103" in Simplify3D.
Supported as part of compatibility with Simplify3D firmware retraction commands.
Same behaviour as G10 without parameters (retract)
Must select "Generate M101, M102, M103" in Simplify3D.
M104 S190 M104 S220 T1
The first example sets the active and standby temperature of the current tool to 190oC and return control to the host immediately (i.e. before that temperature has been reached by the extruder). If no tool is active, it will apply to the lowest non-negative tool number.
The second example sets the active and standby temperatures of tool 1 to 220oC. If tool 1 is off, it will be set to standby as well (resulting in tool 1 heating up to the temperature given).
See also M109.
This command is deprecated in RRF for multi-tool machines because the G10/M568 commands provide more control, for example separate active and standby temperatures. However, it is widely generated by slicers so RRF will continue to support it.
M105 M105 S2
Request the temperature of the current extruder and the build base in degrees Celsius. Reports the current and target temperatures of all active heaters.
1 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 GCode 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.
M106 S127 M106 P1 T45 S0.7 H1:2 ; (RRF 3.3 and earlier, see notes) M106 P1 T45 H1:2 X0.7 ; (RRF 3.4 and later, see notes) M106 P1 T40:50 H1:2
The first example turns on the default cooling fan at half speed. The second (RRF 3.3 and earlier) and third (RRF 3.4 and later) examples sets the second fan to a thermostatic fan for sensors 1 and 2 (e.g. the extruder heaters in a dual-nozzle machine) such that the fan will be on at 70% PWM when either hot end is at or above 45C. The third example also sets up a thermostatic fan, but this time it runs in proportional mode; fan speed scales from 0% to 100% as temperature rises from 40C to 50C.
M308 S10 Y"mcu-temp" A"MCU" ; defines sensor 10 as MCU temperature sensor M308 S11 Y"drivers" A"Duet stepper drivers" ; defines sensor 11 as stepper driver temperature sensor M308 S12 Y"drivers-duex" A"Duex stepper drivers" ; for Duet 2 WiFi/Ethernet with DueX2/5, defines sensor 12 as DueX2/5 stepper driver temps M950 F2 C"fan2" Q100 ; create fan 2 on pin fan2 and set its frequency M106 P2 H10:11:12 T40:70 ; set fan 2 value
This example sets up an electronics cooling fan that starts to turn on when the MCU temperature reaches 45C and reaches full speed when the MCU temperature reaches 70C or if any TMC2660 drivers report that they are over-temperature. The sensors are defined with M308, the fan with M950, then the fan is configured with M106. See Configuring the on-board MCU and stepper driver temperature sensors for further guidance.
Example
; RRF 2.x code M106 P2 I1 F25000 ; fan 2 is a 4-wire PWM fan so invert it and use high PWM frequency. tacho connected to PB6 on expansion connector. PB6 is defined by default. ; RRF 3.x code M950 F2 C"!Fan2+exp.pb6" Q25000 ; fan 2 is a 4-wire PWM fan so invert it, use high PWM frequency, tacho connected to PB6 on expansion connector
M106 S127 M106 P1 T45 S0.5 H1:2 M106 P1 T40:50 H1:2 M106 P2 T45:65 H100:101:102
The first example turns on the default cooling fan at half speed. The second example 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 at 70% PWM when either hot end is at or above 45C. The third example also sets up a thermostatic fan, but this time it runs in proportional mode. The fourth example sets up an electronics cooling fan that starts to turn on when the MCU temperature (virtual heater 100) reaches 45C and reaches full speed when the MCU temperature reaches 65C or if any TMC2660 drivers (virtual heaters 101 and 102) report that they are over-temperature
Deprecated in RepRapFirmware. Use M106 S0 instead.
Note that M107 will turn off the print cooling fan(s) associated with the current tool (see the F parameter in the M563 command).
Breaks out of an M109, M116, M190 or M191 wait-for-temperature loop, continuing the print job.
M109 S215
Deprecated in RRF, but widely generated by slicers. To get the same behaviour, use G10/M568 followed by M116
To better support slicers that don't select a tool when doing a single-extrusion print, RRF will always select a tool when processing M109. If the T parameter is present, that tool will be selected. If no T parameter is present and no tool is already selected, the tool with the lowest non-negative tool number will be selected (typically tool 0).
Note: M109 will not wait for temperatures below 40c because in many cases they may never be reached due to ambient temps. So if you want to wait for a hotend to cool, use 41c or higher.
M110 N123
This example sets the current line number to 123. Thus the expected next line after this command will be 124.
M111 M111 P4 S1 ; enable all debugging for module 4 M111 P4 D2 ; enable just bit 1 debugging information for module 4 M111 B1024 ; allocate a 1K debug buffer (RRF 3.5.0 post RC3 only)
Enable or disable debugging features for the module number specified by the P parameter. M111 without parameters lists all the modules, their numbers, and whether debugging is enabled for each.
Debug output is normally sent to the USB port, and any debug output generated from an interrupt service routine is discarded. However, in RRF 3.5.0 post RC3 you can use M111 with the B parameter to allocate a debug buffer instead; in which case debug output is written to the buffer (even when it comes from an interrupt service routine) and is later extracted and written as a generic message to all active input channels. The B parameter is the debug buffer size in bytes and must be an exact power of 2. Debug data that can't be written to the buffer because it is full is discarded.
Note, print quality may be affected when debug output is enabled because of the volume of data sent to USB. After the B parameter is used to allocate a debug buffer, if excessive amounts of debug data are generated then HTTP disconnections may occur. Debug output should normally be used only for debugging firmware, or when instructed to help with diagnosis of particular issues.
The details of what debugging information is output when debugging is enabled varies from one firmware revision to another, so it is not specified here.
Starting from v3.6.0-beta.1, M111 P-1
can be used to set debug logging parameters for DCS in SBC mode. Additional parameters for M111 P-1
include:
trace
, debug
, info
, warning
, error
, fatal
)O1
)M112
Any moves in progress are immediately terminated, then Duet shuts down. All motors and heaters are turned off. PSU power (if controlled by the Duet via the PS_ON pin) is NOT turned off, to allow any always-on fans to continue to run. The Duet can be started again by pressing the reset button or power cycling the board. See also M0 - stop or unconditional stop and M1 - sleep or conditional stop. To turn off PSU power via the PS_ON pin in an emergency stop, make a trigger macro that includes M81 before M112; see User manual: Connecting an emergency stop.
M114
This reports the X, Y, Z (,U, V, W, A, B, C if configured) and E coordinates to the host. The coordinates reported are those at the end of the last completed move.
For example, the machine returns a string such as:
C: X:10.000 Y:20.000 Z:5.000 E:51.000 E0:51.0 E1:0.0 Count 800 1600 2000 Machine 10.00 20.00 5.00 Bed comp 0.00
The first E value (without an extruder number) is the current virtual extruder position, and is included for the benefit of GCode senders that don't understand multiple extruders. Note that the virtual extruder position is only incremented in absolute extrusion mode (M82), it can also be accessed in the object model at move.virtualEPos
. M92 E"nn" sets the virtual extruder position to the number specified as "nn". The virtual E position is reset when a print is started, as are the individual E0, E1, etc counters. See the M82 section of this page for more information on absolute extrusion, the virtual extruder concept, and why it is generally better to use relative extrusion.
The E0, E1 etc. values are for each individual extruder.
The Count values are the microstep positions of each individual motor or motor group. The Machine values are the machine axis coordinates, which are calculated from the user coordinates by accounting for workplace coordinate offsets, bed compensation, axis skew compensation, babystepping and Z lift.
Note: there is no agreed definition of what the response to M114 should be. We try to keep the M114 response compatible with other firmwares as far as we can, but this is not always possible. Users writing applications which need to fetch current positions from RepRapFirmware 3 are recommended to use object model queries instead.
M115 FIRMWARE_NAME: RepRapFirmware for Duet 2 WiFi/Ethernet FIRMWARE_VERSION: 2.04RC1 ELECTRONICS: Duet WiFi 1.0 or 1.01 FIRMWARE_DATE: 2019-07-14b1
M115 B1 Board EXP3HC firmware 3.0beta1 2019-10-28b1
Request the Firmware Version and Capabilities of the current microcontroller. See the M408 command for a more comprehensive report on machine capabilities.
The B parameter is used on Duet 3 only, in RRF v3.x and later. M115 can take an optional B (board number) parameter which is the CAN address of the board to be queried, default 0 (i.e. main board).
The P parameter is no longer supported, and has been removed from RRF 3.5 and later, to save memory on Duet 2. It is used tell the firmware about the hardware on which it is running, if RRF can't identify it. Should only be used in config.g, if you're having problems. If the P parameter is present then the integer argument specifies the hardware being used.
M116 M116 P1 M116 H0 S5
The first example waits for all bed, chamber, and tool heaters to arrive at their set values. Note that in v3.5, the scope of tool heaters to wait for is limited to the heaters of the currently selected tool of the selected motion system.
The second shows the 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.
The third example waits for the bed to reach its temperature +-5 degC.
See also M109.
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.
'S' parameter sets the temperature tolerance, default 2 degC.
Note: M116 will not wait for temperatures below 40c because in many cases they may never be reached due to ambient temps. So if you want to wait for a hotend or bed to cool, use 41c or higher.
M117 Hello World M117 "Hello world"
This causes the given message to be shown in the status line on an attached LCD or if no LCD is attached, this message will be reported on the web interface. Quotation marks around the string to be displayed are recommended but not mandatory.
RRF >= 3.2.0-beta3: All messages sent via M117 will be logged with log level INFO if logging is enabled at least at log level INFO.
Note: Due to the way M117 messages are communicated, messages sent in quick succession may not all display. Use M118 for those cases.
Supported in RepRapFirmware 1.21 and later.
0
to 2
(only valid for MQTT Client message, optional). Defaults to 0
if not specified.1
or 0
(only valid for MQTT Client message, optional). Defaults to 0
if not specified.1
or 0
(only valid for MQTT Client message, optional). Defaults to 0
if not specified.M118 S"Hello Duet" M118 S"Hello Logfile" L1 M118 P0 S"Hello Logfile and DWC" L1 M118 S"Don't log me" L0 M118 S"My MQTT Message" T"My-MQTT-Topic"
This code may be used to send messages to a specific target. Basically it is a simple wrapper for RepRapFirmware's Platform::Message method.
Note that the implementation in RepRapFirmware always requires the S-parameter to be passed. If it is omitted, an error will be reported.
The second example shows how to send a message to the log file in log level WARN instead of the default log level DEBUG.
The third example shows how to prevent a message from being logged.
Note that a message only having the Lnnn parameter but no Pnnn parameter will only go to the log file (if the log level matches the current log level of the system) and will not be sent to other outputs. If you want it to show on DWC as well then send:
M118 P0 S"message" L1
Note: messages that exceed 100 characters will be truncated.
M119
Returns the current state of the configured endstops. Takes into account any 'inverted endstop' settings, so one can confirm that the machine is interpreting the endstops correctly.
M120
Push the state of the machine onto a stack. Called automatically when a macro file is run. It pushes the following values on the stack:
M121
Recover the last state pushed onto the stack.
M122
Sending an M122 causes the RepRap to transmit diagnostic information.
The 'P' parameter is used to report specific information. The details vary between releases. As at RepRapFirmware version 3.41 they are:
The following 'P' parameters are supported by the LPC and STM32 Port of RepRapFirmware Only
The following P parameter is supported on boards that use Arm Cortex M4 processors:
Note: do not use M122 with a P parameter of 1000 or greater. Most of these values are used to test the error reporting facilities and deliberately cause the firmware to crash . As at firmware 3.45 these are:
The 'B' parameter is used in RepRapFirmware 3 on Duet 3 only, to report diagnostic information from connected boards. The B (board number) parameter is the CAN address of the board to be queried, default 0 (i.e. main board). Example:
M122 B1 Diagnostics for board 1: Board EXP3HC firmware 3.0beta1 2019-10-28b1 Never used RAM 163.4Kb, max stack 376b HEAT 1284 CanAsync 1456 CanRecv 1424 TMC 168 AIN 532 MAIN 2220 Driver 0: standstill, reads 26609, writes 11 timeouts 0, SG min/max 0/0 Driver 1: standstill, reads 26611, writes 11 timeouts 0, SG min/max 0/0 Driver 2: standstill, reads 26614, writes 11 timeouts 0, SG min/max 0/0 Move hiccups: 0 VIN: 24.4V, V12: 12.2V MCU temperature: min 43.8C, current 43.9C, max 44.1C
Available only in RRF 2.02 and earlier. In RRF 2.03 and later the interval is fixed at 250ms.
M135 S300
Set the PID to measure temperatures and calculate the power to send to the heaters every 300ms.
In RRF3 a M140 command with H parameter (other than H-1) must come after the M950 command that creates that heater, and before any M143 command that sets a temperature limit for that heater.
M140 H0 ; bed heater 0 uses heater 0 M140 P1 H1 ; bed heater 1 uses heater 1 M140 H-1 ; disable bed heater M140 S55 ; set bed temperature to 55C M140 S65 R40 ; set bed temperature to 65C and bed standby temperature to 40C M140 S-273.1 ; switch off bed heater
The first example informs the firmware that bed heater 0 (implied, because no P parameter is provided) uses heater 0.
The second example informs the firmware that bed heater 1 (P1) uses heater 1.
The third example disables the bed heater. No bed heaters will be shown in DWC.
The fourth example sets the temperature of the bed heater to 55oC and returns control to the host immediately (i.e. before that temperature has been reached by the bed).
The fifth example sets the bed temperature to 65oC and the bed standby temperature to 40oC.
The sixth example sets the active/target bed temperature to absolute negative temperature (-273 or lower). This switches off the bed heater.
In RRF3 a M141 command with H parameter (other than H-1) must come after the M950 command that creates that heater, and before any M143 command that sets a temperature limit for that heater.
M141 S30 M141 H3 M141 P1 H4
The first example sets the temperature of the chamber to 30oC and return control to the host immediately (i.e. before that temperature has been reached by the chamber).
The second example specifies that chamber heater 0 (the default if no P parameter is given) uses heater 3.
The third example specifies that chamber heater 1 uses heater 4.
Each heater supports a certain number (3 in most builds of RRF) of monitors for that heater. The P parameter allows you to choose which monitor to configure.
By default, monitor 0 is set up to generate a heater fault if a temperature limit is exceeded according to the sensor that controls the heater, and monitors 1 and 2 are disabled.
M143 H1 P0 S275 A2 ; switch off heater 1 temporarily if it exceeds 275°C M143 H1 P1 S285 A0 ; raise a heater fault if it exceeds 285C
M143 S275 ; set the maximum temperature of the hot-end to 275°C M143 H0 S125 ; set the maximum bed temperature to 125C M143 H1 S275 X103 ; use virtual heater 103 to monitor heater 1
You have heater 3 mapped to a chamber heater which is supposed to be temporarily turned off when the temperature in it exceeds 65C. The thermistor for the chamber is set up as a virtual heater on channel 104 and can be viewed on the "Extra" panel on DWC (refer to M305 for further details on how to set this up). To achieve this you can configure an extra heater protection with the following GCode:
M143 P100 H3 X104 A2 C0 S65
To control heaters via two thermistors, RepRapFirmware allows the configuration of extra heater protection elements whose index starts from 100. On the Duet 2 Wifi and Duet 2 Ethernet there are 8 extra heater protections available (100-107). See also M305.
If the heater is a bed or chamber heater then the M143 command must come after the M140 or M141 command that declares the heater as a bed or chamber heater.
1 Supported in RepRapFirmware 1.20 and later. Starting from this version RepRapFirmware allows more granular control over the heater subsystem. By default each heater has one heater protection instance assigned to it, which is by default configured to generate a heater fault if the maximum heater temperature is exceeded.
The default maximum temperature for all heaters was 300°C prior to RepRapFirmware version 1.13, and 262°C from 1.13. At RepRapFirmware 1.17 the default maximum temperatures were 262C for extruders and 125C for the bed. In more recent versions the default maximum heater temperature is 290C, to allow the hot end to be tightened at 285C as per the E3D recommendation. When the temperature of the heater exceeds this value a heater error will be triggered.
With A0 set on RepRapFirmware 1.26.1, PS_ON is triggered after the fault has exisited for the duration defined by the S parameter set in M570.
M144
Switch the bed to its standby temperature. M144 S1 will set it back to its active temperature.
M950 E0 C"led" T1 Q3000000 ; create a RGB Neopixel LED strip on the LED port and set SPI frequency to 3MHz
M150 E0 R255 P128 S20 F1 ; set first 20 LEDs to red, half brightness, more commands for the strip follow M150 E0 U255 B255 P255 S20 ; set next 20 LEDs to cyan, full brightness, finished programming strip
Оn Fysetc 12864mini display you can set all three LEDs separately. For display configuration and encoder illumination:
M918 P2 E-4 F2000000 ; Fysetc 12864mini M950 E0 C"io3.out" T1 U3 ; create a RGB Neopixel LED strip with 3 LEDs on the Duet 3 Mini 5+ 12864_EXP1 header
M150 E0 R0 U0 B255 P255 S1 F1 ; display led blue M150 E0 R255 U0 B0 P255 S1 F1 ; left encoder led red M150 E0 R0 U255 B0 P255 S1 F0 ; right encoder led green
M150 X1 Q3000000 ; set LED type to NeoPixel and set SPI frequency to 3MHz M150 R255 P128 S20 F1 ; set first 20 LEDs to red, half brightness, more commands for the strip follow M150 U255 B255 P255 S20 ; set next 20 LEDs to cyan, full brightness, finished programming strip
Оn Fysetc 12864mini display you can set all three LEDs separately. For display configuration and encoder illumination:
M918 P2 E-4 F2000000 ; Fysetc 12864mini
M150 X2 R255 U0 B0 P255 S1 F1 ; display led M150 X2 R0 U255 B0 P255 S1 F1 ; left encoder led M150 X2 R0 U255 B0 P255 S1 F0 ; right encoder led
; RRF 3.5 example M150 E0 R255 U0 B0 P255 S10 F1 ; Sets first 10 LEDs to red M150 E0 R0 U255 B0 P255 S10 F1 ; Sets next 10 LEDs to green M150 E0 R0 U0 B255 P255 S10 F0 ; Sets next 10 LEDs to blue, and send to LED strip
See also Neopixel and Dotstar LEDs and Connecting 12864 or other displays.
M190 S60
Set the temperature of the bed to 60C and wait for the temperature to be reached.
Note: M190 will not wait for temperatures below 40c because in many cases they may never be reached due to ambient temps. So if you want to wait for a bed to cool, use 41c or higher.
M191 S60
Set the temperature of the build chamber to 60C and wait for the temperature to be reached.
Supported in RRF 1.19 and later
M200 D0 ; disable volumetric extrusion on all extruders M200 S0 ; disable volumetric extrusion for this input channel (RRF 3.5 and later) M200 D1.75 ; set all extruder filament diameters to 1.75mm 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.
If this command refers to any axes other than X, Y and Z then it must be later in config.g than the M584 command that creates those additional axes.
M201 X1000 Y1000 Z100 E2000
Sets the acceleration that axes can do in mm/second^2 for print moves. For consistency with the rest of GCode movement this should be in mm/(minute^2), but that gives really silly numbers and one can get lost in all the zeros. So for this we use seconds.
To calculate the maximum acceleration values for an axis an online Maximum Acceleration Calculator can be used.
RepRapFirmware does not support individual motor settings where an axis has multiple motors connected to different stepper drivers. The first parameter specified will be used for all motors on the axis. You should use identical motors on any axis that has more than one motor to avoid unexpected behaviour.
Example: If you have two motors on your Z axis, physically connected to Z and E0 stepper drivers, configured with M584 Z2:3, set M201 Z100, not M201 Z100:100
Supported in RRF 3.4 and later
M201.1 X500 Y500 Z20 E500:500
Set the acceleration that axes should use for special types of move that should be done using reduced acceleration.
These values are used for probing moves (because some types of Z probe can be triggered by high acceleration at the start of the move) and for moves that involve stall detection endstops (because high acceleration can bring the motor close to stalling). If a single E value is provided, that value is applied to all extruders. The values must be provided in mm/sec2 even if G20 has been used to set units to inches. M201.1 without parameters reports the current settings.
If this command refers to any axes other than X, Y and Z then it must be later in config.g than the M584 command that creates those additional axes.
M203 X6000 Y6000 Z300 E10000
Sets the maximum feedrates that your machine can do in mm/min
RepRapFirmware does not support individual motor settings where an axis has multiple motors connected to different stepper drivers. The first parameter specified will be used for all motors on the axis. You should use identical motors on any axis that has more than one motor to avoid unexpected behaviour.
Example: If you have two motors on your Z axis, physically connected to Z and E0 stepper drivers, configured with M584 Z2:3, set M203 Z300, not M203 Z300,300
M204 P500 T2000
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.
Values are in mm/s².
This command is supported by firmware version 1.18RC1 and later.
If this command refers to any axes other than X, Y and Z then it must be later in config.g than the M584 command that creates those additional axes.
This command is provided as an alternative to M566 for compatibility with Marlin. In M566 the units are mm/min as with all other speeds. In M205 they are in mm/sec.
This command is deprecated. Use G10 L2 P1 instead.
If this command refers to any axes other than X, Y and Z then it must be later in config.g than the M584 command that creates those additional axes.
M206 X10.0 Y10.0 Z-0.4
The values specified will be subtracted from the coordinates given in G0, G1 and related commands. In firmware builds that support workplace coordinates, this command is equivalent to G10 P1 L2 with the X, Y, Z... parameters negated.
The M207 command must come later in config.g than the M563 command that creates the tool to which it relates.
M207 S4.0 F2400 Z0.075
Sets the retract length used by the G10 and G11 firmware retraction and reprime commands. In RRF 3.01 and later, if a P parameter is provided then only the retraction parameters for the specified tool will be set. In other cases, the new retraction parameters will apply to all tools.
Alternative (from RepRapFirmware 2.02/1.23)
If this command refers to any axes other than X, Y and Z then it must be later in config.g than the M584 command that creates those additional axes.
M208 X200 Y200 Z90 ; set axis maxima M208 X-5 Y0 Z0 S1 ; set axis minima M208 X-5:200 Y0:200 Z0:90 ; set axis minima and maxima
The values specified set the software limits for axis travel in the specified direction. The axis limits you set are also the positions assumed when an endstop is triggered.
The min/max axis positions are +/- (2^31 - 1) microsteps. Position accuracy will start to suffer when the positions are outside approx. +/- 2^24 microsteps, because it is held and calculated as a 32-bit float. See also this note on maximum length of moves in the G1 Gcode entry.
The M208 minimum Z value applies to deltas. The M208 XY min/max and Z max values don't.
M220 S80
Sets the speed factor override percentage.
M221 S70 M221 S95 D1
Sets extrude factor override percentage. In the case of RepRapFirmware, sets the extrusion factor percentage for the specified extruder drive only.
M226
Initiates a pause in the same way as if the pause button is pressed, except that execution of all prior GCode commands in the same input stream is completed first. Then the SD card input stream is paused and file sys/pause.g is run.
Send and/or receive data over the i2c bus. Supported in RepRapFirmware 1.21 and later.
M260 A5 B65 ; send 'A' to address 5 now M260 A"x7F" B65 ; send 'A' to address 7F (hex) M260 A0 B82:101:112:82:97:112 ; send 'RepRap' to address 0 M260 A"x71" B19 R2 ; send 19 to address 71 (hex) and read 2 bytes back M260 A5 R2 ; read 2 bytes of data from address 5 M260 A5 S"Hello world" ; send "Hello world" to address 5
Hex addresses are only supported in firmware 2.02 and later.
Supported from firmware version 3.6
Write data to a Modbus slave device.
The port used by the P parameter must already have been set to Device mode using M575.
M260.1 P1 A5 R10 B956 ; write 956 to register 10 of the device at address 5 M260.1 P1 A8 R20 B123:456 ; write 123 to register 20 and 456 to register 21 of the device at address 8
Supported from firmware version 3.6
Write data to a generic UART device.
The port used by the P parameter must already have been set to Device mode using M575.
M260.2 P1 B20 ; write 20 to register 10 of the device at address 5 M260.2 P1 B72:101:108:108:111:32:119:111:114:108:100 ; write "Hello world" (when converted to ascii) M260.2 P1 B{0x02, 0x30, 0x03} ; writing data as hex M260.2 P1 B{0xFF01, 257} ; write 0x01:0x01 to UART as data is truncated to 1 byte M260.2 P1 S"Hello world" ; write "Hello world" to UART
Supported from firmware version 3.6
Write data to a Nordson Ultimus V via UART. https://www.manualslib.com/manual/2917329/Nordson-Ultimus-V.html?page=46#manual
ENQ
ACK
handshake is completed.STX
, number of bytes, the checksum, and ETX
are automatically added to the data provided to create the full message.EOT
The port used by the P parameter must already have been set to Device mode using M575.
M260.3 P1 B{0x50, 0x53, 0x20, 0x20, 0x30, 0x35, 0x30, 0x30} ; complete handshake then send "{STX}08PS 0500F0{ETX}" M260.3 P1 S"PS 0500" ; complete handshake then send "{STX}08PS 0500F0{ETX}"
Deprecated in RRF 2.02 and later. Use M260 instead.
M261 A99 B5 ; Request 5 bytes from Address 99
Supported from firmware version 3.6
Request data (synchronously) from a Modbus slave device.
The port used by the P parameter must already have been set to Device mode using M575.
M261.1 P1 A80 R10 B2 V"modbusData" ; (RepRapFirmware) Read registers 10 and 11 from Modbus station 80 via the first aux port and store the result in var.modbusData
Supported from firmware version 3.6
Request data (synchronously) from a UART device.
The port used by the P parameter must already have been set to Device mode using M575.
M261.2 P1 B2 V"data" ; (RepRapFirmware) Read 2 bytes from the first aux port and store the result in var.data M261.2 P1 B0 ; Clear UART buffer
M950 S0 C"exp.heater3" ; assign GPIO port 0 to heater3 on expansion connector, servo mode ... M280 P0 S80 ; set 80deg servo position on GPIO port 0
Before you can use M280 you must create a GPIO port using M950. Then in the M280 command, the P parameter is the GPIO port number.
To invert the output, specify an inverted pin name in M950 when you create the GPIO port.
In RRF 3.4, Duet 3 supports up to 32 output and 16 input ports, Duet 2 Wifi/Ethernet support up to 20 GPIO ports, and Duet 2 Maestro supports 10 GPIO ports. No GPIO ports are allocated by default.
M280 P1 S50 ; set Heater 1 pin to 50deg servo position M280 P3 I1 S80 ; set Heater 3 pin to 80deg servo position, inverted
The optional I1 parameter 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.
The servo index is the same as the pin number for the M42 command.
S values below 544 are treated as angles, and 544 or greater as the pulse width in microseconds.
The relationship between the S parameter and the pulse width output to the port is the same as in other 3D printer firmwares, so that devices such as BLTouch will perform the same way. However, there is no standard for servos on the relationship between pulse width and servo angle. Therefore, for most servos the value of the S parameter does not equal the servo angle. Almost all servos accept a pulse width range of at least 1us to 2us, which corresponds to an S parameter range of 44.2 to 141.2 degrees. So for many servos, values in the range 44.2 to 141.2 or alternatively 1000 to 2000 will cover the full operating range of the servo.
See also Using hobby servos and DC motors.
Supported in firmware version 1.18 and later.
M290 S0.05 ; babystep the head up 0.05mm M290 R0 S0 ; clear babystepping (RepRapFirmware 1.21 and later only)
This command tells the printer to apply the specified additional offset to the Z coordinate for all future moves, and to apply the offset to moves that have already been queued if this can be done. Baby stepping is cumulative, for example after M290 S0.1 followed by M290 S-0.02, an offset of 0.08mm is used.
M290 with no parameters reports the accumulated baby stepping offset. Marlin doesn't track accumulated babysteps.
In RepRapFirmware 1.19 and earlier, the babystepping offset is reset to zero when the printer is homed or the bed is probed. In RepRapFirmware 1.21 and later, homing and bed probing don't reset babystepping, but you can reset it explicitly using M290 R0 S0.
Supported in firmware version 1.19 and later.
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 (S parameter) are:
S0: No buttons are displayed (non-blocking)
S1: Only "Close" is displayed (non-blocking)
S2: Only "OK" is displayed (blocking, send M292 to resume the execution)
S3: "OK" and "Cancel" are displayed (blocking, send M292 to resume the execution or M292 P1 to cancel the operation in progress)
S4: (RRF 3.5 and later only) Display a number of choices. The names of the choices are given by the K parameter as an array of strings. The choice selected by the user, as the array index, is available to be used in the "input" constant
S5: (RRF 3.5 and later) Prompt for an integer value. L is the minimum accepted value (default 0), H is the maximum accepted value (default unlimited), and F is the default value. The integer is available to be used in the "input" constant
S6: (RRF 3.5 and later) Prompt for a floating point value. L is the minimum accepted value (default 0.0), H is the maximum accepted value, and F is the default value. The floating point value is available to be used in the "input" constant
S7: (RRF 3.5 and later) Prompt for a string value. L is the minimum number of characters (default 1), H is the maximum number of characters (default 10), and F is the default value. The string is available to be used in the "input" constant
M291 R"Title" P"Message" K{"Yes","No"} S4 if (input == 1) echo "No chosen"
M291 R"Title" P"Request for string" S7 L5 H40 F"default string" echo {input^" entered by user"}
Caution: this command is intended to be used by user interfaces only.
This command is sent by the user interface when the user acknowledges a message that was displayed because of a M291 command with parameter S=2 or S=3. DWC and PanelDue 3.5 and later also use thie command to acknowledge a non-blocking message (M291 command with parameter S=0 or S=1) but in that case the S parameter must match the sequence number of the message being acknowledged. The P parameter is ignored unless M291 was called with S=3, and always ignored by RRF 3.5 and later if the R parameter is present.
In RRF versions prior to 3.5, M292 may only be used to acknowledge blocking message boxes. RRF 3.5 and later allow M292 to be used to cancel non-blocking message boxes too, provided that the correct sequence number is specified.
Supported in firmware version 1.19 and later.
M300 S300 P1000
Play beep sound, use to notify events like the end of printing. If an LCD device is attached to RepRapFirmware, a sound is played via the add-on touch screen control panel. Else the web interface will play a beep sound.
If you intend to play multiple notes in a row, you will need to insert a G4 delay command between them at least equal to the length of the tone.
Example:
M300 S2000 P200 G4 P200 M300 S2500 P300 G4 P300
or
M300 C"io5.out"
See also Macros, sounds section
M301 H1 ; Report PID values M301 H1 P20 I0.5 D100 ; Set PID values
Sets Proportional (P), Integral (I) and Derivative (D) values for hot end. See also M303
The P, I and D values must be provided scaled by a factor of 255, for compatibility with older firmwares.
Note: PID parameters are computed automatically when the M307 command is used to define the heater model, or from the default heater model if no M307 command is provided. You can use M301 to override those computed PID parameters, but this is not recommended because it prevents RepRapFirmware from using different PID parameters depending on the heating phase.
M302 ; Report current state M302 P1 ; Allow cold extrusion M302 S120 R110 ; Allow extrusion starting from 120°C and retractions already from 110°C
This tells the printer to only allow movement of the extruder motor above a certain temperature, or if disabled, to allow extruder movement when the hotend is below a safe printing temperature.
The minimum temperatures for extrusion can be set using the Snnn parameter with a default value of 160°C if unset. A minimum retraction temperature can be set with the Rnnn parameter. The default for this is 90°C.
M302 with no parameters it will report the current cold extrusion state.
One limitation of M302 is that it requires a thermistor to be present for the temperature to be monitored. If your system does not have a thermistor or heater to be monitored, you can define your tool in M563 without a heater to disable cold extrusion protection on that tool. Example:
M563 P0 S"Pump" D0 F0
Note the lack of H parameter.
M303 H1 P1 S240 ; tune heater 1 using 100% PWM, target temperature 240C M303 T0 S205 ; tune the primary heater of tool 0 (RRF 3.2beta3.2 and later)
PID Tuning refers to a control algorithm used to tune heating behaviour for hot ends and heated beds. This command computes the process model parameters (see M307), which are in turn used to calculate the PID constants. Note that the tuning algorithm will overshoot the target temperature; the amount of overshoot depends on how powerful the heater is. See Tuning heater temperature control.
Tuning is performed asynchronously. Run M303 with no parameters while a tuning is underway to see the current tuning state, or the last tuning result if the tuning process has already completed.
M304 P1 I2 D3 M304 ; Report parameters
Sets Proportional, Integral and Derivative values for bed. This command is identical to M301 except that the H parameter (heater number) defaults to zero.
RepRapFirmware 3: Use M308 instead (see Notes).
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. DuetWebControl 1.19.2 and newer support optional units to be set by the S parameter in the form of "Heater name [Unit]".
Notes - RepRapFirmware 3
Prior to RRF3, every temperature sensor belongs to a heater. For sensors with no controllable heater (e.g. the MCU temperature sensor) you have to create a "virtual heater" in order to be able to use the sensor. In RRF3, sensors are created and configured independently from heaters, using the M308 command. When creating a heater using M950, you tell it which sensor to use. You must create the sensor before you refer to it in a M950 command. M305 is not used.
Notes - RepRapFirmware 2.x and earlier
RepRapFirmware also supports ADC gain and offset correction and a thermistor selection facility. 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 ADC on the Duet 2 WiFi and Duet 2 Ethernet is self-calibrating, so you should not need to provide any corrections when using these controllers.
The X parameter tells the firmware which temperature sensor channel to use channel, as follows:
If the M305 command for a real heater does not specify a sensor channel and the heater has not been configured yet, then it defaults to using the thermistor associated with that heater.
PT1000 Example:
M305 P1 X501 R2200 ; heater 1 uses a PT1000 connected to thermistor channel 1 which has a 2.2K series resistor (i.e a Duet 2 Maestro)
Note: PT1000 sensors connected to thermistor inputs have lower resolution than PT100 sensors connected via the PT100 daughter board. The accuracy of PT1000 sensors should be very good on the Duet 2 Maestro and generally good on the Duet 2 Wifi and Duet 2 Ethernet. See the PT1000 documentation for more details.
Virtual heaters 100, 101 and 102 are preconfigured to use temperature sensor channels 1000, 1001 and 1002 respectively. We suggest you use virtual heaters 103 upwards if you want to create additional virtual heaters.
If you send the following command:
M305 P101
you should get the response "Heater 101 uses TMC2660 temperature warnings sensor channel 1001". But as this virtual heater has no name, it doesn't show up in DWC. You can fix that by sending:
M305 P101 S"Drivers"
After that, if you go to the "Extra" tab in DWC (where is says Tools/Heaters/Extra), you will see "Drivers" as an entry.
Additional parameters to help control the heating process:
M307 H0 ; report the process parameters for heater 0 M307 H1 R2.186 K0.17:0.11 D5.67 S1.00 V24.0 ; set the process parameters for heater 1
K = ( temperature change / time in seconds ) / (( heater temperature - ambient temperature ) / 100 )^E parameter
K[fan] = ( temperature change / time in seconds ) / (( heater temperature - ambient temperature ) / 100)^E parameter * F (fan PWM in the range 0 to 1)
Additional parameters to help control the heating process:
M307 H0 ; report the process parameters for heater 0 M307 H1 R2.186 C202.1:155.0 D5.67 S1.00 V24.0 ; set the process parameters for heater 1
Additional parameters to help control the heating process:
M307 H0 ; report the process parameters for heater 0 M307 H1 A346.2 C140 D5.3 B0 S0.8 V23.8; set process parameters for heater 1, use PID, and limit heater 1 PWM to 80%
Example:
;RRF 2.x code M307 H0 F100 ; change heater 0 PWM frequency to 100Hz M307 H2 A-1 C-1 D-1 ; disable heater 2 so we can use its pin to drive a fan ;RRF 3.x code M950 H0 C"bed_heat" Q100 T0 ; heater 0 uses the bed_heat pin, sensor 0, PWM frequency 100Hz ; No need to disable heater 2 because we didn't define it in the first place
Additional parameters to help control the heating process:
M307 H2 A-1 C-1 D-1
.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 and Tuning heater temperature control.
For those platforms that provide power voltage monitoring, the calibration voltage setting allows the heating controller to adjust the power automatically in response to changes in the power supply voltage. For example, if a bed or chamber heater is turned on or off, this may cause the power supply voltage to change a little, which if not corrected for would change the extruder heater power.
M308 is supported in RepRapFirmware 3. If running RRF2.x or earlier, use M305.
adjustedReading = (rawReading * (1.0 + v)) + u
Additional parameters for thermistors
Additional parameters for PT1000 sensors
Additional parameters for MAX31856-based thermocouple sensors
Additional parameters for MAX31865-based PT100 sensors
Additional parameters for linear analog sensors
P"nnn" parameter for "dht-humidity", "bme-pressure" and "bme-humidity
DHT sensors provide a primary temperature output and an additional output providing humidity. To access the humidity output of a DHT sensor you must first configure the primary sensor of type "dht21" or "dht22". Then you can configure "dht-humidity" to be attached to the DHT sensor's secondary output, by specifying port P"Snnn.1" where nnn is the sensor number of the primary sensor.
Similarly, BME280 sensors provide a primary temperature output and two additional outputs providing pressure and humidity. To access the additional output of a BME280 sensor you must first configure the primary sensor of type "bme280". Then you can configure sensor "bme-pressure" to be attached to the BME280 sensor's secondary output, by specifying port P"Snnn.1" where nnn is the sensor number of the primary sensor; and you can configure sensor "bme-humidity" to be attached to the BME280 sensor's secondary output by specifying port P"Snnn.2".
M308 S1 P"temp1" Y"thermistor" T100000 B4725 C7.06e-8 ; configure sensor 1 as thermistor on pin temp1 M308 S1 P"temp1" Y"pt1000" ; configure sensor 1 as PT1000 on pin temp1 M308 S1 P"spi.cs1" Y"thermocouple-max31856" ; configure sensor 1 as K-type thermocouple via CS pin spi.cs1 M308 S1 P"spi.cs1" Y"rtd-max31865" ; configure sensor 1 as PT100 on pin spi.cs1 M308 S10 Y"mcu-temp" A"MCU" ; defines sensor 10 as MCU temperature sensor M308 S11 Y"drivers" A"Duet stepper drivers" ; defines sensor 11 as stepper driver temperature sensor M308 S12 Y"drivers-duex" A"Duex stepper drivers" ; for Duet 2 WiFi/Ethernet with DueX2/5, defines sensor 12 as DueX2/5 stepper driver temps
M308 S10 P"0.spi.cs1" Y"dht22" A"Filament Temp" ; define DHT22 temperature sensor M308 S11 P"S10.1" Y"dhthumidity" A"Filament Hum[%]" ; Attach DHT22 humidity sensor to secondary output of temperature sensor
To read mcu and driver temperatures on an expansion board connected to a Duet 3 mainboard, set the CAN address in the P parameter. For example, a board at CAN address 1 would use:
M308 S12 Y"mcu-temp" P"1.dummy" A"3HC MCU" M308 S13 Y"drivertemp" P"1.dummy" A"3HC Steppers"
Note that from RRF 3.4.0 beta 8, "drivertemp" will be changed to "drivers" to match the main board.
M305 P0 T100000 B3950 ; bed heater uses a B3950 thermistor M305 P1 T100000 B4725 C7.06e-8 ; E0 heater uses E3D thermistorNew code:
M308 S0 P"bed_temp" Y"thermistor" T100000 B3950 ; define bed temperature sensor M308 S1 P"e0temp" Y"thermistor" T100000 B4725 C7.06e-8 ; define E0 temperature sensor M950 H0 C"bed_heat" T0 ; heater 0 uses the bed_heat pin, sensor 0 M950 H1 C"e0heat" T1 ; heater 1 uses the e0heat pin and sensor 1
Supported in RepRapFirmware v3.4 and later
Modes (nn)
This command must be later in config.g than any M584 command.
M350 Z1 ;set the Z-axis' driver to use full steps M350 E4:4:4 ;set extruders 0-2 to use quarter steps)
When M350 is processed, the steps/mm will be adjusted automatically to allow for any changes in microstepping. Therefore you can either:
a) Set Steps/mm correctly for the default 1/16 microstepping, then set the microstepping to the desired amount using M350:
M92 X80 Y80 Z400 ; set axis steps/mm M92 E420:430 ; set extruder 0 and 1 steps/mm M350 X128 Y128 Z128 E128:128 ; set microstepping
or
b) Set the microstepping using M350 and then set the correct steps/mm for that microstepping amount:
M350 X128 Y128 Z128 E128:128 ; set microstepping M92 X640 Y640 Z3200 ; set axis steps/mm @128 microstepping M92 E3360:3440 ; set extruder 0 and 1 steps/mm
Assuming that in the first example the microstepping was initially at the default x16, both the above examples result in the same steps/mm settings.
RepRapFirmware does not support individual motor settings where an axis has multiple motors connected to different stepper drivers. The first parameter specified will be used for all motors on the axis. You should use identical motors on any axis that has more than one motor to avoid unexpected behaviour.
Example: If you have two motors on your Z axis, physically connected to Z and E0 stepper drivers, configured with M584 Z2:3, set M350 Z16, not M350 Z16,16
Microstep interpolation at all microstep settings is supported on all Duet 3 boards with onboard drivers (TMC5160, TMC2160 or TMC2209), and on Duet 2 Maestro (TMC2224 drivers). The TMC2660 drivers used on the Duet 2 WiFi and Duet 2 Ethernet support microstep interpolation, but only when microstepping is set to 16. In other configurations, specifying I1 has no effect.
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 G29 S1 or M375 in the config.g file.
The G29 S0 command automatically saves the height map to file, therefore you do not need to use M374 after G29 S0.
Loads the grid matrix file
M375 M375 P"MyAlternateHeightMap.csv"
Without parameters loads default grid (sys/heightmap.csv), and with specified filename attempts to load the specified grid. If not available will not modify the current grid.
In RepRapFirmware this command is equivalent to the G29 S1 command.
M376 H10
This command specifies that bed compensation should be tapered linearly over the specified height, so that full bed compensation is applied at Z=0 and no bed compensation is applied when Z is at or above that height. If H is 1.0mm or less then tapering is not applied. So you can use M376 H0 to disable tapering.
RepRapFirmware does not adjust the extrusion factor to account for the layer height varying when tapered bed compensation is used. Therefore it is recommended that the taper height be set to at least 20x the maximum error in the height map, so that the maximum amount of the resulting over- or under- extrusion is limited to 5%.
M400 ; wait until motion stops, in RRF 3.5.0 and later with multiple motion systems release owned axes and extruders M400 S1 ; wait until motion stops, do not release any axes or extruders
Finishes all current moves and and thus clears the buffer. That's identical to G4 P0 except that G4 P0 does not release any axes or extruders.
M401 M401 P1
This runs macro file sys/deployprobe#.g (where # is the probe number) if it exists, otherwise sys/deployprobe.g if it exists.
M402 M402 P1
This runs macro file sys/retractprobe#.g (where # is the probe number) if it exists, otherwise sys/retractprobe.g if it exists.
M404 N1.75 M404 N3.0 D1.0 ; See note below about D parameter
Enter the nominal filament width (3mm, 1.75mm) or will display nominal filament width without parameters.
The 'D' parameter is used to properly detect the first layer height when files are parsed or a new print is being started. From RRF 3.4-b1 the D parameter is deprecated and no longer used in detecting the first layer height.
The values of this command are currently only used by the print monitor and only when the slicer reports the filament usage by volume instead of by length.
Deprecated in RRF 3.3 and later; planned for removal in RRF 3.5 and later. Use M409 instead to get response from Object Model, which provides more information.
M408 S0
This reports a JSON-style response by specifying the desired type using the 'S' parameter. The following response types are supported:
Here is an example of a typical type 0 response:
{"status":"I","heaters":[25.0,29.0,28.3],"active":[-273.1,0.0,0.0],"standby":[-273.1,0.0,0.0],"hstat":[0,2,1],"pos":[-11.00,0.00,0.00],"extr":[0.0,0.0],"sfactor":100.00, "efactor":[100.00,100.00],"tool":1,"probe":"535","fanPercent":[75.0,0.0],"fanRPM":0,"homed":[0,0,0],"fraction_printed":0.572}
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 GCode 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 GCode 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" or "Smoothieware"
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.
For a more detailed comparison of type 2 - 5, see Status Responses.
PanelDue currently uses only M408 S0 and M408 S1.
M409 K"move.axes" F"f" ; report all frequently-changing properties of all axes M409 K"move.axes[0]" F"v,n,d4" ; report all properties of the first axis, including values not normally reported, to a maximum depth of 4 M409 K"move.axes[].homed" ; for all axes, report whether it is homed M409 K"#move.axes" ; report the number of axes M409 F"v" ; report the whole object model to the default depth
The key string is just the path to the object model variables wanted, with the following extensions:
An empty key string selects the entire object model. Note, the entire object model may be very large, so there is typically insufficient buffer space to construct a JSON response that represents the whole object model. For this reason, RepRapFirmware sets a default maximum depth of 1 if the key string is empty or not present and the 'f' flag is not included in the flags string.
The flags string may include one or more of the following letters:
The flags string may optionally use spaces or commas to separate the individual flags
The response is a JSON object of the following form:
{"key":"key","flag'":"flags","result":object-value}
If the key string is malformed or refers to a property that does not exist in the object model, the result field is null.
For details of the Object Model supported by RepRapFirmware, see Object Model of RepRapFirmware.
Note: as of RRF 3.5.0 some arrays in the M409 response may be truncated under some conditions, to ensure that the response will fit in the available buffer space. Currently the only array affected is move.axes[] which is truncated to 9 elements unless the 'f' flag is included. To retrieve the entire array, make a request for key "move.axes" with flag "a0".
SBC note: When keys are queried that are provided by DSF, potential flags are ignored.
Support in RRF 3.5beta2 and later.
This command tells RRF to insert additional steps when the specified motors reverse direction, to compensate for backlash. The additional steps are inserted over a distance of at least the distance multiplier times the amount of backlash. For example, a multiplier of 10 and a backlash of 0.5mm would mean that the backlash steps would be inserted over as many moves as needed to make up at least 5mm of movement. If the multipler is set too low then missed steps could result.
The X,Y,Z... parameters refer to individual motors or sets of motors, not Cartesian axes. For example, on a CoreXY machine the X parameter defines the backlash compensation applied to the X motor, and the Y parameter defines the backlash compensation applied to the Y motor.
M425 with no parameters reports the current backlash compensation settings. The settings can also be read from the object model in move.axes[].backlash
and move.backlashFactor
.
M425 X0.15 Y0.23 S5
Supported by RRF 1.20 and later.
M450
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 responses are:
PrinterMode:FFF
PrinterMode:Laser
PrinterMode:CNC
The default at power up is FFF.
Supported by RRF 1.20 and later.
M451
Switches to Fused Filament Fabrication mode for filament printing.
Support in RRF 2.01 and later.
; Duet 3 MB6HC M452 C"out9" R255 F200 ; Enable Laser mode, on out9, with max intensity being 255, and a PWM frequency of 200
; Duet 3 Mini 5+ M452 C"out6" R255 F200 ; Enable Laser mode, on out6, with max intensity being 255, and a PWM frequency of 200
; Duet 2 example: M452 C"!exp.heater3" F100 ; laser uses heater3 pin inverted, PWM frequency 100Hz
M452 P3 I1 F100 ; laser uses heater3 pin inverted, PWM frequency 100Hz
M452 P2 R255 F200 ; switch to laser mode using the heater 2 (E1 heater) output pins to control the laser
Supported by RRF 1.20 and later.
Switches to CNC mode. All other parameters have been removed and moved into M950.
none
; Old code M453 S0 T1 C"!exp.heater3" R12000 ; Assign tool 1 to spindle index 0, with PWM pin on heater 3 and 12000 RPM achieved at full PWM
; New code M950 R0 C"!exp.heater3" L12000 ; Create spindle index 0, with PWM pin on heater 3 and 12000 RPM achieved at full PWM M563 P1 S"Spindle 1" R0 ; Create tool 1 with spindle 0 and call it "Spindle 1" M453
; Old code M453 S0 T1 C"exp.heater3+exp.heater4+exp.heater5" Q100 ; spindle PWM on heater 3 pin, on/off on heater 4, reverse/forward on heater 5, PWM frequency 100Hz
; New code M950 R0 C"exp.heater3+exp.heater4+exp.heater5" Q100 M563 P1 S"Spindle 1" R0 ; Create tool 1 with spindle 0 and call it "Spindle 1" M453
M453 C"exp.heater3+exp.heater4+exp.heater5" Q100 T1 ; spindle PWM on heater 3 pin, on/off on heater 4, reverse/forward on heater 5, PWM frequency 100Hz
M453 C"exp.heater3+exp.heater4" F100 T1 ; spindle forward/reverse on heater 3&4 pins, PWM frequency 100Hz
M453 P2 R5000 ; switch to CNC mode using heater 2 (E1 heater) pins to control the spindle motor
Logical pin numbers for the P parameters are as defined for the M42 and M208 commands. If you wish to assign a heater or fan output to control the spindle motor as in the above example, you must first disable the corresponding heater (see M307) or fan (see M106).
(comment)
. Comments cannot include double or nested parentheses, e.g. (comment (a bit more comment))
, and they must start and end on the same line. This complies with NIST Gcode interpreter guidelines. e.g. G28 (here come the axes to be homed) X Y
M470 P"/sys/config.d"
This will create a new directory on the SD-Card. If not otherwise specified the default root should be the first/internal SD-Card.
Supported in RRF >= 2.03.
Supported in RRF >= 2.03.
M471 S"/sys/config-override.g" T"/sys/config-override.g.bak"
Rename or move a file or directory. Using the D parameter will delete any existing file with the target name. Renaming or moving across directories is possible though not from one SD-Card to another.
Supported in RRF >= 3.5.
0
)M472 P"/sys/foobar" R1
Supported in RRF 3.1 and later.
M486 T12 ; Total of 12 objects (otherwise the firmware must count) M486 S3 ; Indicate that the 4th object is starting now M486 S3 A"cube copy 3" ; Indicate that the 4th object is starting now and name it M486 S-1 ; Indicate a non-object, purge tower, or other global feature M486 P10 ; Cancel object with index 10 (the 11th object) M486 U2 ; Un-cancel object with index 2 (the 3rd object) M486 C ; Cancel the current object (use with care!) M486 ; List the objects on the build plate
This provides an interface to identify objects on the print bed and cancel them. Basic usage: Use M486 Tnn to tell the firmware how many objects there are, so it can provide an LCD interface. (Otherwise the firmware counts them up in the first layer.) In every layer of your GCode, preface each object's layer slice with M486 S[index] to indicate which object is being printed. The index should be zero-based. To cancel the first object, use M486 P0; to cancel the 5th object use M486 P4; and so on. The "current" object is canceled with M486 C.
GCodes associated with the canceled objects are no longer printed. Firmware supports this feature by ignoring G0-G3/G5 moves in XYZ while updating F and keeping the E coordinate up-to-date without extruding.
Slicers should number purge towers and other global features with a negative index (or other flag) to distinguish them from regular print objects, since it is important to preserve color changes, purge towers, and brims.
In RepRapFirmware, if the GCode file being printed contains object label comments (e.g. using the "Label objects" option in PrusaSlicer) then it is not necessary to use M486 S commands to indicate which object is being printed. Objects on the build plate will be numbered from 0 in the order in which their labels first appear in the file.
If you do use M486 S commands in the GCode file instead of object label comments, then RepRapFirmware provides an optional A parameter to the M486 S command to allow objects to be named. The name of each object need only be specified once.
For the benefit of Duet Web Control and other user interfaces, the list of objects on the build plate known to RRF may also be retrieved from the object model using M409, including their names (if available) and approximate locations.
Implemented in RepRapFirmware 1.17 and later.
M500 M500 P31 M500 P10 M500 P10:31
Save current parameters to the sys/config-override.g on the SD card, similar to other firmware's storing to EEPROM. The parameters stored are:
Ensure that M501 is at the end of config.g in order for the values in config-override.g to be loaded on startup.
M501
Set the active parameters to those stored in sys/config-override.g on the SD card. This command should be included near the end of the config.g file so that the stored parameters will be loaded at startup. It can also be used to revert parameters to the values stored in config-override.g after experimenting with them.
M502
This sets all machine parameters to the values defined in config.g, ignoring the config-override.g file so that any changes that were saved by M500 are not applied. It does this by running config.g but ignoring any M501 commands that it contains.
M502 does not clear or reset the config-override.g file; so next time the machine is started, the values that were saved by M500 will once again be applied. If you want to cancel the changes saved by M500 permanently, you can run M502 and then M500.
M503
This command asks the firmware to reply with the current print settings stored in sys/config.g. The reply output includes the GCode commands to produce each setting. For example, the Steps Per Unit values are displayed as an M92 command.
The output may be truncated if it is too long. M503 does not include values stored in config-override.g.
M505 P"experimental" ; change config file path from /sys/ to /sys/experimental/
Following this command, files that would normally be fetched from /sys/ (for example, homing files and system macro files in RepRapFirmware) are fetched from the specified folder instead. Any such files that are already being executed will continue to run.
This command can be used to allow multiple configurations to be maintained easily. In RepRapFirmware the file /sys/config.g can contain just these two lines:
M505 P"config1" M98 P"config.g"
The first line changes the config file folder to /sys/config1 and the second one executes file config.g in that folder. To select an alternative configuration, only the first line needs to be edited.
M540 PDE:AD:BE:EF:CA:FE
Sets the MAC address of the printer. This should be done before any other network commands. The MAC address is six one-byte hexadecimal numbers separated by colons. Only works on Ethernet-equipped Duet mainboards, in standalone mode (i.e. not Duets with WiFi or Duet boards with SBC).
M550 P"Godzilla"
Sets the name of the printer to (in the case of the above example) Godzilla. The name can be any string of printable characters except ';', which still means start comment. The name shows at the top of the DWC page.
The machine name is also used to allow local network discovery using mDNS local network discovery. Rather than remembering the ip address of the printer to connect to, or having to find it if assigned by DHCP (mDNS works both with fixed ip address and DHCP), you can use it's name. Using the example name above, in your browser connect to the DWC with http://Godzilla.local
.
M551 P"my-very-secret-word"
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 security. But on machines that are (say) on a network, it might prevent idle messing about. The password can contain any printable characters except ';', which still means start comment.
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.
Quotation marks around the password are mandatory in RRF3, but discretionary in earlier firmware versions.
M552 S1 P"MyNetwork"
Enables networking as a client, and joins the network with the SSID 'MyNetwork', using the parameters (password, IP/gateway address, netmask) configured in M587.
Duet 2 Ethernet:
M552 S1 P192.168.1.14
Sets the IP address of the machine to (in this case) 192.168.1.14. If the S parameter is not present then the enable/disable state of the network interface is not changed.
Duet 3 in SBC mode:
The I1 setting here specifies the second network interface on the SBC. This uses the DuetPi Management Plugin (installed by default from RRF 3.3 onwards) to set the address on the SBC. To determine which interface is which on the SBC the object model explorer can be used to see the current settings of each interface.
M553 P255.255.255.0
Sets the network mask of the RepRap machine to (in this case) 255.255.255.0.
M554 P192.168.1.1
Sets the Gateway IP address of the RepRap machine to (in this case) 192.168.1.1.
M555 P1
Set the firmware to a mode where its input and (especially) output behaves similar to other established firmware. The value of the 'P' argument is:
value | Firmware |
---|---|
0 | RepRap_Firmware |
1 | RepRap_Firmware |
2 | Marlin |
3 | Teacup |
4 | Sprinter |
5 | Repetier |
6 | nanoDLP (RRF 2.02RC6 and later) |
Currently, only RepRapFirmware, Marlin and nanoDLP emulations are supported.
M556 S100 X0.7 Y-0.2 Z0.6 M556 ; reports the axis compensation in use Axis compensations - XY: 0.00700, YZ: -0.00200, ZX: 0.00600
This tells software the tangents of the angles between the axes of the machine obtained by printing then measuring a test part. When used without parameters, reports the axis skew compensation factors in use.
All values in mm.
M557 X0:200 Y0:220 S20 M557 X0:100 Y0:120 S50:60 M557 R150 S15
Defines the grid for G29 Mesh Bed probing.
Deprecated and not supported in firmware 1.18 and later. Cartesian/CoreXY printers only,
M557 P1 X30 Y40.5
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.
M558 must come before G31.
M558 P5 C"e0stop" H5 F120 T3000 ; Z probe connected to Duet 2 E0 endstop input
M574 Z0 P"nil" ; (RRF 3.0 on Duet 2 ONLY) no Z endstop switch, free up Z endstop input M558 P5 C"zstop" H5 F120 T3000 ; Z probe connected to Duet 2 Z endstop input
; BL Touch on Duet 3 Mini 5+ M950 S0 C"io3.out" ; servo/gpio 0 is io3.out pin M558 P9 C"io3.in" H5 F500:120 T3000 ; BLTouch connected to io3.in pin ... M280 P0 S10 ; send control signal to BLTouch through servo/gpio 0
; BLTouch on Duet WiFi M950 S0 C"exp.heater3" ; create servo/gpio 0 on heater 3 pin on expansion connector M558 P9 C"^zprobe.in" H5 F120 T3000 ; BLTouch connected to Z probe IN pin ... M280 P0 S10 ; send control signal to BLTouch through servo/gpio 0
; For the Duet Smart Effector on Duet 2 M558 P8 C"zprobe.in+zprobe.mod" R0.4 F1200 ; zprobe.mod is the programming pin for M672
A Z probe may be a switch, an IR proximity sensor, or some other device. The P parameter selects which to use:
Probe types 4, 6 and 7 (used in RRF 2.x) are no longer supported. Instead, use type 5 (filtered digital) or 8 (unfiltered digital) and use the C parameter to specify the input.
Probes connected to Duet 3 expansion or tool boards are limited to types 8 and 9. Firmware 3.5 also supports type 11.
Only one Type 2 probe can be configured, and if using Duet 3 then it must be connected to the Duet 3 main board, not to a CAN-connected expansion or tool board.
M558 with P parameter deletes the existing probe with that K number (if any) and creates a new Z probe. This resets the G31 values for that probe to default values.
In RRF 3.0 on Duet 2 boards only (not in RRF 3.01 and later, and not in RRF 3.0 on Duet 3), if your Z probe is connected to the Z endstop input, that input is by default pre-assigned to be used by the Z endstop, so you must free it up first with M574 Z0 P"nil"
.
The C parameter specifies the input pin and the optional modulation pin. See Pin names for a list of available pins and their names to use. Invert the input by prefixing the input pin with ! character, when using an NPN output inductive or capacitive sensor or using an NO switch (not recommended, use a NC switch instead). The pullup resistor on the Z probe input is disabled by default. Enable it by prefixing the input pin (C parameter) with the ^ character. Enable pullup resistor with ^ if using Duet 2, running RRF3, using the Z probe input pin, and the probe type is a switch or BLTouch.
The H parameter defines the Z probe dive height, which is the height above the trigger height from which probing starts. The default is 3mm or 5mm depending on firmware version. You may wish to increase it during initial calibration. When using mesh bed compensation or running G30 commands with specified XY coordinates (for example from the bed.g file), the firmware moves the Z probe to this height above where it expects the bed to be before commencing probing. The maximum depth of probing from this position is twice the dive height. A large dive height will tolerate a very uneven bed or poor calibration. A small dive height will make probing faster, because the Z probe has less distance to travel before reaching the bed. Default value if omitted is 5mm.
The F parameter:
The A and S parameters control multiple probing. Probing is repeated until two consecutive probe attempts produce results that differ by no more than the S parameter; then the average of those two results is used. For example, S-1 would force averaging. However, if the number of attempts specified by the A parameter is reached without getting two consecutive results within tolerance of each other, no further probe attempts are made and the average result of all the attempts is used.
Related commands: G29, G30, G31, G32, M401, M402.
See also: Choosing a Z probe, Connecting a Z probe
Obsolete parameters
M558 must come before G31.
M558 P1 X1 Y0 Z1 F500 T5000 H3 ; Z probe is used for homing X and Z axes (RRF 1.19 and earlier)
M558 P4 H5 F120 T3000 ; Z probe connected to E0 endstop input
M558 P7 H5 F120 T3000 ; Z probe connected to Z endstop input
; BLTouch on Duet Maestro M558 P9 H5 F120 T3000 ; BLTouch connected to Z probe IN pin ... M280 P64 S10 ; send control signal to BLTouch through Z probe MOD pin
; BLTouch on Duet WiFi M558 P9 H5 F120 T3000 ; BLTouch connected to Z probe IN pin M307 H3 A-1 C-1 D-1 ; free up heater 3 to use as BLTouch servo pin ... M280 P3 S10 I1 ; send control signal to BLTouch through heater 3 pin
A Z probe may be a switch, an IR proximity sensor, or some other device. The P selects which to use:
The H parameter defines the Z probe dive height, which is the height above the trigger height from which probing starts. The default is 3mm or 5mm depending on firmware version. You may wish to increase it during initial calibration.
The A and S parameters control multiple probing. Probing is repeated until two consecutive probe attempts produce results that differ by no more than the S parameter; then the average of those two results is used. For example, S-1 would force averaging. However, if the number of attempts specified by the A parameter is reached without getting two consecutive results within tolerance of each other, no further probe attempts are made and the average result of all the attempts is used.
In RepRapFirmware versions 1.20beta4 and earlier, the X, Y and Z parameters specify whether each axis uses the Z probe as a substitute homing switch 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. In firmware 1.20beta6 and later, use the S parameter in the M574 command instead to indicate whether you are using a homing switch or a Z probe for homing X and Y.
Related commands: G29, G30, G31, G32, M401, M402.
See also: Choosing a Z probe, Connecting a Z probe
Supported from RRF 3.5.0-rc.1
M558.1 Knn Sn.n
M558.1 Knn Ann.n Bnn.n Cnn.n
M558.1 Knn
M558.1 is used to define the coefficients that calculate the height from the scanning Z probe reading. This can be done either by setting these coefficients directly, or by instigating a calibration move. Both are done with M558.1. If at least the A parameter is present, then the equation to calculate the actual height of the Z probe is set to this:
height = trigger_height + A * (probe_reading - probe_threshold) + B * (probe_reading - probe_threshold)^2 + C * (probe_reading - probe_threshold)^3
where trigger_height is the G31 Z parameter, and probe_threshold (or trigger value) is the G31 P parameter.
Note that the probe_threshold (G31 P parameter trigger value) is set for the trigger_height (G31 Z parameter) during M588.1 calibration.
Before M558.1 is used the probe must be defined as a scanning Z probe using M558, the probe trigger height must be set using G31, the axes must have been homed, the sensor must be over the bed surface and not too close to the edges of the bed, and the sensor drive current should have been set using M558.2 if necessary.
M558.1 K1 S1.7 ; Use probe 1 to calibrate probe, scanning 1.7mm above and below trigger height set by G31 Z parameter M558.1 K1 A-2.865e-4 B2.598e-10 C2.937e-17 ; Set coefficients for probe 1 M558.1 K1 ; report coefficients in use on probe 1
In the first example, if G31 Z2
was set, the probe would calibrate in the range Z3.7 to Z0.3.
M558.1 K1 Scanning probe coefficients [1.840e-1, -2.865e-4, 2.598e-10, 2.937e-17]
See also: Scanning Z Probe calibration
Supported from RRF 3.5.0-rc.1
M558.2 Knn S-1
M558.2 Knn Snn Rnnnn
M558.2 Knn
This command is used to set the drive current of scanning Z probes that use the LDC1612 chip. If the drive current is set too low, the sensor will not work when it is close to the bed. If the drive current is set too high, it will not work when the sensor is distant from the bed. Use M122 B# (where # is the CAN address of the board that carries the sensor) to determine whether the sensor is working normally.
Before M558.2 is used the probe must be defined as a scanning Z probe using M558.
After M558.2 is used to change the drive current and/or reading offset, M558.1 should be used to recalibrate the probe.
M558.2 K1 S-1 ; calibrate coil drive current and reading offset on probe 1, at current Z height M558.2 K1 Snn Rnnnn ; set coil drive current and reading offset on probe 1 M558.2 K1 ; report coefficients in use on probe 1
M558.2 K1 Sensor drive current is 15, offset is 139919
See also: Scanning Z Probe calibration
M559 P"config.g"
In RRF 3.1 and earlier, the default filename is config.g and the default path is /sys. In RRF 3.2 and later there is no default filename.
Quotation marks around the filename are mandatory in RRF 3.2 and later.
Was used by the original web interface to upload a configuration file. Can now be used to upload any file.
M560 P"index.html"
In RRF 3.1 and earlier, the default filename is reprap.htm and the default path is /www.
After sending M560 the 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.
M561
This cancels any bed-plane fitting as the result of probing (or anything else) and returns the machine to moving in the user's coordinate system.
M562 P2 ; Reset a temperature fault on heater 2
If the heater has switched off and locked 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 heater H0, P1 is heater H1, and so on.
In firmware 1.20 and later, M562 with no parameters will clear a heater fault on all heaters
M563 P0 D0:2:3 H1:3 ; create a tool using extruder drives 0, 2 and 3 and heaters 1 and 3 M563 P1 D1 H2 X3 ; create a tool using extruder drive 1 and heater 2 with X movement mapped to the U axis M563 P2 D0:1 H1:2 X0:3 F0:2 ; create a tool using extruder drives 0 and 1, heaters 1 and 2, with X movement mapped to both X and U axes and fan 0 mapped to fans 0 and 2 M563 P3 D0 H1 S"Chocolate extruder" ; create a named tool using extruder drive 0 and heater 1 M563 P1 D-1 H-1 ; Delete tool 1
Tools are usually (though not necessarily) extruders. Normally an M563 command to define a tool is immediately followed by a G10 command to set the tool's offsets and temperatures (temperatures can also be set with M568).
P The 'P' field specifies the tool number. In RRF3, tool numbers may be between 0 and 49. In RRF2 they may be between 0 and 65535. If you use the M563 command with a P value for a tool that has already been defined, and you provide any other parameters, that tool is redefined using the new values you provide.
D The 'D' field specifies the drive(s) used by the tool - in the first example drives 0, 2 and 3. The 'D' field number corresponds to the 'E' parameter defined in the M584 command. '0' means first 'E' driver in M584 and so on. 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. 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.
H 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. 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.
F The print cooling fan number(s) of the tool, default 0. Use this parameter if you are not using fan 0 as the print cooling fan for the tool you are defining. You do not need to, and must not, list the fan numbers of thermostatic hot end fans here. To use more than one print cooling fan for the tool, the definition would typically look like this:
M563 P0 D0 H1 F0:1 ; tool 0 uses extruder drive 0 and heater 1. Fan 0 and Fan 1 are use by tool 0 as print cooling fans.
R The spindle number mapped to this tool. (RRF >= 3.3beta2)
M563 P0 R0 ; assign spindle 0 to tool 0
X, Y, Z The X, Y and Z mapping options are used to create tools on machines with multiple independent X, Y and/or Z carriages. The additional carriages are set up as axes U, V etc. (see M584) and the X/Y/Z mapping option in M563 defines which carriage or carriages are used. Axes are mapped in the order XYZUVWABC, where X=0, Y=1, Z=2, U=3 etc, not by driver number.
S As shown in the example above the S parameter can be used to give a tool a name. 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.
RepRapFirmware maps the loaded filament on a per-extruder basis so if you have a mixing tool (one with more than one extruder), the L parameter tells the web interface which filament to display. If there is more than one extruder and the L parameter is omitted, no filament is displayed at all.
In RepRapFirmware 3.x, in order to avoid the serialised object model getting very large, the P parameter (tool number) may not exceed 49.
M563 with just a P parameter just reports the existing configuration of the tool. Therefore, if you want to create a tool with no heaters and no extruders, you must provide at least one other parameter. For example, you can use the S parameter to name the tool.
RepRapFirmware allows the deletion of existing tools if M563 is called in this way:
M563 P1 D-1 H-1
M564 S0 H0
Allow moves outside the print volume and before homing, or not. If the S parameter is 0, then you can send G codes to drive the RepRap outside its normal working volume, and it will attempt to do so. Likewise if the H parameter is zero you can move the head or bed along axes that have not been homed. The default behaviour is S1 H1. On some types of printer (e.g. Delta and SCARA), movement before homing may be prohibited regardless of the H parameter.
M566 X600 Y600 Z50 E600
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.
X and Y parameter: If you set the 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.
Z parameter: When mesh bed compensation is used, movement may be jerky if the allowed Z jerk is too low, because the Z speed needs to change abruptly as the head moves between squares in the mesh.
P parameter: The default jerk policy is 0, which replicates the behaviour of earlier versions of RRF (jerk is only applied between two printing moves, or between two travel moves, and only if they both involve XY movement or neither does). Changing the jerk policy to 1 allows jerk to be applied between any pair of moves.
The minimum jerk speed supported in as at firmware version 2.02RC3 is 0.1mm/sec.
RepRapFirmware does not support individual motor settings where an axis has multiple motors connected to different stepper drivers. The first parameter specified will be used for all motors on the axis. You should use identical motors on any axis that has more than one motor to avoid unexpected behaviour.
Example: If you have two motors on your Z axis, physically connected to Z and E0 stepper drivers, configured with M584 Z2:3, set M566 Z50, not M566 Z50:50
M567 P2 E0.1:0.2:0.1:0.6
This example sets the mix ratio for tool 2 (the P value). When a G1 or G0 command contains only a single E value but the current tool uses multiple extruders, each extruder will extrude the amount specified in the E parameter times the mix value for that tool. For example:
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 when using a mixing hot end it is normally sensible if they do, otherwise under or over extrusion would occur. When printing concurrently with multiple print heads (e.g. ditto printing on an IDEX machine), it is normal for each print head to have a [total] extrusion factor of 1.0.
WARNING: Currently the firmware will allow to set a mixing ratio where every extruder will drive at 100% - in case of a setup where several extruders feed the same hotend (like Diamond Hotends) this can lead to dangerously high pressures that could damage the printer.
The default is for the first driver to be set to 1, and all others to be set to 0. (ie for 2 drivers the default is E1:0)
Available in RepRapFirmware 3.3beta2 and later. The R and S parameters are alternatives to the temperature-setting functions of G10, which may be deprecated in the future.
M568 P1 R140 S205 ; set standby and active temperatures for tool 1 M568 P0 F5200 ; set spindle RPM for tool 0 M568 P2 A1 ; set tool 2 heaters to their standby temperatures
The R value is the standby temperature in °C that will be used for the tool, and the S value is its operating temperature. If you don't want the tool to be at a different temperature when not in use, set both values the same.
The F value will be used to set the configured spindle RPM for this tool's spindle. This value is direction-independent and needs to be given as a positive number. If the spindle is already running it will apply the new speed to the current direction (selected by M3/M4) immediately.
Remember that any parameter that you don't specify will automatically be set to the last value for that parameter.
RepRapFirmware will report the tool parameters if only the tool number is specified.
Temperatures set with M568 do not wait for the heaters to reach temp before proceeding. In order to wait for the temp use a M116 command after the M568 to wait for temps to be reached.
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.
Deprecated: from firmware 1.19 onwards, this command is no longer required or supported.
M568 P2 S0
Turn on/off automatic mix ratios for tool 2.
If a G1 command for the tool provides just one E value, then the mix ratio defined by M567 will always be used.
After turning off command G1 instructions must send as many E values as the tool has drives: G1 X20 E0.2:0.4:0.166:0.3
M569 Px
can be used to verify the iRun value used and the calculated current the driver will actually apply to the motor. Setting iRun directly can allow setting hysteresis start/end values that are more suitable for specific motors, resulting in lower noise. In theory this should only be needed when using low inductance motors, or a high motor supply voltage (e.g. 48V). You can use the excel calculator provided by TMC to help tune iRun and hysteresis values.M569 P0 S0 ; reverse the direction of the motor attached to driver 0 M569 P5 R1 T2.5:2.5:5:0 ; driver 5 requires an active high enable, 2.5us minimum step pulse, 2.5us minimum step interval, 5us DIR setup time and no hold time
Sets the configuration parameters of a closed loop driver. See the M569 D parameter for switching a driver to closed loop after it has been configured.
For RRF 3.4, if you are using a quadrature encoder on the motor shaft, the encoder counts per full step (Cn.n) can be found from the datasheet of the encoder being used. If the value is stated as counts per revolution (CPR), divide by the steps per revolution of the stepper motor to get the count per step. For example, a 1000 CPR encoder attached to a 200 step/rev (1.8 deg/step) motor will have a count per step of 1000 ÷ 200 = 5.
Duet 3 Expansion 1HCL reading of stepper driver registers fixed in RRF 3.5.1.
Supported in RRF 3.4.0 and later on main boards and CAN-connected boards with TMC22xx or TMC51xx stepper drivers.
Supported in RRF 3.3 and later on main boards only, with TMC22xx or TMC51xx stepper drivers.
M569.2 P1 R0
If the V parameter is not provided, this command reads the specified register and returns the value of that register. If the V parameter is provided, that value is written to the specified register.
WARNING! Use of M569.2 to write stepper driver registers may result in damage to the stepper drivers, for example from excessive motor current or insufficient blanking time.
Supported on Duet 3 MB6HC and MB6XD boards with ODrives connected to the second CAN bus and Hangprinter kinematics configured
Report a current motor encoder positions to the host in units of arc degrees (1/360'ths of turns), relative to some reference position that you set with the S parameter.
M569.3 Error: M569: missing parameter 'P'
M569.3 P54.0 Error: M569.3: Message not received
M569.3 P50.0:51.0:52.0:53.0 [-155.28, -4089.60, 6842.04, 0.00, ],
M569.3 P53.0:51.0:52.0:50.0 [0.00, -4089.60, 6842.04, -155.28, ],
M569.3 P53.0:51.0:52.0:50.0 S [0.00, 0.00, 0.00, 0.00, ],
M569.3 P49.0 Error: M569.3: Max CAN addresses we can reference is 4. Can't reference board 49.
Before the first call with the S parameter, the reference is unknown and arbitrary.
If P is not supplied, an error is returned.
A maximum of four CAN-connected drivers can be reached with M569.3 counting from machine boot. CAN addresses that fail to respond don't count towards this maximum.
Supported in firmware 3.5 post beta4 on Expansion 1HCL and M23CL devices when in closed loop mode. Also supported in firmware 3.4 and later on Duet 3 MB6HC and MB6XD boards with ODrives connected to the second CAN bus and Hangprinter kinematics configured.
Tell one or more motor drivers to apply a specified torque regardless of position.
M569.4 Error: M569: missing parameter 'P'
M569.4 P50.0:51.0 Error: M569: missing parameter 'T'
M569.4 P50.0 T0.001 0.001000 Nm
M569.4 P50.0:51.0 T0 pos_mode, pos_mode
Collect performance data from a drive whilst in closed loop mode. Can be used alongside the Duet Closed Loop plugin for visualisation. Records back to a CSV file located in the /sys/closed-loop directory, which will be created if it does not exist.
The following variables are available to record:
Variable Name | Description | Variable ID |
---|---|---|
Raw Encoder Reading | The raw reading that the expansion board has read from the encoder. For a quadrature encoder, this represents the number of pulses received, so may be 4 times the expected CPR. | 1 |
Measured Motor Steps | The current position of the motor measured in the standard unit of 'steps'. Similar to raw encoder reading, but will be standardised across different types of encoders with different CPRs. | 2 |
Target Motor Steps | The number of steps that the motor has been commanded to take. This becomes the target signal fed into the PID controller. | 4 |
Current Error | The difference between the current motor steps and the target motor steps. Directly used as an input to the PID controller. | 8 |
PID Control Signal | The control signal (normalised between -255 and 255 coming from the PID controller. | 16 |
PID P Term | The value of the PID controller's P term. | 32 |
PID I Term | The value of the PID controller's I term | 64 |
PID D Term | The value of the PID controller's D term. | 128 |
Measured Step Phase | The current position of the motor's stator, expressed as the proportion of the way through the motor's 4 step cycle. Normalised between 0-4095 | 256 |
Desired Step Phase | The angle for which current will be applied. For maximal torque, this value will be 25% ahead of step phase, for minimal torque, this value will equal step phase. | 512 |
Phase Shift | The difference between the desired step phase and the step phase. Roughly proportional to torque applied. | 1024 |
Coil A Current | The current running through coil A, expressed as a proportion of the motor's maximum current normalised between -255 to 255. | 2048 |
Coil B Current | The current running through coil B, expressed as a proportion of the motor's maximum current normalised between -255 to 255. | 4096 |
PID V Term | The value of the PID controller's P term. | 8192 |
PID A Term | The value of the PID controller's I term | 16384 |
Motor current fraction | The fraction of the configured motor current that is set | 32768 |
To record multiple variables, sum the variable IDs and pass the resulting value as the D parameter. For example, to record coil A current (2048) and coil B current (4096), use D6144.
The following manoeuvres are available:
Manoeuvre Name | Description | Manoeuvre ID |
---|---|---|
Polarity Detection and Zeroing | Detects in which orientation the stepper motor coils are connected, this will also detect if a motor's wiring is faulty or it is not plugged in. Ensures that a feedback reading of 0 corresponds to the position the encoder assumes when only coil A is energised. Note this move would normally be carried out using M569.6 prior to PID loop tuning. | 1 |
Absolute SPI Encoder Calibration | Calibrates the encoder positions to the motor. Note this move would normally be carried out using M569.6 prior to PID loop tuning and only needs to be done once per Motor,encoder and 1HCL combination. | 2 |
Step Manoeuvre | Applies a sudden change of 4 full steps to the PID target to view the step response of the PID controller. | 64 |
M569.5 P50.0 S500 A0 R0 D6 V64
Record 500 samples (S500) of the current motor steps and target motor steps (D6) of driver 0 attached to board 50 (P50.0) immediately (A0) and as fast as possible (R0) whilst performing a step manoeuvre (V64)
The Duet Closed Loop plugin can be used to generate and run M569.5 commands.
Supported for drivers attached to:
Note: The driver must be configured in closed loop mode (See M569 D parameter).
Perform a runtime tuning manoeuvre with a closed loop drive.
Warning: Duet firmware currently only supports tuning one driver at a time. This means that when tuning a multi-driver axis, one driver will move and the other(s) will not. If attempting to tune a multi-driver axis, please take appropriate mitigation to ensure the axis doesn't become stressed/misaligned when only one one driver moves.
The closed-loop tuning page lists the available tuning moves.
M569.6 P50.0 V1 ; conduct polarity detection and zeroing move on closed loop driver on HCL board at address 50. M569.6 P51.0 V2 ; conduct magnetic encoder calibration on move on closed loop driver on HCL board with magnetic encoder at address 50.
Supported for drivers attached to:
M569.7 P40.0 C"out1" ; driver 0 on board 40 uses port out1 on board 40 to control the brake M569.7 P0.2 C"out9" S20 ; driver 2 on mainboard uses port out9 to control the brake, with 20ms delay
Supported only on Duet 3 MB6HC and MB6XD boards with ODrives connected to the second CAN bus and Hangprinter kinematics configured
Supported by the STM port of RRF only
M569.9 P0.1 R0.075 S4.4 ; driver 1 on the main board has a 0.075 Ohm sense resistor and will have the maximum current setting limited to 4.4A
This command is available on boards running the STM32 port of RepRapFirmware (version 3.4.2_102 and later), it can be used to inform the firmware of the TMC driver sense resistor and maximum current limit used by driver modules that have non standard values.
The actions taken on a heater fault, after the heater is shutdown, are now handled by the event system.
The actions taken on a heater fault, after the heater is shutdown, are now handled by the event system.
Parameters for RepRapFirmware 1.15e to 3.3
Parameters for RepRapFirmware 1.14 and earlier
When using RepRapFirmware 3 the M570 command must come later in config,g than the M950 command that creates the heater specified in the H parameter.
M570 H1 P4 T15 ; An anomaly on heater 1 must persist for 4 seconds, and must be greater or less than 15C from the setpoint, to raise a heater fault.
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 carefully consider sensible values for the detection time or permitted temperature excursion, setting them incorrectly will reduce the protection. Also note that this protection should not be relied upon exclusively. Protection against fire should be provided external to the operation of the firmware as well (fuses, fire detection, do not print unattended etc)
For further details about heater fault handling see Heater faults and how to avoid them
M571 P3 F200 S1 ; turn on logical pin 3 while extrusion is commanded (RRF 2) M571 P"heater3" S0.5 ; turn on heater 3 output at 50% PWM while extrusion is commanded (RRF 3)
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 3 you specify the pin name using the P parameter.
For RepRapFirmware 1.x and 2.x, 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.
In RepRapFirmware 1.17 and later you can use the P parameter to change the pin used and set the PWM frequency. Defaults to using the FAN0 output.
RepRapFirmware 1.20 and later do not default to using the FAN0 output, so you must send M571 with a P parameter at least once to define the pin that you wish to use.
M572 D0 S0.1 ; set extruder 0 pressure advance to 0.1 seconds M572 D0:1:2 S0.2 ; set extruder 0, 1 and 2 pressure advance to 0.2 seconds (RepRapFirmware 1.20 and later)
This sets the pressure advance coefficient (S parameter) for the specified extruder (D parameter). Only one S value is allowed. If you wish to set different pressure advance for different extruders, use multiple M572 commands.
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.
If you configure Input Shaping, you will need to retune your Pressure Advance. It is recommend to first tune Input Shaping, then Pressure Advance, then Retraction.
For more details such as tuning the value see Pressure advance.
Not supported in RRF 3.4 and later.
M573 P1
This gives a running average (usually taken over about five seconds) of the PWM to the heater specified by the P field. If you know the voltage of the supply and the resistance of the heater this allows you to work out the power going to the heater. Scale: 0 to 1.
In RRF 3.4 and later, if you need to find the average heater PWM, you can query the object model instead. The recommended replacement for M573 P1 is:
echo heat.heaters[1].avgPwm
This command must be later in config.g than the M584 command that creates additional axes, or axes that have multiple motors and endstops.
M574 X1 S1 P"io1.in" ; configure active high endstop switch for low end on X (Duet 3) M574 Y2 S1 P"!io2.in" ; configure active low endstop switch for high end on Y (Duet 3) M574 Z1 S1 P"e0stop" ; configure active high endstop switch for low end on Z (Duet 2) M574 U1 S2 ; configure Z-probe endstop for low end on U M574 V2 S3 ; configure sensorless endstop for high end on V
To use two Z motors using independent homing switches, declare two Z motors in M584, then declare two pins for Z endstops in a single M574 command. Example
M584 X0 Y1 Z2:3 E4 M574 Z1 S1 P"io2.in+io3.in" ; Z axis with two motors, individual min endstops, active high
The order of endstop switch pin names in M574 must match the order of Z motor driver numbers in M584. When homing Z, RRF3 homes the motors of the axis at the same time, independently to their defined endstops. See Axis levelling using endstops.
M574 X1 S1 P"!xstop"
. Invert the input when using an NPN output inductive or capacitive sensor, or using a NO switch (not recommended, use a NC switch instead).If this command refers to any axes other than X, Y and Z then it must be later in config.g than the M584 command that creates those additional axes.
M574 X1 Y2 Z0 S1 ; X endstop at low end, Y endstop at high end, no Z endstop, all active high
This defines the type of endstop switch or opto 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) or low (S0). A normally-closed endstop switch wired in the usual way produces an active high output (S1).
The S2 and S3 options are supported in firmware 1.20 and later.
This is intended for use with boards that provide a single endstop input for each axis that may be used for either a high or a low end endstop, such as the Duet. 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).
If you have more than one homing switch for an axis because you want to home multiple motors driving that axis individually, you will need to split them into separate axes during homing, and home those axes together. See Axis levelling using endstops.
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.
M575 P1 B57600 S1
P0 specifies the main serial interface (typically a USB port), while P1 specifies an auxiliary serial port (for example, the port used to connect a PanelDue) and P2 specifies a second auxiliary port if there is one. The B parameter is the required baud rate (this parameter is ignored if the port is a true USB port).
Modes 2 and 3 are supported in RRF 3.01 and later. Modes 4 and 6 are supported in RRF 3.4 and later. Mode 5 is supported in RRF 3.6 and later. Mode 7 is supported by RRF 3.6 and later on some boards.
In RRF 3.1 and later for Duet 3, the auxiliary serial port remains disabled until a M575 P1 command is received. This is to allow the IO_0 port to be used for other purposes. In RRF 3.2 and later on all boards, the auxilliary serial port(s) remain disabled until enabled using M575.
Supported in RRF 3.4 and later in SBC mode.
This sets the communications parameters of the SPI channel.
Wait for an endstop switch to be triggered or an input to become active.
If M577 uses an input pin number, M577 must come after the M950 command that defines the input pin number.
M577 X S0 ; wait until X endstop is not triggered
M950 J2 P"!e0stop" ; define input pin number 2 M577 P2 ; wait until tE0 endstop input is low
M577 P"!xstop+!e0stop" ; wait until the X and E0 endstop inputs are both low
Use the P parameter to specify one or more pin names. The pin(s) do not need to be exclusively used by M577; for example, it is permitted to specify the name of a pin that has already been declared as used by an endstop switch in a M574 command.
The command waits for a high input level. To wait for a low input level, invert the pin name by prefixing "!".
M577 E0 S1
Wait for an endstop switch to be pressed. The example above will wait until the first extruder endstop is triggered.
The following trigger types may be used using the 'S' parameter:
0: Endstop not hit
1: Low endstop hit
2: High endstop hit
3: Near endstop (only Z probe)
This command is not enabled unless the SUPPORT_INKJET feature is enabled when the firmware is built.
M578 P3 S5
This fires inkjet head 3 (the P field) using the bit pattern specified by the S field, in the example shown would fire bits 101.
If the P parameter is ommitted inkjet 0 is assumed.
This is a version of the M700 command used by Inkshield.
An alternative way of controlling inkjets would be to use the P parameter on the G1 command, in conjunction with the M670 command.
On a Cartesian RepRap you can get prints exactly the right size by tweaking the axis steps/mm using the M92 GCode. 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).
M579 X1.0127 Y0.998
On a suitable-configured IDEX printer, a scaling factor of -1 for the U axis can be used to turn a ditto print into a mirror image print.
This M-code is not available by default. To enable it change the value of SUPPORT_ROLAND in the Pins_*.h file from 0 to 1 and recompile the firmware.
The Modela MDX-20 and similar milling machines are very widely available in hackerspaces and maker groups, but annoyingly they don't speak GCodes. As all RepRap firmware includes a GCode interpreter, it is often easy to add functions to convert GCodes to RML.
M580 R1 PVS4;!VZ2;!MC1;
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 T2 P0:3 S1 R1 ; invoke trigger 2 when an inactive-to-active edge is detected on input 0 or input 3 and a file is being printed from SD card M581 T3 X Y S1 ; invoke trigger 3 when the X or Y endstop switch is triggered M581 T2 P-1 ; don't invoke trigger 2 on any input change any more
For examples, see Using triggers to control the Duet and Connecting and emergency stop.
M581 P"e0stop+e1stop" 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 M581 P"nil" T2 ; don't invoke trigger 2 on any input change any more
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
M582 T2 ; check levels of inputs that give rise to trigger #2 M582 T3 S1 ; set trigger #3 pending unconditionally
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. If the S1 parameter is used then the trigger will be activated unconditionally (RRF 3.5 and later only).
For example, if you use M581 to support an out-of-filament sensor, then M582 allows you to check for out-of-filament just before starting a print.
M584 X0 Y1 Z2:3 E4:5:6 ; Driver 0 controls the X motor, 1 controls Y, 2 and 3 control Z motors, 4 5 and 6 control E motors
M584 X0 Y1 Z2 E3:4:1.0:1.1
The "0" index for the main board is implicit, this is equivalent to the previous example:
M584 X0.0 Y0.1 Z0.2 E0.3:0.4:1.0:1.1
; Here axis B and extruder E0 have already been assigned and possibly moved, but we now want to reassign them M18 B E0 ; disable the axes/extruder that we are going to reassign M584 B3 E4 ; reassign them M906 B1000 E1000 ; set the motor currents M350 B16 E16 I1 ; set the microstepping
Supported in RRF 1.20 and later.
In machines with at least one tool probe this code allows to update the current tool's offset by driving it into a given endstop. This code works similarly to G1 .. H1 (machine homing; G1 .. S1 is RRF 2.02 and earlier) except that it sets the offset of the current tool instead of the machine position, and that a custom endstop number (RRF 2.x) or custom Z probe (RRF 3.x) can be used.
M558 K1 P5 C"!e0stop" ; create probe #1 for use with M585, active low ... M585 X100 F600 P1 S0 ; probe X until probe #1 is triggered
M585 X100 F600 E3 L0 S0 ; probe X until E0 endstop goes low
You can only specify one axis per M585 call and that XYZ are not the only possible axes for this code (UVWABC would be valid as well).
The values of the XYZ parameters are the absolute distances between the position at which the endstop is actually triggered and your own start position. It is mandatory to measure this distance once before M585 can be used reliably. An example: Say you wish to probe the tool offset on the X axis. If the trigger position of your endstop is at X=210 and you want to drive your tool from X=190 into the endstop switch, you need to specify -20 as your X parameter because you expect to travel 20mm towards the endstop switch and need to correct this factor. If you drive the tool backwards (e.g. from X=210 to X=190), the correction factor should be 20.
In case you are using different switches for tool probing, RepRapFirmware allows you to use a custom endstop. If a different endstop than the axis endstop is used, the drive number of the matching endstop can be specified via the optional E parameter (e.g. E4 for the E1 endstop).
In principle the following workflow should be performed for each axis using a macro file. You may wish to enhance this workflow depending on your own requirements and endstop configuration.
Reset the axis tool offset (G10/M568 Pxx X0 Y0 Z0)
Note: TLS has not yet been implemented in RepRapFirmware, therefore T1 will not work.
; standalone mode M586 P0 S1 ; enable HTTP M586 P1 S0 ; disable FTP M586 P2 S1 ; enable Telnet ; SBC mode ; NOTE: In SBC mode sending these makes a persistant change, do not add to config.g M586 P0 T1 S1 ; enable HTTPS M586 P1 T1 S1 ; disable SFTP M586 P2 T1 S1 ; enable SSH
M586 I
is not supported. Configure ufw or another firewall to restrict protocol access per adapter if required.Supported from firmware version 3.5, on WiFi-equipped Duet 3 series main boards running in standalone mode. Requires the WiFi interface to be running WiFi server version 2.1 or later.
U
parameter is also present; not needed if broker supports anonymous login).W
parameter is also present).0
to 2
(only processed if the W
parameter is also present, optional). Defaults to 0
if not specified.1
or 0
(only processed if the W
parameter is also present, optional). Defaults to 0
if not specified.0
to 2
(only processed if the S
parameter is also present).M586.4 C"duet" ; Set client ID M586.4 U"username" K"password" ; Set authentication credentials M586.4 S"subscription" O2 ; Subscribe to topic M586 P4 R1884 H192.168.10.244 S1 ; Enable MQTT protocol/client M118 P6 S"message" T"topic" ; Publish message (See M118 for more details) M586 P4 S0 ; Disable MQTT protocol/client; disconnects from broker gracefully.
For a full demonstration, see this GitHub repository.
This command must not be used in the config.g file.
The SSID and password must always be enclosed in double quotation marks.
RepRapFirmware 3.5beta4 and later with WiFiServer 2.1beta3 or later support WiFi Enterprise Authentication experimentally. The modes supported are:
All three protocols have an option to specify an anonymous identity and CA validation certificate.
When using one of these modes there are additional parameters and the meaning of the P parameter may be changed, as follows:
EAP-TLS
EAP-TTLS-MSCHAPv2 and EAP-PEAP-MSCHAPv2
M587 S"Network-ssid-123" P"Password123" I192.128.1.200 ; connect to access point "Network-ssid-123" using WPA2-PSK authentication M587 X2 E"ca.pem" S"test-ap" U"bob" P"hello" ; Connect to AP "test-ap" with EAP-PEAP-MSCHAPv2, username "bob" and password "hello". Perform CA validation with certificate sys/ca.pem
Important! Do not use M587 within config.g. As well as being a security hazard, writing the access point parameters to WiFi chip every time you start the Duet may eventually wear out the flash memory. Also, the wifi module does not get enabled until the end of running config.g (see this forum thread for explanation). It is better to use a macro to send M587.
This command must not be used in the config.g file.
Supported only by RRF 3.5 or later with WiFi firmware 2.0 or later.
None
This command causes the WiFi module to start a network scan. During the scan, any existing WiFi connection will be lost until the scan is complete. If starting ths command from Duet Web Control connected over WiFi, wait for the reconnection before sending M587.2.
This command must not be used in the config.g file.
Supported only by RRF 3.5 or later with WiFi firmware 2.0 or later.
This command waits for any active wifi scan to compete, then returns the result. The JSON format is intended for use by Duet Web Control, PanelDue and other user interfaces.
This command must not be used in the config.g file
M588 S"Network-ssid-123" M588 S"*"
This command must not be used in the config,g file
M589 S"DuetSSID" P"password" I192.168.0.1 C1
To use AP mode:
This command configures a given pin to read a filament sensor and configures filament monitoring for its corresponding extruder. The filament sensor may be a simple switch that detects the presence of filament, or a sensor that measures filament motion (e.g. laser, magnetic or pulsed filament monitor), or both.
In RRF 3.4 and later the action on a filament error is to raise a filament-error event. See Events.
In RRF 3.3 and 3.2 the action on a filament error is to.
RRF 1.19 to 3.1.1 does not support filament-error macros. The action on a filament error is to enter the Pausing state, show a message on all available targets with the type of filament error, and invoke system macro pause.g. The job is paused and will need manual intervention to resume the print.
Note that filament monitoring in RRF is only active when printing from SD card.
Additional parameters for Duet3D laser filament monitor
Additional parameters for Duet3D rotating magnet filament monitor
Additional parameters for a pulse generating filament monitor
M591 P3 C"e0stop" S1 D0 ; filament monitor connected to E0 endstop M591 D0 ; display filament sensor parameters for extruder drive 0
As RRF3, except 'C' parameter is the endstop number.
M591 D0 P3 C3 S1 R70:130 L24.8 E3.0 ; Duet3D rotating magnet sensor for extruder drive 0 is connected to E0 endstop input, enabled, sensitivity 24.8mm.rev, 70% to 130% tolerance, 3mm detection length M591 D0 ; display filament sensor parameters for extruder drive 0
Additional parameters for Duet3D rotating magnet filament monitor
M591 D0 P5 C3 R70:140 E3.0 S1 ; Duet3D rotating magnet sensor for extruder drive 0 is connected to E0 endstop input, sensitivity 1.05, tolerance 70% to 140%, 3mm detection length M591 D1 ; display filament sensor parameters for extruder drive 1
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 RepRap forum post here and the graph here for an example.
The purpose of input shaping is to reduce ringing (also called ghosting).
RRF 3.4 and later
M593 P"zvd" F40.5 ; use ZVD input shaping to cancel ringing at 40.5Hz M593 P"none" ; disable input shaping M593 P"custom" H0.4:0.7 T0.0135:0.0135 ; use custom input shaping
RRF 3.3
M593 P"daa" F40.5 ; use DAA to cancel ringing at 40.5Hz M593 P"none" ; disable DAA
The L parameter has changed in RRF 3.5.0-rc.2 and is now the minimum fraction of the original acceleration or feed rate to which the acceleration or feed rate may be reduced in order to apply input shaping. For example, if the commanded feedrate is F1000, L0.25 would allow the feedrate to reduce to F250, while L0.75 would only allow it to reduce to F750. So the least amount of reduction of acceleration or feed rate is from the highest L value.
Input Shaper | Shaper Duration | Vibration reduction with default damping factor (0.1) |
---|---|---|
ZVD | 1 / Frequency | ± 15% Frequency |
ZVDD | 1.5 / Frequency | |
ZVDDD | 2 / Frequency | |
MZV | 1 / Frequency | ± 4% Frequency |
EI2 | 1.5 / Frequency | ± 35% Frequency |
EI3 | 3 / Frequency | ± -45%...+50% Frequency |
Example (RRF 3.2 and earlier)
M593 F40.5 ; use DAA to cancel ringing at 40.5Hz
Note: In firmware 2.02 up to 3.3 the only form of input shaping supported is Dynamic Acceleration Adjustment (DAA). By default, DAA is disabled. If it is enabled, then acceleration and deceleration rates will be adjusted per-move to reduce ringing at the specified frequency. Acceleration limits set by M201 and M204 will still be honoured when DAA is enabled, so DAA will only ever reduce acceleration. Therefore your M201 and M204 limits must be high enough so that DAA can reduce the acceleration to the optimum value. Where possible DAA reduces the acceleration or deceleration so that the time for that phase is the period of the ringing. If that is not possible because of the acceleration limits, it tries for 2 times the period of the ringing.
Input shaping not working for your printer? Check this:
Input shaping is most useful to avoid exciting low-frequency ringing, for which S-curve acceleration is ineffective and may make the ringing worse. High-frequency ringing would be better countered by using S-curve acceleration; however, low-frequency ringing is more of a problem in most 3D printers.
The ringing frequencies are best measured using an accelerometer, for which support is provided in RRF 3.3 and later.
If you don't have an accelerometer, take a print that exhibits ringing on the perimeters (for example a cube), preferably printed single-wall or external-perimeters-first. Divide the speed at which the outer perimeter was printed (in mm/sec) by the distance between adjacent ringing peaks (in mm). When measuring the distance between peaks, ignore peaks close to the corner where the ringing started (these peaks will be spaced more closely because the print head will have been accelerating in that area).
Cartesian and CoreXY printers will typically have different frequencies of ringing for the X and Y axes. In this case it is is usually best to aim to cancel the lower ringing frequency. If the frequencies are not much different, in a moving-bed Cartesian printer you can reduce the higher ringing frequency by adding mass to that axis or reducing belt tension on that axis. Note that X axis ringing causes artefacts predominantly on the Y face of the test cube, and vice versa.
Keep in mind that you have to retune Pressure Advance after you have configured Input Shaping. The Pressure Advance will differ from shaper to shaper and from frequency to frequency.
See also: Connecting an accelerometer and Input shaping
Height following mode allows the Z position of the tool to be controlled by a PID controller using feedback from a sensor. See also M951 for configuration.
If a movement command (e.g. G1) explicitly mentions the Z axis while height following mode is active, existing moves in the pipeline will be allowed to complete and the machine allowed to come to a standstill. Then height following mode will be terminated and the new move executed.
Supported in RRF 3.2 and later.
Different features of motion control firmware may have competing demands on microcontroller RAM. In particular, operations that use many short segments (e.g. laser rastering) need longer movement queues than typical 3D printing, but have fewer motors to control. This command allows the movement queue parameters to be adjusted so that the queue can be lengthened if necessary, or kept short if a long movement queue is not needed and there are other demands on RAM.
M595 without any parameters reports the length of the movement queue and the number of per-motor movement objects allocated.
Supported from firmware version 3.5 on Duet 3 main boards
This command is supported in RepRapFirmware 3.5 and later builds that can execute moves on different axis systems asynchronously, for example for concurrent processing of two or more actions. It specifies that subsequent GCode commands from this input channel should be routed to the specified movement queue and the tool associated with that queue.
The number of available queues is firmware-dependent but will typically be 2. Before using a movement queue other than queue 0 it may be necessary to use M595 to increase the length of that queue, because the default length of movement queues other than the primary one may be quite short.
At the start of a file print, queue 0 is selected automatically.
M596 without the P parameter reports the current movement queue number for the input channel that the command was received on.
Supported from firmware version 3.5 on Duet 3 main boards
This configuration command is intended for use in systems having multiple tool heads that can be moved independently and asynchronously. The axis letters must be different from each other, so must the values of aaa and bbb. Normally, aaa will be zero and bbb will be positive. The command specifies that the machine position of the axis with the higher value must always be at least the difference in values greater than the position of the other axis. If this is not the case, the job will be aborted prior to starting the first move that would cause the conflict.
M597 V0 Y23.5
In the above example, the position of the Y axis must always be at least 23.5mm greater than the position of the V axis.
When Y and V are driven by independent motion systems and executing moves independently, in any block of GCode between synchronisation points, using this example the minimum of all Y coordinates inside the block (including the initial Y coordinate) must be at least 23.5mm greater than the maximum of the all V coordinates inside the block. If this is not the case, the job will be aborted prior to starting the first move that would cause the conflict.
Supported from firmware version 3.5 on Duet 3 main boards
None
This command is used in print files when multiple movement systems are being used (see the M596 command). It causes all motion systems to complete all queued movements and execute no further instructions until they have all reached this command and are ready to proceed.
Supported from firmware version 3.5b2 on Duet 3 main boards
M599 X10:25 Y0:20
This command establishes a "no entry" zone for the toolhead reference point. If any G0/G1/G2/G3 move attempts to move the toolhead reference point inside the no entry zone, the job will be aborted with an error message. In other words, in 3.5b2, the X, Y etc coordinates are in machine coordinates.
Supported in firmware 2.02 and later.
This command behaves like M226 except that if macro file filament-change.g exists in /sys on the SD card, it is run in preference to pause.g.
M606 S1 ; Fork input reader
This command is only supported on firmware configurations that support two or more motion systems that execute asynchronously with respect to each other.
If the S1 parameter is present and the command occurs within a job from SD card or other storage media, or within a macro file invoked by such a job, it causes the input stream to be forked. From that point on, each motion system can read and execute commands from the job file and any macro files invoked by it independently of other motion systems. In consequence, when the movement queue of one motion system becomes full, or one motion system is waiting for a tool change or other action to complete, the other motion system(s) can still read and execute commands.
When the input stream is forked, all local variables belonging to the un-forked input stream are copied to the fork(s). If the command occurs in a macro then the return stack is also copied to the forks, so that each fork will execute the remainder of all the macro files in the stack.
In the event that this command with the S1 parameter is executed from a job file when the input stream has already been forked, it is ignored.
If the S1 parameter is present and the command is used from an input channel other than a file stream then a warning is issued but it is otherwise ignored.
If this command is run without the S parameter then the firmware just reports whether the input stream that runs stored jobs has been forked.
See also the M596 command that selects a motion system, and the M598 command which is used to synchronise forked input streams at particular point in the file.
This command is sent by nanoDLP to set the parameters for the peel move used after curing a layer. RepRapFirmware 2.02 ignores this command. If you use RepRapFirmware 2.03 with nanoDLP, create an empty M650.g file in the /sys folder of the SD card so that RRF will ignore it without emitting an error message.
This command is sent by nanoDLP to execute a peel move after exposing a layer. RepRapFirmware 2.02 executes macro /sys/peel-move.g in response to this command. To use RepRapFirmware 2.03 or later with nanoDLP, create a macro file M651.g in the /sys folder of the SD card and populate it with the commands needed to execute the peel move.
Set the delta calibration variables
M665 L250 R160 B80 H240 X0 Y0 Z0
The X, Y and Z parameters are the X, 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 RRF 2.03 and later, multiple L values can be provided, for example:
L260.1:260.2:260.0
The values are the lengths of the rods to the X, Y and Z towers respectively. If more than 3 values are provided, the firmware assumes that there are as many towers as L values up to the maximum supported (currently 6). The XY coordinates of the additional towers must be defined subsequently using the M669 command. If only one L value is provided, the machine is assumed to have 3 towers with all rods having the same length.
Sets delta endstops adjustments.
M666 X-0.1 Y+0.2 Z0
Positive endstop adjustments move the head closer to the bed when it is near the corresponding tower. Endstop corrections are expressed in mm.
This command is deprecated from RRF 2.03, and removed from RRF 3.5 and later. Use M669 instead.
M667 S1
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 will be reported.
RepRapFirmware 2.03 and later can support any kinematics for which the movement of each axis is a linear combination of the movement of the motors. The relationship between axis movement and motor movement is defined by a matrix. So K0, K1, K2, K5, K8 and K11 all select the same kinematics, but with different default matrices.
RRF 2.03 and later only
M669 must come earlier in config.g than any M671 command.
Response to M669 (no parameters) on simple Cartesian machine:
M669 Kinematics is Cartesian, matrix: 1.00 0 0 0 1.00 0 0 0 1.00
CoreXY with extra Markforge U axis (see this forum post for an example):
M669 K1 X1:1:0:0 Y1:-1:0:-1 Z0:0:1:0 U0:0:0:1
Note U motor values in X, Y, Z and U parameters come after the Z motor values. M669 reports:
M669 Kinematics is modified CoreXY, matrix: 1.00 1.00 0 0 1.00 -1.00 0 -1.00 0 0 1.00 0 0 0 0 1.00
For more information on
RRF 2.03 and later only
M669 K4 P300 D250 A-90:90 B-135:135 C0:0:0 S100 X300 Y0
M670 T5 C"sx1509b.0+sx1509b.1+sx1509b.2" ; RRF 3.x M670 T5 P220:221:222 ; RRF 2.x
Informs the firmware of the positions of the pivot points, where the bed or gantry connect to the Z axis.
M671 must come later in config.g than any command that changes the kinematics, e.g. M667 or M669.
M671 X-15.0:100.0:215.0 Y220.0:-20.0:220.0 ; Z pivot points are at (-15,220), (100,-20) and (215,220)
M671 is used to define the pivot points of the bed or gantry where it connects to the Z axis. These pivot points are often at each leadscrew, but may also be offset from the leadscrews, if the bed/gantry rests on a carriage extending out from the leadscrew, for example on a kinematic mount.
When this command is used to define the pivot point positions, 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 levelling by adjusting the Z motors individually after bed probing. See the G32 command.
The X and Y coordinates in M671 are measured from the origin X0,Y0 set by M208.
The order of the X and Y coordinates is important; they relate to the order the motor drivers are defined in the M584 command. The first defined motor in M584 should be the first defined coordinates for X and Y in M671, and so on. For example, if you have M584 Z3:4:5 and M671 X[a]:[b]:[c] Y[a]:[b]:[c], the positions of X and Y for the motor on Z3 are defined by X[a],Y[a], Z4 by X[b],Y[b], and Z5 by X[c],Y[c].
The firmware algorithm assumes perfect gimbal joints at the pivot point, so that the bed is completely free to adopt the plane (or the twisted plane if there are 4 points) defined by the pivot points. In real printers this is rarely the case and the corrections are insufficient to level the bed, so multiple G32 commands need to be sent if the bed is a long way off level. The F parameter allows for the corrections calculated by the firmware to be multiplied by a factor so as to achieve faster convergence in this situation.
For machines without multiple independently-driven Z axes, this command can also be used to define the positions of the bed levelling 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 levelling screws. See Manual Bed Levelling Assistant.
For printers that print directly onto a desktop and have levelling feet, this command can be used to define the coordinates of the levelling feet, so that bed probing can be used to calculate and display the adjustments needed to the feet. In this case the displayed corrections must be reversed. For example, "0.2 turn down" means the bed needs to be lowered or the printer raised by 0.2 turn lower at that screw position. See Manual Bed Levelling Assistant.
This command is for sending configuration data to programmable Z probes such as the Duet3D delta effector, for example to set the sensitivity. 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.
M672 S105:50:205
For the Duet3d smart effector:
See the Smart effector and carriage adapters for delta printer documentation for more details.
Supported in RepRapFirmware 2.02 and later.
This code is intended to align a plane that is mounted on a rotary axis.
M673 A
To make use of this code it is required to take two probe points via G30 P first.
This code is intended to determine the Z center point of a stash that is mounted on a rotary axis. This code is yet to be implemented.
This code is intended to find the center of a cavity that can be measured using the configured axis endstop. It probes towards the minimum end of the specified axis to find one side of the cavity, backs off a little, and then probes towards the maximum end of the same axis to find the other side.
M675 X R2 F1200
If using a Z probe for this purpose, make sure the endstop type for the corresponding axis is updated before this code is run.
How it works:
RepRapFirmware 1.19 and later implements a filament management mechanism to load and unload different materials. This code may be used to load a material for the active tool.
M701 S"PLA"
This code will work only for tools that have exactly one extruder assigned.
When called the firmware does the following:
If this code is called without any parameters, RepRapFirmware will report the name of the loaded filament (if any).
Supported in RepRapFirmware 2.02 and newer.
This code is intended to unload the previously loaded filament from the selected tool.
M702
RepRapFirmware will do the following when called:
After assigning a filament to a tool, this command may be used to run /filaments/<filament name>/config.g to set parameters like temperatures, extrusion factor, retract distance. If no filament is loaded, the code completes without a warning.
M703
If the filaments feature is used, it is recommended to put this code into tpost*.g to ensure the right filament parameters are set.
This code may be used as an OEM extension to enable scanner functionality in the firmware.
M750
After a regular start of RepRapFirmware, the 3D scan extension is disabled by default, but if additional scanner components are attached, this code may be used to enable certain OEM functions.
When a 3D scanner board is attached to the USB port, this code is used to turn on communication between the 3D printing and the scanner board.
M751
If the USB connection is removed while the 3D scanner configuration is active, the firmware will disable it again and restore the default communication parameters.
Instruct the attached 3D scanner to initiate a new 3D scan and to upload it to the board's SD card (i.e. in the "scans" directory).
M752 S300 Pmyscan
Before the SCAN command is sent to the scanner, the macro file "scan_pre.g" is executed and when the scan has finished, the macro file "scan_post.g" is run. Be aware that both files must exist to avoid error messages.
Instruct the attached 3D scanner to cancel the current operation. Cancelling uploads is not supported.
M753
Calibrates the attached 3D scanner.
M754
Before the calibration is performed by the external scanner, "calibrate_pre.g" is run and when it is complete, "calibrate_post.g" is executed.
Sends the ALIGN ON/OFF command the attached 3D scanner.
M755 P1 M755 P0
Some devices turn on a laser when this command is received. If the 'P' parameter is missing, equal to, or less than 0, the alignment feature is turned off. Depending on whether the alignment is turned on or off, either align_on.g or align_off.g is executed before the ALIGN command is sent to the scanner.
Sends the SHUTDOWN command the attached 3D scanner.
M756
RepRapFirmware 2.02 and later
M851 Z-2.3
M851 is implemented for backwards compatibility with other firmware. It sets the Z probe trigger in the same way as G31 Z-nn (note the sign reversal). It also flags the Z-probe G31 parameters as to be saved in config-override.g if the M500 command is used.
G31 should be used in preference to M851.
Supported in RepRapFirmware version 1.16 and later.
Updates the machine's local date and time or reports them if no parameters are specified.
M905 P2016-10-26 S00:23:12 M905 P"2016-10-26" S"00:23:12" T"Europe/Berlin" ; DSF v3.3 and later only M905 A0 P"2024-09-17" S"15:19:54" T"Europe/Berlin" ; DSF v3.5.3 and later only
The time should be specified in 24-hours format as in "13:45" instead of 1:45PM.
Timezone setting is only supported by Duets in SBC mode with DSF v3.3 and later.
Sets the peak currents to send to the stepper motors for each axis. The values are in milliamps.
This command must be later in config.g than any M584 command.
M906 X300 Y500 Z200 E350:350
RRF uses peak current. Divide by 1.414 for RMS current as used in Marlin implementations for Trinamic drivers
Current setting on the various Duet boards are as follows:
The I parameter is the percentage of normal that the motor currents should be reduced to when the printer becomes idle but the motors have not been switched off. The default value is 30% and will always be at least 100mA - starting from RRF 2.02 setting it to 0 will disable the steppers after timeout like M18|M84 do and if an axis is related to the motor, throw out the "homing" of it, since it is likely that the position cannot be precisely determined anymore. Note that the idle current is applied globally for all motors and cannot be set per axis.
Every driver that is assigned must have its current set using M906. Not setting a current will default a low current (approx 1/32 of the driver max current), however M906 will report 0 until a current is assigned. Disable the driver explicitly if you do not want any current sent to a driver that is assigned.
As a rule of thumb, the recommendation is to set M906 to use 60-85% of the rated maximum current for the motor. Though you can go above or below as needed, and will have to tune for a balance of motor temperature, motor torque, and noise level. You can also use the EMF calculator (reprapfirmware.org and click on EMF calculator) to play with different values to see how it changes behaviour.
The T parameter (RRF 3.6.0-beta.2 and later) is used to set the idle timeout for all motors (M84 was previously used for this). For example, M906 T10 will idle the stepper motors after 10 seconds of inactivity. Setting M906 T0
does NOT mean "never idle hold" (ie motors stay on all the time, at full current), and T0 is an invalid setting. The correct way to set no idle hold (ie motors are 'always on') is to use M906 I parameter to set the idle hold to the required level, eg M906 I100
.
RepRapFirmware does not support individual motor settings where an axis has multiple motors connected to different stepper drivers. The first parameter specified will be used for all motors on the axis. You should use identical motors on any axis that has more than one motor to avoid unexpected behaviour. Example: If you have two motors on your Z axis, physically connected to Z and E0 stepper drivers, configured with M584 Z2:3, set M906 Z200, not M906 Z200:200
Supported in RepRapFirmware 1.19 and later in standalone mode. Supported in SBC mode in DSF v3.4-b2 and later (see here).
M911 S19.8 R22.0 P"M913 X0 Y0 G91 M83 G1 Z3 E-5 F1000"
When the supply voltage falls below the auto save threshold while a print from SD card is in progress, all heaters will be turned off, printing will be stopped immediately (probably in the middle of a move), the position saved, and the specified command string executed. You should typically do the following in the command string:
For Duet + SBC, a solid external 5V supply is recommended for the Duet + SBC for this feature to work. When power to the Duet + SBC is cut, the SBC may turn off before the Duet can inform the SBC about the content of resurrect.g, or the SBC may lose power while it's trying to write the content of resurrect.g to the microSD card. An external 5V buck regulator may be sufficient to keep a Duet 3 Mini 5+ and SBC on long enough. For Duet 3 MB6HC, the on-board 5V regulator might not endure long enough for resurrect.g to be written to persistent storage if the Duet powers an SBC as well. Hence we recommend using an external 5V PSU if this feature is configured.
M911 with no parameters displays the current enable/disable state, and the threshold voltages if enabled.
See this page for more details: Setting up to resume a print after a power failure or planned power down
M911 S12.0:19.5:22.0
Enables auto-pause if the power voltage drops below the pause threshold. The firmware records the current state of the print so that it can be resumed when power is restored and executes the pause procedure to attempt to park the print head using the residual energy in the power supply capacitors. If the supply voltage continues to drop below the shutdown threshold, the firmware disables all heaters and motors and goes into the shutdown state until either the voltage exceeds the resume threshold or the board is reset. In either case, it may be possible to resume the paused print. If the supply voltage does not fall below the shutdown threshold but recovers and exceeds the resume threshold, then the print is resumed automatically.
If any of the three values for the S parameter are zero or negative, or the three values are not in ascending order, then auto-save is disabled.
M911 with no parameters displays the current enable/disable state, and the threshold voltages if enabled.
M912 P0 S10.5
Many microcontrollers used to control 3D printers have built-in temperature monitors, but they normally need to be calibrated for temperature reading offset. The S parameter specifies the value that should be added to the raw temperature reading to provide a more accurate result.
(Currently only for the CPU on-chip temperature sensor P0. Other P parameter could in the future be added for boards with multiple on-chip sensors)
This allows motor currents to be set to a specified percentage of their normal values as set by M906. It can be used (for example) to reduce motor current during course homing, to make homing quieter or to reduce the risk of damage to endstops, and to reduce current while loading filament to guard against the possibility of feeding too much filament. Use M913 again with the appropriate parameters set to 100 to restore the normal currents.
M913 X50 Y50 Z50 ; set X Y Z motors to 50% of their normal current M913 E30:30 ; set extruders 0 and 1 to 30% of their normal current
When M913 is executed, it does not wait for all motion to stop first (unlike M906). This is so that it can be used in the M911 power fail script. When using M913 elsewhere, you will typically want to use M400 immediately before M913.
RepRapFirmware does not support individual motor settings where an axis has multiple motors connected to different stepper drivers. The first parameter specified will be used for all motors on the axis. You should use identical motors on any axis that has more than one motor to avoid unexpected behaviour. Example: If you have two motors on your Z axis, physically connected to Z and E0 stepper drivers, configured with M584 Z2:3, set M913 Z50, not M913 Z50:50
This command is supported in the Alligator build of RepRapFirmware only.
M914 S5 ; set expansion signal level to 5V M914 ; report expansion signal voltage level
This sets the stall detection parameters and optionally the low-load current reduction parameters for TMC2660, TMC2130 or similar driver chips. Use either the P parameter to specify which driver number(s) you want to configure, or the axis names of the axes that those motors drive (the parameters will then be applied to all the drivers associated with any of those axes).
If this command refers to any axes other than X, Y and Z then it must appear later in config.g than the M584 command that creates those additional axes.
M915 P0:2:3 S10 F1 R0 M915 X Y S5 R2
Supported in firmware 1.20 beta 2 and later.
If the last print was not completed and resume information has been saved (either because the print was paused or because of a power failure), then the heater temperatures, tool selection, head position, mix ratio, mesh bed compensation height map etc. are restored from the saved values and printing is resumed.
M916
RepRapFirmware also requires macro file /sys/resurrect-prologue.g to be present on the SD card before you can use M916. This file is executed after the heater temperatures have been set, but before waiting for them to reach the assigned temperatures. You should put commands in this file to home the printer as best as you can without disturbing the print on the bed. To wait for the heaters to reach operating temperature first, use command M116 at the start of the file.
See this page for more details: Setting up to resume a print after a power failure or planned power down
Version 1.19 of RepRapFirmware does not support M916 but you can achieve the same effect using command M98 P"/sys/resurrect.g".
Supported in firmware 3.01 and later for Duet 3.
Motor drivers on Duet 3 allow higher motor currents to be used while the motor is moving. This command sets the percentage of the current set by M906 that is to be used when the motor is stationary but not idle, or moving very slowly.
If this command refers to any axes other than X, Y and Z then it must appear later in config.g than the M584 command that creates those additional axes.
M917 X70 Y70 Z80 E70:70
Standstill current reduction is not the same as idle current reduction. The standstill current must be high enough to produce accurate motion at low speeds. The idle current needs only to be high enough to hold the motor position well enough so that when the current is restored to normal, the position is the same as it was before the current was reduced to idle.
When M906 is used to set the motor current to 71% or more of the maximum permitted current, RRF will limit the maximum standstill current percentage so that the standstill current is no more than 71% of the maximum permitted motor current. This is to ensure that a single phase of the driver does not pass more than 71% of the maximum current continuously, which would risk overheating the output mosfets of that phase.
Note this is not supported on Duet 2 with TMC2660 or on external drivers.
This command is used to tell RepRapFirmware about a directly-connected LCD such as a 12864 or compatible display.
M918 P1 E2
See Connecting 12864 or other display for supported Duet boards and usage.
When event logging is enabled, important events such as power up, start/finish printing and (if possible) power down will be logged to the SD card. Each log entry is a single line of text, starting with the date and time if available, or the elapsed time since power up if not. If the log file already exists, new log entries will be appended to the existing file.
M929 P"eventlog.txt" S1 ; start logging warnings to file eventlog.txt M929 S0 ; stop logging
From RepRapFirmware 3.2.0 and later, more granular logging is available. There are three log levels, and no logging. When logging is enabled, each line in the log will have the log level of that message added after the timestamp.
Caution: do not rename or delete the current log file while logging is enabled!
Also see M118.
Supported in RepRapFirmware 3.
M950 is used to create heaters, fans, GPIO ports, spindles (3.3 and later) and LED strips (3.5 and later), and to assign pins to them. Each M950 command assigns a pin or pins to a single device. Every M950 command must have exactly one of the H, F, J, P, S, D (for Duet 3 MB6HC only) or E (in RRF 3.5 and later) parameters.
If a M950 command has C and/or Q parameters, then the pin allocation and/or frequency will be configured accordingly. Otherwise, the current configuration will be reported.
1 Check the individual hardware pages, some IO pins have permanent pullups.
1 Check the individual hardware pages, some IO pins have permanent pullups.
1 Check the individual hardware pages, some IO pins have permanent pullups.
1 Check the individual hardware pages, some IO pins have permanent pullups.
M950 H1 C"out1" Q100 T1 ; create heater 1 M950 H2 C"nil" ; disable heater 2 and free up the associated pin M950 H1 C"3.out0+out2" Q100 T1 ; create heater 1 using ports OUT0 and OUT2 on CAN board 3 (RRF 3.4 or later)
In RRF 3.4 and later, when using M950 to create a heater, multiple port names can be provided, separated by the '+' sign. The maximum number of ports that may be used depends on the board. Any CAN address at the start of the port name string applies to all the port names.
M950 F3 C"heater2" Q100 ; Fan 3 is connected to heater 2 pin, PWM at 100Hz M950 F2 C"!fan2+^exp.pb6" ; Fan 2 uses the Fan2 output, but we are using a PWM fan so the output needs to be inverted, also we are using PB6 as a tacho input with pullup resistor enabled M950 F5 C"!out4+out4.tach" Q450 ; Create Fan 5 on the mainboard on OUT4 with a tacho input M950 F0 C"!1.out3+out3.tach" Q450 ; Create Fan 0 on expansion board 1, output OUT3 with a tacho input
When using M950 to create a fan, the port name string may be either a single port, or two ports separated by the '+' sign. The second port is used to read the fan tacho. Any CAN address at the start of the port name string applies to both port names.
M950 J1 C"!^e1stop" ; Input 1 uses e1Stop pin, inverted, pullup enabled
M950 P0 C"exp.heater3" ; create output/servo port 0 attached to heater 3 pin on expansion connector
Supported in RRF 3.3 and later.
M950 R0 C"!exp.heater3" L12000 ; Spindle 0 uses exp.heater3 as RPM pin and has a max RPM of 12000
When using M950 to create a spindle use the following format:
M950 R0 C"pwm_pin + on/off_pin + forward/reverse_pin" Qfff Laa:bb
M950 D1 C"spi.cs0+spi.cs2" ; on Duet 3 MB6HC support external SD card using pins spi.cs0 and spi.cs2 for the CS and Card Detect pins respectively (RRF 3.4 and later)
Duet 3 MB6HC only, configures the SD slot number. The only value supported is 1. (RRF 3.4 and later)
Supported in RRF 3.5.0-beta.4 and later.
M950 E0 C"led" T2 ; create a RGBW Neopixel LED strip on the LED port (RRF 3.5 and later)
Supported in RepRapFirmware 3.x
Height following mode allows the Z position of the tool to be controlled by a PID controller using feedback from a sensor. See also M594.
If commanding the motors to increase Z causes the sensor value to increase, then all of P, I and D must be positive. If commanding the motors to increase Z causes the sensor value to decrease, then all of P, I and D must be negative.
Some CAN-connected expansion boards are too small to carry address selection switches. Such boards default to a standard address, which can be changed using this command.
M952 B121 A20 ; change the CAN address of expansion board 121 to 20 M952 B20 S500 ; change the CAN bit rate or expansion board 20 to 500kbps
The change of CAN address will not take place until the expansion board is restarted.
This command can also be used to change the normal data rate, for example if the printer has CAN bus cables that are too long to support the standard data rate (1Mbits/sec in RepRapFirmware). All boards in the system on the same CAN bus must use the same CAN data rate. The procedure for changing the data rate is:
Provisional specification - not yet implemented
This command allows the bandwidth of the CAN bus to be optimised, by increasing the data rate during transmission of CAN-FD data packets by means of the BRS (bit rate switch) feature. The maximum speed supported by CAN-FD is 8Mbits/sec but the practical limit depends on the cable length, cable quality, number of devices on the bus and CAN interface hardware used. The rate specified will be rounded down to the nearest achievable rate.
M953 S4.0 T0.6 J0.2
The optional C parameter allows fine-tuning of the transmitter delay compensation. The first parameter is the offset added to the measured transmitter delay. The optional second value, which must be greater than the first, is the minimum delay compensation applied.
Glitches seen by the receiver while the transceiver delay is being measured will be ignored if they would result in a transceiver delay compensation lower than this value.
When CAN is implemented on Microchip SAME5x and SAMC21 processors, these values are converted from nanoseconds into time quanta and stored in the TDCO and TDCF fields of the transceiver delay compensation register.
Supported in RRF 3.4 and later on Duet 3 boards
This command is used to reconfigure the board it is executed on as a CAN-connected expansion board. It would typically be the only command in the config.g file. When it is executed, the board changes its CAN address to the one specified in the A parameter, stops sending CAN time sync messages, and responds to requests received via CAN just like a regular expansion board.
After this command is executed, for diagnostic purposes a few GCode commands can still be sent to the USB port for local execution, for example M111 and M122.
Supported in RRF 3.4 and later (limited support in 3.3)
This command configures an accelerometer.
M955 P0 C"spi.cs1+spi.cs0" I10 ; configure accelerometer on mainboard using SPI pins and specify orientation M955 P121.0 I10 ; configure accelerometer on toolboard with CAN address 121 and specify orientation
Supported in RRF 3.4 and later (limited support in 3.3)
This command causes the specified number of accelerometer samples to be collected and saved to a .csv file.
0:/sys/accelerometer
. If not specified then the filename will be composed from the current date/time.Supported in RepRapFirmware 3.4 and later for raising events
This command is used to raise an event or trigger internally as if the event had actually occurred, and execute any related handler macro for that event or trigger. Its main use is to test event handler and trigger macros.
M957 E"heater_fault" D1 B2
Raise a heater fault from expansion board at CAN address 2 on heater 1
Support in RepRapFirmware 3.6 and later
Motor drivers on Duet 3 6HC allow for direct control of the motor phases. This command allows setting the motion controller to use phase stepping instead of step and direction.
This command must appear after any M584 command that refers to the same axis.
M970 X1 Y0 Z0 E1:0
Enable phase stepping for X
and E0
, enable step direction for Y
, Z
, and E1
.
Support in RepRapFirmware 3.6 and later
Configure the velocity constant used to scale the motor current in phase stepping.
M970.1 X1000.0 Y2000.0 Z1000.0 E1000.0:1000.0
Support in RepRapFirmware 3.6 and later
Configure the acceleration constant used to scale the motor current in phase stepping.
M970.2 X50000.0 Y50000.0 Z50000.0 E50000.0:50000.0
This command triggers a firmware update if the necessary files are present on the SD card.
M997 ; update firmware on mainboard (S0 is the default) M997 B121 ; update firmware on CAN-connected expansion/tool board at CAN address 121 M997 S1 ; update firmware on WiFi module (standalone only) M997 S1 P"0:/sys/DuetWiFiServer.bin" ; update firmware on WiFi module with specific file (standalone only) M997 S0:1 ; update firmware modules 0 and 1 (mainboard and WiFi module, standalone only) M997 S2 ; update DSF (SBC mode only) M997 S2 F"unstable" ; Set package feed for DSF packages (SBC mode only) M997 S2 F"stable-3.5" ; Set package feed and version for DSF packages (SBC mode only) M997 S2 V"3.5.0-rc.2" ; Install a specific DSF/RRF combination (SBC mode only) M997 S3 B121 ; update bootloader on CAN-connected expansion/tool board at CAN address 121 M997 S4 ; update firmware on connected PanelDue
M997 S2
can be used to install the latest DSF and security-related packages on DuetPi (via apt update
/unattended-upgrade
). It also supports two optional arguments:
<feed>
can be stable
(default), unstable
, stable-x.y
, or unstable-x.y
where x.y corresponds to a version. e.g. 3.4 or 3.5.M997 F
). Example: M997 S2 V"3.5.0-rc.2"
M997 S2
updates the web server file system (DuetWebControl.bin).M997 S3
was used to put the WiFi module into bootloader mode, so that firmware can be uploaded directly via its serial port.M998 P34
Request a resend of line 34.
In some implementations the input-handling code overwrites the incoming G Code with this when it detects, for example, a checksum error. Then it leaves it up to the GCode interpreter to request the resend.
Restarts the firmware using a software reset.
M999
The P parameter can also put the board into firmware upload mode (as if the Erase button had been pressed) if parameter P"ERASE"
is present.
Starting from v3.3 the B parameter may be set to -1 to reboot the attached SBC (DuetPi + SBC). DSF v3.5 also supports P"OFF"
to shut down the SBC.
T0 ; select tool 0 T1 P0 ; select tool 1 but don't run any tool change macro files T-1 P0 ; deselect all tools but don't run any tool change macro files T R1 ; select the tool that was active last time the print was paused T ; report the current tool number T T{state.currentTool + 1} ; select the tool whose number is one higher than the current tool
If Tn is used to select tool n but that tool is already active, the command does nothing. Otherwise, the sequence followed is:
Note: Prior to RRF 3.3, when changing tools, tool change macro files are not run unless all axes have been homed. In RRF 3.3 and later, tool change macro files are run regardless of whether axes have been homed or not. You can use conditional GCode to choose which commands are executed if axes have been homed/not homed.
For more information and example usage of tool change macros, see: Multiple tools and tool change macros
Codes for print head movements follow the NIST GCode Interpreter Version 3 standard, so RepRapFirmware should be usable for CNC milling and similar applications but be aware of the GCodes not implemented. See also on Wikipedia. For more information and background, along with the master list of all RepRap GCodes, check RepRap GCode page.
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.
All communication is in printable ASCII characters. Messages sent back to the host computer are terminated by a newline and look like this:
xx [line number to resend] [T:93.2 B:22.9] [C: X:9.2 Y:125.4 Z:3.7 E:1902.5] [Some debugging or other information may be here]
xx can be one of ok, rs or !!
ok means that no error has been detected.
rs means resend, and is followed by the line number to resend.
!! means that a hardware fault has been detected. The RepRap machine will shut down immediately after it has sent this message.
The T: and B: values are the temperature of the currently-selected extruder and the bed respectively, and are only sent in response to M105. If such temperatures don't exist (for example for an extruder that works at room temperature and doesn't have a sensor) then a value below absolute zero (-273oC) is returned.
C: means that coordinates follow. Those are the X: Y: etc values. These are only sent in response to M114 and M117.
The RepRap machine may also send lines that look like this:
// This is some debugging or other information on a line on its own. It may be sent at any time.
Such lines will always be preceded by //.
On the latest version of Pronterface and Octoprint (1.2.0+) a special comment of the form:
// action:command
is allowed to be sent from the firmware, the command can currently be pause, resume or disconnect which will execute those commands on the host. As this is also a comment other hosts will just ignore these commands. The most common response is simply:
ok
When the machine boots up it sends the string
start
once to the host before sending anything else. This should not be replaced or augmented by version numbers and the like. M115 (see above) requests those.
All this means that every line sent by RepRap to the host computer except the start line has a two-character prefix (one of ok, rs, !! or //). The machine should never send a line without such a prefix.
Exceptions:
RepRapFirmware responds to some commands with a reply string in JSON format, terminated by a newline. This allows later firmware revisions to include additional information without confusing clients (e.g. PanelDue) that do not expect it, and to make responses self-describing so that the client will not be confused if responses are delayed or lost. The commands affected are:
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. For general information and examples (not specific to RepRapFirmware) there is more info on the Start GCode routines and End GCode routines pages.