Back to the Gcode Dictionary
G31: Set or Report Current Probe status
- G31 Pnnn Xnnn Ynnn Znnn Cnnn Snnn
- 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 RRF3) 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.
- G31 P500 Z2.6
- G31 X16.0 Y1.5
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.
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.