Back to the Gcode Dictionary
M558: Set Z probe type
M558 in RepRapFirmware 2.x and earlier
- 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). This is also the Z lift speed after probing. The corresponding axis speed limits set by M203 will be used instead if they are lower.
- 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)
- 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)
- 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:
- M558 with P parameter deletes the existing probe with that K number (if any) and creates a new Z probe. This resets the G31 values for that probe to default values.
- New optional parameter K selects the Z probe number. If there is no K parameter then 0 is used. 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 then it must be connected to the Duet 3 main board, not to a CAN-connected expansion or tool board.
- From RRF 3.3 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
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
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
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
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
For the Duet Smart Effector
M558 P8 C"zprobe.in+zprobe.mod" R0.4 F1200 ; zprobe.mod is the programming pin for M672