M-code Reference

M

List all M-codes

Lists all the M-codes implemented by this firmware. To get a long description of each code use '?' after the code name, for instance, M92? will give a decription of M92. To get all g-codes with wiki formatting, add token 'F0'.

To search for a phrase add S

M17

Enable steppers

Power on and enable all steppers. Motors are active after this command.

M18

Disable all steppers or set power down

Disable all steppers. No more current is applied to the stepper motors after this command. If only token D is supplied, set power down mode (0 or 1)

M19

Reset the stepper controllers

Reset the stepper controllers

M20

List all files on an external memory location

For an already attached external memory location, list all the files available. The supported devices are:

id device
/usb usb memory attached to host
/sd microsd card
/lcl local storage (octoprint)

Use M21 to attach a device.

> M20 /usb
- /usb/myfile.gcode
- /usb/mydirectory/myotherfile.gcode
- /usb/yetanotherfile.gcode

> M20 /lcl
- /lcl/example.gcode

M21

Initialize external memory location

Attach external memory device, choose from:

id device
/usb usb memory attached to host
/sd microsd card
/lcl local storage (octoprint)
> M20 /usb
> M20 /sd

Use M22 to unattach a device before removing.

Note

local storage is always mounted; used with M21 will be a no-op

M22

Release external memory location

Disconnect external memory device, choose from:

id device
/usb usb memory attached to host
/sd microsd card
/lcl local storage (octoprint)
> M21 /usb
> M21 /sd

Note

local storage is always mounted; used with M22 will be a no-op

M23

Choose a file from external location

Choose a gcode file for printing from external location:

id device
/usb usb memory attached to host
/sd microsd card
/lcl local storage (octoprint)
> M23 /usb/myfile.gcode
> M23 /sd/myfolder/myotherfile.gcode
> M23 /lcl/anotherfile.gcode

M24

Start/unpause a print

Start printing from an externally selected file using the M23 command.

If the current print (from any source) was paused by M25, this will resume the print.

M25

Pause the current print.

Pause the current print.

M27

Report external file print status

If printing from an externally selected file (from M23), display of how many lines from the active file have been processed. Will also display total number of lines in the file.

> M27
file '/usb/myfolder/myfile.gcode' printing: 10 of 211 lines

M81

Shutdown or restart Replicape

Shutdown the whole Replicape controller board. If paramter P is present, only exit loop. If R is present, restart daemon

M82

Set the extruder mode to absolute

Makes the extruder interpret extrusion as absolute positions. This is the default in Redeem.

M83

Set the extruder mode to relative

Makes the extruder interpret extrusion values as relative positions.

M84

Set stepper in lowest current mode

Set each of the steppers with a token to the lowest possible current mode. This is similar to disable, but does not actually disable the stepper.

M92

Set number of steps per millimeters for each steppers

Set number of steps per millimeters for each steppers

M101

Deprecated

Deprecated

M103

Deprecated

Deprecated

M104

Set extruder temperature

Set extruder temperature. Use either T or P to choose heater, use S for the target temp

M105

Get extruder temperature

Gets the current extruder temperatures, power and cold end temperatures. Extruders have prefix T, cold endsa have prefix C, power has prefix @

M106

Set fan power.

Set the current fan power. Specify S parameter for the power (between 0 and 255) and the P parameter for the fan number. P=0 and S=255 by default. If no P, use fan from config. If no fan configured, use fan 0. If 'R' is present, ramp to the value

M107

set fan off

Set the current fan off. Specify P parameter for the fan number. If no P, use fan from config. If no fan configured, use fan 0

M108

Break out of any running M116 loop

Break out of any running M116 loop

M109

Set extruder temperature and wait for it to be reached

Set extruder temperature and wait for it to be reached

M110

Set current gcode line number

Set current gcode line number

M111

Set debug level

set debug level, S sets the level. If no S is present, it is set to 20 = Info

M112

Cancel all the planned moves in emergency.

Cancel all the planned moves in emergency.

M114

Get current printer head position

Get current printer head position. This is the ideal positition, without bed compensation. The returned value is in millimeters.

M = Return the position seen with the bed matix enabled

M115

Get Firmware Version and Capabilities

Get Firmware Version and CapabilitiesWill return the version of Redeem running, the machine type and the extruder count.

M116

Wait for a specific temperature/all temperatures to be reached

Wait for a specific temperature/all temperatures to be reachedIf no parameter is added M116 will wait for all temperatures to be reachedIf P or T is set then M116 will wait for the specific Heater to reach temperature onlyPossible values are:

-1 - Heated Bed

0 - Extruder E

1 - Extruder H 2 - Extruder A

3 - Extruder B

4 - Extruder C

M117

Send a message to a connected display

Use 'M117 message' to send a message to a connected display. Typically this will be a Manga Screen or similar.

M119

Get current endstops state or set invert setting

Get endstops state or set invert state of an endstop. If two tokens are supplied, the first must be a single end stop and the second either S1 or S0, to invert or un-invert that endstop, respectively.Ex: 'M119 X1 S1', to invert end stop X1

M130

Set PID P-value, Format (M130 P0 S8.0)

Set PID P-value, Format (M130 P0 S8.0), S<-1, 0, 1>

M131

Set PID I-value, Format (M131 P0 S8.0)

Set PID I-value, Format (M131 P0 S8.0)

M132

Set PID D-value, Format (M132 P0 S8.0)

Set PID D-value, Format (M132 P0 S8.0)

M140

Set heated bed temperature

Set heated bed temperature

M141

Set fan P, to power S (1.0 = 100%) and PWM frequency I (in Hz). ex. M141 P0 I1000 S0.5

Set fan P, to power S (1.0 = 100%) and PWM frequency I (in Hz).

ex. M141 P0 I1000 S0.5

M151

Enable min temperature alarm

Should be enabled after target temperatures have been reached, typically after an M116 G-code or similar. Once enabled, if the temperature drops below the set point, the print will stop and all heaters will be disabled. The min temp will be disabled once a new temperture is set. Example: M151

M190

Set heated bed temperature and wait for it to be reached

Set heated bed temperature and wait for it to be reached

M201

Set print acceleration

Sets the acceleration that axes can do in units/minute^2 for print moves.

Example: M201 X1000 Y1000 Z100 E2000"

Values get rounded to nearest whole number, in current G20/21 units.

For CoreXY and HJ-belt mechines, Y value is forced to that supplied for X (Y is ignored).

For Delta machines, X and Y values are forced to that supplied for X (Y and Z are ignored).

In all cases, axes H, A, B and C remain independant.

M204

Set default print acceleration, dummy MCode

Set default acceleration. Dummy MCode for now.

M206

Set or get end stop offsets

If no parameters are given, get the current end stop offsets.

To set the offset, provide the axes and their offset relative to

the current value. All values are in mm.

Example: M206 X0.1 Y-0.05 Z0.03

M220

Set speed override percentage

M220 S - set speed factor override percentage

M221

Set extruder override percentage

M221 S - set extrude factor override percentage

M270

Set coordinate system

Set coordinate system. Parameter S set the type, which is 0 = Cartesian, 1 = H-belt, 2 = CoreXY, 3 = Delta

M280

Set servo position

Set servo position. Use 'S' to specify angle, use 'P' to specify index, use F to specify speed.

M290

Baby stepping

Baby stepping. 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 case 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.

The baby stepping offset is reset to zero when the printer is homed or the bed is probed.

M301

Set P, I and D values, Format (M301 E0 P0.1 I100.0 D5.0)

Set P, I and D values, Format (M301 E0 P0.1 I100.0 D5.0)P = Kp, default = 0.0I = Ti, default = 0.0D = Td, default = 0.0E = Extruder, -1=Bed, 0=E, 1=H, 2=A, 3=B, 4=C, default = 0

M303

Run PID tuning

PID Tuning refers to a control algorithm used in some repraps to tune heating behavior for hot ends and heated beds. This command generates Proportional (Kp), Integral (Ki), and Derivative (Kd) values for the hotend or bed (E-1). Send the appropriate code and wait for the output to update the firmware.

Inputs:

H<0 or 1> overrides the extruder. Use H-1 for heated bed.

Default is the 'E' extruder with index 0.

S overrides the temperature to calibrate for. Default is 200.

N overrides the number of cycles to run, default is 4

P (0,1) Enable pre-calibration. Useful for systems with very high power

L Tuning algorithm. 0 = Tyreus-Luyben, 1 = Zieger-Nichols classic

M308

Set or get direction and search length for end stops

Set or get direction and search length for end stops

If not tokens are given, return the end stop travel search length in mm.

If tokens are given, they must be a space separated list of pairs.

Example: 'M308 X250 Y220'. This will set the travel search length for the

X nd Y axis to 250 and 220 mm. Th values will appear in the config file in meters, thus 0.25 and 0.22

M360

Get current config

Get current config

M400

Wait until all buffered paths are executed

Wait until all buffered paths are executed

M409

Get a status report from each filament sensor connected, or enable action command

Get a status report from each filament sensor connectedIf the token 'H' is present, get a human readable status. If no token is present, return a machine readable form, similar to the return from temperature sensors, M105.

If token 'S' is present without token value, enable sending filament data for all sensors. If a value is present, enable sending filament data for this extruder number.

Examples:

M409 S0 - enables sending filament data for Extruder 0 (E)

M409 S - Enable action command filament data for all filament sensors

M409 D - Disable sending filament data for all filament sensors

M500

Store parameters to file

Save all changed parameters to file.

M557

Set probe point

Set the points at which the bed will be probed to compensate for its plane being slightly out of horizontal. 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.

P = Probe point number.

X = X-coordinate

Y = Y-coordinate

Z = Z-coordinate. If missing, set to 0.

Values for X/Y/Z are in mm, regadless of current G20/G21 status.

M558

Set probe type

Example: M558 P0

where P can be

0 - Servo with Switch

1 - IR

2 - IR

3 - Proximity sensor

A Z probe may be a switch (the default) an IR proximity sensor, or some other

device. This selects which to use. P0 gives a switch. P1 gives an unmodulated

IR probe, or any other probe type that emulates an unmodulated IR probe (probe

output is an analog signal that rises with decreasing nozzle height above

the bed). If there is a control signal to the probe, it is driven high when

the probe type is P1. P2 specifies a modulated IR probe, where the modulation

is commanded directly by the main board firmware using the control signal to

the probe. P3 selects an alternative Z probe by driving the control signal to

the probe low. See also G31 and G32.

M561

Show, update or reset bed level matrix to identity

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.

Add 'S' to show the marix instead of resetting it.

Add 'U' to update the current matrix based on probe data

M562

Reset temperature fault.

Reset a temperature fault on heater/sensor If the priner has switched off and locked a heater because it has detected a fault, this will reset the fault condition and allow you to use the heater again. Obviously to be used with caution. If the fault persists it will lock out again after you have issued this command. P0 is the bed; P1 the first extruder, and so on.

M569

Set or get stepper direction

Set the direction for each axis. Use for each of the axes you want.Axis is one of X, Y, Z, E, H, A, B, C and direction is 1 or -1Note: This will store the result in the local config and restart the path planner. If no tokens are given, return the current config.

M574

Set or get end stop config

If no tokens are given, return the current end stop config. To set the end stop config:

This G-code takes one end stop, and one configuration where the configuration is which stepper motors to stop and the direction in which to stop it.

Example:

M574 X1 x_ccw

(The single space separators are required.)

This will cause the X axis to stop moving in the counter clock wise direction.

Note that this recompiles and restarts the firmware.

M608

Set stepper slave mode

Set stepper slave mode, making one stepper follow the other.

If no tokens are given, return the current setup

For each token, set the second argument as slave to the first

So M608 XY will set Y as a slave to X

If only the axis is given, no slave is set.

M665

Set delta arm calibration values

L sets the length of the arm. If the objects printed are too small, try increasing(?) the length of the arm

R sets the radius of the towers. If the measured points are too convex, try increasing the radius

M666

Set or get axis offset values

Set or get axis offset values. If no tokens are given, reuturn the current offset values.If tokens are given, set the offset value to each of the tokens given in mm.

Format: M666 offset2>

Example: 'M666 X200' sets the X-axis to have offset 200 mm.

This M-code is to set the offset, to adjust the offset, use M206

M668

Adjust backlash compensation for each named axis

Adjust backlash compensation for each named axis

M906

Set stepper current in mA

Set the stepper current. Unit is mA. Typical use is 'M906 X400'.This sets the current to 0.4A on the X stepper motor driver.Can be set for multiple stepper motor drivers at once.

M907

Set stepper current in A

Set stepper current in A

M909

Set microstepping value

Example: M909 X3 Y5 Z2 E3

Set the microstepping value for each of the steppers. In Redeem this is implemented as 2^value, so M909 X2 sets microstepping to 2^2 = 4, M909 Y3 sets microstepping to 2^3 = 8 etc.

M910

Set stepper controller decay mode

Example: M910 X3 Y5 Z2 E3Set the decay mode foreach of the steppers. In Redeem this is implementedfor Replicape rev B as a combination of CFG0, CFG4, CFG5.A value between 0 and 7 is allowed, setting the three registers to the binary value represented by CFG0, CFG4, CFG5.

CFG0 is chopper off time, the duration of slow decay phase.

CFG4 is chopper hysteresis, the tuning of zero crossing precision.

CFG5 is the chopper blank time, the dureation of banking of switching spike.

Please refer to the data sheet for further details on the configs.