Backlash cleanup (#13659)
…And save backlash, fil. sensor, ExtUI userdata to EEPROM.
This commit is contained in:
committed by
Scott Lahteine
parent
0181e57417
commit
15357af67c
@ -31,6 +31,7 @@
|
||||
#include "../../module/tool_change.h"
|
||||
#include "../../module/endstops.h"
|
||||
#include "../../feature/bedlevel/bedlevel.h"
|
||||
#include "../../feature/backlash.h"
|
||||
|
||||
|
||||
/**
|
||||
@ -55,11 +56,6 @@
|
||||
#define HAS_X_CENTER BOTH(CALIBRATION_MEASURE_LEFT, CALIBRATION_MEASURE_RIGHT)
|
||||
#define HAS_Y_CENTER BOTH(CALIBRATION_MEASURE_FRONT, CALIBRATION_MEASURE_BACK)
|
||||
|
||||
#if ENABLED(BACKLASH_GCODE)
|
||||
extern float backlash_distance_mm[], backlash_smoothing_mm;
|
||||
extern uint8_t backlash_correction;
|
||||
#endif
|
||||
|
||||
enum side_t : uint8_t { TOP, RIGHT, FRONT, LEFT, BACK, NUM_SIDES };
|
||||
|
||||
struct measurements_t {
|
||||
@ -79,13 +75,13 @@ struct measurements_t {
|
||||
#define TEMPORARY_SOFT_ENDSTOP_STATE(enable) REMEMBER(tes, soft_endstops_enabled, enable);
|
||||
|
||||
#if ENABLED(BACKLASH_GCODE)
|
||||
#define TEMPORARY_BACKLASH_CORRECTION(value) REMEMBER(tbst, backlash_correction, value)
|
||||
#define TEMPORARY_BACKLASH_CORRECTION(value) REMEMBER(tbst, backlash.correction, value)
|
||||
#else
|
||||
#define TEMPORARY_BACKLASH_CORRECTION(value)
|
||||
#endif
|
||||
|
||||
#if ENABLED(BACKLASH_GCODE) && defined(BACKLASH_SMOOTHING_MM)
|
||||
#define TEMPORARY_BACKLASH_SMOOTHING(value) REMEMBER(tbsm, backlash_smoothing_mm, value)
|
||||
#define TEMPORARY_BACKLASH_SMOOTHING(value) REMEMBER(tbsm, backlash.smoothing_mm, value)
|
||||
#else
|
||||
#define TEMPORARY_BACKLASH_SMOOTHING(value)
|
||||
#endif
|
||||
@ -454,22 +450,22 @@ inline void calibrate_backlash(measurements_t &m, const float uncertainty) {
|
||||
|
||||
#if ENABLED(BACKLASH_GCODE)
|
||||
#if HAS_X_CENTER
|
||||
backlash_distance_mm[X_AXIS] = (m.backlash[LEFT] + m.backlash[RIGHT]) / 2;
|
||||
backlash.distance_mm[X_AXIS] = (m.backlash[LEFT] + m.backlash[RIGHT]) / 2;
|
||||
#elif ENABLED(CALIBRATION_MEASURE_LEFT)
|
||||
backlash_distance_mm[X_AXIS] = m.backlash[LEFT];
|
||||
backlash.distance_mm[X_AXIS] = m.backlash[LEFT];
|
||||
#elif ENABLED(CALIBRATION_MEASURE_RIGHT)
|
||||
backlash_distance_mm[X_AXIS] = m.backlash[RIGHT];
|
||||
backlash.distance_mm[X_AXIS] = m.backlash[RIGHT];
|
||||
#endif
|
||||
|
||||
#if HAS_Y_CENTER
|
||||
backlash_distance_mm[Y_AXIS] = (m.backlash[FRONT] + m.backlash[BACK]) / 2;
|
||||
backlash.distance_mm[Y_AXIS] = (m.backlash[FRONT] + m.backlash[BACK]) / 2;
|
||||
#elif ENABLED(CALIBRATION_MEASURE_FRONT)
|
||||
backlash_distance_mm[Y_AXIS] = m.backlash[FRONT];
|
||||
backlash.distance_mm[Y_AXIS] = m.backlash[FRONT];
|
||||
#elif ENABLED(CALIBRATION_MEASURE_BACK)
|
||||
backlash_distance_mm[Y_AXIS] = m.backlash[BACK];
|
||||
backlash.distance_mm[Y_AXIS] = m.backlash[BACK];
|
||||
#endif
|
||||
|
||||
backlash_distance_mm[Z_AXIS] = m.backlash[TOP];
|
||||
backlash.distance_mm[Z_AXIS] = m.backlash[TOP];
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -24,20 +24,9 @@
|
||||
|
||||
#if ENABLED(BACKLASH_GCODE)
|
||||
|
||||
#include "../../feature/backlash.h"
|
||||
#include "../../module/planner.h"
|
||||
|
||||
float backlash_distance_mm[XYZ] = BACKLASH_DISTANCE_MM;
|
||||
uint8_t backlash_correction = BACKLASH_CORRECTION * all_on;
|
||||
|
||||
#ifdef BACKLASH_SMOOTHING_MM
|
||||
float backlash_smoothing_mm = BACKLASH_SMOOTHING_MM;
|
||||
#endif
|
||||
|
||||
#if ENABLED(MEASURE_BACKLASH_WHEN_PROBING)
|
||||
float backlash_measured_mm[XYZ] = { 0 };
|
||||
uint8_t backlash_measured_num[XYZ] = { 0 };
|
||||
#endif
|
||||
|
||||
#include "../gcode.h"
|
||||
|
||||
/**
|
||||
@ -60,59 +49,52 @@ void GcodeSuite::M425() {
|
||||
LOOP_XYZ(i) {
|
||||
if (parser.seen(axis_codes[i])) {
|
||||
planner.synchronize();
|
||||
const float measured_backlash = (
|
||||
#if ENABLED(MEASURE_BACKLASH_WHEN_PROBING)
|
||||
backlash_measured_num[i] > 0 ? backlash_measured_mm[i] / backlash_measured_num[i] : 0
|
||||
#else
|
||||
0
|
||||
#endif
|
||||
);
|
||||
backlash_distance_mm[i] = parser.has_value() ? parser.value_linear_units() : measured_backlash;
|
||||
backlash.distance_mm[i] = parser.has_value() ? parser.value_linear_units() : backlash.get_measurement(i);
|
||||
noArgs = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (parser.seen('F')) {
|
||||
planner.synchronize();
|
||||
backlash_correction = MAX(0, MIN(1.0, parser.value_float())) * all_on;
|
||||
backlash.set_correction(parser.value_float());
|
||||
noArgs = false;
|
||||
}
|
||||
|
||||
#ifdef BACKLASH_SMOOTHING_MM
|
||||
if (parser.seen('S')) {
|
||||
planner.synchronize();
|
||||
backlash_smoothing_mm = parser.value_linear_units();
|
||||
backlash.smoothing_mm = parser.value_linear_units();
|
||||
noArgs = false;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (noArgs) {
|
||||
SERIAL_ECHOPGM("Backlash correction is ");
|
||||
if (!backlash_correction) SERIAL_ECHOPGM("in");
|
||||
SERIAL_ECHOPGM("Backlash Correction ");
|
||||
if (!backlash.correction) SERIAL_ECHOPGM("in");
|
||||
SERIAL_ECHOLNPGM("active:");
|
||||
SERIAL_ECHOLNPAIR(" Correction Amount/Fade-out: F", float(ui8_to_percent(backlash_correction)) / 100, " (F1.0 = full, F0.0 = none)");
|
||||
SERIAL_ECHOLNPAIR(" Correction Amount/Fade-out: F", backlash.get_correction(), " (F1.0 = full, F0.0 = none)");
|
||||
SERIAL_ECHOPGM(" Backlash Distance (mm): ");
|
||||
LOOP_XYZ(a) {
|
||||
SERIAL_CHAR(' ');
|
||||
SERIAL_CHAR(axis_codes[a]);
|
||||
SERIAL_ECHO(backlash_distance_mm[a]);
|
||||
SERIAL_ECHO(backlash.distance_mm[a]);
|
||||
SERIAL_EOL();
|
||||
}
|
||||
|
||||
#ifdef BACKLASH_SMOOTHING_MM
|
||||
SERIAL_ECHOLNPAIR(" Smoothing (mm): S", backlash_smoothing_mm);
|
||||
SERIAL_ECHOLNPAIR(" Smoothing (mm): S", backlash.smoothing_mm);
|
||||
#endif
|
||||
|
||||
#if ENABLED(MEASURE_BACKLASH_WHEN_PROBING)
|
||||
SERIAL_ECHOPGM(" Average measured backlash (mm):");
|
||||
LOOP_XYZ(a) {
|
||||
if (backlash_measured_num[a] > 0) {
|
||||
if (backlash.has_any_measurement()) {
|
||||
LOOP_XYZ(a) if (backlash.has_measurement(a)) {
|
||||
SERIAL_CHAR(' ');
|
||||
SERIAL_CHAR(axis_codes[a]);
|
||||
SERIAL_ECHO(backlash_measured_mm[a] / backlash_measured_num[a]);
|
||||
SERIAL_ECHO(backlash.get_measurement(a));
|
||||
}
|
||||
}
|
||||
if (!backlash_measured_num[X_AXIS] && !backlash_measured_num[Y_AXIS] && !backlash_measured_num[Z_AXIS])
|
||||
else
|
||||
SERIAL_ECHOPGM(" (Not yet measured)");
|
||||
SERIAL_EOL();
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user