Below are 2 versions of modified block from Distortion.cpp file. The 1st version implements optimized, zig-zag shaped movement that starts from Xmin/Ymin. The directions of the movement are consistent with the movements performed after executing G32. The 2nd version implements zig-zag shaped movement, but keeps existing staring point at Xmin/Ymax. My personal preference would be to stay consistent, but it is up to developers to decide which option to pick (if any). Below snippets of the code replace the following block of lines.
Replace these lines:
for (iy = DISTORTION_CORRECTION_POINTS - 1; iy >= 0; iy--)
for (ix = 0; ix < DISTORTION_CORRECTION_POINTS; ix++) {
#if (DRIVE_SYSTEM == DELTA) && DISTORTION_EXTRAPOLATE_CORNERS
if (isCorner(ix, iy)) continue;
#endif
#if DRIVE_SYSTEM == DELTA
float mtx = Printer::invAxisStepsPerMM[X_AXIS] * (ix * step - radiusCorrectionSteps);
float mty = Printer::invAxisStepsPerMM[Y_AXIS] * (iy * step - radiusCorrectionSteps);
#else
float mtx = Printer::invAxisStepsPerMM[X_AXIS] * (ix * xCorrectionSteps + xOffsetSteps);
float mty = Printer::invAxisStepsPerMM[Y_AXIS] * (iy * yCorrectionSteps + yOffsetSteps);
#endif
//Com::printF(PSTR("mx "),mtx);
//Com::printF(PSTR("my "),mty);
//Com::printF(PSTR("ix "),(int)ix);
//Com::printFLN(PSTR("iy "),(int)iy);
Printer::moveToReal(mtx, mty, z, IGNORE_COORDINATE, EEPROM::zProbeXYSpeed());
float zp = Printer::runZProbe(false, false, Z_PROBE_REPETITIONS);
#if defined(DISTORTION_LIMIT_TO) && DISTORTION_LIMIT_TO != 0
if(zp == ILLEGAL_Z_PROBE
fabs(z - zp + zCorrection * Printer::invAxisStepsPerMM[Z_AXIS]) > DISTORTION_LIMIT_TO) {
#else
if(zp == ILLEGAL_Z_PROBE) {
#endif
Com::printErrorFLN(PSTR("Stopping distortion measurement due to errors."));
Printer::finishProbing();
return false;
}
setMatrix(floor(0.5f + Printer::axisStepsPerMM[Z_AXIS] * (z - zp)) + zCorrection,
matrixIndex(ix, iy));
}Option 1 (starting point Xmin/Ymin):
int iydir = 1; // 1 if moving towards increasing Y, -1 when in opposite direction
for(int ix = 0; ix < DISTORTION_CORRECTION_POINTS; ix++) {
if (iydir == 1) {
iy = 0;
} else {
iy = DISTORTION_CORRECTION_POINTS - 1;
}
while ((iydir == 1 && iy < DISTORTION_CORRECTION_POINTS) || (iydir == -1 && iy >= 0)) {
#if (DRIVE_SYSTEM == DELTA) && DISTORTION_EXTRAPOLATE_CORNERS
if (isCorner(ix, iy)) continue;
#endif
#if DRIVE_SYSTEM == DELTA
float mtx = Printer::invAxisStepsPerMM[X_AXIS] * (ix * step - radiusCorrectionSteps);
float mty = Printer::invAxisStepsPerMM[Y_AXIS] * (iy * step - radiusCorrectionSteps);
#else
float mtx = Printer::invAxisStepsPerMM[X_AXIS] * (ix * xCorrectionSteps + xOffsetSteps);
float mty = Printer::invAxisStepsPerMM[Y_AXIS] * (iy * yCorrectionSteps + yOffsetSteps);
#endif
//Com::printF(PSTR("mx "),mtx);
//Com::printF(PSTR("my "),mty);
//Com::printF(PSTR("ix "),(int)ix);
//Com::printFLN(PSTR("iy "),(int)iy);
Printer::moveToReal(mtx, mty, z, IGNORE_COORDINATE, EEPROM::zProbeXYSpeed());
float zp = Printer::runZProbe(false, false, Z_PROBE_REPETITIONS);
#if defined(DISTORTION_LIMIT_TO) && DISTORTION_LIMIT_TO != 0
if(zp == ILLEGAL_Z_PROBE
fabs(z - zp + zCorrection * Printer::invAxisStepsPerMM[Z_AXIS]) > DISTORTION_LIMIT_TO) {
#else
if(zp == ILLEGAL_Z_PROBE) {
#endif
Com::printErrorFLN(PSTR("Stopping distortion measurement due to errors."));
Printer::finishProbing();
return false;
}
setMatrix(floor(0.5f + Printer::axisStepsPerMM[Z_AXIS] * (z - zp)) + zCorrection,
matrixIndex(ix, iy));
iy += iydir;
}
iydir = -iydir;
}
Option 2 (starting point Xmin/Ymax):
int ixdir = 1; // 1 if moving towards increasing X, -1 when in opposite direction
for(int iy = DISTORTION_CORRECTION_POINTS -1; iy >= 0; iy--) {
if (ixdir == 1) {
ix = 0;
} else {
ix = DISTORTION_CORRECTION_POINTS - 1;
}
while ((ixdir == 1 && ix < DISTORTION_CORRECTION_POINTS) || (ixdir == -1 && ix >= 0)) {
#if (DRIVE_SYSTEM == DELTA) && DISTORTION_EXTRAPOLATE_CORNERS
if (isCorner(ix, iy)) continue;
#endif
#if DRIVE_SYSTEM == DELTA
float mtx = Printer::invAxisStepsPerMM[X_AXIS] * (ix * step - radiusCorrectionSteps);
float mty = Printer::invAxisStepsPerMM[Y_AXIS] * (iy * step - radiusCorrectionSteps);
#else
float mtx = Printer::invAxisStepsPerMM[X_AXIS] * (ix * xCorrectionSteps + xOffsetSteps);
float mty = Printer::invAxisStepsPerMM[Y_AXIS] * (iy * yCorrectionSteps + yOffsetSteps);
#endif
//Com::printF(PSTR("mx "),mtx);
//Com::printF(PSTR("my "),mty);
//Com::printF(PSTR("ix "),(int)ix);
//Com::printFLN(PSTR("iy "),(int)iy);
Printer::moveToReal(mtx, mty, z, IGNORE_COORDINATE, EEPROM::zProbeXYSpeed());
float zp = Printer::runZProbe(false, false, Z_PROBE_REPETITIONS);
#if defined(DISTORTION_LIMIT_TO) && DISTORTION_LIMIT_TO != 0
if(zp == ILLEGAL_Z_PROBE || fabs(z - zp + zCorrection * Printer::invAxisStepsPerMM[Z_AXIS]) > DISTORTION_LIMIT_TO) {
#else
if(zp == ILLEGAL_Z_PROBE) {
#endif
Com::printErrorFLN(PSTR("Stopping distortion measurement due to errors."));
Printer::finishProbing();
return false;
}
setMatrix(floor(0.5f + Printer::axisStepsPerMM[Z_AXIS] * (z - zp)) + zCorrection,
matrixIndex(ix, iy));
ix += ixdir;
}
ixdir = -ixdir;
}
Both versions of the code were successfully tested on CoreXY printer.
Finally, here is time-lapse video showing the sequence of G32 S2 and G33 commands running on my printer after implementing these changes https://www.youtube.com/watch?v=ChvEcDOx-rE
Thanks