@hbrownell said in Bed leveling dual Z motor programming:
... Here is the bed.g code
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)
...
if you dont use a bl touch remove the M402
; Drives
M569 P0 S0 ; Physical drive 0 goes Backwards
M569 P1 S0 ; Physical drive 1 goes Backwards
M569 P2 S1 ; Physical drive 2 goes forwards
M569 P3 S0 ; Physical drive 3 goes forwards
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
M350 X16 Y16 Z16 E16 I1 ; Configure microstepping with interpolation
DO I NEED TO CALIBRATE EACH STEPPER MOTOR INDEPENDENTLY?
M92 X99.9 Y100.1 Z399.6183 E100 ; Set steps per mm
M566 X900.00 Y900.00 Z12.00 E120.00 ; Set maximum instantaneous speed changes (mm/min)
M203 X6000.00 Y6000.00 Z4000.00 E1200.00 ; Set maximum speeds (mm/min)
M201 X500.00 Y500.00 Z20.00 E250.00 ; Set accelerations (mm/s^2)
M906 X1100.00 Y1100.00 Z1100.00 E1100.00 I30 ; Set motor currents (mA) and motor idle factor in per cent
M84 S30 ; Set idle timeout
; Axis Limits
M208 X0 Y0 Z0 S1 ; Set axis minima
M208 X210 Y210 Z200 S0 ; Set axis maxima
M208 X-5:205 Y0:200 ; X carriage moves from -5 to 205, Y bed goes from 0 to 200
; Endstops
M574 X1 Y1 S1 ; Set active high endstops
; Z-Probe
M574 Z1 S2 ; Set endstops controlled by probe
M307 H3 A-1 C-1 D-1 ; Disable heater on PWM channel for BLTouch
M558 P9 H5 F120 T6000 ; Set Z probe type to bltouch and the dive height + speeds
G31 P500 X34.82 Y-8 Z0.073 ; Set Z probe trigger value, offset and trigger height
M557 X0:200 Y15:200 S50 ; Define mesh grid
; Heaters
M305 P0 T100000 B4138 R4700 ; Set thermistor + ADC parameters for heater 0
M143 H0 S120 ; Set temperature limit for heater 0 to 120C
M305 P1 T100000 B4725 C7.060000e-8 R4700 ; Set thermistor + ADC parameters for heater 1
M143 H1 S280 ; Set temperature limit for heater 1 to 280C
; Fans
M106 P0 S0 I0 F500 H T45 ; Set fan 0 value, PWM signal inversion and frequency. Thermostatic control is turned on
M106 P1 S1 I0 F500 H1 T45 ; Set fan 1 value, PWM signal inversion and frequency. Thermostatic control is turned on
; Tools
M563 P0 D0 H1 ; Define tool 0
G10 P0 X0 Y0 Z0 ; Set tool 0 axis offsets
G10 P0 R0 S0 ; Set initial tool 0 active and standby temperatures to 0C
; Automatic saving after power loss is not enabled
; Custom settings are not configured
; Miscellaneous
M501 ; Load saved parameters from non-volatile memory