Gcode dictionary
This page describes the RepRapFirmware supported G-codes, originally based on the information from the RepRap wiki G-code page.
G-Codes are a widely used machine control language. They are human readable and editable. This page describes the RepRapFirmware supported G-codes. RepRapFirmware follows the philosophy of "G-code everywhere", in essence the users or external program's interaction with the firmware should be through G-codes. There are G-codes for all supported control and configuration inputs along with status and debugging information.
RepRapFirmware G-codes were originally based on the information from the RepRap wiki G-code page. There are some G-Codes listed on that page that are not implemented in RepRapFirmware. More details can be found on the G-Codes not implemented page.
Introduction
A typical piece of G-code 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 1000 more lines...
G-Code Everywhere
A design philosophy of RepRapFirmware is "G-code everywhere" what this means is explained in this sub section
The G-code can originate from a number of sources:
- Sent to over USB (for example from http://www.pronterface.com/)
- Sent by the Duet Web Control Web (DWC) Interface
- Sent by an external controller such as the PanelDue.
In all cases the G-Code could
- be entered by user one line at time, for example during configuration or testing
- be sent by the User Interface (Pronterface, Web Interface or PanelDue) in response to the user pressing buttons
- originate from macros that are triggered on startup, on certain events (such as error conditions), or called by the user or UI.
- be from a g-code file which are normally stored on the on-board or external SD card.
A key difference from other 3d printer firmwares is not employing a separate command set (other than G-codes) to configure the printer. To that end RepRapFirmware has a large collection of configuration g-codes that allow the behaviour of the machine to be controlled. For some examples of when these G-Codes are employed have a look at these wiki pages:
- Configuring RepRapFirmware for a Cartesian printer
- Configuring RepRapFirmware for a Delta printer
- Configuring RepRapFirmware for a CoreXY printer
- Configuring RepRapFirmware for an IDEX printer
- Configuring RepRapFirmware for a SCARA printer
- Configuring RepRapFirmware for a Polar printer
- Configuring RepRapFirmware for a Hangprinter printer
- Tuning the heater temperature control
- Setting up automatic probing of the print bed
- Using servos and controlling unused IO pins
The advantage of "G-code everywhere" is the same commands can be send from any of the G-Code 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.
G-Code Structure
This section explains the elements that make up a G-Code command.
Command Order
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:
- Don't refer to any axis letter or extruder number that you haven't created using M584 (except that XYZ already exist by default)
- Don't refer to any temperature sensor in M950 or M106 before you create it using M308
- Don't refer to a heater in M307, M140, M141, M143 or m563 before you create it using M950
- Don't refer to a fan in M106 before you create it using M950
- Don't refer to a tool in G10/M568 before you create it using M563
Comments
G-Code comments begin at a semicolon, and end at the end of the line:
T0 ; This is a comment G92 E0 ''';So is this''' G28
Alternatively, comments can be enclosed in brackets, but they must start and end on the same line:
G28 (here come the axes to be homed) X Y
Comments and white space will be ignored by RepRapFirmware when executing the G-Code
Fields
A RepRap G-Code is a list of fields that are separated by white spaces or line breaks. A field can be interpreted as a command, parameter, or for any other special purpose. It consists of one letter directly followed by a number, or can be only a stand-alone letter (Flag). The letter gives information about the meaning of the field (see the list below in this section). Numbers can be integers (128) or fractional numbers (12.42), depending on context. For example, an X coordinate can take integers (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 G-Code command, such as move to a point |
Mnnn | RepRap-defined command, such as turn on a cooling fan |
Tnnn | Select tool nnn. In RepRap, a tool is typically associated with a nozzle, which may be fed by one or more extruders. |
Snnn | Command parameter, such as time in seconds; temperatures; voltage to send to a motor |
Pnnn | Command parameter, such as time in milliseconds; proportional (Kp) in PID Tuning |
Xnnn | A X coordinate, usually to move to. This can be an Integer or Fractional number. |
Ynnn | A Y coordinate, usually to move to. This can be an Integer or Fractional number. |
Znnn | A Z coordinate, usually to move to. This can be an Integer or Fractional number. |
U,V,W | Additional axis coordinates |
Innn | Parameter - X-offset in arc move (Not yet implemented in RepRapFirmware); integral (Ki) in PID Tuning; signal inversion |
Jnnn | Parameter - Y-offset in arc move (Not yet implemented in RepRapFirmware) |
Dnnn | Parameter - used for diameter; derivative (Kd) in PID Tuning; drive number |
Hnnn | Parameter - used for heater number in PID Tuning |
Fnnn | Feedrate in mm per minute. (Speed of print head movement) |
Rnnn | Parameter - used for temperatures |
Qnnn | Parameter - not currently used |
Ennn | Length of filament to move through the extruder. This is exactly like X, Y and Z, but for the length of filament to consume. |
Nnnn | Line number. Used to request repeat transmission in the case of communications errors. Optional |
*nnn | Checksum. Used to check for communications errors. Optional |
Case sensitivity
The original NIST GCode standard requires gcode interpreters to be case-insensitive, except for characters in comments. However, not all 3D printer firmwares conform to this and some recognise uppercase command letters and parameters only.
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.
Quoted strings
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"
Checking
This is an optional feature that is seldom used as g-code files are normally printed form the on-board SD card.
N: Line number
Example: N123
If present, the line number should be the first field in a line. For G-code stored in files on SD cards the line number is usually omitted.
If checking is supported, the 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).
*: Checksum
Example: *71
If present, the checksum should be the last field in a line, but before a comment. For G-code stored in files on SD cards the checksum is usually omitted.
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.
Method
Example: N123 [...G Code in here...] *71
The firmware checks the line number and the checksum.
You can leave both of these out - RepRap will still work, but it won't do checking. You have to have both or neither though. If only one appears, it produces an error. See this thread for an example of usage, in this case sending g-code to the PanelDue port without disabling cheksums: https://forum.duet3d.com/topic/15134/how...
The checksum "cs" for a G-Code string "cmd" (including its line number) is computed by exor-ing the bytes in the string up to and not including the * character as follows:
int cs = 0; for(i = 0; cmd[i] != '*' && cmd[i] != NULL; i++) cs = cs ^ cmd[i]; cs &= 0xff; // Defensive programming...
and the value is appended as a decimal integer to the command after the * character.
Conditional execution, loops, and other command words
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 elif else 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.
Multiple commands on a single line
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 must be the last command in that line of GCode, because any following commands on the same line will not be executed.
Buffering
RepRapFirmware stores some commands in a ring buffer internally for execution. This means that there is no (appreciable) delay while a command is acknowledged and the next transmitted. In turn, this means that sequences of line segments can be plotted without a dwell between one and the next. As soon as one of these buffered commands is received it is acknowledged and stored locally. If the local buffer is full, then the acknowledgement is delayed until space for storage in the buffer is available. PC host programs rely on this for flow control when the controller electronics does not support device level flow control.
Only the G0 to G3 movement commands are buffered by RepRapFirmware. All other G, M or T commands are not buffered. When M555 P6 is used to select nanoDLP compatibility mode, no commands are buffered.
When an unbuffered command is received it is stored, but it is not acknowledged to the host until the buffer is exhausted and then the command has been executed.
G-commands
G0 & G1: Move
- G0 : Rapid Move
- G1 : Controlled *(linear) Move
Usage
- RRF_2.02 and later, RRF_3
- G0 Xnnn Ynnn Znnn Ennn Fnnn Snnn Hnnn
- G1 Xnnn Ynnn Znnn Ennn Fnnn Snnn Hnnn
- RRF_2.01 and earlier
- G0 Xnnn Ynnn Znnn Ennn Fnnn Snnn
- G1 Xnnn Ynnn Znnn Ennn Fnnn Snnn
Parameters
- Not all parameters need to be used, but at least one of XYZEF must be used
- Xnnn The position to move to on the X axis
- Ynnn The position to move to on the Y axis
- Znnn The position to move to on the Z axis
- Ennn The amount to extrude between the starting point and ending point
- Fnnn The feed rate per minute of the move between the starting point and ending point (if supplied)
- Hnnn Move type (RRF_2.02 and later, RRF_3)
- Snnn In RRF_3, this parameter is used to set laser power, when switched into Laser mode (see M452); its use for defining move type is deprecated, use 'H' parameter instead. In RRF_2.02 and later, when switched into Laser mode (see M452), this parameter sets the laser power. When not switched into Laser mode, and always in firmware 2.01 and earlier, it defines the move type (see the description of the H parameter).
- Rn Return to the coordinates stored in restore point #n (see G60). Any X, Y, Z and other axis parameters in the command are used as offsets from the stored position. Axes not mentioned are not moved, so use offset 0 for axes you want to restore to the stored value. For example, G1 R0 X0 Y0 Z2 will move to 2mm above the position stored in restore point 0.
- Pnnnn (supported only in some builds of RepRapFirmware) IOBITS parameter. Defines the states of output pins while this command is executed. See the M670 command.
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.
The meaning of the H parameter (and the S parameter in RRF_2, when it is not controlling laser power) is as follows:
- H0 no special action (default)
- H1 terminate the move when the endstop switch is triggered and set the axis position to the axis limit defined by M208. On delta printers, H1 also selects individual motor mode as for H2. Normally used with relative motor coordinates (see G91).
- H2 Individual motor mode. X refers to the X motor, Y refers to the Y motor, and so on. Normally used with relative motor coordinates (see G91).
- H3 terminate the move when the endstop switch is triggered and set the axis limit to the current position, overriding the value that was set by M208.
- H4 terminate the move when the endstop switch is triggered and update the current position (supported in RRF 3.2-b4 or newer)
Examples
- 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)
RepRapFirmware treats G0 and G1 in the same way 'except as follows:
- On SCARA and similar architectures that normally require linear motion to be approximated by short segments, a single continuous non-segmented movement will be used if this can be done without the print head dropping below the current Z height.
- In Laser and CNC mode, G0 moves are executed at the maximum feed rate available, to comply with the NIST GCode standard, This feed rate is set by the M203 command.
Feedrate
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.
G0/G1 S and H parameter
RRF_2.01 and earlier | |
---|---|
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 and later, BEFORE M452 Laser Mode. | |
S parameter behaves as shown above. | |
RRF_2.02 and later, BEFORE or 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 and above, AFTER M452 Laser Mode. | |
S parameter sets laser power with range of 0 to 254. H parameter behaves as shown above. | |
RRF_3, BEFORE and AFTER M452 Laser Mode. | |
S parameter sets laser power with range of 0 to 254 when M425 Laser mode set, otherwise ignored. H parameter behaves as shown above. |
G2 & G3: Controlled Arc Move
Supported by RRF_1.18 and later.
Usage
- G2 Xnnn Ynnn Znnn Innn Jnnn Ennn Fnnn (Clockwise Arc)
- G3 Xnnn Ynnn Znnn Innn Jnnn Ennn Fnnn (Counter-Clockwise Arc)
Parameters
- Xnnn The position to move to on the X axis.
- Ynnn The position to move to on the Y axis.
- Znnn The position to move to on the Z axis.
- Innn The X coordinate of the arc centre relative to the current X coordinate (optional, ignored if R parameter is present).
- Jnnn The Y coordinate of the arc centre relative to the current Y coordinate (optional, ignored if R parameter is present).
- Ennn The amount to extrude between the starting point and ending point.
- Fnnn The feedrate per minute of the move between the starting point and ending point (optional, defaults to the current feed rate).
- Rnnn The radius of the arc (optional, RRF_2.03 and later)
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.
Examples
- 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)
G4: Dwell
Pause the machine for a period of time.
Parameters
- Pnnn Time to wait, in milliseconds
- Snnn Time to wait, in seconds
Example
- G4 P200
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.
G10: Tool Temperature Setting
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.
Usage
- G10 Pnnn Rnnn Snnn
Parameters
- Pnnn Tool number
- Rnnn Standby temperature(s)
- Snnn Active temperature(s)
Order dependency
The tool must be created with M563 before it is referenced with this command.
Examples:
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 .
G10: Set workplace coordinate offset or tool offset
This form of the G10 command is recognised by having the X, Y, Z, U, V, W etc parameters, normally with an L parameter. Supported on the Duet 2 series and later Duets.
Parameters
- Ln (Default L1) Mode (see below)
- Pnnn Tool number if L=1, coordinate system number if L=2 or L=20
- Xnnn X offset
- Ynnn Y offset
- U,V,Wnnn U, V and W axis offsets1
- Znnn Z offset2
Modes
- L=1: this sets the tool offset, as if the L parameter was not present
- L=2: this sets the origin of the coordinate system number specified by the P parameter (1 to 9) to the specified X, Y, X... values
- L=20: this is similar to L=2 except that the origin is specified relative to the current position of the tool.
Notes
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
- X=110
- Y=110
- Z=20
and you want to make this the origin (i.e. X=0, Y=0, Z=0) 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.
Order dependency
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.
G10: Retract
This form of the G10 command is recognised by having no parameters.
Parameters
- (no parameters in the RepRapFirmware implementation)
Example
- G10
Retracts filament then performs any zlift/hop according to settings of M207.
RepRapFirmware recognizes G10 as a command to set tool offsets and/or temperatures if the P parameter is present, and as a retraction command if it is absent.
G11: Unretract
Parameters
- no parameters in the RepRapFirmware implementation)
Example
- G11
Unretracts/recovers filament after undoing any zlift/hop according to settings of M207.
G17: Select XY plane for arc moves
Supported from RepRapFirmware 3.3beta1.
Parameters: none
The active plane determines how the tool path of an arc (G2 or G3) is interpreted. Each input channel (e.g. SD card, USB, DWC) remembers the current plane independently of the other channels.
G17 is supported in RRF 2.03 to RRF 3.2.2, however as no other plane selection command (G18, G19) is supported, it accepts this command, but takes no action on receiving it.
G18: Select XZ plane for arc moves
Supported from RepRapFirmware 3.3beta1.
Parameters: none
The active plane determines how the tool path of an arc (G2 or G3) is interpreted. Each input channel (e.g. SD card, USB, DWC) remembers the current plane independently of the other channels.
G19: Select YZ plane for arc moves
Supported from RepRapFirmware 3.3beta1.
Parameters: none
The active plane determines how the tool path of an arc (G2 or G3) is interpreted. Each input channel (e.g. SD card, USB, DWC) remembers the current plane independently of the other channels.
G20: Set Units to Inches
Example
- G20
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/M568 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.
In RRF 2.03 and later, each GCode input channel has a separate inches/mm setting.
G21: Set Units to Millimeters
Example
- G21
Units from this command onwards are in millimeters. (This is the default.).
G28: Home
Parameters
This command can be used without any additional parameters.
- X Flag to home the X axis
- Y Flag to home the Y axis
- Z Flag to home the Z axis
- U, V, W, A, B, C, D Flags to home additional axes that may have been created
Restrictions
This command may not be used within a homing file.
Examples
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:
- If there are no G28 parameters that correspond to axes that exist, or if the printer is a delta, then all axes are to be homed. Otherwise, the axes to be homed are determined by enumerating parameters of the G28 command.
- Each axis or delta tower to be homed is flagged as "position not known".
- If all axes or towers are to be homed, the file homeall.g is processed, except that on a delta printer homedelta.g is processed. If this process results in some but not all axes become flagged as "position known", an attempt will be made to home the remaining axes as if the G28 command had listed those axes.
- For each remaining axis flagged as "to be homed" the appropriate homing file is executed (homex.g, homey.g, homez.g etc.).
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.
G29: Mesh bed probe
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 compensation so that the nozzle will remain parallel to the bed. The printer must be homed with G28 before using this command.
Usage
- G29
- G29 S0
- G29 S1 [P"filename"]
- G29 S2
- G29 S3 P"filename"
Parameters
- S0Probe the bed, save the height map in a file on the SD card, and activate bed compensation. The height map is stored in file is /sys/heightmap.csv.
- S1 Load the height map from file and activate bed compensation. The default filename is as for S0 but a different filename can be specified using the P parameter.
- S2 Clear height map
- S3 Save height map (supported in RepRapFirmware 2.04 and later)
- P"file.csv" Optional file name for bed height map file to save with S3 or load with S1.
- Kn (supported in RRF 3.01-RC5 and later only, default 0) Z probe number
If G29 is commanded with no S parameter, then file sys/mesh.g is run if it exists, otherwise the command behaves like G29 S0.
Examples
G29 S0 ; Probe the bed, save height map to heightmap.csv and enable compensation
G29 S3 P"usual.csv" ; Save the current height map to file usual.csv
G29 S2 ; clear bed height map (disables bed compensation)
G29 S1 P"usual.csv" ; Load height map file usual.csv and enable compensation
To define the probe grid, see M557.
You can define a height to taper off the compensation using M376
You can find more detailed information about setting up Mesh Compensation here.
G30: Single Z-Probe
Usage
- G30 [Pnnn] [Xnnn] [Ynnn] [Znnn] [Hnnn] [Snnn]
Parameters
- Pnnn Probe point number
- Xnnn X coordinate
- Ynnn Y coordinate
- Znnn Z coordinate
- Hnnn Height correction
- Snnn Set parameter
- Kn (supported in RRF 3.01-RC5 and later only, default 0) Z probe number
Examples
- G30
Examples
- 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 it can be used to home the Z axis, to measure the Z probe trigger height, or to adjust the Z offset of the current tool.
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 Z parameter of -9999 or less, 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.
On the last G30 command in the sequence, the S parameter indicates that a complete set of points has been probed and instructs the firmware what sort of calibration to perform. If the value is -1 then the Z offsets of all the points probed are printed, but no calibration is done. If the value is zero or not present, then this specifies that the number of factors to be calibrated is the same as the number of points probed. Otherwise, the value indicates the number of factors to be calibrated, which must be no greater than the number of points probed. From version 1.09, the number of factors may be 3, 4 or 5 when doing old-style auto bed compensation on a Cartesian or CoreXY printer, and 3, 4, 6, 7, 8 or 9 when doing auto calibration of a Delta printer.
See Calibrating a Delta Printer, setting up the bed.g file for a more detailed explanation.
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 optional H parameter is a height correction for that probe point. It allows for the Z probe having a trigger height that varies with XY position. The nominal trigger height of the Z probe (e.g. at bed centre) is declared in the Z parameter of the G31 command in the config.g file. When you probe using G30 and the probe triggers, the firmware will assume that the nozzle is at the nominal trigger height plus the value you have in the H parameter.
G31: Set or Report Current Probe status
Usage
- G31 Pnnn Xnnn Ynnn Znnn Cnnn Snnn
Parameters
- Pnnn Trigger value
- Xnnn Probe X offset1
- Ynnn Probe Y offset1
- X,Y,U,V,W,A,B,C...nnn Probe Offsets for all axes except Z1 (RRF >=3.3beta2)
- Znnn Trigger Z height
- Cnnn Temperature coefficient2 (RRF <= 3.3beta1)
- Tnnn Temperature coefficient2 (RRF >= 3.3beta2)
- Snnn Calibration temperature2
- Tnnn (RRF 1.17 and later, removed in RRF_3) Z probe type to which these parameters apply, defaults to the current Z probe type as defined by M558 P parameter.
- Knnn (RRF3) Selects the Z probe number. If there is no K parameter then the current Z probe number is used. The current Z probe number is 0 at startup.
- Hnnn (RRF3) Selects the sensor number to use for temperature compensation when the C and S parameters are used.
Examples
- G31 P500 Z2.6
- G31 X16.0 Y1.5
Order dependency
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).
When used on its own this reports whether the Z probe is triggered, or gives the Z probe value in some units if the probe generates height values. If combined with a Z and P field (example: G31 P312 Z0.7) this will set the Z height to 0.7mm when the Z-probe value reaches 312 when a G28 Z0 (zero Z axis) command is sent. The machine will then move a further -0.7mm in Z to place itself at Z = 0. This allows non-contact measuring probes to approach but not touch the bed, and for the gap left to be allowed for. If the probe is a touch probe and generates a simple 0/1 off/on signal, then G31 Z0.7 will tell the RepRap machine that it is at a height of 0.7mm (as configured by Z0.7 in this example) when the probe is triggered.
If you are using the nozzle as a probe (for example with a peizo or switch that the hotend had a travel distance to trigger then remember the Z offset needs to be negative (ie the probe triggers under Z0
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.
Notes
1X and Y offsets of the Z probe relative to the print head (i.e. the position when the empty tool is selected) can be specified. 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.
2Optional parameters 'S' (temperature in °C at which the specified Z parameter is correct, default is current temperature) and 'C' (temperature coefficient of Z parameter in mm/°C, default zero) ('T' in RRF >=3.3beta2) can be set. This is useful for probes that are affected by temperature. In RRF2 the bed temperature reading is used. In RRF3 you must specify which temperature sensor to use in the H parameter.
G32: Run bed.g macro
Parameters
None
Example
- G32
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
G38.2 to G38.5: Straight Probe
Supported in RepRapFirmware 3 and later.
Parameters
- X,Y,Z,U,V,W,A,B,Cnnn: Target position (up until RRF 3.1.1 these are expected to be machine coordinates)
- Pnnn: Probe number to use (defaults to current probe)
Modes
- G38.2: probe toward workpiece, stop on contact, signal error if failure
- G38.3: probe toward workpiece, stop on contact
- G38.4: probe away from workpiece, stop on loss of contact, signal error if failure
- G38.5: probe away from workpiece, stop on loss of contact
Conditions considered an error (for G38.2 and G38.4)
- Probe already in target state (triggered for G38.2 and not triggered for G38.4)
- No target coordinates given
- Target coordinates equal to current position
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).
G53 Use machine coordinates
Supported on the Duet 2 and later Duets only.
This 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. See the NIST GCode Interpreter Version 3 standard for more details.
G54 to G59.3: Select coordinate system
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.
G60: Save current position to slot
Supported in firmware 1.21 and later.
Usage
- G60 Snn
Parameters
- Snn <nn> specifies memory slot # (0-based) to save into (default 0)
Slots 0, 1 and 2 are available. When a print is paused the coordinates are saved to slot 1 automatically, and at the start of a tool change the coordinates are saved to slot 2 automatically. Use G0 or G1 with the R0, R1 or R2 parameter to move the current tool to a saved position.
G90: Set to Absolute Positioning
Example: G90
All coordinates from now on are absolute relative to the origin of the machine.
Note: RepRapFirmware uses M82 to set the extruder to absolute mode: extrusion is NOT set to absolute using G90
G91: Set to Relative Positioning
Example: G91
All coordinates from now on are relative to the last position.
Note: RepRapFirmware uses M83 to set the extruder to relative mode: extrusion is NOT set to relative using G91
G92: Set Position
Parameters
- This command can be used without any additional parameters.
- Xnnn new X axis position
- Ynnn new Y axis position
- Znnn new Z axis position
- Ennn new extruder position
Example
- G92 X10 E90
Allows manual specification of the axis positions by specifying the current position to the values given. This example would set the machine's X coordinate to 10, and the extrude coordinate to 90. No physical motion will occur.
In RepRapFirmware, a G92 without coordinates does nothing.
M-commands
M0: Stop or Unconditional stop
Parameters
- This command can be used without any additional parameters.
- Hnnn Keep heaters on
Example
- M0
The effect of M0 depends on the state of the machine.
- The firmware finishes any moves left in its buffer.
- Either: if the axes are homed and if a print is being cancelled (M25), it executes the macro file cancel.g if present.
Or: if M0 is sent at any other time, stop.g is run if present. - All motors are put into idle mode.
- If no H1 parameter is present, the heaters are turned off too.
See also M1, M112.
M1: Sleep or Conditional stop
Example
- M1
The effect of M1 depends on the state of the machine.
- The firmware finishes any moves left in its buffer.
- Either: if the axes are homed and if a print is being cancelled (M25), it executes the macro file cancel.g if present.
Or: if M1 is sent at any other time, sleep.g is run if present. - All motors and heaters are are turned off.
G and M codes can still be sent, the first of which will wake it up again. See also M0, M112.
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.
M3: Spindle On, Clockwise (CNC specific)/ Laser on (Laser specific)
Supported in RepRapFirmware version 1.20 and later when the printer mode is set to CNC mode (see M453) or laser mode (M452).
Parameters
- Snnn Spindle RPM (CNC mode) or laser power (laser mode). In laser mode, the relationship between the S parameter and laser power depends on the R parameter that was specified in the M452 command.
- Pnnn Spindle slot (CNC mode only). Directly address a spindle slot.
Example
- M3 S4000
The spindle is turned on with a speed of 4000 RPM.
M3 in RepRapFirmware 3.3 and later
M3 can be called without any parameters and will start the spindle of the current tool turning clockwise at the spindle RPM of that tool.
Using the S parameter will additionally set the spindle RPM of the current tool.
It is an error if there is no tool active or the active tool does not have a spindle assigned and there is no P parameter provided to define which spindle this should be applied to.
M4: Spindle On, Counterclockwise (CNC specific)
Supported in RepRapFirmware version 1.20 and later when the printer mode is set to CNC (see M453).
Parameters
- Snnn Spindle RPM
- Pnnn Spindle slot (CNC mode only). Directly address a spindle slot.
Example
- M4 S4000
The spindle is turned on with a speed of 4000 RPM.
M4 in RepRapFirmware 3.3 and later
M4 can be called without any parameters and will start the spindle of the current tool turning counterclockwise at the spindle RPM of that tool.
Using the S parameter will additionally set the spindle RPM of the current tool.
It is an error if there is no tool active or the active tool does not have a spindle assigned and there is no P parameter provided to define which spindle this should be applied to.
M5: Spindle Off (CNC specific), laser off (Laser specific)
Supported in RepRapFirmware version 1.20 and later when the printer mode is set to CNC (see M453) or Laser (see M452).
Parameters
- none
Example
- M5
The spindle motor or laser is turned off.
M5 in RepRapFirmware 3.3 and later
M5 will stop the spindle of the current tool (if any) or all defined spindles if the current tool has no spindle assigned or there is no active tool.
M17: Enable all stepper motors
Available in RepRapFirmware 3.3beta2 and later.
Parameters:
- This command can be used without any additional parameters.
- X X axis
- Y Y axis
- Z Z axis
- U U axis
- V V axis
- W W axis
- ... or any other defined axis
- E[n] Extruder drive(s)
Examples
- M17
- M17 X E0
Enables all stepper motors when used without parameters. Stepper 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 stepper motors
Parameters:
- This command can be used without any additional parameters.
- X X axis
- Y Y axis
- Z Z axis
- U U axis
- V V axis
- W W axis
- ... or any other defined axis
- E[n] Extruder drive(s)
Examples
- M18
- M18 X E0
Disables stepper motors and allows axes to move 'freely.' Stepper motors can be disabled selectively. For example, M18 X E0:2 will disable the X, extruder 0 and extruder 2 motors. Also see M84.
M20: List SD card
Parameters
- This command can be used without any additional parameters.
- Snnn Output style: 0 = text (default), 2 = JSON
- P"path" Folder to list, defaults to the standard folder for GCode files (0:/gcodes in RepRapFirmware)
- Rnnn Number of files to skip, default 0
Examples
- M20 ; lists all files in the root folder of the internal SD card
- 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.
M21: Initialize SD card
Parameters
- This command can be used without any additional parameters.
- Pnnn SD card number (default 0)
Examples
- M21
- M21 P1
The specified SD card is initialized. If an SD card is loaded when the machine is switched on, this will happen by default. SD card must be initialized for the other SD functions to work.
M22: Release SD card
Parameters
- This command can be used without any additional parameters.
- Pnnn SD card number (default 0)
Examples
- M22
- M22 P1
The specified SD card is released, so further (accidental) attempts to read from it are guaranteed to fail. Helpful, but not mandatory before removing the card physically.
M23: Select SD file
Example
- M23 filename.gco
The file specified as filename.gco is selected ready for printing. RepRapFirmware supports long filenames as well as 8.3 format.
M24: Start/resume SD print
Example
- 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: Pause SD print
Example
- 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 G-code 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:
- When RRF receives M25 it will look for a move in the current queue after which it can stop without violating the configured jerk limits.
- If it finds one it stops after that move without decelerating (because the jerk limits allow that)
- If it can't find one it will plan and execute a deceleration. in this case the pause will occur 1move+2 seconds after M25 is sent.
That means the longest it will take to pause is 1move+2seconds. In nearly all 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.
M26: Set SD position
Parameters
- Snnn File position from start of file in bytes
- Pnnn (Optional) Proportion of the first move to be skipped, default 0.0, must be less than 1.0
Example
- 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: Report SD print status
Example
- 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: Begin write to SD card
Example
- 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: Stop writing to SD card
Example
- M29
File opened by M28 command is closed, and all subsequent commands sent to the machine are executed as normal.
M30: Delete a file on the SD card
Examples
- M30 filename.g
- M30 "filename.g"
filename.g is deleted.
M32: Select file and start SD print
Examples
- M32 filename.g
- M32 "filename.g"
It can be used when printing from SD card and does the same as M23 and M24.
M36: Return file information
Examples
- M36 filename.g
- M36 "filename.g"
Returns information for the specified SD card file in JSON format. If no path is specified in the filename, the default path is the folder where GCode file to print are normally stored, which in RepRapFirmware is 0:/gcodes.
A sample response is:
{"err":0,"size":457574,"height":4.00,"layerHeight":0.25,"filament":[6556.3],"generatedBy":"Slic3r 1.1.7 on 2014-11-09 at 17:11:32"}
The "err" field is zero if successful, nonzero if the file was not found or an error occurred while processing it. The "size" field should always be present if the operation was successful. The presence or absence of other fields depends on whether the corresponding values could be found by reading the file. The "filament" field is an array of the filament lengths required from each spool. The size is in bytes, all other values are in mm. The fields may appear in any order, and additional fields may be present.
If the file name parameter is not supplied and a file on the SD card is currently being printed, then information for that file is returned including additional field "fileName". This feature is used by the web interface and by PanelDue, so that if a connection is made when a file is already being printed, the name and other information about that file can be shown.
M37: Simulation mode
Parameters
- S1 Enter simulation mode
- S0 Leave simulation mode
- P"filename" (optional) Simulate printing a file from SD card
Examples
- M37 S1
- M37 P"MyModel.g"
Used to switch between printing mode and simulation mode. Simulation mode allows the electronics to compute an accurate printing time, taking into account the maximum speeds, accelerations etc. that are configured.
M37 S1 enters simulation mode. All G and M codes will not be acted on, but the time they would take to execute will be calculated.
M37 S0 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).
M38: Compute SHA1 hash of target file
Example:
- M38 gcodes/myfile.g
Used to compute a hash of a file on the SD card and returns a hexadecimal string which is the SHA1 of the file. If the file cannot be found, then the string "Cannot find file" is returned instead.
M39: Report SD card information
Supported in ReprapFirmware 1.21 and later.
Parameters
- Pn SD slot number, default 0
- Sn Response format. S0 returns a plain text response, S2 returns a response in JSON format.
Examples:
- M39 ; report information for SD card 0 in plain text format
- M39 P1 S2 ; report information for SD card 1 in JSON format
This command returns information about the SD card in the specified slot in the requested format. At least the following is returned:
- Whether or not a usable card is present in the slot
- The capacity of the card in bytes (if a card is present)
- The amount of free space on the card in bytes (if a card is present)
The JSON response has the following format (this is provisional):
{"SDinfo":{"slot":0,"present":1,"capacity":4294967296,"free":2147485184,"speed":20971520}}
The capacity and free space are in bytes and the interface speed is in bytes/second.
M42: Switch I/O pin
Parameters
- Pnnn Pin number
- Snnn Pin value
- Fnnn PWM frequency (optional)
Example
- M42 P7 S255
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..1 or 0..255. The pin reference is an internal firmware reference named "digital pin" which It maps on different connector pins depending the hardware.1.
RepRapFirmware 3 Notes
In RRF_3, before you can use M42 you must create a GPIO port using M950. Then in the M42 command, the P parameter is the GPIO port number, not the logical pin number. Duet 2 supports up to 10 GPIO ports, numbered 0 to 9. No GPIO ports are allocated by default.
In RRF_3, the F and I parameters are no longer supported in M42. Instead, use the F and I parameters in M950 when you create the GPIO port.
Example - RRF_2 code:
M42 P3 I1 S0.5 F500 ; set Heater 3 pin to 50% PWM at 500Hz
RRF_3 code:
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
See also
See Using servos and controlling unused IO pins for all the unused pin mappings.
See also M280, M950
Note:
1 For Duet 0.8.5 and 0.6, along with pre 1.16 versions of RepRapFirmware see: http://reprap.org/wiki/G-code#M42:_Switc...
M73: Set remaining print time
Parameters
- Pnn Percentage of the print that has been completed (not used by RRF)
- Rnn Remaining print time in minutes
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: ATX Power On
Example
- M80
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, it is cancelled.
M81: ATX Power Off
Parameters
- Sn n=0 turn power off immediately (default), n=1 turn power off when all thermostatic fans have turned off (RepRapFirmware 1.20 and later only)
Example
- M81 ; turn power off immediately
- M81 S1 ; turn power off when all thermostatic fans have turned off
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.
M82: Set extruder to absolute mode
Example
- M82
Makes the extruder interpret extrusion as absolute positions.
M83: Set extruder to relative mode
Example
- M83
Makes the extruder interpret extrusion values as relative positions.
M84: Stop idle hold
Parameters
- This command can be used without any additional parameters.
- Snnn Idle Time-out
- X,Y, E0:1.. etc
Example
- M84
- M84 E0:1:2:3:4
Stop the idle hold on all axis and extruder. Be aware that by disabling idle hold during printing, you will get quality issues.
For example, "M84 S10" will idle the stepper motors after 10 seconds of inactivity.
You can disable individual motors with the standard X, Y, Z etc switches.
M92: Set axis steps per unit
Parameters
- This command can be used without any additional parameters.
- Xnnn Steps per mm for the X drive
- Ynnn Steps per mm for the Y drive
- Znnn Steps per mm for the Z drive
- Unnn Steps per mm for the U drive
- Vnnn Steps per mm for the V drive
- Wnnn Steps per mm for the W drive
- Ennn Steps per mm for the extruder drive(s)
- Snnn Defines in which microstepping the above steps per unit are given. If omitted it will use the microstepping currently set by M350. This parameter is supported in RRF >=2.03.
Order dependency
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.
Examples
- 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: Call Macro/Subprogram
Parameters
- P"nnn" Macro filename1
Example
- M98 P"mymacro.g"
Runs the macro in the file mymacro.g. Macro calls can be nested (ie a macro can call another macro).
The filename to include a path to a subdirectory. For relative paths, the default folder is /sys, but some implementations may check the /macros directory too. Absolute file paths are also supported starting with "0" for the internal SD card or "1" for the external SD card if fitted.
Notes
1 In RRF_2.x and earlier, string can be enclosed in quotes if required, see Quoted Strings for details. In RRF_3, quotation marks around the filename are mandatory.
M99: Return from Macro/Subprogram
Example
- 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.
M104: Set Extruder Temperature
Parameters
- Snnn target temperature
- Tn optional tool number
Example
- 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 is deprecated because temperatures should be set using the G10/M568 and T commands.
M105: Get Extruder Temperature
Parameters:
- This command can be used without any additional parameters.
- Rnnn Response sequence number1
- Snnn Response type1
Examples
- 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.
Notes
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 G-code response that the client has already received. M105 S2 is equivalent to M408 S0, and M105 S3 is equivalent to M408 S2. Usage of these forms of M105 is deprecated, please use M408 instead.
M106: Fan On
Parameters
- Pnnn Fan number (optional, defaults to 0). (In RRF_3 relates to the fan number created by M950, NOT the fan pin number on the board)
- Snnn Fan speed (0 to 255 or 0.0 to 1.0))
Extra Parameters
- Innn Invert PWM (I1), disable fan (I-1), or normal mode (I0, default) (not supported in RRF_3, use M950)
- Fnnn Fan PWM frequency (not supported in RRF_3, use M950)
- Lnnn Set the minimum fan speed (0 to 255 or 0.0 to 1.0) when a non-zero fan speed is requested.
- Xnnn Set the maximum fan speed (0 to 255 or 0.0 to 1.0) when a non-zero fan speed is requested. (supported in RRF >= 2.02)
- Bnnn Blip time - fan will be run at full PWM for this number of seconds when started from standstill. Default is B0.1 which means that there is a 100ms burst after starting the fan.
- Hnn:nn:nn... Enable thermostatic mode and select heaters monitored. H-1 disables thermostatic mode. (In RRF_3 relates to the sensor number(s) created by M308, not the temperature sensor pin number on the board)
- Rnnn Restore fan speed to the value it has when the print was paused (R1) or the last time the fan speed was set and no P parameter was provided (R2).
- Tnnn or Tnn:nn Set thermostatic mode trigger temperature, or temperature control range
- C"name" Set custom name for this fan (supported in RRF >= 2.01)
- Ann Logical pin number that this fan is connected to (supported in RRF >= 2.02) (not supported in RRF_3, use M950)
Examples
- M106 S127
- M106 P1 T45 S0.7 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
RepRapFirmware 3 Notes
- The A, F and I parameters are no longer supported. Instead, specify the corresponding parameters in the M950 command when you create the fan.
- The P parameter relates to the fan number created by M950, NOT the fan pin number on the board as in RRF2.x.
- The H parameter relates to the sensor number(s) created by M308, not the temperature sensor pin number on the board.
- If you were using the PB6 tacho input, you must declare this in a M950 command for the fan concerned.
Example - old code:
M106 P2 I1 F25000 ; fan 2 is a 4-wire PWM fan so invert it and use high PWM frequency
New 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
Notes - all firmware versions
The parameter 'S' declares the PWM value (0-255 or 0-1.0). M106 S0 turns the fan off.
If an S parameter is provided but no other parameter is present, then the speeds of the print cooling fans associated with the current tool will be set (see the F parameter in the M563 command). If no tool is active then the speed of Fan 0 will be set. Either way, the speed is remembered so that it can be recalled using the R2 parameter (see below).
If no S parameter is given but the R1 parameter is used, the fan speed when the print was last paused will be set, this allows the pause.g macro to switch off the fans and have them resume when the print is resumed. If the R2 parameter is used, then the speeds of the print cooling fans associated with the current tool will be set to the remembered value (see above). R2 allows the configured fan speed to be passed between tools which is useful on multi extruder printers where the slicing software may not specify the fan speed on tool change and the tool change macros shut down fans when not in use.
The F parameter sets the fan PWM frequency, in Hz. The default is F250, which works with most fans, Try F100 or lower if you find that you can't control the speed of your fan. This parameter is ignored for fans connected to the fan outputs of a Duex 2 or Duex 5 because those outputs don't support variable PWM frequency. The F parameter is not supported in RRF_3, use M950 instead.
The T and H parameters allow a fan to be configured to operate in thermostatic mode, for example to use one of the fan channels to control the hot end fan. In this mode the fan will be on with the PWM set by the S parameter (subject to a minimum of 0.5) when the temperature of any of the heaters listed in the H parameter is at or above the trigger temperature set by the T parameter, and off otherwise. Thermostatic mode can be disabled using parameter H-1.
In firmware 1.19 and later, the T parameter may be of the form Taaa:bbb where aaa is the temperature at/below which the fan should be fully off and bbb is the temperature at which the fan should be fully on. The PWM will be set proportionally if the temperature is between these limits.
In firmware versions 1.19 and later, fans can respond to virtual heaters (which have heater numbers 100 upwards) as well as real heaters. If a fan is configured to trigger on a virtual heater whose sensor represents TMC2660 driver over-temperature flags, then when the fan turns on it will delay the reporting of an over-temperature warning for the corresponding drivers for a few seconds, to give the fan time to cool the driver down.
The B parameter sets the time for which the fan will be operated at full PWM when started from cold, to allow low fan speeds t be used. A value of 0.1 seconds is usually sufficient.
The L parameter defines the minimum PWM value that is usable with this fan. If a lower value is commanded that is not zero, it will be rounded up to this value.
The X parameter defines the same for a maximum PWM value. If a higher value is commanded, it will be rounded down to this value.
The I parameter causes the fan output signal to be inverted if its value is greater than zero. This makes the cooling fan output suitable for feeding the PWM input of a 4-wire fan via a diode. If the parameter is present and zero, the output is not inverted. If the I parameter is negative then in RRF 1.16 and later the fan is disabled, which frees up the pin for use as a general purpose I/O pin that can be controlled using M42. The I parameter is not supported in RRF_3, use M950 instead.
The A parameter can be used to assign a fan to a different output pin, for example a spare heater output (use a M307 command to disable the heater and free up the pin first). The F parameter is not supported in RRF_3, use M950 instead.
M107: Fan Off
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).
M108: Cancel Heating
Breaks out of an M109 or M190 wait-for-temperature loop, continuing the print job. Use this command with caution! If cold extrusion prevention is enabled (see M302) and the temperature is too low, this will start "printing" without extrusion. If cold extrusion prevention is disabled and the hot-end temperature is too low, the extruder may jam.
M109: Set Extruder Temperature and Wait
Parameters
- Snnn minimum target temperature, waits until within 2.5C of target if heating
- Rnnn accurate target temperature, waits until within 2.5C of target always
- Tn optional tool number
Example
- 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: Set Current Line Number
Parameters
- Nnnn Line number
Example
- M110 N123
This example sets the current line number to 123. Thus the expected next line after this command will be 124.
M111: Set Debug Level
Parameters
- Pnn Debug module number
- Sn Debug on (S1), off (S0)
Examples
- M111
- M111 P1 S1 ; enable debugging for module 1
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 enabl d for each..
Note, print quality may be affected when debug output is enabled because of the volume of data sent to USB. 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.
M112: Emergency Stop
Example
- M112
Any moves in progress are immediately terminated, then RepRap shuts down. All motors and heaters are turned off. It can be started again by pressing the reset button or power cycling the board. See also M0 and M1.
M114: Get Current Position
Example
- 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. 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: Get Firmware Version and Capabilities
Parameters
- This command can be used without any additional parameters.
- Pnnn Electronics type (See Notes)
- Bnnn Board number (RRF_3/Duet 3 only, see Notes)
Examples
- M115
- M115 P2
Request the Firmware Version and Capabilities of the current microcontroller.
The details are returned to the host computer as key:value pairs separated by spaces and terminated with a linefeed.:
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
See the M408 command for a more comprehensive report on machine capabilities.
Notes
The 'P' parameter 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. The following are supported on first-generation Duets:
- M115 P0 - Automatic board type selection if supported, or default if not
- M115 P1 - Duet 0.6
- M115 P2 - Duet 0.7
- M115 P3 - Duet 0.85
The 'B' parameter is used on Duet 3 only, using RRF_3. 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). Example:
M115 B1 Board EXP3HC firmware 3.0beta1 2019-10-28b1
M116: Wait
Parameters
- This command can be used without any additional parameters.
- Pnnn Tool number
- Hnnn Heater number
- Cnnn Chamber number
- Snn Tolerance in degC (firmware 2.02/1.23 and later, default 2)
Examples
- M116
- M116 P1
- M116 H0 S5
The first example waits for all temperatures and other slowly-changing variables to arrive at their set values.
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: Display Message
Example
- 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.
M118: Send Message to Specific Target
Supported in RepRapFirmware 1.21 and later.
Parameters
- Pnnn Message type (0 = Generic [default], 1 = USB, 2 = PanelDue/UART, 3 = HTTP, 4 = Telnet, 5 = second UART) (optional)
- S"msg" Message to send
- Lnnn Log level of this message (0 = do not log this line, 1 = log as WARN, 2 = log as INFO, 3 = log as DEBUG (default)) (RRF >= 3.2.0-beta3)
Examples
M118 S"Hello Duet" M118 S"Hello Logfile" L1 M118 P0 S"Hello Logfile and DWC" L1 M118 S"Don't log me" L0
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
M119: Get Endstop Status
Example
- 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
Example
- 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:
- Current feedrate
- Extruder positions
- Whether moves (and separately extrusion) are relative or absolute
M121: Pop
Example
- M121
Recover the last state pushed onto the stack.
M122: Diagnose
Parameters
- This command can be used without any additional parameters.
- Pnnn report specific information (See Notes)
- Bnnn Board number (RRF_3/Duet 3 only, see Notes)
- "DSF" Immediate DSF diagnostics (RRF_3/Duet3 only with attached SBC)
Example
- M122
Sending an M122 causes the RepRap to transmit diagnostic information.
Notes
The 'P' parameter is used to report specific information. The details vary between releases. As at RepRapFirmware version 2.03 they are:
- P1 print summary test report (additional parameters: Taa:bb = min/max accepted MCU temperature reading, Vaa:bb = min/max VIN voltage reading, Waa:bb = min/max 12V regulator voltage reading if applicable)
- P100 print a summary of recent moves (only if move logging is enabled in the firmware build)
- P101 print the status of an attached DueX expansion board
- P102 print how long it takes to evaluate the square root of a 62-bit unsigned integer
- P103 print how long it takes to evaluate sine and cosine
- P104 print how long it takes to write a file to the SD card (specify the file size in Mbytes in the S parameter, default 10)
- P105 print the sizes of various objects used by RepRapFirmware
Note: do not use M122 with a P parameter of 1000 or greater. There are a few values that deliberately cause the firmware to crash, which are used to test the error reporting facilities. As at firmware 2.03 these are:
- P1001 cause a watchdog reset
- P1002 test what happens when a module gets stuck in a spin loop
- P1003 test what happens when we write a blocking message to USB
- P1004 test integer division by zero
- P1005 test the response to an unaligned memory access
- P1006 test the response to accessing an invalid region of memory
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
M135: Set PID sample interval
Parameters
- Snnn Heat sample time in milliseconds
Example
- M135 S300
Set the PID to measure temperatures and calculate the power to send to the heaters every 300ms.
NOTE: removed in RRF 2.03beta2
M140: Set Bed Temperature (Fast) or Configure Bed Heater
Parameters
- Pnnn (RRF 1.20 and later) Bed heater index, default 01
- Hnnn Heater number
- Snnn Active/Target temperature
- Rnnn Standby temperature
Examples
- M140 H0
- M140 S55
- M140 S65 R40
The first example informs the firmware that bed heater 0 (implied, because no P parameter is provided) uses heater 0.
The second 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 third example sets the bed temperature to 65oC and the bed standby temperature to 40oC.
If the absolute negative temperature (-273 or lower) is passed as target temperature, the bed heater to be switched off:
M140 S-273
RepRapFirmware also provides an optional 'H' parameter to set the hot bed heater number(s). If no heated bed is present, a negative value may be specified to disable it. M140 commands with H parameters would normally be used only in the config.g file.
Order dependency
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.
1 On the Duet 2 WiFi and Duet 2 Ethernet you can configure up to 4 bed heaters.
M141: Set Chamber Temperature (Fast) or Configure Chamber Heater
Parameters
- Pnnn (RRF 2.03 and later only) Chamber heater index, default 0
- Hnnn Heater number
- Snnn Active/Target temperature
- Rnnn Standby temperature
Examples
- M141 S30
- M141 H3
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 uses heater 3.
M141 commands with H parameters would normally be used only in the config.g file.
Order dependency
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.
M143: Maximum heater temperature
M143 in RRF 3.01RC1 and earlier
Parameters
- H Heater number to turn off if an anomaly is detected (default 1 which is normally the first hot end). This must be a real heater.
- S Maximum permitted temperature
- P Heater protection instance (defaults to H parameter if omitted)1
- X Heater number whose temperature sensor is used to monitor the heater specified in the H parameter. This can be a virtual heater. It default to the value of the H parameter.1
- A Action to trigger (0: Generate heater fault [default] 1: Switch off permanently 2: Switch off temporarily)1
- C Condition for temperature event (0: Temperature too high [default] 1: Temperature too low)1
Examples
- 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
Order dependency
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.
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.
Notes
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.
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.
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).
Example
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
M143 in RRF 3.01RC2 and later
Parameters
- H Heater number to monitor (default 1 which is normally the first hot end)
- S Maximum permitted temperature
- P Heater monitor number, default 0
- T Sensor number used to monitor the heater. It default to the sensor that controls the heater (as was specified in the M305 command when the heater was created).
- A Action to trigger (0: Generate heater fault [default] 1: Switch off permanently 2: Switch off temporarily 3: Shut down the printer)1
- C Condition for temperature event (0: Temperature too high [default] 1: Temperature too low, -1: Monitor is disabled)
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, and monitors 1 and 2 are disabled.
Examples
- 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
M144: Bed Standby
Parameters
- Pnnn Bed index1
- Sn 0 = put bed heater on standby (default), 1 = make bed heater active
Example
- M144
Switch the bed to its standby temperature. M144 S1 will set it back to its active temperature.
1 Only supported in RepRapFirmware 1.20 and later.
M150: Set LED colours
Parameters
- Rnnn Red component, 0-255
- Unnn Green component, 0-255
- Bnnn Blue component, 0-255
- Pnnn Brightness, 0-255 (RepRapFirmware 2.03 and later)
- Snnn Number of individual LEDs to set to these colours
- Fn Following command action. F0 (default) means this is the last command for the LED strip, so the next M150 command starts at the beginning of the strip. F1 means further M150 commands for the remainder of the strip follow this one.
- Xn LED type: X0 (default) = DotStar, X1 = NeoPixel. This parameter is remembered from one call to the next, so it only needs to be given once.
- Ynn 'Brightness, 0-31 (alternative to P 0-255)
- Qnnn (optional) Use specified SPI frequency (in Hz) instead of the default frequency. This parameter is ont normally needed, and is only processed if X parameter also present. When using NeoPixels, only frequencies in the range 2.4 to 4MHz will work.
Example
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
This command is only supported on controllers that have an output connector for DotStar or NeoPixel LEDs.
The specified RGB values will be sent to the number of LEDs in the LED strip as specified by the S parameter, pushing the existing colours along the strip. To set all the LEDs the same colour, make the S parameter equal to or a little longer than the number of LEDs in the strip.
M190: Wait for bed temperature to reach target temp
Parameters
- Snnn minimum target temperature, waits while heating
- Pnnn Bed index1
- Rnnn accurate target temperature, waits while heating and cooling
Example
- 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.
1 Only supported in RepRapFirmware 1.20 and later.
M191: Wait for chamber temperature to reach target temp
Parameters
- Snnn minimum target temperature, waits while heating
- Rnnn accurate target temperature, waits while heating and cooling
- Pnnn Chamber index. This defaults to 0 and the maximum is dependent on the board type. 1
Example
- M191 S60
Set the temperature of the build chamber to 60C and wait for the temperature to be reached.
1 Only supported in RepRapFirmware 1.20 and later.
M200: Set filament diameter
Parameters
- Daaa:bbb:ccc... Sets filament diameter to aaa for extruder 0, bbb for extruder 1 and so on. If any of aaa, bbb etc. are zero then volumetric extrusion is disabled for that extruder.
- Daaa Sets filament diameter (or disables volumetric extrusion) for all extruders
Examples
- M200 D0 ; disable volumetric extrusion on all extruders
- 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.
Sending M200 without parameters reports the current volumetric extrusion state and (where appropriate) filament diameter for each extruder.
Note that if you use slicer-commanded retraction, the retraction amounts must be specified in mm3 too. If instead you use firmware retraction, then the firmware retraction amounts specified using the M207 command are still interpreted as mm.
This command is supported in RepRapFirmware 1.19beta10 and later.
M201: Set max acceleration
Parameters
- Xnnn Acceleration for X axis
- Ynnn Acceleration for Y axis
- Znnn Acceleration for Z axis
- Unnn Acceleration for U axis
- Vnnn Acceleration for V axis
- Wnnn Acceleration for W axis
- Ennn Acceleration for extruder drives
Order dependency
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.
Example
- 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 G Code 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
M203: Set maximum feedrate
Parameters
- Xnnn Maximum feedrate for X axis
- Ynnn Maximum feedrate for Y axis
- Znnn Maximum feedrate for Z axis
- Unnn Maximum feedrate for U axis
- Vnnn Maximum feedrate for V axis
- Wnnn Maximum feedrate for W axis
- Ennn:nnn... Maximum feedrates for extruder drives
- Innn Minimum overall movement speed (firmware 2.03 and later), default 30mm/min
Order dependency
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.
Example
- 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: Set printing and travel accelerations
Parameters
- Pnnn Acceleration for printing moves
- Tnnn Acceleration for travel moves
Example
- 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.
M205: Set max instantaneous speed change in mm/sec
- Xnnn X axis max instantaneous speed change in mm/sec
- Ynnn Y axis max instantaneous speed change in mm/sec
- Znnn Z axis max instantaneous speed change in mm/sec
- Unnn, Vnnn, Wnnn etc. U, V, W axis max instantaneous speed change in mm/sec
Order dependence
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.
M206: Offset axes
Parameters
- Xnnn X axis offset
- Ynnn Y axis offset
- Znnn Z axis offset
- Unnn U axis offset
- Vnnn V axis offset
- Wnnn W axis offset
Order dependency
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.
Example
- 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.
M207: Set retract length
Parameters
- Pn Tool number (optional, supported in RRF 3.01 and later only)
- Snnn positive length to retract, in mm
- Rnnn positive or negative additional length to un-retract, in mm, default zero
- Fnnn retraction feedrate, in mm/min
- Tnnn feedrate for un-retraction if different from retraction, mm/min (RepRapFirmware 1.16 and later only)
- Znnn additional zlift/hop
Example
- 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.
M208: Set axis max travel
Parameters
- Snnn 0 = set axis maximum (default), 1 = set axis minimum
- Xnnn X axis limit
- Ynnn Y axis limit
- Znnn Z axis limit
Alternative (from RepRapFirmware 2.02/1.23)
- Xaaa:bbb X axis minimum and maximum limit
- Yaaa:bbb Y axis minimum and maximum limit
- Zaaa:bbb Z axis minimum and maximum limit
Order dependence
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.
Example
- 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.
Note The M208 minimum Z value applies to deltas. The M208 XY min/max and Z max values don't.
M220: Set speed factor override percentage
Parameters
- Snnn Speed factor override percentage (0..100 or higher)
Example
- M220 S80
Sets the speed factor override percentage.
M221: Set extrude factor override percentage
Parameters
- Snnn Extrude factor override percentage (0..100 or higher), default 100%
- Dnnn Extruder drive number (RepRapFirmware only), default 0
Example
- 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: Synchronous Pause
Example
- 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.
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 (such as the web interface console, PanelDue or a Macro), so if you need to pause from those use M25 instead.
M260: i2c Send and/or request Data
Send and/or receive data over the i2c bus. Supported in RepRapFirmware 1.21 and later.
Parameters
- Ann I2C address
- Bnn:nn:nn... Bytes to send (optional in firmware 2.02 and later)
- Rnn Number of bytes to receive (optional) - firmware 2.02 and later only
Examples
- 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
Hex addresses are only supported in firmware 2.02 and later.
M261: i2c Request Data
Deprecated in RRF 2.02 and later. Use M260 instead.
Parameters
- Ann I2C address
- Bnn How many bytes to request
Example
- M261 A99 B5 ; Request 5 bytes from Address 99
M280: Set servo position
Set servo position absolute.
Parameters
- Pnnn Servo index
- Snnn Angle (see note) or microseconds
- I1 Invert polarity (not supported in RRF_3)
Example
- M280 P1 S50
S values below 544 are treated as angles, and 544 or greater as the pulse width in microseconds.
Notes
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.
RRF_3: 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, not the logical pin number. Duet 2 supports up to 10 GPIO ports, numbers 0 to 9. No GPIO ports are allocated by default.
RRF_3: The I parameter is no longer supported in M280. Instead, specify an inverted pin name in M950 when you create the GPIO port.
Example - old code (RRF_2):
M280 P3 I1 S80 ; set Heater 3 pin to 80deg servo position, inverted
New code (RRF_3):
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
RRF_2: 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.
RRF_2: The servo index is the same as the pin number for the M42 command. See Using servos and controlling unused IO pins for details for the Duet 2 Wifi and Ethernet or the table below for the 0.8.5.
Duet 0.8.5 M280 P value to Expansion Port Pin Mapping | ||
---|---|---|
P | Name | Expansion Port Pin |
Use M307 H# A-1 C-1 D-1 before using these pins | ||
3 | PC4_PWML1 | 18 |
4 | PC23_PWML6 | 21 |
5 | PC22_PWML5 | 22 |
6 | PC21_PWML4 | 23 |
M290: Baby stepping
Supported in firmware version 1.18 and later.
Parameters
- Snnn Amount to baby step Z in mm. Positive values raise the head or lower the bed, negative values do the opposite.
- Znnn Synonym for S (RepRapFirmware 1.21 and later)
- X,Y,U... Amount to babystep other axes (RRF 2.03 and later)
- Rn (Optional, RepRapFirmware 1.21 and later) R1 = relative (add to any existing babystep amount, the default), R0 = absolute (set babystepping offset to the specified amount)
Examples
- 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.
M291: Display message and optionally wait for response
Supported in firmware version 1.19 and later.
Parameters
- P"message" The message to display, which must be enclosed in double quotation marks. If the message itself contains a double quotation mark, use two double quotation marks to represent it.
- R"message" Optional title for the message box. Must be enclosed in double quotation marks too.
- Sn Message box mode (see below), default 1
- Tn Timeout in seconds, ignored if S=2 or S=3. The message will be cancelled after this amount of time, if the user does not cancel it before then. A zero or negative value means that the message does not time out (it may still be cancelled by the user if it has a Close button). The default value is 10 seconds (this applies to modes 0 and 1 only).
- X, Y, Zn 0 = no special action (default), 1 = display jog buttons alongside the message to allow the user to adjust the head position on the specified axis
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 are:
0. No buttons are displayed (non-blocking) 1. Only "Close" is displayed (non-blocking) 2. Only "OK" is displayed (blocking, send M292 to resume the execution) 3. "OK" and "Cancel" are displayed (blocking, send M292 to resume the execution or M292 P1 to cancel the operation in progress)
The combination S0 T0 is not permitted, because that would generate a message box with no close button and that never times out, which would lock up the user interface.
Duet Web Control 2.03 and later support HTML messages but that may not be displayed correctly on an attached PanelDue.
Note the limit in RRF2 is 160 characters in the entire GCode command. In RRF3 it's 200 characters.
M292: Acknowledge message
Parameters:
- Pnnn Whether the current operation shall be cancelled (P=1) or continued (P=0).
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. The P parameter is ignored unless M291 was called with S=3.
Supported in firmware version 1.19 and later.
M300: Play beep sound
Parameters
- Snnn frequency in Hz
- Pnnn duration in milliseconds
Example
- 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.
Note: 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.
Ex:
M300 S2000 P200 G4 P200 M300 S2500 P300 G4 P300
M301: Set PID parameters
Parameters
- Hnnn heater number
- Pnnn proportional (Kp)
- Innn integral (Ki)
- Dnnn derivative (Kd)
Examples
- 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
- H: Is the heater number, and is compulsory. H0 is the bed, H1 is the first hot end, H2 the second etc.
- P: Proportional value
- I: Integral value
- D: Derivative value
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: Allow cold extrudes
Parameters
- This command can be used without any additional parameters.
- Pnnn Cold extrude allow state (RepRapFirmware)
- Snnn Minimum extrusion temperature (RepRapFirmware 2.02 and later)
- Rnnn Minimum retraction temperature (RepRapFirmware 2.02 and later)
Examples
- 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.
Note: 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. ex: M563 P0 S"Pump" D0 F0 Note the lack of H parameter.
M303: Run heater tuning
Parameters
- Hnnn heater number (in RRF 3.2 and later, this parameter is optional if the T parameter is given)
- Pnnn PWM to use, 0 to 1 (you should normally use 1 i.e. full power), default 1
- Snnn target temperature
- Tnnn (RRF 3.2 and later, optional) Tool whose primary heater is to be tuned
- Annn (RRF 3.2 and later, optional) ambient temperature - use this parameter if you want to tune a heater that has been on and has not cooled down to ambient temperature yet
- 'Ynn (RRF 3.3beta3 and laterm optional) Tuning cycle hysteresis, default 5C. When tuning bed heaters that are slow to cool down, tuning will be faster if you use a lower value, provided that there is no noise in the temperature readings.
- Fnn (RRF 3.3beta3 and later) Fan PWM to use when the print cooling fan is turned on (ignored if the T parameter is not present), default 1.0. Use a lower value if youpr printer uses a powerful print cooling fan that you do not normally run at full PWM.
Examples
- 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 Wiki:Tuning 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: Set PID parameters - Bed
Parameters
- This command can be used without any additional parameters.
- Pnnn proportional (Kp)
- Innn integral (Ki)
- Dnnn derivative (Kd)
Examples
- 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.
M305: Set temperature sensor parameters
RepRapFirmware 3: Use M308 instead (see Notes).
Parameters
- Pnnn Heater number (0, 1, 2...) or virtual heater number (100, 101, 102...)
- S"name" Heater name (optional). Named virtual heaters are shown in Duet Web Control; anonymous virtual heaters are not.
- Xnnn Heater ADC channel, or thermocouple or PT100 adapter channel; defaults to the same value as the P parameter
- Tnnn (for thermistor sensors) The thermistor resistance at 25oC
- T"c" (for MAX31856-based thermocouple sensor daughter boards) The thermocouple type letter, default K
- Bnnn If the sensor is a thermistor, this is the Beta value. For the Steinhart-Hart thermistor model, this is the reciprocal of the B coefficient
- Cnnn If the sensor is a thermistor, this is the Steinhart-Hart C coefficient, default 0
- Rnnn If the sensor is a thermistor or PT1000 sensor, this is the Series resistor value, see here for more information if you need it: the default for your board.
- Lnnn If the sensor is a thermistor, this is the ADC low offset. If it is a current loop sensor, this is the temperature when the current is 4mA.
- Hnnn If the sensor is a thermistor, this is the ADC high offset. If it is a current loop sensor, this is the temperature when the current is 20mA.
- Fnn (where nn is 50 or 60) If the sensor interface uses a MAX31856 thermocouple chip or MAX31865 PT100 chip, this is the local mains frequency. Readings will be timed to optimise rejection of interference at this frequency.
- Wn Configure number of wires used to connect PT100 sensor. Should be [2..4].
Example
- M305 P1 T100000 R1000 B4200
Sets the parameters for temperature measurement. The example above tells the firmware that for heater 1 (P parameter: 0 = heated bed, 1 = first extruder) the thermistor 25C resistance (T parameter) is 100Kohms, the thermistor series resistance (R parameter) is 1Kohms, the thermistor beta (B parameter) is 4200. All parameters other than P are optional. If only the P parameter is given, the existing values are displayed. 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:
- Channels 0, 1... are the thermistor inputs for heaters 0, 1 etc.
- Channels 100, 101... are MAX31855 thermocouple channels using chip selects CS1, CS2... on the SPI bus, see Connecting thermocouples.
- Channels 150, 151... are MAX31856 thermocouple channels using chip selects CS1, CS2... on the SPI bus
- Channels 200, 201... are MAX31865 PT100 channels using chip selects CS1, CS2... on the SPI bus, see Connecting PT100 temperature sensors.
- Channels 300, 301... are current loop channels using chip selects CS1, CS2... on the SPI bus
- Channels 400, 401... are DHTxx temperature channels. The DATA line of the DHTxx must be connected to one of pins CS1, CS2... on the SPI bus. Specify the sensor type (11 for DHT11, 21 for DHT21 or 22 for DHT22) via the T-parameter. e.g. M305 P102 X401 T22 S"DHT temperature"
- Channels 450, 451... are as 400, 401... but specify the corresponding humidity sensor of the DHTxx
- Channels 500, 501... are the thermistor inputs, but configured for PT1000 sensors rather than thermistors. Only the R, H and L parameters are significant, see example below.
- Channel 1000 is the on-chip microcontroller temperature sensor
- Channel 1001 represents the temperature warning and overheat flags on the TMC2660, TMC2224 or other smart drivers on the Duet main board. It reads 0C when there is no warning, 100C if any driver reports over-temperature warning , and 150C if any driver reports over temperature shutdown.
- Channel 1002 is as channel 1001 but for drivers on the Duex 2 or Duex 5 expansion board.
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. However, it may be poor on the Duet 06, Duet 085 and other SAM3X8E-based electronics. 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.
M307: Set or report heating process parameters
Parameters
- Hn Heater number (0 is usually the bed heater)
- Annn (deprecated in RRF 3.2beta3.2 and later in favour of the R parameter) gAin, expressed as ultimate temperature rise obtained in degC divided by the PWM fraction. For example, if G=180 then at 50% PWM the ultimate temperature rise would be 90C.
- Cnnn or Caaa:bbb dominant time Constant of the heating process in seconds. If two values are provided (supported in RRF 3.2beta3.2 and later), the first value is with the fan off and the second is with the fan on at full PWM.
- Dnnn Dead time in seconds
- Innn Invert PWM signal (I0 = not inverted, I1 = invert PWM/bang-bang signal for inverted temperature control [e.g. with Peltier elements], I2 = full PWM signal inversion, I3 = both) (supported by RRF > 1.20)
- Rnnn Heating rate, supported in RRF 3.2beta3.2 and later
Additional parameters to help control the heating process:
- Bn selects Bang-bang control instead of PID if non-zero. Default at power-up is 0 for extruder heaters, 1 for the bed heater.
- Fnnn PWM frequency to use (RepRapFirmware 1.20 and later).
- Snnn maximum PWM to be used used with this heater on a scale of 0 to 1. Default 1.0.
- Vnnn VIN supply voltage at which the A parameter was calibrated (RepRapFirmware 1.20 and later). This allows the PID controller to compensate for changes in supply voltage. A value of zero disables compensation for changes in supply voltage. Use V0 for AC mains powered heaters. (V0 is the default. Leaving off V is the same as V0)
Examples
- 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%
- M307 H2 R2.186 C202.1:155.0 D5.67 S1.00 V24.0 ; set the process parameters (RRF 3.2beta3.2 or later)
Notes - RepRapFirmware 3
The F parameter is no longer supported. Use M950 to set the frequency in the M950 command that you use to define the heater .
The I2 parameter is no longer supported, and I3 does the same as I1. You can use M950 to invert the output.
You can no longer disable a heater using M307 A-1 C-1 D-1. To use the pin for something else, don't create a heater on that pin.
Example - old 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
New 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
Notes
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 Wiki:Tuning 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.
RepRapFirmware 1.16 and later allow the PID controller for a heater to be disabled by setting the A, C and D parameters to -1. This frees up the corresponding heater control pin for use as a general purpose I/O pin to use with the M42 or M280 command.
M308: Set or report sensor parameters
M308 is supported in RepRapFirmware 3. If running RRF_2.x or earlier, use M305.
Common Parameters
- Sn Sensor number
- P"pin_name" The name of the control board pin that this sensor uses. For thermistors it is the thermistor input pin name, see Pin Names. For sensors connected to the SPI bus it is the name of the output pin used as the chip select.
- Y"sensor_type" The sensor and interface type, one of: "thermistor", "pt1000", "rtd-max31865", "thermocouple-max31855", "thermocouple-max31856", "linear-analog", "dht21", "dht22", "dhthumidity", "current-loop-pyro", "drivers". All boards except the Duet 3 Mini also support "mcu-temp". Duet WiFi/Ethernet with an attached DueX2 or DueX5 also support "drivers-duex". Firmware 3.2 and earlier also supports "dht11" but this support is likely to be removed in future firmware versions.
- A"name" Sensor name (optional), displayed in the web interface
Additional parameters for thermistors
- Tnnn (for thermistor sensors) Thermistor resistance at 25°C
- Bnnn Beta value, or the reciprocal of the Steinhart-Hart thermistor model B coefficient
- Cnnn Steinhart-Hart C coefficient, default 0
- Rnnn Series resistor value. Leave blank to use the default for your board.
- Lnnn ADC low offset correction, default 0 (ignored if the hardware supports automatic ADC gain and offset calibration)
- Hnnn ADC high offset correction, default 0 (ignored if the hardware supports automatic ADC gain and offset calibration)
Additional parameters for PT1000 sensors
- Rnnn Series resistor value. Leave blank to use the default for your board.
- Lnnn ADC low offset correction, default 0 (ignored if the hardware supports automatic ADC gain and offset calibration)
- Hnnn ADC high offset correction, default 0 (ignored if the hardware supports automatic ADC gain and offset calibration)
Additional parameters for MAX31856-based thermocouple sensors
- T"c" The thermistor type letter, default K
- Fnn (where nn is 50 or 60) The local mains frequency. Readings will be timed to optimise rejection of interference at this frequency.
Additional parameters for MAX31865-based PT100 sensors
- Rnnn Series resistor value. Leave blank to use the default for your board.
- Fnn (where nn is 50 or 60) The local mains frequency. Readings will be timed to optimise rejection of interference at this frequency.
Additional parameters for linear analog sensors
- Fn F0 = unfiltered (fast response), F1 = filtered (slower response, but noise reduced and ADC oversampling used to increase resolution)
- Bnnn The temperature or other value when the ADC output is zero
- Cnnn The temperature or other value when the ADC output is full scale
P"nnn" parameter for "dhthumidty"
Reimplementing DHT support in RepRapFirmware 3 has led to a new concept of additional outputs a sensor can have. With the exception of DHT sensors all other sensors have just a primary output (output number 0). All DHT variants though have - besides their primary output for temperature - a secondary output that delivers the humidity values. "dhthumidity" will be attached to an existing DHT sensor's secondary output by using its full sensor number (including the leading S) and the output's index separated by a dot.
Example:
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
This code replaces M305 in RepRapFirmware 3. In earlier versions of RepRapFirmware, sensors only existed in combination with heaters, which necessitated the concept of a "virtual heater" to represent a sensor with no associated heater (e.g. MCU temperature sensor). RepRapFirmware 3 allows sensors to be defined independently of heaters, up to a max of 32 sensors. The association between heaters and sensors is defined using M950.
M308 can be used in the following ways:
M308 Snn Y"type" [other parameters] ; delete sensor nn if it exists, create a new one with default settings, and configure it using the other parameters. At least the pin name must also be provided, unless the sensor doesn't use a pin (e.g. MCU temperature sensor).
M308 Snn ; report the settings of sensor nn, this will also report the last error on that sensor if applicable
M308 A"name" ; report the settings of the first sensor named "name"
M308 Snn [any other parameters except Y] ; amend the settings of sensor nn
Sensor type names obey the same rules as Pin Names, i.e. case is not significant, neither are hyphen and underscore characters.
When converting from older versions of RRF to RRF_3 you must replace each M305 command by a similar M308 command, which must be earlier in config.g than any M950 command that uses it. You must also use M950 to define each heater that you use, because there are no default heaters.
Example - old code:
M305 P0 T100000 B3950 ; bed heater uses a B3950 thermistor M305 P1 T100000 B4725 C7.06e-8 ; E0 heater uses E3D thermistor
New 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
M350: Set microstepping mode
Usage
- M350 Xnn Ynn Znn Enn Inn
Parameters
- Not all parameters need to be used, but at least ''one'' should be used. As with other commands, RepRapFirmware reports the current settings if no parameters are used.
- Xnn Set stepping mode for the X axis
- Ynn Set stepping mode for the Y axis
- Znn Set stepping mode for the Z axis
- Enn Set stepping mode for Extruder 0 (use Enn:nn:nn etc. for multiple extruders)
- Inn Enable (nn=1) or disable (nn=0) microstep interpolation mode for the specified drivers, if they support it. The Duet 2 WiFi/Ethernet support interpolation (to x256 microstepping) only when configured for x16 microstepping. The Duet 2 Maestro supports interpolation at all microstep settings.
Modes (nn)
- 1 = full step
- 2 = half step
- 4 = quarter step
- 8 = 1/8 step
- 16 = 1/16 step
- 32 = 1/32 step
- 64 = 1/64 step
- 128 = 1/128 step
- 256 = 1/256 step
Order dependency
This command must be later in config.g than any M584 command.
Examples
- 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.
Notes
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 is available on the TMC2660 drivers used on the Duet 2 WiFi and Duet 2 Ethernet, but only when microstepping is set to 16. In other configurations, specifying I1 has no effect. Microstepping interpolation is available on the TMC2224 drivers used on the Duet 2 Maestro at all microstepping settings,
M374: Save height map
Saves the height map.
Parameters
- P"filename" Name of the file to save to
Usage
- M374
- M374 P"MyAlternateHeightMap.csv"
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.
M375: Load height map
Loads the grid matrix file
Parameters
- P"filename"
Examples
- 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: Set bed compensation taper
Parameters
- Hnnn Height (mm) over which to taper off the bed compensation
Example
- 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 zero or negative then no tapering is applied, so compensation is performed throughout the entire print.
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 for current moves to finish
Example
- M400
Finishes all current moves and and thus clears the buffer. That's identical to G4 P0.
M401: Deploy z-probe
Parameters
- P Probe number (RRF 3.01RC4 and later)
Examples
- 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: Retract z-probe
Parameters
- P Probe number (RRF 3.01RC4 and later)
Examples
- 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: Filament width and nozzle diameter
Parameters
- Nnnn Filament width (in mm)
- Dnnn Nozzle diameter (in mm)
Examples
- M404 N1.75
- M404 N3.0 D1.0
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.
The values of this command are currently only used for the print monitor.
M408: Report JSON-style response
Parameters
- Snnn Response type (only used when P is zero or not present)
- Rnnn Response sequence number
Example
- M408 S0
When P is missing or zero, this reports a JSON-style response by specifying the desired type using the 'S' parameter. The following response types are supported:
- Type 0 is a short-form response, similar to the response used by older versions of the web interface.
- Type 1 is like type 0 except that static values are also included.
- Type 2 is similar to the response provided by the web server for Duet Web Control.
- Type 3 is an extended version of type 2 which includes some additional parameters that aren't expected to change very frequently.
- Type 4 is an extended version of type 2 which may be used to poll for current printer statistics.
- Type 5 reports the current machine configuration.
Here is an example of a typical type 0 response:
{"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 G-code response or error message. Only present if the R parameter was provided and the current sequence number is greater than that.
resp: the most recent non-trivial G-code response or error message. Only present if the R parameter was provided and the current sequence number is greater.
The type 1 response comprises these fields plus some additional ones that do not generally change and therefore do not need to be fetched as often. The extra fields include:
myName: the name of the printer
firmwareName: the name of the firmware, e.g. "RepRapFirmware" 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: Query object model
Parameters
- K"key" Key string, default empty
- F"flags" Flags string, default empty
Examples
- 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 element that is an array may be followed by either [number] to select just one element, or by [] to select all elements and report the results as an array
- The path may be preceded by # in which case the path must refer to an array and just the number of array elements is returned
An empty key string selects the entire object model. Note, the entire object model may be very large. RepRapFirmware 3.0beta2 and later set a default maximum depth of 1 if the key string is empty or not present, to avoid generating a response that may be too long to send.
The flags string may include one or more of the following letters:
- f: return only those values in the object model that typically change Frequently during a job
- v: Verbose: include values that are rarely needed and not normally returned
- n: include fields with null values
- o: include obsolete fields (v3.3 and newer)
- d: limit the depth of the reported tree to the specified number following the letter d. Objects at the maximum depth will be returned as {}.
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.
M450: Report Printer Mode
Example
- 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.
M451: Select FFF Printer Mode
Parameters
- none
Example
- M451
Switches to Fused Filament Fabrication mode for filament printing.
M452: Select Laser DeviceMode
Parameters
- Pnnn Logical pin number used to control the laser (not supported in RRF_3, see notes)
- In Invert (I1) or don't invert (I0, default) the output polarity (not supported in RRF_3, see notes)
- Rnnn The value of the S parameter in M3 commands that corresponds to full laser power, default 255
- Sn 1= laser power is sticky across G1 commands, 0 (default) = laser is off when executing G1 commands that have no S parameter
- Fnnn The PWM frequency used to drive the laser - default is 500Hz
Example
- M452 P2 R255 F200 ; switch to laser mode using the heater 2 (E1 heater) output pins to control the laser
Switches to laser mode. This mode enables handling of a laser pin and makes sure that the laser is only activated during G1 moves if laser was enabled or E is increasing. G0 moves should never enable the laser. M3/M5 can be used to enable/disable the laser for moves. Logical pin numbers for the P parameter are as defined for the M42 and M208 commands. If a heater or fan output is used to control the laser, you must disable the corresponding heater (see M307) or fan (see M106) first.
Very important! If you use M452 to put your machine into Laser mode and are running Firmware 2.02 or above, 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.
Notes - RepRapFirmware 3
In RRF_3, the P and I parameters are removed. Use the C parameter to select the laser control pin instead.
Example - old code (RRF_2.x):
M452 P3 I1 F100 ; laser uses heater3 pin, PWM frequency 100Hz
New code (RRF_3):
M452 C"exp.heater3" F100 ; laser uses heater3 pin, PWM frequency 100Hz
M453: Select CNC Device Mode
M453 in RepRapFirmware 1.x and 2.x
Parameters
- Snnn (optional) Spindle index, defaults to 0. Duet 2 supports 4 spindles max
- Pfff:rrr Logical pin numbers used to drive the spindle motor in clockwise and counterclockwise directions. Omit the ":rrr" part if the spindle turns clockwise only. (Not supported in RRF_3, see notes)
- In Invert (I1) or don't invert (I0, default) the output polarity. (Not supported in RRF_3, see notes)
- Rnnn Spindle RPM that is achieved at full PWM. Used to convert the S parameter in M3 and M4 commands to a PWM value.
- Fnnn (optional) The PWM frequency to use
- Tnnn (optional) Assign spindle to a tool allowing better control in DWC
Example
- M453 P2 R5000 ; switch to CNC mode using heater 2 (E1 heater) pins to control the spindle motor
Switches to CNC mode. In this mode M3/M4/M5 control the pins defined for the milling device. By default, no output is assigned to the spindle motor. Logical pin numbers for the P parameters are as defined for the M42 and M208 commands. If you wish to assign a heater or fan output to control the spindle motor as in the above example, you must first disable the corresponding heater (see M307) or fan (see M106).
M453 in RepRapFirmware 3.0 and 3.1.x
Parameters
- Snnn (optional) Spindle index, defaults to 0. Duet 2 supports 4 spindles max
- C"fff+rrr" Names of the ports used to drive the spindle motor in clockwise and counterclockwise directions. Omit the "+rrr" part if the spindle turns clockwise only.
- Rnnn Spindle RPM that is achieved at full PWM. Used to convert the S parameter in M3 and M4 commands to a PWM value.
- Fnnn (optional) The PWM frequency to use
- Tnnn (optional) Assign spindle to a tool allowing better control in DWC
Example:
M453 C"exp.heater3+exp.heater4" F100 ; spindle forward/reverse on heater 3&4 pins, PWM frequency 100Hz
M453 in RepRapFirmware 3.2
Parameters
- Snnn (optional) Spindle index, defaults to 0. Duet 2 supports 4 spindles max
- C"aaa+bbb+ccc" Names of the ports used to drive the spindle motor. "aaa" is the PWM port used to control the speed. "bbb" (optional)is the digital port used to turn the spindle motor on. "ccc" (optional) is the name of the port used to command reverse instead of forward spindle rotation.
- Rbbbor Raaa:bbb (optional) RPM values that are achieved at zero PWM and at maximum RPM. Used to convert the S parameter in M3 and M4 commands to a PWM value.
- Qnnn (optional) The PWM frequency to use
- Tnnn (optional) Assign spindle to a tool allowing better control in DWC
Example:
M453 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
M453 in RepRapFirmware 3.3beta2 and later
Parameters
none
Switches to CNC mode. All other parameters have been removed and moved into M950.
Example:
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"
M470: Create Directory on SD-Card
Parameters
- P"name" Name of directory to create
Example
- 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.
M471: Rename File/Directory on SD-Card
Parameters
- S"name" Name of existing file/directory
- T"name" New name of file/directory
- Dnnn Setting this to 1 will delete an existing file that matches the T parameter value
Usage
- M471 S"source/name" T"dest/name" D1
Example
M471 S"/sys/config-override.g" T"/sys/config-override.g.bak"
Rename or move a file or directory. Using the D parameter can delete a file with the target name. Renaming or moving across directories is possible though not from one SD-Card to another.
Supported in RRF >= 2.03.
M486: Object cancellation
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 G-code, 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.
G-codes associated with the canceled objects are no longer printed. Firmware supports this feature by ignoring G0-G3/G5 moves in XYZ while updating F and keeping the E coordinate up-to-date without extruding.
Slicers should number purge towers and other global features with a negative index (or other flag) to distinguish them from regular print objects, since it is important to preserve color changes, purge towers, and brims.
Usage
- 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
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.
Supported in RRF 3.01-RC5 and later.
M500: Store parameters
Usage
- 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). Implemented in RepRapFirmware 1.17 and later. The parameters stored are:
- M307 auto tune results
- PID parameters, if you used M301 to override the auto tune PID settings
- Delta printer M665 and M666 settings
- Any M208 axis limits that were determined using a G1 S3 move
- If the P31 parameter is used, the G31 trigger height, trigger value and X and Y offsets for each possible Z probe type (in older firmware versions the G31 parameters are stored even if the P31 parameter is not present)
- If the P10 parameter is present, the G10/M568 tool offsets
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: Read stored parameters
Parameters
- None
Example
- 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: Revert stored parameters
Example
- 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: Print settings
Example
- M503
This command asks the firmware to reply with the current print settings stored in sys/config.g. The reply output includes the G-Code commands to produce each setting. For example, the Steps Per Unit values are displayed as an M92 command.
Note that the output may be truncated if it is too long. M503 does not include values stored in config-override.g.
M505: Set configuration file folder
Parameters
- P"name" ; name of folder, default path is the existing sys path if a relative path is given
Example
- 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: Set MAC address
Parameters
- Pnnn The MAC address
Examples
- M540 PDE:AD:BE:EF:CA:FE
Sets the http://en.wikipedia.org/wiki/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.
All devices running on the same network shall all have different MAC addresses. For your printers, changing the last digit is sufficient.
Note on the Duet 2 Wifi the MAC address is unique and set on the Wifi Module so this command has no effect. The default MAC address on a Duet 2 Ethernet is generated from the unique processor ID so there is normally no need to change it.
M550: Set Name
Parameters
- P"nnn" Machine name
Example
- M550 P"Godzilla"
Sets the name of the printer to (in this case) 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.
mDNS local network discovery
The machine name is also used to allow local network discovery using mDNS. 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
mDNS is supported natively in Windows 10, most Ubuntu distributions, and Mac OS. For older versions of Windows, install Apple's Bonjour Print Services for Windows. If you have installed Skype, Apple’s iTunes or Adobe Photoshop CS3 or later, Bonjour will already have been installed.
Use of mDNS naming also relies on the firmware on the Duet:
- Duet 2 WiFi - mDNS support in all firmware versions
- Duet 2 Ethernet, Duet 2 Maestro - mDNS support introduced with firmware v2.04RC3
- Duet 0.6/0.84 - mDNS support in all versions up to 1.23. mDNS was disabled in legacy Duets from 1.24 due to code quality issues causing reboots, https://forum.duet3d.com/topic/8352/duet...
The machine name is also used as the NetBIOS name, which can help to identify the Duet on a network. This is only supported on Duet 2 WiFi and legacy Duet 0.6/0.85.
Note: Both the mDNS and NetBIOS name are limited to 15 characters. If you use a longer name, the mDNS name will be the first 15 characters, eg if the Duet name is "3DPrinterWithVeryLongName", you should still be able to connect to "3DPrinterWithVe.local".
Quotation marks around the machine name are mandatory in RRF_3, but discretionary in earlier firmware versions.
M551: Set Password
Parameters
- P"nnn" Password
Example
- 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 RRF_3, but discretionary in earlier firmware versions.
M552: Set IP address, enable/disable network interface
Parameters
- Innn (Optional) Number of the network interface to manage (defaults to 0)
Parameters for Ethernet interfaces (Duet 2/3 Ethernet and 06/085)
- Pnnn IP address, 0.0.0.0 means acquire an IP address using DHCP
- Snnn 0 = disable networking, 1 = enable networking
- Rnnn (optional, RepRapFirmware 1.17 and earlier only) HTTP port, default 80
Parameters for WiFi interfaces (Duet 2/3 WiFi)
- P"ssid" (optional, RepRapFirmware 1.20 and later) SSID of network to connect to. The SSID and password must already have been registered using M587. If this parameter is not present, the Duet 2 WiFi will try to connect to the strongest network that is broadcasting its SSID and whose SSID has been registered using M587.
- Snnn 0 = disable networking, 1 = enable networking as a client, 2 = enable networking as an access point , -1 = disable WiFi module
Example (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.
Example (Duet 2 WiFi)
- M552 S1 P"MyNetwork"
M552 with no parameters reports the current network state and IP address.
In firmware 1.18 and later the HTTP port address is set using the M586 command, so the R parameter of this command is no longer supported.
On the Duet 2 WiFi running firmware 1.19 and later, the IP address is set in the M587 command when you configure the access point details.
M553: Set Netmask
Parameters
- Innn (Optional) Number of the network interface to manage (defaults to 0)
- Pnnn Net mask
Example
- M553 P255.255.255.0
Sets the network mask of the RepRap machine to (in this case) 255.255.255.0. A restart may be required before the new network mask is used. If no 'P' field is specified, this echoes the existing network mask configured.
DuetWifiFirmware versions 1.18 and earlier do not support setting the network mask manually.
M554: Set Gateway and/or DNS server
Parameters
- Innn (Optional) Number of the network interface to manage (defaults to 0)
- Pnnn Gateway
- Snnn (Optional) DNS server (only supported by DSF 3.3 with DuetPi system config plugin)
Example
- M554 P192.168.1.1
Sets the Gateway IP address of the RepRap machine to (in this case) 192.168.1.1. A restart may be required before the new gateway IP address is used. If no 'P' field is specified, this echoes the existing Gateway IP address configured.
DuetWifiFirmware versions 1.18 and earlier do not support setting the gateway address.
M555: Set compatibility
Parameters
- Pnnn Emulation type
Example
- 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: Axis skew compensation
Parameters
- Snnn Height of the measured distances
- Xnnn Deviation in X direction
- Ynnn Deviation in Y direction
- Znnn Deviation in Z direction
- Pnnn Apply XY compensation to Y axis instead of X (defaults to 0, requires RRF 3.2-b4 or newer)
Example
- M556 S100 X0.7 Y-0.2 Z0.6
This tells software the tangents of the angles between the axes of the machine obtained by printing then measuring a test part. The S parameter (100 here) is the length of a triangle along each axis in mm. The X, Y and Z figures are the number of millimeters of the short side of the triangle that represents how out of true a pair of axes is. The X figure is the error between X and Y, the Y figure is the error between Y and Z, and the Z figure is the error between X and Z. Positive values indicate that the angle between the axis pair is obtuse, negative acute.
Printable parts for calibrating the deviation from orthogonality can be found at https://github.com/reprappro/RepRapFirmw....
M557: Set Z probe point or define probing grid
Parameters to define G29 probe grid (all values in mm)
- Xaaa:bbb Minimum and maximum X coordinates to probe
- Yaaa:bbb Minimum and maximum Y coordinates to probe
- X,Y,U,V,W,A,B,C...aaa:bbb Minimum and maximum coordinates of an arbitrary axis (except Z) to probe (RRF >=3.3beta2)
- Raaa Radius to probe
- Saaa Probe point spacing (RepRapFirmware 1.19beta10 and later also support Saaa:bbb)
- Pnn or Pxx:yy (RRF 2.02 and later) Number of points to probe in the X and Y axis directions (alternative to specifying the probe point spacing)
Examples
- M557 X0:200 Y0:220 S20
- M557 X0:100 Y0:120 S50:60
- M557 R150 S15
In RRF >= 3.3beta2 it is possible to use an arbitrary axes pair for probing, e.g. X-A or U-C. When using Raaa to define a radius this will default to X-Y.
Parameters to define G32 probe points (Cartesian/CoreXY printers only, deprecated and not supported in firmware 1.18 and later)
- Pnnn Probe point number
- Xnnn X coordinate
- Ynnn Y coordinate
Example
- M557 P1 X30 Y40.5
Set the points at which the bed will be probed to compensate for its plane being slightly out of horizontal.
The first form defines the grid for G29 bed probing. For Cartesian printers, specify minimum and maximum X and Y values to probe and the probing interval. For Delta printers, specify the probing radius. If you define both, the probing area will be the intersection of the rectangular area and the circle. There is a firmware-dependent maximum number of probe points supported. Currently this is 121 on the Duet 06/085 (enough for a 11x11 grid) and 441 for the Duet 2 WiFi and Duet 2 Ethernet (enough for a 21x21 grid)
The second form defines the points for for G32 bed probing. The P value is the index of the point (indices start at 0) and the X and Y values are the position to move extruder 0 to to probe the bed. An implementation should allow a minimum of three points (P0, P1 and P2). This just records the point coordinates; it does not actually do the probing. See G32. Defining the probe points in this way is deprecated in RepRapFirmware, you should define them in a bed.g file instead.
M558: Set Z probe type
M558 in RepRapFirmware 2.x and earlier
Parameters
- Pnnn Z probe type
- Fnnn Feed rate (i.e. probing speed, mm/min)
- Hnnn Dive height (mm). 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.
- Innn Invert (I1) or do not invert (I0, default) the Z probe reading (RepRapFirmware 1.16 and later)
- Rnnn Z probe recovery time before the probing move is started , default zero (seconds) (RepRapFirmware 1.17 and later). This is to allow the probe to settle after executing a travel move to the coordinates to probe.
- Tnnn Travel speed to and between probe points (mm/min)
- Annn Maximum number of times to probe each point, default 1. Maximum, as of 2.03, is 31. Setting M558 A parameter to anything >31 set it to 0 instead of to 31
- Snnn Tolerance when probing multiple times, default 0.03mm
- Bn If 1, turn off all heaters while probing, default (B0) leaves heaters on. (RepRapFirmware 1.21 and later)
- Cn Endstop input number when the probe type is P4, default 3 (RepRapFirmware 2.02/1.23 and later)
Obsolete parameters
- Xnnn If nonzero, use probe for homing X axis (RRF 1.19 and earlier)
- Ynnn If nonzero, use probe for homing Y axis (RRF 1.19 and earlier)
- Znnn If nonzero, use probe for homing Z axis (RRF 1.19 and earlier)
Example
- M558 P1 X0 Y0 Z1 F500 T5000 H3
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.
A Z probe may be a switch, an IR proximity sensor, or some other device. This selects which to use:
- P0 indicates that no Z probe is present. Whenever Z probing is commanded, you will be prompted to jog the Z axis until the nozzle is just touching the bed and then signal completion.
- P1 specifies an unmodulated or smart IR probe, or any other probe type that emulates one (probe output is an analog signal that rises with decreasing nozzle height above the bed). If there is a control signal to the probe, it is driven high when the probe type is P1.
- P2 specifies a simple modulated IR probe, where the modulation is commanded directly by the main board firmware using the control signal to the probe.
- P3 is similar to P1 but drives the control signal to the probe low. This may be used to switch between different Z probes.
- P4 selects a switch for bed probing. In recent firmware versions the C parameter specifies the endstop input number, default 3 (on the Duets this is the E0 endstop input).
- P5 (from RepRapFirmware 1.14) selects a switch by default (normally closed) for bed probing between the In and Gnd pins of the Z-probe connector (Duet 0.8.5 and Duet 2 WiFi).
- P6 is as P4 but the switch is connected to an alternative connector (on the Duet series, the E1 endstop connector). Deprecated in recent firmware versions, use P4 C4 instead.
- P7 (from RepRapFirmware 1.20) selects a switch (by default normally closed) connected to the Z endstop input. Deprecated in recent firmware versions, use P4 C2 instead.
- P8 (from RepRapFirmware 1.20) is as P5 but is unfiltered, for faster response time.
- P9 (from RepRapFirmware 1.21RC2) is as P5 but for a BLTouch probe that needs to be retracted and redeployed between probe points.
- P10 means use Z motor stall detection as the Z probe trigger.
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.
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.
Note: M558 must come before G31.
M558 in RepRapFirmware 3
All of the above for RepRapFirmware 2.x relates to RepRapFirmware 3, except the following:
- New optional parameter K selects the Z probe number. If there is no K parameter then the current Z probe number is used. The current Z probe number is 0 at startup. You can ignore this parameter if you have only one Z probe.
- New parameter C specifies the input pin and the optional modulation pin. This parameter is mandatory, except for probe type 0 (manual probing) and 10 (Z motor stall detection).
- Invert the input by prefixing the input pin (C parameter) 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.
- Z probe types 4, 6 and 7 are no longer supported. Instead, use type 5 (filtered digital) or 8 (unfiltered digital) and use the C parameter to specify the input. Note, if your Z probe is connected to the Z endstop input, 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), that input is by default pre-assigned to be used by the Z endstop, so you must free it up first.
- Only one Type 2 probe can be configured, and if using Duet 3 + expansion or tool boards, it must be connected to the Duet 3 main board.
- From RRF 3.3beta2 you can provide two F parameters instead of one, where the second is lower than the first, for example F1000:500. When doing a plain G30 command, an additional probe will be done using the first speed to establish the approximate bed position, before one or more additional probes are done using the second speed. The first speed will not be used when probing at a defined point or when mesh bed probing.
Note: M558 must come before G31.
Example 1 - old code:
M558 P4 H5 F120 T3000 ; Z probe connected to E0 endstop input
New code:
M558 P5 C"e0stop" H5 F120 T3000 ; Z probe connected to E0 endstop input
Example 2 - old code:
M558 P7 H5 F120 T3000 ; Z probe connected to Z endstop input
New code:
M574 Z0 P"nil" ; no Z endstop switch, free up Z endstop input M558 P5 C"zstop" H5 F120 T3000 ; Z probe connected to Z endstop input
Example 3 (BLTouch on Duet Maestro) - old code:
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
New code:
M558 P9 C"zprobe.in" H5 F120 T3000 ; BLTouch connected to Z probe IN pin, free up MOD pin M950 S0 C"zprobe.mod" ; servo/gpio 0 is Z probe MOD pin ... M280 P0 S10 ; send control signal to BLTouch through servo/gpio 0
Example 4 (BLTouch on Duet WiFi) - old code:
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
New code:
M558 P9 C"^zprobe.in" H5 F120 T3000 ; BLTouch connected to Z probe IN pin M950 S0 C"exp.heater3" ; create servo/gpio 0 on heater 3 pin on expansion connector ... M280 P0 S10 ; send control signal to BLTouch through servo/gpio 0
M559: Upload file
Parameters
- P"filename". File name to upload to. In RRF 3.1 and earlier, the default filename is config.g. In RRF 3.2 and later there is no default filename. If the filename does not include a path, the default is /sys. Quotation marks around the filename are mandatory in RRF 3.2 and later.
- Snnn File size for binary transfer. If not present, the transfer is terminated by a M29 command
- Cnnn CRC-32 of the file (optional)
Example
- M559 P"config.g"
Was used by the original web interface to upload a configuration file. Can now be used to upload any file.
M560: Upload file
Parameters
- As for M559 except that the default filename (in RRF 3.1 and earlier) is reprap.htm and the default path is /www. If the S parameter is absent then the file data is terminated by a special string as described below.
Example
- M560 P"index.html"
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: Set Identity Transform
Example
- 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: Reset temperature fault
Parameters
- Pnnn Heater number
Example
- M562 P2
Reset a temperature fault on heater/sensor 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 the bed; P1 the first extruder, and so on.
In firmware 1.20 and later, M562 with no parameters will clear a heater fault on all heaters
M563: Define or remove a tool
Parameters
- Pnnn Tool number
- S"name"'' Tool name (optional)
- Dnnn Extruder drive(s)
- Hnnn Heater(s)
- Fnnn Fan(s) to map fan 0 to (RepRapFirmware 1.16 and later)
- Xnnn Axis or axes to map X movement to (RepRapFirmware 1.16 and later)
- Ynnn Axis or axes to map Y movement to (RepRapFirmware 1.19 and later)
- Lnnn Drive to use for filament mapping. By default RRF will use the first and only extruder drive if this parameter is not specified (supported by RRF >= 2.02)
- Rnn Spindle number (RRF >= 3.3beta2)
Example
- 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
Description
Tools are usually (though not necessarily) extruders. Normally an M563 command to define a tool is immediately followed by a G10/M568 command to set the tool's offsets and temperatures.
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. 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.
The 'D' field number corresponds to the 'E' parameter defined in the M584 command. '0' means first 'E' driver in M584 and so on.
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 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.
""Example""
To map more than one fan to 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 mapped to tool 0
R The spindle number mapped to this tool. (RRF >= 3.3beta2)
""Example""
M563 P0 R0 ; assign spindle 0 to tool 0
X, Y The X and Y mapping option is used to create tools on machines with multiple independent X and/or Y carriages. The additional carriages are set up as axes U, V etc. (see M584) and the X mapping option in M563 defines which carriage or carriages are used. 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.
Note: 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: Limit axes
Parameters
- Hnnn H1 = forbid movement of axes that have not been homed, H0 = allow movement of axes that have not been homed (firmware 1.21 and later)
- Snnn S1 = limit movement within axis boundaries, S0 = allow movement outside boundaries
Example
- 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: Set allowable instantaneous speed change
Parameters
- Xnnn Maximum instantaneous speed change of the X axis (mm/min)
- Ynnn Maximum instantaneous speed change of the Y axis
- Znnn Maximum instantaneous speed change of the Z axis
- Ennn Maximum instantaneous speed change of the extruder drives
- Pn Jerk policy (RepRapFirmware 2.03 and later)
Example
- 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.
If you set these X and Y values too low, then the printer will be slow at printing curves. If they are too high then the printer may be noisy when cornering and you may suffer ringing and other print artefacts, or even missed steps.
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.
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.
Note: 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: Set tool mix ratios
Parameters
- Pnnn Tool number
- Ennn Mix ratios
Example
- 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.
Note 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)
M568: Set Tool Settings
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.
Usage
- M568 Pnnn Rnnn Snnn Fnnn
Parameters
- Pnnn Tool number
- Rnnn Standby temperature(s)
- Snnn Active temperature(s)
- Fnnn Spindle RPM
Examples:
- M568 P1 R140 S205 (set standby and active temperatures for tool 1)
- M568 P0 F5200 (set spindle RPM for tool 0)
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.
The R value is the standby temperature in °C that will be used for the tool, and the S value is its operating temperature. If you don't want the tool to be at a different temperature when not in use, set both values the same.
Temperatures set with M568 do not wait for the heaters to reach temp before proceeding. In order to wait for the temp use a M116 command after the M568 to wait for temps to be reached.
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 .
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.
See also M585.
M568: Deprecated : Turn off/on tool mix ratios
Deprecated: from firmware 1.19 onwards, this command is no longer required or supported. If a G1 command for the tool provides just one E value, then the mix ratio defined by M567 will always be used.
Parameters
- Pnnn Tool number
- Snnn Whether mix ratios should be activated
Example
- M568 P2 S0
Turn on/off automatic mix ratios for tool 2. If the S parameter is 0 mixing is turned off; if it is non-zero it is turned on.
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
The off state is the default.
M569: Set motor driver direction, enable polarity and step pulse timing
Parameters
- Pnnn Motor driver number
- Snnn Direction of movement of the motor(s) attached to this driver: 0 = backwards, 1 = forwards (default 1)
- Rnnn Driver enable polarity: 0 = active low, 1 = active high, -1 = driver is always disabled and is not monitored (default 0)
- Tnnn (firmware 1.14 and later) Minimum driver step pulse width and interval in microseconds
- Taa:bb:cc:dd (firmware 1.21 and later) Minimum driver step pulse width, step pulse interval, direction setup time and direction hold time, in microseconds
- Dnn (firmware 2.0 and later, only applies to TMC2660, TMC22xx, TMC2160, TMC5160 and TMC5161 stepper drivers) Driver mode: 0=constant off time, 1=random off time, 2=spread cycle, 3=stealthChop or stealthChop2 (mode 3 for TMC22xx/TMC2160/TMC516x only). The default is spreadCycle for TMC2660, TMC2160 and TMC516x drivers, and stealthChop2 for TMC22xx. In stealthChop mode the drivers will switch over to spreadCycle automatically at high speeds, see the V parameter.
- Fnn (firmware 2.02 and later) Off-time in the chopper control register, 1 to 15
- Cnnnn (firmware 2.0 and later, only applies to TMC2660, TMC22xx, TMC2160 and TMC516x stepper drivers) Lowest 17 bits of the chopper control register value.
- Bnn (firmware 2.02 and later) Blanking time (tbl) in the chopper control register, 0 to 3. See the TMC driver datasheet.
- Hnn (firmware 2.02 and later) thigh parameter for those stepper driver chips that support it, e.g. TMC5160 and TMC2160. Send M569 P# (where # is the driver number) with no additional parameters to see how this translates into mm/sec. See also the V parameter.
- Yaa:bb or Yaa:bb:cc (firmware 2.02 and later) Hysteresis start, end and decrement values in the chopper control register. See the TMC driver datasheet for the meaning.
- Vnnn (firmware 2.02 and later) tpwmthrs parameter for those stepper driver chips that support it. This is the interval in clock cycles between 1/256 microsteps below which the drivers will switch from stealthChop to to spreadCycle mode. Only applies when the driver is configured in stealthChop mode. Typical value are from 100 (high speed) to 4000 (low speed). Send M569 P# (where # is the driver number) with no additional parameters to see how this translates into mm/sec.
Examples
- 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
Notes
- If no T parameter is given, then on boards having internal drivers the step pulse width and interval are guaranteed to be suitable for the on-board drivers only, and will generally be too fast for external drivers. On the EXP1XD board the default is T2.6:2.6:2.6:2.6.
- RepRapFirmware only remembers the highest T parameters seen in any M569 command, and applies that value to all drivers for which any nonzero T parameter was specified. Therefore if you reduce the T parameters, you must restart the firmware for the change to take effect. On Duet 3 systems with CAN-connected expansion boards this note applies separately to each board, and does not apply to the EXP1XD.
- Some versions of RepRapFirmware prior to 1.14 also provided XYZ and E parameters to allow the mapping from axes and extruders to stepper driver numbers to be changed. From 1.14 onward, this functionality is provided by M584 instead.
M569.1: Stepper driver closed loop control
Supported for drivers on Duet 3 closed loop driver boards.
Parameters
- Pnn Motor driver number
- Sn Mode: 0=open loop (default), 1=closed loop
- Tn Encoder type: 0=none, 1=linear quadrature encoder on axis, 2=quadrature encoder on motor shaft, 3=AS5047D encoder on motor shaft, 4=TLI5012B encoder on motor shaft
- En.n Encoder counts per mm (encoder on linear axis) or per degree (encoder on rotary axis) or per full step (encoder on motor)
- Rn.n Proportional constant
- In.n Integral constant
- Dn.n Derivative constant
M569.2: Read or write stepper driver register
Support in RRF 3.3 and later on main boards with TMC22xx or TMC51xx stepper drivers.
Parameters
- Pnn Motor driver number
- Rnn Register number, 0-127
- Vnnnn Value to write (optional)
Example
- 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.
M570: Configure heater fault detection
Parameters for RepRapFirmware 1.14 and earlier
- Snnn Heater timeout (in seconds)
Example
- M570 S120
After a heater has been switched on, wait 120 seconds for it to get close to the set temperature. If it takes longer than this, raise a heater fault.
Parameters for RepRapFirmware 1.15e and later
- Hnnn Heater number
- Pnnn Time in seconds for which a temperature anomaly must persist on this heater before raising a heater fault (default 5 seconds)
- Tnnn Permitted temperature excursion from the setpoint for this heater (default 15C)
- Snnn Integer timeout in minutes (can be set to 0) for print to be cancelled after heater fault (Firmware 1.20 and later).
Order dependency
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.
Example
- M570 H1 P4 T15
Warning! Heating fault detection is provided to reduce the risk of starting a fire if a dangerous fault occurs, for example if the heater cartridge or thermistor falls out of the heater block. You should carefully consider sensible values for the detection time or permitted temperature excursion, setting them to 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)
M571: Set output on extrude
Parameters
- Snnn Output value
- Fnnn Output PWM frequency (RepRapFirmware 1.17 and later; deprecated in 3.2beta2 and later)
- Qnnn Output PWM frequency (RepRapFirmware 3.2beta2 and later)
- Pnnn [RepRapFirmware 1 and 2] Logical pin number (RepRapFirmware 1.17), defaults to the FAN0 output in firmware 1.19 and earlier until M571 with a P parameter has been seen
- P"pin-name" [RepRapFirmware 3] Name of the pin to use
Example
- 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% PWSM 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 1.17 and later you can use the P parameter to change the pin used and you can also set the PWM frequency. 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 3 you specify the pin name instead.
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: Set or report extruder pressure advance
Parameters
- Dnnn Extruder number(s)
- Snnn Pressure advance amount (in seconds) to use for that extruder or extruders
Examples
- 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.
For more details on Pressure Advance such as tuning the value see here.
M573: Report heater PWM
Parameters
- Pnnn Heater number
Example
- 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.
M574: Set endstop configuration
M574 - RepRapFirmware 2.x and earlier
Parameters
- Xnnn Position of X endstop: 0 = none, 1 = low end, 2 = high end.
- Ynnn Position of Y endstop: 0 = none, 1 = low end, 2 = high end.
- Znnn Position of Z endstop: 0 = none, 1 = low end, 2 = high end.
- E Select extruder endstops to define active high or low (RepRapFirmware 1.16 and earlier only)
- Snnn Endstop type: 0 = active low endstop input, 1 = active high endstop input, 2 = Z probe, 3 = motor load detection
Order dependency
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.
Example
- M574 X1 Y2 Z0 S1 ; X endstop at low end, Y endstop at high end, no Z endstop, all active high
Usage
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).
Notes
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 Independent Z motors and endstop switches in RRF2
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.
M574 - RepRapFirmware 3
Parameters
- Xnnn Position of X endstop: 0 = none, 1 = low end, 2 = high end.
- Ynnn Position of Y endstop: 0 = none, 1 = low end, 2 = high end.
- Znnn Position of Z endstop: 0 = none, 1 = low end, 2 = high end.
- P"pin_name" Defines the pin name(s) that the endstop(s) for the specified axis are connected to, see Pin Names. Needed when S=1. May need ! before pin name to invert signal, or ^ to enable the pullup resistor, for example on the Duex expansion board.
- Snnn 1 = switch-type (eg microswitch) endstop input, 2 = Z probe (when used to home an axis other than Z), 3 = single motor load detection, 4 = multiple motor load detection (see Notes).
Order dependency
This command must be later in config.g than the M584 command that creates additional axes, or axes that have multiple motors and endstops.
Usage
The M574 command has been updated to allow for more flexibility. This includes supporting axes defined with multiple motors and multiple endstops (one per motor), use of non-default endstop inputs, and re-assigning endstop inputs.
Notes
- Use a separate M574 command for each axis.
- Endstop type S0 (active low switch) is no longer supported in M574 commands. Instead, use type S1 and invert the input by prefixing the pin name with '!'. Ex: 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).
- New parameter P gives the pin name(s) for the endstop(s) for the specified axis. If the number of pins matches the number of motors assigned to that axis, motors will be stopped individually when their endstop switches trigger.
- New endstop type S4 means use motor stall detection (like S3) but if there are multiple motors, stop each one individually as it stalls. S3 means use motor stall detection but as in RRF 2: stop all relevant motors when the first one stalls.
- The S2 option of M574 is intended for use only when axes other than Z are using the Z probe for homing. The only printers known that do this using Duet electronics are the RepRapPro Ormerod, Huxley Duo, and Mendel Tricolour machines. When using the Z probe to home Z, M574 Z has no bearing on the probe setup or usage. A Z probe and a Z endstop can both be configured at the same time. G30 calling the probe setup with M558, and G1 H1 Z moves calling the endstop configured with M574 Z.
Example
Old RRF_2.x code:
M574 X1 Y1 Z1 U2 S1 ; active high endstop switches, XYZ at min, U at max
New RRF_3 code:
M574 X1 S1 P"xstop" ; X min active high endstop switch M574 Y1 S1 P"ystop" ; Y min active high endstop switch M574 Z1 S1 P"zstop" ; Z min active high endstop switch M574 U2 S1 P"e0stop" ; U max active high endstop switch
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, RRF_3 homes the motors of the axis at the same time, independently to their defined endstops.
M575: Set serial comms parameters
Parameters
- Pnnn Serial channel number
- Bnnn Baud rate, default 57600 (same as the default PanelDue baud rate)
- Snnn Mode: 0 = PanelDue mode without checksums; 1 (default) = PanelDue mode, checksum required; 2= raw mode, 3 = raw mode with checksums. Modes 2 and 3 are only supported in RRF 3.01-RC11 and later.
Example
- M575 P1 B57600 S1
This sets the communications parameters of the serial comms channel specified by the P parameter. P0 specifies the main serial interface (typically a USB port, or serial-over-USB), while P1 specifies an auxiliary serial port (for example, the port used to connect a PanelDue). The B parameter is the required baud rate (this parameter is typically ignored if the port is a true USB port).
In RRF 3.01-RC11 and later for Duet 3, the 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.
M577: Wait until endstop is triggered
M577 - RepRapFirmware 2.x and earlier
Parameters
- Snnn Desired endstop level
- Xnnn Select X axis endstop
- Ynnn Select Y axis endstop
- Znnn Select Z axis endstop
- Ennn Select extruder drive endstop
Example
- 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)
M577 - RepRapFirmware 3.0 up to 3.01RC1
Parameters
- P"nnn" Specifies one or more pin names, see Pin Names
Example
- M577 P"!xstop+!e0stop"
In RRF_3, 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 "!".
Example - old code (RRF_2.x):
M577 X E0 S0 ; wait until the X and E0 endstop inputs are both low
New code (RRF_3):
M577 P"!xstop+!e0stop" ; wait until the X and E0 endstop inputs are both low
M577 - RepRapFirmware 3.01RC2 and later
Parameters
- Sn Desired endstop or input level: 1 = triggered/active (default), 0 =not triggered/inactive
- X, Y, Z, U, V, W, A, B, C, D Axis endstop to wait for
- Pnnn Input pin number to wait for (see M950 with J parameter)
Example
- M577 X S0 ; wait until X endstop is not triggered
- M577 P2 ; wait
Wait for an endstop switch to be triggered or an input to become active.
M578: Fire inkjet bits
This command is not enabled unless the SUPPORT_INKJET feature is enabled when the firmware is built.
Parameters
- Pnnn Inkjet head number
- Snnn Bit pattern
Example
- M578 P3 S5
This fires inkjet head 3 (the P field) using the bit pattern specified by the S field. The example shown would fire bits 101. If the P parameter is ommitted inkjet 0 is assumed.
This is a version of the M700 command used by http://reprap.org/wiki/Inkshield.
An alternative way of controlling inkjets would be to use the P parameter on the G1 command, in conjunction with the M670 command.
M579: Scale Cartesian axes
Parameters
- Xnnn Scale factor for X axis
- Ynnn Scale factor for Y axis
- Znnn Scale factor for Z axis
- U, V, W, A, B, C Scale factors for additional axes
Example
- M579 X1.0127 Y0.998
On a Cartesian RepRap you can get prints exactly the right size by tweaking the axis steps/mm using the M92 G Code above. But this does not work so easily for Delta and other RepRaps for which there is cross-talk between the axes. This command allows you to adjust the X, Y, and Z axis scales directly. So, if you print a part for which the Y length should be 100mm and measure it and find that it is 100.3mm long then you set Y0.997 (= 100/100.3).
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.
M580: Select Roland
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
Parameters
- Rnnn Whether Roland mode should be activated
- Pnnn Initial text to send to the Roland controller
Example
- M580 R1 PVS4;!VZ2;!MC1;
The Modela MDX-20 and similar milling machines are very widely available in hackerspaces and maker groups, but annoyingly they don't speak G Codes. As all RepRap firmware includes a G-Code interpreter, it is often easy to add functions to convert G Codes to RML. M580 selects a Roland device for output if the R field is 1, and returns to native mode if the R field is 0. The optional P string is sent to the Roland if R is 1. It is permissible to call this repeatedly with R set to 1 and different strings in the P field to communicate directly with a Roland.
M581: Configure external trigger
M581 - RepRapFirmware 2.x and earlier
Parameters
- Tnn Logical trigger number to associate the endstop input(s) with, from zero up to a firmware-specific maximum (e.g. 9 for RepRapFirmware)
- X, Y, Z, E Selects endstop input(s) to monitor
- P Reserved, may be used in future to allow general I/O pins to cause triggers
- S Whether trigger occurs on a rising edge of that input (S1, default), falling edge (S0), or ignores that input (S-1). By default, all triggers ignore all inputs.
- C Condition: whether to trigger at any time (C0, default) or only when printing a file from SD card (C1)
Example
- M581 E1:2 S1 T2 C1 ; invoke trigger 2 when a rising edge is detected on the E1 or E2 endstop input and a file is being printed from SD card
Notes
- When M581 is executed, if the T parameter is present but the other parameters are omitted, the trigger inputs and edge polarities for that trigger number are reported. Otherwise, the specified inputs and their polarities are added to the conditions that cause that trigger. Using S-1 with no X Y Z or E parameters sets the trigger back to ignoring all inputs.
- Trigger number 0 causes an emergency stop as if M112 had been received. Trigger number 1 causes the print to be paused as if M25 had been received. Any trigger number # greater than 1 causes the macro file sys/trigger#.g to be executed. Polling for further trigger conditions is suspended until the trigger macro file has been completed. RepRapFirmware does not wait for all queued moves to be completed before executing the macro, so you may wish to use the M400 command at the start of your macro file. If several triggers are pending, the one with the lowest trigger number takes priority.
- A maximum of 16 triggers can be configured on Duet 2.
- Warning: if executed during a build process, and more than one line long the gcode within the trigger file may be executed between later commands from the build file. Bounding the trigger file with M25 and M24 may help, but this will cause error warnings if the trigger happens outside of a build process. The use of M25/M24 will cause the execution of pause and resume system macros.
M581 - RepRapFirmware 3.0 to 3.01RC1 (but not 3.01RC2 and later)
Parameters
- P Specify one or more pin names, see Pin Names
- Tnn Logical trigger number to associate the endstop input(s) with, from zero up to a firmware-specific maximum
- C Condition: whether to trigger at any time (C0, default) or only when printing a file from SD card (C1)
Example
- 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
Notes
- Use the P parameter to specify one or more pin names. Use P"nil" to disable that trigger number.
- The pin(s) do not need to be exclusively used by M581; 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 S parameter used in RRF_2.x is removed. The command waits for a low-to-high input transition. To wait for a high-to-low transition, invert the pin name using '!'.
- When M581 is executed, if the T parameter is present but the other parameters are omitted, the trigger inputs and edge polarities for that trigger number are reported. Otherwise, the specified inputs and their polarities are added to the conditions that cause that trigger.
- Trigger number 0 causes an emergency stop as if M112 had been received. Trigger number 1 causes the print to be paused as if M25 had been received. Any trigger number # greater than 1 causes the macro file sys/trigger#.g to be executed. Polling for further trigger conditions is suspended until the trigger macro file has been completed. RepRapFirmware does not wait for all queued moves to be completed before executing the macro, so you may wish to use the M400 command at the start of your macro file. If several triggers are pending, the one with the lowest trigger number takes priority.
- Warning: if executed during a build process, and more than one line long the gcode within the trigger file may be executed between later commands from the build file. Bounding the trigger file with M25 and M24 may help, but this will cause error warnings if the trigger happens outside of a build process. The use of M25/M24 will cause the execution of pause and resume system macros.
M581 - RepRapFirmware 3.01RC2 and later
Parameters
- P Specify one or more input pin numbers that you created using M950 with the J parameter, or -1 to delete the trigger
- Tnn Logical trigger number to associate the input(s) with, from zero up to a firmware-specific maximum
- S Whether trigger occurs on an inactive-to-active edge of that input (S1, default), active-to-inactive edge (S0), or ignores that input (S-1). By default, all triggers ignore all inputs.
- R Condition: whether to trigger at any time (R0, default) or only when printing a file from SD card (R1). In RRF 3.01-RC2 to 3.01-RC10 inclusive this parameter was C instead of R, but that clashed with a possible C axis.
- X, Y, Z or any other axis letter: axis or axes whose endstop switches are to cause the trigger
Example
- 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
Notes
- When M581 is executed, if the T parameter is present but the other parameters are omitted, the trigger inputs and edge polarities for that trigger number are reported. Otherwise, the specified inputs and their polarities are added to the conditions that cause that trigger.
- Trigger number 0 causes an emergency stop as if M112 had been received. Trigger number 1 causes the print to be paused as if M25 had been received. Any trigger number # greater than 1 causes the macro file sys/trigger#.g to be executed. Polling for further trigger conditions is suspended until the trigger macro file has been completed. RepRapFirmware does not wait for all queued moves to be completed before executing the macro, so you may wish to use the M400 command at the start of your macro file. If several triggers are pending, the one with the lowest trigger number takes priority.
* A maximum of 32 triggers can be configured on Duet 3, a maximum of 16 on Duet 2.
- Warning: if executed during a build process, and more than one line long the gcode within the trigger file may be executed between later commands from the build file. Bounding the trigger file with M25 and M24 may help, but this will cause error warnings if the trigger happens outside of a build process. The use of M25/M24 will cause the execution of pause and resume system macros.
M582: Check external trigger
Parameters
- T Trigger number to poll
Example
- M582 T2 ; check levels of inputs that give rise to trigger #2
Triggers set up by the M581 command are normally activated only when the specified inputs change state. This command provides a way of causing the trigger to be executed if the input is at a certain level. For each of the inputs associated with the trigger, the trigger condition will be checked as if the input had just changed from the opposite state to the current state.
For example, if you use M581 to support an out-of-filament sensor, then M582 allows you to check for out-of-filament just before starting a print.
M584: Set drive mapping
Parameters
- Xnnn Driver number(s) for X motor(s)
- Ynnn Driver number(s) for Y motor(s)
- Znnn Driver number(s) for Z motor(s)
- Rn (optional, supported in RRF 3.2beta1 and later) 0 = axes creates in this command are linear, 1 = axes created are rotational. If not present, then RRF 3.2beta3 and later assume UVW are linear and ABCD are rotational.
- Sn (optional, supported in RRF 3.2beta3 and later) 0 = axes created in this command are treated as linear in feedrate calculations, 1 = axes created are treated as rotational in feedrate calculations. See section 2.1.2.5 of the NIST GCode standard for how the feedrate is interpreted. Default is S0 for linear axes and S1 for rotational axes (see the R parameter).
- U, V, W, A, B, Cnnn Driver number(s) for additional axes U, V, W, A, B and C (UVW available in RepRapFirmware 1.16 and later; UVWABC available in RepRapFirmware 1.19 and later; UVWABCD available in RepRapFirmware 3.0 and later).
- Ennn Driver number(s) for E motor(s)
- Pnnn Number of visible axes, defaults to the total number of axes configured.
Order dependence
- M584 must come earlier in config.g than any M350 and M906 commands. If it creates new axes, it must also be earlier than any M92, M201, M203, M208, M350, M566, M574, M667 and M669 commands.
Example
- 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
Notes
- VERY IMPORTANT! Assigning a drive using M584 does not remove its old assignment. Therefore, if you assign a drive that defaults to being an extruder drive, you should also assign the extruder drives explicitly as in the above example. Failure to do so may result in unexpected behaviour.
- You can use M584 to create additional axes - for example, to represent additional carriages on a machine with multiple independent X carriages. In 1.20 and later firmware you can create new axes in any order. In earlier firmware versions, additional axes must be created in the order UVWABC. You can hide some of the last axes you create using the P parameter. Hidden axes have no homing buttons or jog controls in the user interface.
- 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
- If you create more than one axis in a M584 command, the axes are created in the order UVWABCD regardless of the order of the parameters in the M584 command. This affects which axes will be hidden if you use the M584 P parameter to hide axes. For example, M584 C5 U6 creates axes U and C in that order, so M584 P4 would hide the C axis, not the U axis. If you want to create the axes in the order C then U (so that M584 P4 hides the U axis), use two M584 commands: M584 C5 followed by M584 U6.
- Using M584 to map drivers to axes does not affect endstop inputs. In RRF2, endstop inputs XYZ are pre-allocated, after that they are allocated in the order in which axes are created. So if you create just one extra axes (e.g. U), it will use the E0 endstop input. If more than one axis is created in a single M584 command, endstop inputs are allocated to the new axes in axis creation order (see previous item). For example, M584 C5 U6 would allocate endstop input E0 to the U axis and E1 to the C axis.
- On the Duet 2 WiFi and Duet 2 Ethernet, if you configure multiple drivers for an axis, either all of them must be TMC2660 drivers on the Duet or a Duet expansion board, or none of them must be. This is to facilitate dynamic microstepping and other features of the TMC2660.
- In RRF_3, M584 works the same way as in RRF_2, with exception that on Duet 3 the driver on expansion boards are assigned with <board address>.<driver number>. Example:
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
- If you assign an axis or extruder to one or more drivers, and later you want to reassign it to a different driver, then to ensure correct operation you must disable those axes/extruders using M18 before using M584 to reassign them. After using M584, you must set the motor current using M906 and the microstepping using M350. Example:
; 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
M585: Probe Tool
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.
Parameters
- Xnnn - Probe tool in X direction where nnn specifies the expected distance between the trigger point of your endstop switch and the starting point
- Ynnn - Probe tool in Y direction where nnn specifies the expected distance between the trigger point of your endstop switch and the starting point
- Znnn - Probe tool in Z direction where nnn specifies the expected distance between the trigger point of your endstop switch and the starting point
- U,V,W,A,B,Cnnn - As for X,Y,Z above
- Ennn - [Not supported in RepRapFirmware 3] Custom endstop number to use (optional). This must be the drive number of the according endstop (i.e. X=0, Y=1, Z=2, E0=3 etc.)
- Lnnn - [RepRapFirmware 2.04 and later, not supported in RepRapFirmware 3] Trigger level of the custom endstop (optional, 0 = active-low, 1 = active-high). This requires the 'E' parameter to be present
- Pn - [RepRapFirmware 3 only] Z probe number to use (optional)
- Fnnn - Requested feedrate of the probing move. If this parameter is omitted, the last set feedrate is used
- Snnn - Direction of the probing move. S=0 (default) means travel forwards (towards the axis maximum), S=1 means go backwards (towards the axis minimum)
- Rnnn - Probing radius, i.e. the relative movement amount from the current position (optional, if used the S parameter is ignored) [requires RRF 1.20beta8 or later]
Notes
- 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)
- Select your tool (Txx)
- Move the tool to your starting position (G1 X?? Y?? Z?? F3000)
- Drive the tool into the endstop, stop there and apply the new tool offset with the given correction factor (M585 XYZ?? F1000 E??)
- Call G10/M568 Pxx with your tool number to get the corrected tool offset or call M500 (supported in RRF 1.20beta3 and later) to store the probed tool offsets on the SD card
Notes - RepRapFirmware 3
- You can use M585 to probe until a regular axis endstop is triggered as before.
- The E and L parameters are removed, instead there is a new P parameter that specifies a probe number. If you want to probe until a custom input is triggered, use M558 to configure an additional probe that uses that pin, then refer to that probe in your M585 command.
Example - old code:
M585 X100 F600 E3 L0 S0 ; probe X until E0 endstop goes low
New code:
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
M586: Configure network protocols
Parameters:
- Pnn Protocol: 0 = HTTP or HTTPS, 1 = FTP or SFTP, 2 = Telnet or SSH (which of the two choices depends on the T parameter)
- Snn 0 = disable this protocol, 1 = enable this protocol
- Rnn TCP port number to use for the specified protocol. Ignored unless S = 1. If this parameter is not provided then the default port for that protocol and TLS setting is used.
- Tnn 0 = don't use TLS, 1 = use TLS. Ignored unless S = 1. If this parameter is not provided, then TLS will be used if the firmware supports it and a security certificate has been configured. If T1 is given but the firmware does not support TLS or no certificate is available, then the protocol will not be enabled and an error message will be returned.
- C"<site>" Set or reset allowed site for cross-orgin HTTP requests (RRF > 3.2-b4.1)
- Note: TLS has not yet been implemented in RepRapFirmware, therefore T1 will not work.
M586 with no S parameter reports the current support for the available protocols.
RepRapFirmware 1.18 and later enable only HTTP (or HTTPS if supported) protocol by default. If you wish to enable FTP and/or Telnet, enable them using this command once or twice in config.g.
M587: Add WiFi host network to remembered list, or list remembered networks
This command must not be used in the config.g file. In SBC mode (v3.3 and later) it is not possible to configure different IP addresses per SSID
Parameters:
- S"ccc" Network SSID
- P"ccc" Network password
- Inn.nn.nn.nn (optional) IP address to use when connected to this network. If zero or not specified then an IP address will be acquired via DHCP.
- Jnn.nn.nn.nn (optional) Gateway IP address to use when connected to this network.
- Knn.nn.nn.nn (optional) Netmask to use when connected to this network
- Lnn.nn.nn.nn (optional, supported only by DuetPi + DSF v3.3 or newer) DNS server to use
- Cnnn (supported only by DuetPi + DSF v3.3 or newer) Country code for the WiFi adapter, only required if not set before
The SSID and password must always be enclosed in double quotation marks.
Notes
Many programs used to send GCodes convert all characters to uppercase. In firmware 1.19.2 and later, within any quoted string you can use a single-quote character to indicate that the following character should be changed to lowercase. For example, M587 S"ABC" P"P'A'S'SW'O'R'D" would specify that the password is "PassWord". Use two single quote characters to represent one actual single quote character in the password or in the SSID. For example, if your SSID is "Pete's network" then enter "Pete''s network".
The use of special characters in the SSID cannot be guaranteed to work. In general it's best to avoid most special characters. Spaces, periods, dashes, underscores, and other punctuation is likely ok, but special characters on the number keys likely are not safe. (@#$%^&*). If you are having troubles adding your SSID, try a simplified version with only letters and numbers.
M587 with no parameters lists all the remembered SSIDs, but not the remembered passwords.
The M587 command will fail if the WiFi module has not yet been taken out of reset. So if the WiFi module has not been started, send M552 S0 to put it in idle mode first.
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. It is better to use a macro to send M587 (source: https://forum.duet3d.com/post/42798)
M588: Forget WiFi host network
This command must not be used in the config,g file
Parameters:
- S"ccc" Network SSID to remove from the remembered list
The specified SSID will be removed from the remembered list and the associated password cleared out of EEPROM. If the SSID is given as "*" then all remembered networks will be forgotten.
Example: M588 S"*"
The M588 command will fail if the WiFi module has not yet been taken out of reset. So if the WiFi module has not been started, send M552 S0 to put it in idle mode first. M588 does not work from within config.g at startup.
M589: Configure access point parameters
This command must not be used in the config,g file
Parameters:
- S"ccc" The SSID that the WiFi interface should use when it is commanded to run as an access point
- P"ccc" The WiFi password
- Inn.nn.nn.nn The IP address to use
- Cnn The WiFi channel to use (optional)
Example command: M589 S"DuetSSID" P"password" I192.168.0.1 C1
To use AP mode:
- Send a M589 command once from the console, or via macro to set the access point name, IP address etc. These parameters will be saved within the WiFi module.
- The M589 command will fail if the WiFi module has not yet been taken out of reset. So if the WiFi module has not been started, send M552 S0 to put it in idle mode first.
- M589 does not work from within config.g at startup.
- Use M552 S2 in config.g to start the wifi module.
- WPA2 security will be used by default.
- Look for the wireless network name you specified on your device and connect to it using the password you set.
M591: Configure filament sensing
This configures filament sensing for the specified extruder. The sensor may be a simple filament presence detector, or a device that measures movement of filament, or both. The action on a filament error is to pause the print and advise you that there has been a filament error. Note that filament monitoring in RRF is only active when printing from SD card.
M591 - RepRapFirmware 3
Parameters
- Dnn Extruder drive number (0, 1, 2...),
- Pnn Type of sensor:
- 0=none
- 1=simple sensor (high signal when filament present)
- 2=simple sensor (low signal when filament present)
- 3=Duet3D rotating magnet sensor
- 4=Duet3D rotating magnet sensor with microswitch
- 5 = Duet3D laser sensor
- 6 = Duet3D laser sensor with microswitch
- 7 = pulse-generating sensor
- C"name" Pin name the filament sensor is connected to (RRF_3 only), see Pin Names
- Sn 0 = disable filament monitoring (default), 1 = enable filament monitoring when printing from SD card. Supported for all filament sensor types in firmwares 1.21.1 and in 2.0 and later. In firmware 1.21 this parameter is not supported for sensor types 1 and 2. Filament monitors accumulate calibration data (where applicable) even when filament monitoring is disabled.
Additional parameters for Duet3D laser filament monitor
- Raa:bb Allow the filament movement reported by the sensor to be between aa% and bb% of the commanded values; if it is outside these values and filament monitoring is enabled, the print will be paused
- Enn minimum extrusion length before a commanded/measured comparison is done, default 3mm
- An (firmware 2.03 and later) 1 = check All extruder motion, 0 (default) = only check extruder motion of printing moves (moves with both movement and forward extrusion)
- Lnn (firmware 3.2 and later) Calibration factor, default 1.0. The filament movement reported by the laser sensor is multiplied by this value before being compared with the commanded extrusion. Intended for use with sensors that use the laser to read movement of a wheel that is turned by the filament.
Additional parameters for Duet3D rotating magnet filament monitor
- Lnn Filament movement per complete rotation of the sense wheel, in mm
- R, E, A As for Duet3D laser filament monitor
Additional parameters for a pulse generating filament monitor
- Lnn Filament movement per pulse in mm
- R, E As for Duet3D laser filament monitor
Example
M591 P3 C"e0stop" S1 D0 ; filament monitor connected to E0 endstop
M591 - RepRapFirmware 1.21 to 2.x
Parameters
As RRF_3, except 'C' parameter is the endstop number.
- Cnn Which input the filament sensor is connected to. On Duet electronics: 0=X endstop input, 1=Y endstop input, 2=Z endstop input, 3=E0 endstop input etc. If you have a Duex 2 or Duex 5 in your system, note that C5 thru C9 (the endstop inputs on the DueX) cannot be used for filament monitors, but C10 and C11 (the endstop inputs on the CONN_LCD connector) can.
Example
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
M591 - RepRapFirmware 1.20 and earlier
Parameters
- Dnn Extruder drive number (0, 1, 2...),
- Pnn Type of sensor, where:
- 0=none,
- 1=simple sensor (high signal when filament present)
- 2=simple sensor (low signal when filament present)
- 3=Duet3D rotating magnet sensor
- 4=Duet3D rotating magnet sensor with microswitch
- Cn Which input the filament sensor is connected to. On Duet electronics: 0=X endstop input, 1=Y endstop input, 2=Z endstop input, 3=E0 endstop input etc.
Additional parameters for Duet3D rotating magnet filament monitor
- Snn Sensitivity, in mm of filament movement per complete rotation of the sense wheel.
- Rnn Tolerance as a percentage of the commanded extrusion amount. A negative value puts the firmware in calibration mode.
- Enn minimum extrusion length before a commanded/measured comparison is done, default 3mm
Examples
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
Documentation
- Duet3d Filament Monitor: Rotating Magnet Version
- Duet3d Filament Monitor: Laser Version
- Connecting and configuring filament-out sensors
M592: Configure nonlinear extrusion
Parameters
- Dnn Extruder drive number (0, 1, 2...)
- Annn A coefficient in the extrusion formula, default zero
- Bnnn B coefficient in the extrusion formula, default zero
- Lnnn Upper limit of the nonlinear extrusion compensation, default 0.2
- T nnn Reserved for future use, for the temperature at which these values are valid
Examples
M592 D0 A0.01 B0.0005 ; set parameters for extruder drive 0 M592 D0 ; report parameters for drive 0
Most extruder drives use toothed shafts to grip the filament and drive it through the hot end. As the extrusion speed increases, so does the back pressure from the hot end, and the increased back pressure causes the amount of filament extruded per step taken by the extruder stepper motor to reduce. This may be because at high back pressures, each tooth compresses and skates over the surface of the filament for longer before it manages to bite. See forum post http://forums.reprap.org/read.php?262,80... and the graph at http://forums.reprap.org/file.php?262,fi... for an example.
Nonlinear extrusion is an experimental feature in RepRapFirmware to compensate for this effect. The amount of extrusion requested is multiplied by (1 + min(L, A*v + B*v^2)) where v is the requested extrusion speed (calculated from the actual speed at which the move will take place) in mm/sec.
Nonlinear extrusion is not applied to extruder-only movements such as retractions and filament loading.
M593: Configure DAA or Input Shaping
Parameters (RRF 3.3 and earlier)
- Fnnn Frequency of ringing to cancel by DAA, in Hz. Zero or negative values disable DAA.
- Lnnn Minimum acceleration allowed, default 10mm/sec^2. DAA will not be applied if it requires the average acceleration to be reduced below this value.
Parameters (RRF 3.4 and later)
- Pn Type of input shaping to use: 0 = none, 1 = custom, 2 = ZVD, 3 = ZVDD, 4 = EI2, 5 = EI3, 6 = DAA (support for DAA may be withdrawn in future releases)
- Fnnn Frequency of ringing to cancel in Hz. Zero or negative values disable the feature.
- Snnn Damping factor of ringing to be cancelled, default 0.1.
- Lnnn Minimum acceleration allowed, default 10mm/sec^2. Input shaping will not be applied if it requires the average acceleration to be reduced below this value.
- Hnn:nn... Amplitudes of each impulse except the last, normally below 1.0. Only used with P1 parameter.
- Tnn:nn Durations of each impulse except the last. Only used with P1 parameter.
Example (RRF 3.3 and earlier)
M593 F40.5 ; use DAA to cancel ringing at 40.5Hz
Examples (RRF 3.4 and later)
M593 P2 F40.5 ; use ZVD input shaping to cancel ringing at 40.5Hz
[code[M593 P1 H0.4:0.7 T0.0135:0.0135 ; use custom input shaping[/code]
The purpose of input shaping is to reduce ringing (also called ghosting).
In firmware 2.02 up to at least 3.3beta2, 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 cancel out 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.
It is intended to offer three additional types of input shaping in future firmware versions: ZVD, ZVDD and EI2. Note, the use of EI2 input shaping in motion control systems is covered by US Patent 4916635.
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.
To measure the ringing frequency, take a print that exhibits ringing on the perimeters (for example a cube), preferably printed single-wall or external-perimeters-first. Divide the speed at which the outer perimeter was printed (in mm/sec) by the distance between adjacent ringing peaks (in mm). 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.
High X and Y jerk values reduce the effectiveness of DAA; therefore you should set the X and Y jerk limits only as high as necessary to allow curves to be printed smoothly.
M594: Enter/Leave Height Following mode
Parameters
- Pn P1 = enter height following mode, P0 = leave height following mode
Height following mode allows the Z position of the tool to be controlled by a PID controller using feedback from a sensor. See also M951.
If a movement command (e.g. G1) explicitly mentions the Z axis while height following mode is active, existing moves in the pipeline will be allowed to complete and the machine allowed to come to a standstill. Then height following mode will be terminated and the new move executed.
M595: Set movement queue length
Supported in RRF 3.2 and later.
Parameters
- Pnn Maximum number of moves held in the movement queue. RepRapFirmware uses this value to determine how many DDA objects to allocate.
- Snn (optional) Number of pre-allocated per-motor movement objects. If the number of pre-allocated objects is insufficient, RepRapFirmware will attempt to allocate additional omnes dynamically when they are needed.
- Rnnn Grace period in milliseconds (supported in RRF 3.3 and later). When filling the movement queue from empty, the system waits for this amount of time after the last movement command was received before starting movement. This is to allow the movement queue to fill more before movement is started when commands are received from USB, Telnet or another serial channel. It should not be needed when processing a GCode file from the SD card.
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.
M600: Filament change pause
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. Supported in firmware 2.02 and later.
M650: Set peel move parameters
This command is sent by nanoDLP to set the parameters for the peel move used after curing a layer. RepRapFirmware 2.02 ignores 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.
M651: Execute peel move
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.
M665: Set delta configuration
Parameters
- Lnnn Diagonal rod length2
- Rnnn Delta radius
- Bnnn Safe printing radius
- Hnnn Nozzle height above the bed when homed after allowing for endstop corrections
- Xnnn X tower position correction1
- Ynnn Y tower position correction1
- Znnn Z tower position correction1
Examples
- M665 L250 R160 B80 H240 X0 Y0 Z0
Set the delta calibration variables
Notes
1X, Y and Z tower angular offsets from the ideal (i.e. equilateral triangle) positions, in degrees, measured anti-clockwise looking down on the printer.
2In 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.
M666: Set delta endstop adjustment
Parameters
- Xnnn X axis endstop adjustment
- Ynnn Y axis endstop adjustment
- Znnn Z axis endstop adjustment
- Annn X bed tilt in percent1
- Bnnn Y bed tilt in percent1
Example
- M666 X-0.1 Y+0.2 Z0
Sets delta endstops adjustments.
Positive endstop adjustments move the head closer to the bed when it is near the corresponding tower. Endstop corrections are expressed in mm.
1RepRapFirmware 1.16 and later.
M667: Select CoreXY or related mode
This command is deprecated in RRF 2.03 and later. Use M669 instead.
Parameters
- Snnn CoreXY mode
- Xnnn X axis scale factor (RRF 2.02 and earlier)
- Ynnn Y axis scale factor (RRF 2.02 and earlier)
- Znnn Z axis scale factor (RRF 2.02 and earlier)
Order dependency
- M667 must come earlier in config.g than any M671 command.
Example
- M667 S1
M667 S0 selects Cartesian mode (unless the printer is configured as a delta using the M665 command). Forward motion of the X motor moves the head in the +X direction. Similarly for the Y motor and Y axis, and the Z motor and Z axis. This is the default state of the firmware on power up.
M667 S1 selects CoreXY mode. Forward movement of the X motor moves the head in the +X and +Y directions. In firmware 1.19 and later, forward movement of the Y motor moves the head in the +X and -Y directions.
M667 S2 selects CoreXZ mode. Forward movement of the X motor moves the head in the +X and +Z directions. In firmware 1.19 and later, forward movement of the Z motor moves the head in the -X and +Z directions.
In versions of RRF prior to 2.03, additional parameters X, Y and Z may be given to specify factors to scale the motor movements by for the corresponding axes. For example, to specify a CoreXZ machine in which the Z axis moves 1/3 of the distance of the X axis for the same motor movement, use M667 S2 Z3. The default scaling factor after power up is 1.0 for all axes.
In RRF 2.03 and later the XYZ parameters are no longer supported. Use the M669 XYZ parameters to alter the movement matrix instead.
To change the motor directions, see the M569 command.
M669: Set kinematics type and kinematics parameters
Parameters
- Knnn Kinematics type: 0 = Cartesian, 1 = CoreXY, 2 = CoreXZ, 3 = linear delta, 4 = serial SCARA, 5 = CoreXYU, 6 = Hangprinter, 7 = polar, 8 = CoreXYUV, 9 = five-bar parallel SCARA (in RRF 3.01, experimental), 10 = rotary delta, 11 = Mark Forged, 12 = reserved for Collinear Tripteron, 13 = reserved for 5-axis robot arm
Note: 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.
Order dependency
- M669 must come earlier in config.g than any M671 command.
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.
Parameters for Cartesian/CoreXY/CoreXZ/CoreXYU/CoreXYUV/MarkForged kinematics (RRF 2.03 and later only)
- Xnn:nn:nn... Motor movement coefficients required to move X axis (first row of matrix)
- Ynn:nn:nn... Motor movement coefficients required to move Y axis (second row of matrix)
- Znn:nn:nn... Motor movement coefficients required to move Z axis (third row of matrix)
- Unn:nn:nn..., Vnn:nn:nn... etc. Motor movement coefficients required to move U, V... axes (fourth and subsequent rows of matrix)
All these parameters are optional. The movement coefficient matrices are initialised to suitable value for the kinematics type you selected in the M667 or M669 command, but you can modify them using these parameters. If you send M669 with no parameters, the existing matrix will be reported.
Note: when CoreXZ kinematics is selected, the default matrix assumes there is a 3:1 reduction on the Z axis, as in the original CoreXZ design described at https://reprap.org/forum/read.php?2,3778.... If your CoreXZ printer has a different reduction or no reduction then you will need to use the Z parameter to change the Z line of the matrix. For example, if there is no Z reduction then use Z1:0:-1.
Examples
M669 Kinematics is Cartesian, matrix: 1.00 0 0 0 1.00 0 0 0 1.00
CoreXY with extra Markforge U axis (see https://forum.duet3d.com/post/136554 )
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
Parameters for Linear Delta kinematics (RRF 2.03 and later only)
- Xnn:nn:nn... Extruder offset from nozzle in X
- Ynn:nn:nn... Extruder offset from nozzle in X
This is used when a 4th axis is added to a linear Delta, to carry the extruder and follow in Z. It specifies the XY offsets of the extruder outputs on additional towers, relative to machine centre in the M669 command. See Configuring RepRapFirmware for a Linear Delta printer
Parameters for serial SCARA kinematics
- Pnnn Proximal arm length (mm)
- Dnnn Distal arm length (mm)
- Annn:nnn Proximal arm joint movement minimum and maximum angles, in degrees anticlockwise seen from above relative to the X axis
- Bnnn:nnn Proximal-to-distal arm joint movement minimum and maximum angles, in degrees anticlockwise seen from above relative to both arms in line
- Cnnn:nnn:nnn Crosstalk factors. The first component is the proximal motor steps to equivalent distal steps factor, the second is the proximal motor steps to equivalent Z motor steps factor, and the third component is the distal motor steps to equivalent Z motor steps factor.
- Rnnn (optional, RRF 2.03 and later only) Minimum permitted printing radius from the proximal axis. If not specified, it will be calculated to be slightly larger than the distance between nozzle and proximal axis when the distal axis is homed.
- Snnn Segments per second (because smooth XY motion is approximated by means of segmentation)
- Tnnn Minimum segment length (mm) (because smooth XY motion is approximated by means of segmentation)
- Xnnn X offset of bed origin from proximal joint
- Ynnn Y offset of bed origin from proximal joint
Examples
M669 K4 P300 D250 A-90:90 B-135:135 C0:0:0 S100 X300 Y0
The minimum and maximum arm angles are also the arm angles assumed by the firmware when the homing switches are triggered. The P, D, A and B parameters are mandatory. The C, X and Y parameters default to zero, and the segmentation parameters default to firmware-dependent values.
Parameters for Polar kinematics
- Annn Maximum turntable acceleration in degrees per second^2
- Fnnn Maximum turntable speed in degrees per second
- Hnnn Radius of the nozzle from the centre of the turntable when the radius arm homing switch is triggered
- Raaa:bbb Minimum (aaa) and maximum (bbb) radius on the turntable reachable by the nozzle.
- Snnn Segments per second (because smooth XY motion is approximated by means of segmentation)
- Tnnn Minimum segment length (mm) (because smooth XY motion is approximated by means of segmentation)
- Xnnn X offset of bed origin from turntable centre (not yet implemented)
- Ynnn Y offset of bed origin from proximal joint (not yet implemented)
There is currently no facility for offsetting the radius arm sideways from the centre of rotation of the turntable, or for moving the origin.
M670: Set IO port bit mapping
Parameters
- Pnn:nn:nn... - List of logical port numbers that bits 0, 1, 2... control (supported in RRF_2.x and earlier)
- Cnnn - Used to specify the pin name(s) to be controlled (supported in RRF_3), see Pin Names
- Tnnn - Port switching time advance in milliseconds
Notes
- In RRF_3, the P parameter is removed. Use the new C parameter to specify the pin names to be used.
Example - old code:
M670 T5 P220:221:222
New code:
M670 T5 C"sx1509b.0+sx1509b.1+sx1509b.2"
- RepRapFirmware 1.19 and later provides an optional P parameter on the G1 command to allow I/O ports to be set to specified states for the duration of the move. The argument to the P parameter is a bitmap giving the required state of each port. The M670 command specifies the mapping between the bits of that argument and logical port numbers. Optionally, the T parameter can be used to advance the I/O port switching a short time before the corresponding move begins.
M671: Define positions of Z leadscrews or bed levelling screws
Parameters
- Xnn:nn:nn... List of between 2 and 4 X coordinates of the leadscrews that drive the Z axis or the bed levelling screws
- Ynn:nn:nn... List of between 2 and 4 Y coordinates of the leadscrews that drive the Z axis or the bed levelling screws
- Snn Maximum correction allowed for each leadscrew in mm (optional, default 1.0)
- Pnnn Pitch of the bed levelling screws (not used when bed levelling using independently-driven leadscrews). Defaults to 0.5mm which is correct for M3 bed levelling screws.
- Fnn Fudge factor, default 1.0
Order dependency
- M671 must come later in config.g than any M667 or M669 command.
Example
- M671 X-15.0:100.0:215.0 Y220.0:-20.0:220.0 ; Z leadscrews are at (-15,220), (100,-20) and (215,220)
Informs the firmware of the positions of the leadscrews used to raise/lower the bed or gantry. When this command is used to define the leadscrew 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 leadscrew motors individually after bed probing. See the G32 command.
For machines without multiple independently-driven Z leadscrews, 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.
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.
The firmware algorithm assumes perfect gimbal joints between the bed and the leadscrews, so that the bed is completely free to adopt the plane (or the twisted plane if there are 4 leadscrews) defined by the leadscrews. 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.
Note: the M671 command in config.g must come after any command to change the kinematics, for example M667 or M669.
M672: Program Z probe
Parameters
- Snn:nn:nn... Sequence of 8-bit unsigned values to send to the currently-selected Z probe
Example
- M672 S105:50:205
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.
For the Duet3d smart effector:
*The programming pin has to be defined in the M558 command
*To program the sensor, send command M672 S105:aaa:bbb replacing aaa by the desired sensitivity and bbb by 255 - aaa. The green LED will flash 4 times if the command is accepted. When you subsequently power up the effector, the green LED will flash three times instead of twice to indicate that a custom sensitivity is being used.
*To revert to factory settings, send command M672 S131:131. The green LED will flash 5 times if the command is accepted. When you subsequently power up the effector, the green LED will flash twice to indicate that default settings are being used.
See the Smart effector and carriage adapters for delta printer documentation for more details.
M673: Align plane on rotary axis
Parameters
- U,V,W,A,B,C Rotary axis name on which the plane is mounted
- Pnnn Factor to multiply the correction amount with (defaults to 1)
Example
- M673 A
This code is intended to align a plane that is mounted on a rotary axis. To make use of this code it is required to take two probe points via G30 P first.
Supported in RepRapFirmware 2.02 and later.
M674: Set Z to center point
This code is intended to determine the Z center point of a stash that is mounted on a rotary axis. This code is yet to be implemented.
M675: Find center of cavity
Parameters
- X,Y,Z Axis to probe on
- Fnnnn Probing feedrate
- Rnnn Distance to move away from the lower endstop before the next probing move starts
Additional Parameter in RepRapFirmware 3 and later
- Pnnn Use probe with the given number instead of endstop
Examples
- M675 X R2 F1200
This code is intended to find the center of a cavity that can be measured using the configured axis endstop. If using a Z probe for this purpose, make sure the endstop type for the corresponding axis is updated before this code is run. Once this code starts, RepRapFirmware will move to the lower end looking for an endstop to be triggered. Once it is triggered, the lower position is saved and the axis maximum is probed. As soon as both triggers have been hit, the center point is calculated and the machine moves to the calculated point.
M701: Load filament
Parameters
- This command can be used without any additional parameters.
- Snn Filament to load
Example
- M701 S"PLA"
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, however be aware that this code will work only for tools that have exactly one extruder assigned.
When called the firmware does the following:
1) Run the macro file "load.g" in the subdirectory of the given material (e.g. /filaments/PLA/load.g)
2) Change the filament name of the associated tool, so it can be reported back to Duet Web Control
If this code is called without any parameters, RepRapFirmware will report the name of the loaded filament (if any).
M702: Unload filament
Parameters
- This command can be used without any additional parameters.
Example
- M702
In contrast to M701 this code is intended to unload the previously loaded filament from the selected tool. RepRapFirmware will do the following when called:
1) Run the macro file "unload.g" in the subdirectory of the given material (e.g. /filaments/PLA/unload.g)
2) Change the filament name of the current tool, so it can be reported back to Duet Web Control
M703: Configure filament
Parameters
- This command can be used without any additional parameters.
Example
- M703
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.
If the filaments feature is used, it is recommended to put this code into tpost*.g to ensure the right filament parameters are set. Supported in RepRapFirmware 2.02 and newer.
M750: Enable 3D scanner extension
Example
M750
This code may be used as an OEM extension to enable scanner functionality in the firmware. After a regular start of RepRapFirmware, the 3D scan extension is disabled by default, but if additional scanner components are attached, this code may be used to enable certain OEM functions.
M751: Register 3D scanner extension over USB
Example
M751
When a 3D scanner board is attached to the USB port, this code is used to turn on communication between the 3D printing and the scanner board. If the USB connection is removed while the 3D scanner configuration is active, the firmware will disable it again and restore the default communication parameters.
M752: Start 3D scan
Parameters
- Snnn: Length/degrees of the scan
- Rnnn: Resolution (new in RRF 2.0) [optional, defaults to 100]
- Nnnn: Scanner mode (new in RRF 2.0) [optional, 0=Linear (default), 1=Rotary]
- Pnnn: Filename for the scan
Example
M752 S300 Pmyscan
Instruct the attached 3D scanner to initiate a new 3D scan and to upload it to the board's SD card (i.e. in the "scans" directory). Before the SCAN command is sent to the scanner, the macro file "scan_pre.g" is executed and when the scan has finished, the macro file "scan_post.g" is run. Be aware that both files must exist to avoid error messages.
M753: Cancel current 3D scanner action
Example
M753
Instruct the attached 3D scanner to cancel the current operation. Cancelling uploads is not supported.
M754: Calibrate 3D scanner
Parameters
- Nnnn: Scanner mode (new in RRF 2.0) [optional, 0=Linear (default), 1=Rotary]
Example
M754
Calibrates the attached 3D scanner. Before the calibration is performed by the external scanner, "calibrate_pre.g" is run and when it is complete, "calibrate_post.g" is executed.
M755: Set alignment mode for 3D scanner
Parameters
- Pnnn Whether to turn on (> 0) or off (<= 0) the alignment feature
Examples
M755 P1
M755 P0
Sends the ALIGN ON/OFF command the attached 3D scanner. Some devices turn on a laser when this command is received. If the 'P' parameter is missing, equal to, or less than 0, the alignment feature is turned off. Depending on whether the alignment is turned on or off, either align_on.g or align_off.g is executed before the ALIGN command is sent to the scanner.
M756: Shutdown 3D scanner
Example
M756
Sends the SHUTDOWN command the attached 3D scanner.
M851: Set Z-Probe Offset (Marlin Compatibility)
RepRapFirmware 2.02 and later
M851 Znn 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.
M905: Set local date and time
Supported in RepRapFirmware version 1.16 and later.
Parameters
- Pnnn Current date in the format YYYY-MM-DD
- Snnn Current time in the format HH:MM:SS
- Tnnn (Supported by DSF v3.3 and later) Timezone to set (e.g Europe/Berlin)
Examples
- M905 P2016-10-26 S00:23:12
- M905 P2016-10-26 S00:23:12 T"Europe/Berlin" 1
Updates the machine's local date and time or reports them if no parameters are specified. The time should be specified in 24-hours format as in "13:45" instead of 1:45PM.
1 Only supported by Duets in SBC mode with DSF v3.3 or newer
M906: Set motor currents
Parameters
- Xnnn X drive peak motor current13
- Ynnn Y drive peak motor current13
- Znnn Z drive peak motor current13
- Ennn E drive(s) peak motor current(s)13
- Innn Motor current idle factor (0..100)2
Order dependency
This command must be later in config.g than any M584 command.
Example
- M906 X300 Y500 Z200 E350:350
Sets the peak currents to send to the stepper motors for each axis. The values are in milliamps.
Notes
1Current setting on the various Duet boards are as follows:
- Duet 2 WiF/Ethernet is done in steps of 100mA and is rounded down.
- Duet Maestro is in steps of 50mA and rounded down.
- Duet 3 MB6HC and EXP3HC it is 26.2mA.
- Duet 3 Mini5+ it is 74mA (provisionally), rounded down.
- Duet 3 1LC tool board is 50ma, rounded down.
2This 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.
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
3Divide by 1.414 for RMS current as used in Marlin implementations for Trinamic drivers
M911: Configure auto save on loss of power
Firmware 1.20 and later:
This code is not supported in SBC mode yet (see here).
Parameters
- Saaa Auto save threshold in volts. The print will be stopped automatically and resume parameters saved if the voltage falls below this value. Set to around 1V to 2V lower than the voltage that appears at the Duet VIN terminals at full load. A negative or zero value disables auto save.
- Raaa Resume threshold in volts. Must be greater than the auto save voltage. Set to a high value to disable auto resume.
- P"command string" G-Code commands to run when the print is stopped.
Example
- 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:
*If possible, use M913 to reduce the motor current in order to conserve power. For example, on most printers except deltas you can probably set the X and Y motor currents to zero.
*Retract a little filament and raise the head a little. Ideally the retraction should happen first, but depending on the power reserve when low voltage is detected, it may be best to do both simultaneously.
M911 with no parameters displays the current enable/disable state, and the threshold voltages if enabled.
Firmware 1.19:
Parameters
- Saaa:bbb:ccc Shutdown threshold (aaa), pause threshold (bbb) and resume threshold (ccc) all in volts, with aaa < bbb < ccc
Example
- 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 is 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: Set electronics temperature monitor adjustment
Parameters
- Pnnn Temperature monitor channel, default 0
- Snnn Value to be added to the temperature reading in degC
Example:
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)
M913: Set motor percentage of normal current
Parameters
- X, Y, Z, E Percentage of normal current to use for the specified axis or extruder motor(s)
Example:
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
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.
Important! 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
M914: Set/Get Expansion Voltage Level Translator
This command is supported in the Alligator build of RepRapFirmware only.
Parameters
- Sn Expansion voltage signal level, n must be 3 or 5
Example
M914 S5 ; set expansion signal level to 5V
M914 ; report expansion signal voltage level
M915: Configure motor stall detection
Parameters
- Pnnn:nnn:... Drive number(s) to configure
- X,Y,Z,U,V,W,A,B,C Axes to configure (alternative to using the P parameter)
- Snnn Stall detection threshold (-64 to +63, values below -10 not recommended). Lower values make stall detection more sensitive. S3 is a good starting point for many motors.
- Fn Stall detection filter mode, 1 = filtered (one reading per 4 full steps), 0 = unfiltered (default, 1 reading per full step)
- Hnnn (optional) Minimum motor full steps per second for stall detection to be considered reliable, default 200
- Tnnn (optional) Coolstep control register, 16-bit unsigned integer
- Rn Action to take on detecting a stall from any of these drivers: 0 = no action (default), 1 = just log it, 2 = pause print, 3 = pause print, execute /sys/rehome.g, and resume print
Order dependency
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.
Examples
- M915 P0:2:3 S10 F1 R0
- M915 X Y S5 R2
This sets the stall detection parameters and optionally the low-load current reduction parameters for TMC2660, TMC2130 or similar driver chips. Use either the P parameter to specify which driver number(s) you want to configure, or the axis names of the axes that those motors drive (the parameters will then be applied to all the drivers associated with any of those axes).
If any of the S, F, T and R parameters are absent, the previous values for those parameters associated with the specified drivers will continue to be used. If all the parameters are absent, the existing settings for the specified drive(s) will be reported.
See the Trinamic TMC2660 and TMC2130 datasheets for more information about the operation and limitations of motor stall detection.
See here for more detailed information on Stall Detection and Sensorless Homing.
M916: Resume print after power failure
Supported in firmware 1.20 beta 2 and later.
Parameters
- none
Example
- M916
If the last print was not completed and resume information has been saved (either because the print was paused or because of a power failure), then the heater temperatures, tool selection, head position, mix ratio, mesh bed compensation height map etc. are restored from the saved values and printing is resumed.
RepRapFirmware also requires macro file /sys/resurrect-prologue.g to be present on the SD card before you can use 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.
Version 1.19 of RepRapFirmware does not support M916 but you can achieve the same effect using command M98 P/sys/resurrect.g.
M917: Set motor standstill current reduction
Supported in firmware 1.20 and later for the Duet 2 Maestro, and 3.01 and later for Duet 3.
Parameters
- X,Y,Z,E Percentage of normal current to use when the motor is standing still or moving slowly, default 100
Order dependency
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.
Example
- M917 X70 Y70 Z80 E70:70
Some motor drivers 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.
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.
M918: Configure direct-connect display
This command is used to tell RepRapFirmware about a directly-connected LCD such as a 12864 or compatible display. Supported on Duet 2 Maestro.
Parameters
- Pn Directly-connected display type: P1 = 128x64 pixel mono graphics display using ST7920 display driver chip, P2 = 128x64 display using ST7567 display driver chip (RRF 3.02 and later).
- En The number of pulses generated by the rotary encoder per detent. Typical values are 2 and 4. Negative values (e.g. -2 and -4) reverse the encoder direction.
- F (optional, supported in RRF 2.03 and later) SPI clock frequency in Hz, default 2000000 (i.e. 2MHz)
- C (optional, supported in RRF 3.2 and later) Display contrast, in range 0 to 100. Only used with ST7567-based displays. ST7920-based displays usually have a contrast potentiometer instead.
- R (optional, supported in RRF 3.2 and later) Display resistor ratio, in range 1 to 7. Only used with ST7567-based displays. The default value of 6 is suitable for the Fysetc Mini 12864 display. Some other displays need 3.
Example
- M918 P1 E2
M929: Start/stop event logging to SD card
Parameters
- P"filename" The name of the file to log to. Only used if the S1 parameter is present. A default filename will be used if this parameter is missing.
- Sn S1 = start logging, S0 = stop logging (RRF <= 3.2.0-beta2)
- Sn S0 = stop logging, S1 = log level WARN, S2 = log level INFO, S3 = log level DEBUG (RRF >= 3.2.0-beta3)
Example
- M929 P"eventlog.txt" S1 ; start logging to file eventlog.txt
- M929 S0 ; stop logging
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.
Starting with RepRapFirmware 3.2.0-beta3 there is a more fine granular logging available that is not split into 3 log levels plus no logging. Each line in the log will have the log level of that message added right after the timestamp.
- WARN: All log messages from previous versions will fall into this log level
- INFO: G10, M117, M291 and M292 invocations will fall into this log level
- DEGUG: all output not listed above will be logged within this log level
Also see M118 .
Caution: do not rename or delete the current log file while logging is enabled!
M950: Create heater, fan, spindle or GPIO/servo pin
Supported in RepRapFirmware 3.
M950 is used to create heaters, fans and GPIO ports and to assign pins to them. Each M950 command assigns a pin or pins to a single device. So every M950 command must have exactly one of the H, F, J, P or S 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.
Parameters:
- Hnn Heater number
- Fnn Fan number
- Jnn Input pin number (RRF 3.01RC2 and later only)
- Pnn or Snn Output/servo pin number. Sservo pins are just GpOut pins with a different default PWM frequency.
- Rnn Spindle number (RRF 3.3beta2 and later only)
- C"name" Pin name(s) and optional inversion status, see Pin Names. Pin name "nil" frees up the pin. A leading '!' character inverts the input or output. A leading '^' character enables the pullup resistor. The '^' and '!' characters may be placed in either order.
- Qnn PWM frequency in Hz. Valid range: 0-65535, default: 500. (optional)
- T Temperature sensor number, required only when creating a heater. See M308.
- Lbbbor Laaa:bbb RPM values that are achieved at zero PWM and at maximum RPM. (optional and for spindles only - RRF 3.3beta2 and later)
Order dependency
- When M950 is used to create a heater, the M950 command must come later in config.g than the M308 command that creates the sensor referred to in the T parameter
- M950 must come before any commands that refer to the device being created. For example, when M950 is used to create a heater, it must be earlier than the M307 command used to set the heater parameters, and earlier than any M563 commands that create tools that use that heater. When M950 is used to create a fan, it must come earlier than any M106 commands relating to that fan.
Examples:
M950 H1 C"out1" Q100 T1 ; create heater 1 M950 H2 C"nil" ; disable heater 2 and free up the associated pin M950 F3 C"heater2" Q100 ; Fan 3 is connected to heater 2 pin, PWM at 100Hz M950 P0 C"exp.heater3" ; create output/servo port 0 attached to heater 3 pin on expansion connector M950 F2 C"!fan2+^pb6" ; Fan 2 uses the Fan2 output, but we are using a PWM fan so the output needs to be inverted, also we are using PB6 as a tacho input with pullup resistor enabled M950 J1 C"!^e1stop" ; Input 1 uses e1Stop pin, inverted, pullup enabled M950 R0 C"!exp.heater3" L12000 ; Spindle 0 uses exp.heater3 as RPM pin and has a max RPM of 12000
M951: Set height following mode parameters
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.
Parameters:
- Snn or Hnn Sensor number
- Pnn.n Proportional factor, in mm per sensor unit
- Inn.n Integral factor, in mm per sensor unit per second
- Dnn.n Derivative factor, in mm per rate of change of sensor units (change in sensor unit per second)
- Fnn.n (optional) Sample and correction frequency (Hz), default 5Hz
- Znn.n:nn.n Minimum and maximum permitted Z values
If commanding the motors to increase Z causes the sensor value to increase, then all of P, I and D must be positive. If commanding the motors to increase Z causes the sensor value to decrease, then all of P, I and D must be negative.
M952: Set CAN-FD expansion board address and/or normal data rate
Parameters
- Bn Existing CAN address of expansion board to be changed, 1 to 125.
- An New CAN address of that expansion board, 1 to 125.
- Sn.n Requested bit rate in Kbits/second (1K = 1000)
- T0.n Fraction of the bit time between the bit start and the sample point (optional)
- J0.n Maximum jump time as a fraction of the bit time (optional)
Examples
- 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
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.
Note: 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:
- Use M952 to change the data rate on all the expansion boards, one at a time. After changing the data rate on each expansion board, you will no longer be able to communicate with it, and you may need to power it down or disconnect it from the CAN bus to prevent it interfering with subsequent CAN communications.
- Change the data rate of the main board last. Then the main board should be able to communicate with all the expansion boards again.
M953: Set CAN-FD bus fast data rate
Parameters
- Sn.n Requested bit rate in Mbits/second. Ignored if it is lower than the bit rate for the negotiation phase.
- T0.n Fraction of the bit time between the bit start and the sample point (optional)
- J0.n Maximum jump time as a fraction of the bit time (optional)
- Caa:bb Transceiver delay compensation offset and minimum, in nanoseconds (optional)
Example
M953 S4.0 T0.6 J0.2
This command allows the bandwidth of the CAN bus to be optimised, by increasing the data rate during transmission of CAN-FD data packets 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.
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 see by the receiver while the transceiver delay is being measured will be ignored if they would result in a transceiver delay compensation lower than this value. When CAN is implemented on Microchip SAME5x and SAMC21 processors, these values are converted from nanoseconds into time quanta and stored in the TDCO and TDCF fields of the transceiver delay compensation register.
M954: Configure as CAN expansion board
Parameters
- Ann CAN address to use (required)
This command is used to reconfigure the board it is executed on as a CAN-connected expansion board. It would typically be the only command in the config.g file. When it is executed, the board changes its CAN address to the one specified in the A parameter, stops sending CAN time sync messages, and responds to requests received via CAN just like a regular expansion board. A few GCode commands can still be executed locally for diagnostic purposes, for example M111 and M122
M955: Configure Accelerometer
To be supported in RRF 3.4 (limited support in 3.3beta3)
Parameters (provisional)
- Pnn or Pbb.nn Accelerometer to use (required)
- Inn Accelerometer orientation
- Snnn Sample rate (Hz)
- Rnn Resolution (bits), typically 8, 10 or 12
This command configures an accelerometer.
The P parameter selects which accelerometer to use and is mandatory. To use an accelerometer on a CAN-connected expansion board, use the form P''board-address.device-number'' for example P22.0.
If none of the other parameters are provided, the current configuration of the specified accelerometer is reported. Otherwise the configuration of that accelerometer is adjusted according to the I, S, and R parameters. These configuration settings persist until they are changed.
The I (orientation) parameter tells the firmware which of the 24 possible orientations the accelerometer chip is in relative to the printer axes. It is expressed as a 2-digit number. The first digit specifies which machine direction the Z axis of the accelerometer chip (usually the top face of the chip) faces, as follows: 0 = +X, 1 = +Y, 2 = +Z, 4 = -X, 5 = -Y, 6 = -Z. The second digit expresses which direction the X axis of the accelerometer chip faces, using the same code. If the accelerometer chip axes line up with the machine axis, the orientation is 20. This is the default orientation if no orientation has been specified.
The S and R parameters control how the accelerometer is programmed. The R parameter is ignored unless the S parameter is also provided. If S is provided but R is missing, a default resolution is used. The sensor resolution will be adjusted to be no greater than the value of the R parameter (or the minimum supported resolution if greater), then the sensor sampling rate will be adjusted to a value supported at that resolution that is close to the S parameter. The actual rate and resolution selected can be found by using M955 with just the P parameter.
M956: Collect accelerometer data and write to file
To be supported in RRF 3.4 (limited support in 3.3beta3)
Parameters (provisional)
- Pnn or Pbb.nn Accelerometer to use (required)
- Snnn Number of samples to collect (required)
- X and/or Y and/or Z Machine axes to collect data for. If no axes are specified, data is collected for all three axes.
- An (required) 0 = activate immediately, 1 = activate just before the start of the next move, 2 = activate just before the start of the deceleration segment of the next move
- Kn (optional, default 0) Skip the specified number of moves before activating (use with A1 or A2)
This command causes the specified number of accelerometer samples to be collected and saved to a .csv file in folder /sys/accelerometers on the internal SD card.
The P parameter selects which accelerometer to use and is mandatory. To use an accelerometer on a CAN-connected expansion board, use the form P''board-address.device-number'' for example P22.0.
M997: Perform in-application firmware update
Parameters
- Snnn Firmware module number(s), default 0
- Bnnn CAN address of the board to be updated (RRF_3, Duet 3 only)
- P"filename" Filename of firmware binary to use (RRF 3.3beta2 and later)
Example:
- M997 S0:1 - update firmware modules 0 and 1
Notes
This command triggers a firmware update if the necessary files are present on the SD card. In RepRapFirmware on the Duet series, module numbers are as follows:
- 0 - main firmware, filename sys/RepRapFirmware.bin (older Duets) or sys/Duet2CombinedFirmware (Duet 2). File sys/iap.bin (Duet) or sys/iap4e.bin (Duet 2) must also be present.
- 1 - web server firmware, filename sys/DuetWiFiServer.bin (Duet 2 WiFi only)
- 2 - web server file system, filename sys/DuetWebControl.bin (needed only when using RepRapFirmware 1.18 series and earlier for Duet 2 WiFi)
- 3 - put the WiFi module into bootloader mode, so that firmware can be uploaded directly via its serial port
- 4 - PanelDue firmware (RRF 3.2-beta4.1 and later; see PanelDue firmware update instructions).
On Duet 3 only this command take an optional B (board number) parameter which is the CAN address of the board to be updated, default 0 (i.e. main board).
The optional P parameter can be used to provide the filename of the file to be used for updating a module. This can either only be a filename in which case it will prepend directories.firmware to it (0:/firmware) or can be an absolute path to the file to be used. It is not allowed to use P parameter and multiple modules, e.g. S1:4. (RRF 3.3beta2 and later)
See Installing and Updating Firmware for detailed documentation.
M998: Request resend of line
Parameters
- Pnnn Line number
Example
- 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.
M999: Restart
Parameters
- This command can be used without any additional parameters.
- Bnnn Optional CAN address of the board to restar (defaults to 0)2
- Pnnn Reset flags1
Example
- M999
Restarts the firmware using a software reset.
Notes
1This also puts the board into firmware upload mode (as if the Erase button had been pressed) if parameter P"ERASE" is present.
2 Starting from v3.3 this parameter may be set to -1 to reboot the attached SBC (DuetPi + SBC)
T: Select Tool
Parameters
- nnn: Tool number to select. A negative number deselects all tools.
- R1: Select the tool that was active when the print was last paused (firmware 1.20 and later)
- Pnnn: Bitmap of all the macros to be run (dc42 build 1.19 or later and ch fork 1.17b or later)
- Tool number
Example
- 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
If Tn is used to select tool n but that tool is already active, the command does nothing. Otherwise, the sequence followed is:
- If another tool is already selected and all axes have been homed, run macro tfree#.g where # is the number of that tool
- If another tool is already selected, deselect it and set its heaters to their standby temperatures (as defined by the R parameter in the most recent G10/M568 command for that tool)
- If all axes have been homed, run macro tpre#.g where # is the number of the new tool
- Set the new tool to its operating temperatures specified by the S parameter in the most recent G10/M568 command for that tool
- If all axes have been homed, run macro tpost#.g where # is the number of the new tool. Typically this file would contain at least a M116 command to wait for its temperatures to stabilise.
- Apply any X, Y, Z offset for the new tool specified by G10/M568
- Use the new tool.
Selecting a non-existent tool (100, say) just does Steps 1-2 above1. That is to say it leaves the previous tool in its standby state. You can, of course, use the G10/M568 command beforehand to set that standby temperature to anything you like.
After a reset tools will not start heating until they are selected. You can either put them all at their standby temperature by selecting them in turn, or leave them off so they only come on if/when you first use them. The M0, M1 and M112 commands turn them all off. You can, of course, turn them all off with the M1 command, then turn some back on again. Don't forget also to turn on the heated bed (if any) if you use that trick.
Tool numbering starts at 0 by default however M563 allows the user to specify tool numbers, so with them you can have tools 17, 99 and 203 if you want. Negative numbers are not allowed.
Starting from RRF 3.3beta2 both selecting as well as deselecting with a configured spindle will stop the spindle assigned to these tools. This is in accordance to NIST GCode standard that says "after a tool change is complete the spindle is stopped".
Notes
1 Selecting a non-existent tool also removes any X/Y/Z offset applied for the old tool.
2 Under special circumstances, the execution of those macro files may not be desired. RepRapFirmware 1.19 or later supports an optional P parameter to specify which macros shall be run. If it is absent then all of the macros above will be run, else you can pass a bitmap of all the macros to be executed. The bitmap of this value consists of tfree=1, tpre=2 and tpost=4.
3 You may wish to include a move to a parking position 'within the tfreeN.g gcode macro in order to allow the new extruder to reach temperature while not in contact with the print.
4 Tool offsets are applied whenever there is a current tool. So they are applied in tfree.g (for the outgoing tool) and in tpost.g (for the incoming tool), but not in tpre.g (because no tool is current at that point).
G-Code Background Information
Codes for print head movements follow the http://www.nist.gov/manuscript-publicati..., so RepRapFirmware should be usable for CNC milling and similar applications but be aware of the G-Codes not implemented. See also on https://en.wikipedia.org/wiki/G-code.
For more information and background, along with the master list of all RepRap G-Codes check the http://reprap.org/wiki/G-code.
For the technically minded, G-Code 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.
Replies from the RepRap machine to the host computer
All communication is in printable ASCII characters. Messages sent back
to the host computer are terminated by a newline 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
!!
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:
- M20 S2
- M36
- M408
Slicer Start and End G-Codes
Slicers will optionally add G-Code scripts to the beginning and end of their output file to perform specified actions before and/or after a print such as z-probing the build-area, heating/cooling the bed and hotend, performing ooze free "nozzle wipe" startup routine, switching system power on/off, and even "ejecting" parts. For general information and examples (not specific to RepRapFirmware) there is more info on the https://reprap.org/wiki/Start_GCode_rout... and https://reprap.org/wiki/End_GCode_routin... pages.
17 Comments
Great Page. Wail reading about pause options, I notest that under M226 the detail about running the pause.g macro is missing. It is only mentioned under M25 and a hind is in M600.
sjk - Reply
With the addition of meta commands I was wondering if it would be possible to get a new version of M291 where you could ask a question of the user and have custom response button text (like Q“Yes”:”No”:“Continue”, etc…) Q for question or A for answer? or or not have the cancel button kill the processing of the rest of the g-code. It would also need to update the “result” variable
Bill Lafreniere - Reply
just a note: with 308 on a Duet Maestro hooked up PT1000, you do enter ANY resistance values or you get 360*c. Evidentally the Maestro’s don’t have a same series resistors that the Wifi/Ethernet do, not that I found it documented anywhere. Just a plain M308 S1 P"e0temp" Y"pt1000" works like a charm though
Jeneva Samples - Reply
Typo:
Should be: ‘When M950 is used…’
RichWP - Reply
Thanks. Fixed.
Manuel Coenen -