Mesh bed compensation (MBC) allows the printer adjust the nozzle height during printing to compensate for an uneven bed or for sag in the gantry.
Mesh bed compensation works like this:
The Z probe trigger height must not vary significantly with XY position. Measure the trigger height of your Z probe at various XY positions and make sure it is consistent. To measure the trigger height:
On a delta printer, it can be quite hard to achieve a consistent trigger height. Z probes that are mounted on the effector are sensitive to any tilting of the effector, because it affects the relative heights of the Z probe and the nozzle. You can reduce this effect by mounting the probe as close to the nozzle as possible. Probing solutions that use the nozzle itself as the probe are usually not affected by effector tilt, but some types are sensitive to the XY position of the nozzle for other reasons.
Once you are satisfied with your trigger height result (should be between 0 and 4mm, depending on your printer), open your config.g file (this can be found in your DuetWebControl), find the G31 command and enter your trigger height in the Z parameter (ex. G31 X0 Y0 Z1.3).
Use the M557 command to define the spacing of the mesh that you want to set up, and either the X and Y limits or (for a delta printer) the probing radius.
Example for a Cartesian or CoreXY printer:
M557 X10:190 Y10:190 S20 ; probe from X=10 to 190, Y=10 to 190mm with a mesh spacing of 20mm
Example for a delta printer:
M557 R130 S20 ; probe within a radius of 130mm from the centre with a mesh spacing of 20mm
There is a firmware-dependent limit of 441 in RRF 3.4 (971 for 6HC/6XD in RRF 3.5) on the number probe points allowed. If you exceed that limit, an error message will be returned when you run the M557 command, and you should increase the mesh spacing (S parameter) to reduce the number of probe points.
Using a small number of points (ie. 9) is akin to using the older style simple planar correction.
From RRF 3.5, for Duet 3 mainboards, RepRapFirmware now supports selective probing using G29 S4
. This allows you to skip specific probe points defined by the mesh, for example to miss out points where there are holes, or if your probe is affected by magnets in certain places. RRF will interpolate the missing points.
To do this, the probe points file (default /sys/probePoints.csv) needs to be manually created, then activated:
/sys/probePoints.csv
. The format of a probe points file is similar to a height map file except for the following:G29 S4
command, eg G29 S4 P"probePoints.csv"
, to activate the probe points file.G29 S0
is called subsequently, the grid definition defined in the probe points file is used instead of the grid defined by M557, and reachable points are probed or not as indicated in the file.For this M557:
M557 X-85:85 Y-85:85 P5 ; 5x5 grid, origin at centre
where 9 probe points are over magnets, an example probePoints.csv file would be:
RepRapFirmware probe points file v2
axis0,axis1,min0,max0,min1,max1,radius,spacing0,spacing1,num0,num1
X,Y,-85.00,85.00,-85.00,85.00,-1.00,42.50,42.50,5,5
0, 1, 0, 1, 0
1, 1, 1, 1, 1
0, 1, 0, 1, 0
1, 1, 1, 1, 1
0, 1, 0, 1, 0
Before you probe the bed using G29 S0, you must establish a Z=0 datum using the Z probe. This must be done at the same temperatures that you use when probing the bed. It's normally best to probe with the bed and extruder at printing temperatures. If you are using a nozzle-contact Z probe and the bed surface might be damaged by a nozzle at full printing temperature, use a slightly lower nozzle temperature instead. So preheat the bed and hot end. Once the bed and nozzle are up to temperature, establish a Z=0 datum by one of the following methods:
Note, whichever of these techniques you use, you must do exactly the same any time you want to use G29 S1 to reload the height map.
Use the command G29 (or G29 S0) to run the probing sequence. All points in the mesh that are reachable by the probe will be probed. When probing is complete, a message will be returned indicating whether or not it was successful. if it was successful, the height map will also be saved on the SD card.
Multiple heightmaps can be saved with unique names using G29 S3 P"filename.csv". The heightmap can then be loaded at a later time with G29 S1 P"filename.csv". G29 S1 will load the default "heightmap.csv"
If you sent the G29 command from Duet Web Control, it should display the height map automatically. Otherwise you can view the height map in Duet Web Control by right-clicking the arrow next to the Auto Bed Compensation or Auto Delta Calibration button and selecting "Show Mesh Grid Heightmap" from the drop-down menu.
The height map file is normally called /sys/heightmap.csv but you can specify a different filename in G29, M374 and M375 commands. You can view, edit or download it using the System Editor tab in Duet Web Control.
Running G32 to auto calibrate a delta printer or to adjust leadscrews to level the bed will clear the local height map info (but not the copy in heightmap.csv). Therefore, if you wish to use both auto calibration/leadscrew bed levelling and mesh bed compensation, you must run G32 before you run G29, not after. You can include a G29 S0 or G29 S1 command at the end of your bed.g file if you wish.
Multiple heightmaps can be saved with unique names using G29 S3 P"filename.csv". The heightmap can then be loaded at a later time with G29 S1 P"filename.csv". G29 S1 will load the default "heightmap.csv"
Do not use G29 S1 within config.g, because no Z=0 datum has been established at that point. If you wish to load the height map automatically, here are some options:
If you get jerky movements when the head moves across the bed at speed with mesh bed levelling enabled, but not with it disabled, this indicates that your Z jerk setting is too low for the travel speed you are using and the amount of compensation needed. Increase the Z parameter in the M566 command in config.g, or use a lower travel speed.
If the heightmap.csv file contains a column of zeros at the start or the end, this indicates that the corresponding X coordinate was not reachable by the probe, taking account of the bed size specified in the M665 command on a delta printer or the M208 commands for other printers, and the probe offset specified by the X and Y parameters in the G31 command. Similarly, if there is a row of zeros then the corresponding Y coordinate was not reachable.
If you are manually editing heightmap.csv note that the firmware uses 0.0 to mean zero height error and 0 to mean that the point was not probed so the height error needs to be extrapolated.