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
- You must have a bed probe that can probe at points near the Z leadscrews.
- Each Z motor must be driven from a separate stepper motor output on the Duet + optional DueX expansion board, or Maestro + 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.
- Note: If you are experiencing the Z axis compensating in the opposite direction needed, that means your Z motors are swapped. You can either swap the X values in the M671 command, or swap the stepper motors plugged into the Duet.
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.
Axis levelling using endstops
If you have an axis with more than one motor (doesn't have to be Z, can be X, Y or any other multi-motor axis), with each motor connected to a separate motor driver on the Duet, and each motor has an associated endstop, you can home each motor individually to level the axis.
In RepRapFirmware 2
To do this in RepRapFirmware 2, see Independent Z motors and endstop switches in RRF2 for an example of Z axis levelling. This can be applied to other axes, if necessary.
In RepRapFirmware 3
In RepRapFirmware 3, you do not need to split the axes to level them, as you do in RRF2. The firmware understands if you define the axis endstops correctly. For example, if you have a dual motor Z axis, with endstops at the axis minimum, define the Z endstop in config.g as follows:
M574 Z1 S1 P"zstop+e1stop" ; configure active-high endstops for low end on Z via pins zstop and e1stop
Make sure that the two endstops are defined in the same order in the M574 command as the corresponding Z motors in your M584 command. For the example above, M584 Z2:4 would be correct, assuming one Z motor is plugged into driver 2 (Z driver on Duet 2) and its endstop is plugged into zstop, while the second Z motor is plugged into driver 4 (E1 driver on Duet 2) and its endstop is plugged into the E1 endstop pins.
When homing, RRF3 will home both axes, and stop each motor when each endstop is triggered. Note that DWC and M119 will only show one endstop per axis, but will show the axis endstop as triggered if either switch is triggered. So you can test them by triggering one at a time.