This page gives RepRapFirmware’s codes that set up what the machine is and watches: printer, laser and CNC modes, skew compensation, tool definitions, axis limits, endstops, input waits and triggers, tool offset probing and filament sensors, from the Duet3D G-code dictionary as read on 3 December 2026. RRF means RepRapFirmware, and version numbers are its versions.
M450 and M451: reporting and choosing the mode
(1.20) M450 reports PrinterMode:FFF,
PrinterMode:Laser or PrinterMode:CNC; filament
printing is the mode at power-up. M451 returns to it. Neither takes
parameters. From 3.7 an absolute G0 or G1 without
H to an unreachable position is an error in this mode too; earlier
versions silently limit it.
M452: laser mode
| Parameter (3.x) | Meaning |
|---|---|
C"pin" | Laser pin; a leading ! inverts it |
R | The S value that means full power, default 255 |
S | 0 (default) non-sticky: a G1 without S does not fire; 1 sticky: power carries over from earlier commands |
F | PWM frequency in Hz, default 500 |
M452 C"out9" R255 F200
The laser fires only during G1 moves given power with
S, or with rising E through M571;
G0 never fires it. In sticky mode M3 S sets the power
and M5 zeroes it without firing; later G1 moves use the
last value until M3 S0, G1 S0 or M5. In
non-sticky mode M3 is redundant. Lines holding only coordinates may
follow a G0 or G1. Power follows velocity during
ramps. From 3.7 a relative move past the limits is clamped unless
M564 R0 is set; earlier it is an error. When upgrading from 2.01 or
earlier, change S to H on G0 and
G1 in homing files, because S now means power.
RRF 2.x (from 2.01) takes P logical pin number and I1
to invert in place of C, with R, S and
F as above, and has no power ramping. A heater or fan output used
for the laser must first be disabled (M307, M106).
In 2.01 to 2.04 M3 and M5 switch the laser at once and
sticky is the default; from 2.05 they do not, and non-sticky is the
default.
M453: CNC mode
(1.20) Switches M3, M4 and M5 to spindle
control. From 3.3 it takes no parameters: the spindle is made with
M950 R and attached to a tool with M563 R.
| Older parameter | 3.2 | 3.0 and 3.1 | 1.x and 2.x |
|---|---|---|---|
S | Spindle index, default 0 (Duet 2: at most 4 spindles) | ||
| Pins | C"pwm+on+reverse", last two optional | C"forward+reverse" | Pforward:reverse logical pins, I1 inverts |
| Speed | R RPM at full PWM, or min:max | R RPM at full PWM | |
| Frequency | Q | F | |
T | Tool to attach the spindle to | ||
M950 R0 C"out3+out4+out5" Q100
M563 P1 S"Spindle 1" R0
M453
No spindle output is assigned by default. In CNC mode lines holding only
coordinates may follow a G0 or G1, and one pair of
parentheses on one line, not nested, is a comment. Inside { }
parentheses still group expressions, so every bracketed expression or function
call must be inside braces. From 3.7 a relative move past the limits is clamped
unless M564 R0 is set.
M556: axis skew compensation
| Parameter | Meaning |
|---|---|
S | Length in mm of the measured triangle along each axis |
X Y Z | Out-of-true distance in mm between X and Y, Y and Z, and X and Z; positive for an obtuse angle, negative for acute. With S1 they are the tangents (skew factors) themselves |
P (3.2) | 1 applies the XY correction to Y instead of X; default 0 |
M556 S100 X0.7 Y-0.2 Z0.6
M556
Axis compensations - XY: 0.00700, YZ: -0.00200, ZX: 0.00600
Without parameters it reports the factors in use.
M563: define or remove a tool
| Parameter | Meaning |
|---|---|
P | Tool number, 0 to 49 in 3.x (0 to 65535 in 2.x) |
S"name" | Name |
D | Extruder drives, colon-separated, numbered from the first E driver in M584; without it, none |
H | Heaters; without it, none. The bed is usually heater 0. Tools may share drives and heaters |
F (1.16) | Print cooling fans, default 0; never list thermostatic hot end fans |
X (1.16), Y (1.19), Z (3.5) | Axes that follow X, Y or Z movement for this tool, for multiple carriages: numbered in the order XYZUVWABC with X = 0, U = 3 |
L (2.02) | Extruder whose loaded filament the web interface shows; needed on mixing tools, which otherwise show none |
R (3.3) | Spindle number |
M563 P0 D0:2:3 H1:3
M563 P2 D0:1 H1:2 X0:3 F0:2
M563 P0 D0 H1 F0:1
M563 P1 D-1 H-1
Giving an existing number with other parameters redefines the tool;
P alone reports it, so a tool with no drives or heaters needs at
least a name. D-1 H-1 deletes. A definition is normally followed by
G10 or M568 for offsets and temperatures. Mixing tools
are fed by several E values on a move, or by a ratio set with
M567. Versions up to 3.0 also had M563 Sn,
which added n to every later tool number in the input; it was removed
in 3.1.0.
M564: limit axes
| Parameter | Meaning |
|---|---|
S | 1 (default) keep moves inside the axis limits, 0 allow moves outside |
H (1.21) | 1 (default) refuse to move axes that are not homed, 0 allow it; some kinematics, such as delta and SCARA, may refuse regardless |
R (3.7) | 1 (default) clamp relative moves that pass a limit, 0 make them an error |
M564 S0 H0
With S1 a move without H may still ask for an
unreachable point (by M208 limits, kinematics or bed radius). From
3.7 an absolute one is an error in every mode and a relative one follows
R. Up to 3.6 filament printing mode limits it silently, while laser
and CNC modes report an error.
M574: endstops
| Parameter (RRF 3) | Meaning |
|---|---|
X Y Z… | Position of that axis’s endstop: 0 none (frees its pins), 1 low end, 2 high end |
S | 1 switch, 2 Z probe (homing an axis other than Z), 3 motor stall detection, all motors of the axis stopping at the first stall, 4 stall detection stopping each motor separately, 5 (3.7) encoder position error |
P"pins" | Input pins, needed for S1; ! inverts (active low), ^ enables a pull-up; several joined with + |
K (3.5) | Z probe number for S2, default 0 |
E (3.7) | Extruder: binds an input made with M950 J, number given by P, as its filament endstop; P-1 returns to stall detection (default). Not together with axis letters |
M574 X1 S1 P"io1.in"
M574 Y2 S1 P"!io2.in"
M574 V2 S3
M584 X0 Y1 Z2:3 E4
M574 Z1 S1 P"io2.in+io3.in"
M574 E0 P2
- It must follow, in
config.g, theM584that creates extra axes or motors, and forEtheM950 J. - With as many pins as motors, in the same order as the
M584drivers, each motor stops at its own switch. - Use one command per axis; several in one is tolerated for now.
S5triggers when a motor on a CAN board lags the commanded position by the first value ofM569.1 E, in full steps. It works open or closed loop, needs no tuning orM915, has no minimum speed, and stops all motors of the axis.- A Z endstop and a Z probe can both exist:
G1 H1uses the endstop,G30the probe. - A filament endstop stops a
G1 H1orH4extruder-only move when active while feeding forward or inactive while retracting.M574 E0reports it;M574alone lists all.
RRF 2.x and earlier: the axis letters give the position as above and
S the type: 0 active low, 1 active high (default), 2 Z probe and 3
stall detection (1.20). Up to 1.16 E set the polarity of a probe on
the E0 input, a job later given to M558 I. Delta towers normally
all use high-end endstops.
M577: wait for an input
| Versions | Parameters |
|---|---|
| 3.01 and later | S level awaited, 1 triggered (default) or 0 not; axis letters (X Y Z U V W A B C D) for their endstops; P input number made earlier with M950 J |
| 3.0 | P"pins" pin names joined with +; waits for high, ! for low. A pin in use as an endstop is allowed |
| 2.x | X Y Z E choose the endstop; S 0 not hit, 1 low end hit, 2 high end hit, 3 near (Z probe only) |
M577 X S0
M950 J2 C"!io3.in"
M577 P2
M578: fire inkjet bits
P head (default 0) and S bit pattern;
M578 P3 S5 fires pattern 101 on head 3. Not in 3.5 and later, and
earlier only in builds with inkjet support. G1 P with
M670 is the other way to drive inkjets.
M581: triggers on inputs and endstops
| Parameter (3.01 and later) | Meaning |
|---|---|
T | Trigger number, required; the highest depends on board and version |
P | Input numbers made with M950 J; P-1 deletes the trigger (other parameters ignored, action reset) |
| Axis letters | Endstops that cause the trigger |
S | Edge for the inputs named in this command: 1 inactive to active (default), 0 active to inactive, −1 ignore them |
R | When enabled: −1 never, 0 always (default for a new trigger), 1 only while printing from SD card, 2 (3.2) only when not |
K (3.7.1) | Action: 0 emergency stop (as M112), 1 pause (as M25), 2 run sys/triggern.g, 3 feed hold (M25.1), 4 feed hold and abort (M25.1 S1). Default: trigger 0 uses 0, trigger 1 uses 1, others 2 |
M581 T2 P0:3 S1 R1
M581 T3 X Y S1
M581 T4 P2 S1 K3
M581 T2 P-1
- Inputs are added to those the trigger already has. With only
Tthe trigger is reported. - Up to 3.7.0 triggers 0 and 1 are fixed as stop and pause; trigger files serve 2 upwards.
- Actions 0, 4 and 3 happen at detection, in that order of priority. Of
pending 1 and 2 actions the lowest number goes first, and no more are polled
until its macro ends. Queued moves are not waited for; start the macro with
M400if that matters. - A pause trigger is ignored when nothing is printing, when already paused or
during a feed hold.
M24does not release a feed hold while its input is still active. - During a job, lines of a trigger macro can interleave with the job’s.
| Older versions | Parameters |
|---|---|
| 3.0 | T number; P"pins" pin names (P"nil" disables, ! for a falling edge); C 0 any time (default), 1 only printing from card |
| 2.x | T number (for example up to 9; 16 triggers on Duet 2); X Y Z E endstops; S 1 rising (default), 0 falling, −1 ignore; C as above; P reserved |
M581.1 and M582: expression triggers and polling
M581.1 (3.7) fires when an object model expression turns from
false to true: T number (required), P"expression"
yielding a boolean (P-1 deletes), R −1, 0, 1 or 2 and
K (3.7.1) as for M581. An expression that fails at
creation creates nothing; one that fails later is reported to all channels and
the trigger disabled. Numbers are shared with M581: either command
can report, delete or change R and K of any trigger,
but a trigger holds inputs or an expression, and setting one removes the
other.
M581.1 T2 P"sensors.gpIn[0].value = 1" R1
M582 Tn checks a trigger against current levels, as if
each of its inputs had just changed into its present state, for instance to
test for missing filament before a print. S1 (3.5) fires it
regardless; S0 is the default.
M585: probe a tool offset
(1.20) Drives the current tool into a switch or probe, like a homing move, but sets that tool’s offset instead of the machine position.
| Parameter | Meaning |
|---|---|
One of X Y Z U V W A B C | Expected distance between the starting point and the trigger point, used as the correction; one axis per command. Starting at 190 and triggering at 210 takes −20; the reverse takes 20 |
F | Probing speed; required in 3.x, optional in 2.x |
S | 0 (default) move towards the axis maximum, 1 towards the minimum |
R | Relative distance to travel from the current position; S is then ignored |
P or K (3.x) | Z probe number; K wins. Without them an axis endstop can be used. For another input, make a probe on it with M558 |
E, L (2.x) | Another endstop by drive number (X 0, Y 1, Z 2, E0 3…) and (2.04) its trigger level, 0 low or 1 high |
M558 K1 P8 C"!io3.in"
M585 X100 F600 P1 S0
A macro per axis typically clears the offset with G10, selects the
tool, moves to the start, runs M585, then reads the offset with
G10 or saves it with M500.
M591: filament sensors
| Parameter (3.x) | Meaning |
|---|---|
D | Extruder, from 0 |
P | 0 none, 1 switch high when filament present, 2 switch low when present, 3 Duet3D rotating magnet, 4 the same with microswitch, 5 Duet3D laser, 6 the same with microswitch, 7 pulse generator |
C"pin" | Input pin (up to 2.x an endstop input number: 0 X, 1 Y, 2 Z, 3 E0…) |
S | 0 monitoring off (default), 1 while printing from SD card, 2 (3.5) always. Calibration data is gathered even when off |
Ra:b | Types 3 to 7: allowed measured movement as a percentage of commanded, default 60:160 |
E | Types 3 to 7: extrusion needed before comparing, default 3 mm (5 mm for type 7) |
A | Magnet and laser: 1 check all extrusion, 0 (default) only printing moves |
L | Magnet: mm per wheel turn, default 25.1. Laser (3.2): calibration factor applied to the reading, default 1.0, for laser sensors watching a wheel. Pulse: mm per pulse, default 1.0 |
M591 D0 P3 C"io3.in" S1
M591 D0
With D alone it reports; P0 frees the pin. On a
detected fault, 3.4 and later raise a filament error event; 3.2 and 3.3 pause
and run filament-errorn.g, else
filament-error.g, else show a message and run
pause.g; 1.19 to 3.1.1 pause with a message. From 3.7 presence is
in the object model, and presence and motion appear as virtual inputs usable by
triggers and M574 E.
On Duet 3 with CAN boards a monitor of type 3 to 7 must be on the board of its extruder driver; a switch may also be on the main board from 3.5.2. DueX expansion endstop inputs take only presence switches.
| Versions | Differences |
|---|---|
| 1.21 to 2.x | As 3.x, but C is an endstop input number, for example M591 D0 P3 C3 S1 R70:130 L24.8 E3.0 |
| 1.20 and earlier | P 0 to 4; S is the magnet sensor’s mm per turn; R a tolerance percentage, negative to calibrate; E as above |
Sources
- G-code dictionary – Duet3D’s documentation of RepRapFirmware’s commands, published under a Creative Commons attribution share-alike licence; this page is written in our own words