Bed levelling using multiple independent Z motors
On a printer which uses two or more Z motors to raise/lower the bed or gantry, you can have the firmware probe the bed and adjust the motors individually to eliminate tilt. This feature is implemented in firmware version 1.19 and later.
- You must have a bed or gantry that is raised/lowered by two, three or four leadscrews or similar, where each one is driven by its own Z motor
- Each Z motor must be driven from a separate stepper motor output on the Duet + optional DueX expansion board
- As usual with this arrangement, you must use M584 to assign the 2, 3 or 4 drivers to the Z axis
- You must use the M671 command to define the X and Y coordinates of the leadscrews. The M671 command must come after the M584 command and must specify the same number of X and Y coordinates as the number of motors assigned to the Z axis in the M584 command; and these coordinates must be in the same order as the driver numbers of the associated motors in the M584 command. The M671 command must also come after any M667 or M669 command.
- You can optionally specify a maximum correction per leadscrew in the M671 command (S parameter). If you don't, it defaults to 1mm.
- You must set up a bed.g file in the usual way with at least as many probe points as Z motors. You can have more if you wish.
- The value of the S parameter on the final G30 command in bed.g must equal the number of Z motors.
How it works
A valid M671 command enables auto calibration of the Z motors. When you run G32 to perform bed probing, the final G30 command (the one with the S parameter) in bed.g will then cause auto calibration to be performed. The auto calibration uses a least squares algorithm that minimises the sum of the height errors. The deviation before and expected deviation after calibration is reported.
If you have two Z motors, the calibration process adjusts the bed tilt along a line between the two leadscrew positions, on the assumption that the tilt at right angles to this will not change. With three motors, it adjusts the tilt in both directions. With four motors, it adjusts the tilt in both directions and also the twist. You should not use 4 leadscrews with a bed that is rigid enough to resist twisting strongly.
You can run G32 again to repeat the process if you wish.
If your bed is not perfectly flat or the gantry sags a little when the head is over the middle of the bed, the process will cause a small shift in the Z=0 position. To correct this, if you are using the Z probe to do Z homing, you can just re-home Z at the end of your bed.g file.
- If you have 3 or 4 Z motors, in bed.g use at least one probe point close to each leadscrew.
- If you have just 2 Z motors, one at each end of the X axis, then set the Y coordinates of the leadscrews in the M671 command to be equal (the value doesn't matter, so you can use zero). Use at least two probe points, one at each end of the X axis. All your probe points should have the same Y coordinate, which should be at or near the middle of the printable range.
Example for 2 motors
... M584 X0 Y1 Z2:4 E3; two Z motors connected to driver outputs Z and E1 M671 X-20:220 Y0:0 S0.5 ; leadscrews at left (connected to Z) and right (connected to E1) of X axis M208 X-5:205 Y0:200 ; X carriage moves from -5 to 205, Y bed goes from 0 to 200 ...
G28 ; home M401 ; deploy Z probe (omit if using bltouch) G30 P0 X20 Y100 Z-99999 ; probe near a leadscrew, half way along Y axis G30 P1 X180 Y100 Z-99999 S2 ; probe near a leadscrew and calibrate 2 motors M402 ; retract probe (omit if using bltouch)
Example for 3 motors
... M584 X0 Y1 Z2:5:6 E4; three Z motors connected to driver outputs 2, 5 and 6 M671 X-15:100:215 Y190:-10:190 S0.5 ; leadscrews at rear left, front middle and rear right ...
G28 ; home M401 ; deploy Z probe (omit if using bltouch) G30 P0 X20 Y190 Z-99999 ; probe near a leadscrew G30 P1 X180 Y190 Z-99999 ; probe near a leadscrew G30 P2 X100 Y10 Z-99999 S3 ; probe near a leadscrew and calibrate 3 motors M402 ; retract probe (omit if using bltouch)
Note on M584 from examples above
VERY IMPORTANT! Assigning a drive using M584 does not remove its old assignment. Therefore, if you assign a drive that defaults to being an extruder drive, you should also assign the extruder drives explicitly as in the above example. Failure to do so may result in unexpected behaviour.
If you have more than one Z motor, each connected to separate motor driver on the Duet, and each motor has an associated endstop, you can home each motor individually. See Independent Z motors and endstop switches for an example.