Improved homing macros
-
Morning all!
Just thought I'd share a macro that has saved me a lot of time since implementing it. It's for homing x and y taking advantage of the axis measuring feature to detect if sensorless homing on any axis was bad (triggered too early). I use sensorless homing on a CoreXY and it can be a bit finicky over time and sometimes give me vastly incorrect homing. With these new homing macros for X and Y, both axes are measured and compared to their set length. It's likely not going to be a drop-in replacement for your own machines, but perhaps something similar could be useful.
Normal homing behaviour for me:
- Bump Xmax
- Bump Ymax
- Wait at Xmax, Ymax to proceed with other start gcode
New homing behaviour:
- Bump Xmin
- Measure distance to Xmax. If shorter than expected (aka bump Xmin triggered too early, or travel to Xmax stopped too early), abort if unable to home after n retries
- Bump Ymin
- Measure distance to Y max. If shorter than expected (aka bump Ymin triggered too early, or travel to Ymax stopped too early), abort if unable to home after n retries
One note to add is that this of course requires either an endstop at both min and max of both axis, or something to bump against at both ends if using sensorless. This meant for me I had to add something to bump against at Ymin, otherwise my print head would be the first thing to crash into the front of my corexy.
Hope it's useful!
(note, comments in the code are outdated so take them with a pinch of salt)
; homex.g ; called to home the X axis ;G1 Xnnn Ynnn Znnn H0 Ignore endstops while moving. ;G1 Xnnn Ynnn Znnn H1 Sense endstops while moving (ignoring the axis limits). ;G1 Xnnn Ynnn Znnn H2 Ignore endstops while moving. Also ignore if axis has not been homed. On Delta and Core XY, axis letters refer to individual towers. ;G1 Xnnn Ynnn Znnn H3 Sense endstops while measuring axis length, setting the appropriate M208 limit to the measured position at which the endstop switch triggers. M400 ; Make sure everything stops var x_backoff = 10 var x_max = move.axes[0].max var x_min = move.axes[0].min var x_length = var.x_max - var.x_min M566 X50.00 Y50.00 ; Set maximum instantaneous speed changes (mm/min) M201 X500.00 Y500.00 ; Set accelerations (mm/s^2) M913 X50 Y50 ; Set current for X axis to 60% of normal value M915 X Y S2 ; 0 is too sensitive, 4 isnt sensitive enough. G91 ; relative positioning G1 H2 Z5 F{60*60} ; Lift Z a little. while true if iterations = 20 M18 X G1 H2 Z-5 F{60*60} ; lower Z again G90 ; absolute positioning M913 X100 Y100 ; Reset motor currents M98 P"0:/macros/Parameters" abort "Too many auto calibration attempts" M574 X1 S4 ; Set endstop configuration: low end on X (1), single motor load detection (3) G1 H1 X-999 F{60*60} ; Move to X_min G1 H0 X{var.x_backoff} F{60*60} ; Back off a little M574 X2 S4 ; Set endstop configuration: low end on X (1), single motor load detection (3) G1 H3 X999 F{60*60} ; Move to X_max, set x measured length G1 H0 X{-var.x_backoff} F{60*60} ; Back off a little var x_measured_length = move.axes[0].max - move.axes[0].min echo {"Set length: " ^ var.x_length ^ "mm"} echo {"Measured length: " ^ var.x_measured_length ^ "mm"} M208 X{var.x_min}:{var.x_max} if var.x_measured_length >= var.x_length G92 X{var.x_max-var.x_backoff} break echo "Repeating homing, axis length is too low. Measured (" ^ var.x_measured_length ^ "mm) < Set (" ^ var.x_length ^ "mm)" G4 S1 echo "X Homing Successful" G1 H2 Z-5 F{60*60} ; lower Z again G90 ; absolute positioning M913 X100 Y100 ; Reset motor currents M98 P"0:/macros/Parameters"
; homey.g ; called to home the Y axis ;G1 Xnnn Ynnn Znnn H0 Ignore endstops while moving. ;G1 Xnnn Ynnn Znnn H1 Sense endstops while moving (ignoring the axis limits). ;G1 Xnnn Ynnn Znnn H2 Ignore endstops while moving. Also ignore if axis has not been homed. On Delta and Core XY, axis letters refer to individual towers. ;G1 Xnnn Ynnn Znnn H3 Sense endstops while measuring axis length, setting the appropriate M208 limit to the measured position at which the endstop switch triggers. M400 ; Make sure everything stops var y_backoff = 10 var y_max = move.axes[1].max var y_min = move.axes[1].min var y_length = var.y_max - var.y_min M566 X50.00 Y50.00 ; Set maximum instantaneous speed changes (mm/min) M201 X500.00 Y500.00 ; Set accelerations (mm/s^2) M913 X50 Y50 ; Set current for X axis to 60% of normal value M915 X Y S2 ; 0 is too sensitive, 4 isnt sensitive enough. G91 ; relative positioning G1 H2 Z5 F{60*60} ; Lift Z a little. while true if iterations = 20 M18 Y G1 H2 Z-5 F{60*60} ; lower Z again G90 ; absolute positioning M913 X100 Y100 ; Reset motor currents M98 P"0:/macros/Parameters" abort "Too many auto calibration attempts" M574 Y1 S4 ; Set endstop configuration: low end on X (1), single motor load detection (3) G1 H1 Y-999 F{60*60} ; Move to X_min G1 H0 Y{var.y_backoff} F{60*60} ; Back off a little M574 Y2 S4 ; Set endstop configuration: low end on X (1), single motor load detection (3) G1 H3 Y999 F{60*60} ; Move to X_max, set x measured length G1 H0 Y{-var.y_backoff} F{60*60} ; Back off a little var y_measured_length = move.axes[1].max - move.axes[1].min echo {"Set length: " ^ var.y_length ^ "mm"} echo {"Measured length: " ^ var.y_measured_length ^ "mm"} M208 Y{var.y_min}:{var.y_max} if var.y_measured_length >= var.y_length G92 Y{var.y_max-var.y_backoff} break echo "Repeating homing, axis length is too low. Measured (" ^ var.y_measured_length ^ "mm) < Set (" ^ var.y_length ^ "mm)" G4 S1 echo "Y Homing Successful" G1 H2 Z-5 F{60*60} ; lower Z again G90 ; absolute positioning M913 X100 Y100 ; Reset motor currents M98 P"0:/macros/Parameters"
-
@ww1g16
That's a good thing to have, but I thought, we'd have to home XY at once for a CoreXY?
Another thing is the 'backoff' move. Shouldn't you increase the motorcurrent first, to make sure this move doesn't cause an error?
Why do you abort the macro? Instead increase motorcurrent on every iteration, until it is high enough.