|
@@ -103,7 +103,7 @@ xyz_pos_t Probe::offset; // Initialized by settings.load()
|
103
|
103
|
#endif
|
104
|
104
|
|
105
|
105
|
#if ENABLED(SENSORLESS_PROBING)
|
106
|
|
- Probe::sense_bool_t Probe::test_sensitivity;
|
|
106
|
+ Probe::sense_bool_t Probe::test_sensitivity = { true, true, true };
|
107
|
107
|
#endif
|
108
|
108
|
|
109
|
109
|
#if ENABLED(Z_PROBE_SLED)
|
|
@@ -531,12 +531,12 @@ bool Probe::probe_down_to_z(const_float_t z, const_feedRate_t fr_mm_s) {
|
531
|
531
|
#if ENABLED(SENSORLESS_PROBING)
|
532
|
532
|
sensorless_t stealth_states { false };
|
533
|
533
|
#if HAS_DELTA_SENSORLESS_PROBING
|
534
|
|
- if (test_sensitivity.x) stealth_states.x = tmc_enable_stallguard(stepperX); // Delta watches all DIAG pins for a stall
|
|
534
|
+ if (test_sensitivity.x) stealth_states.x = tmc_enable_stallguard(stepperX); // Delta watches all DIAG pins for a stall
|
535
|
535
|
if (test_sensitivity.y) stealth_states.y = tmc_enable_stallguard(stepperY);
|
536
|
536
|
#endif
|
537
|
|
- if (test_sensitivity.z) stealth_states.z = tmc_enable_stallguard(stepperZ); // All machines will check Z-DIAG for stall
|
|
537
|
+ if (test_sensitivity.z) stealth_states.z = tmc_enable_stallguard(stepperZ); // All machines will check Z-DIAG for stall
|
|
538
|
+ endstops.set_homing_current(true); // The "homing" current also applies to probing
|
538
|
539
|
endstops.enable(true);
|
539
|
|
- set_homing_current(true); // The "homing" current also applies to probing
|
540
|
540
|
#endif
|
541
|
541
|
|
542
|
542
|
TERN_(HAS_QUIET_PROBING, set_probing_paused(true));
|
|
@@ -553,6 +553,11 @@ bool Probe::probe_down_to_z(const_float_t z, const_feedRate_t fr_mm_s) {
|
553
|
553
|
#endif
|
554
|
554
|
;
|
555
|
555
|
|
|
556
|
+ // Offset sensorless probing
|
|
557
|
+ #if HAS_DELTA_SENSORLESS_PROBING
|
|
558
|
+ if (probe_triggered) probe.refresh_largest_sensorless_adj();
|
|
559
|
+ #endif
|
|
560
|
+
|
556
|
561
|
TERN_(HAS_QUIET_PROBING, set_probing_paused(false));
|
557
|
562
|
|
558
|
563
|
// Re-enable stealthChop if used. Disable diag1 pin on driver.
|
|
@@ -563,7 +568,7 @@ bool Probe::probe_down_to_z(const_float_t z, const_feedRate_t fr_mm_s) {
|
563
|
568
|
if (test_sensitivity.y) tmc_disable_stallguard(stepperY, stealth_states.y);
|
564
|
569
|
#endif
|
565
|
570
|
if (test_sensitivity.z) tmc_disable_stallguard(stepperZ, stealth_states.z);
|
566
|
|
- set_homing_current(false);
|
|
571
|
+ endstops.set_homing_current(false);
|
567
|
572
|
#endif
|
568
|
573
|
|
569
|
574
|
#if ENABLED(BLTOUCH)
|
|
@@ -666,8 +671,7 @@ float Probe::run_z_probe(const bool sanity_check/*=true*/) {
|
666
|
671
|
if (try_to_probe(PSTR("FAST"), z_probe_low_point, z_probe_fast_mm_s,
|
667
|
672
|
sanity_check, Z_CLEARANCE_BETWEEN_PROBES) ) return NAN;
|
668
|
673
|
|
669
|
|
- const float first_probe_z = current_position.z;
|
670
|
|
-
|
|
674
|
+ const float first_probe_z = DIFF_TERN(HAS_DELTA_SENSORLESS_PROBING, current_position.z, largest_sensorless_adj);
|
671
|
675
|
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("1st Probe Z:", first_probe_z);
|
672
|
676
|
|
673
|
677
|
// Raise to give the probe clearance
|
|
@@ -709,7 +713,7 @@ float Probe::run_z_probe(const bool sanity_check/*=true*/) {
|
709
|
713
|
|
710
|
714
|
TERN_(MEASURE_BACKLASH_WHEN_PROBING, backlash.measure_with_probe());
|
711
|
715
|
|
712
|
|
- const float z = current_position.z;
|
|
716
|
+ const float z = DIFF_TERN(HAS_DELTA_SENSORLESS_PROBING, current_position.z, largest_sensorless_adj);
|
713
|
717
|
|
714
|
718
|
#if EXTRA_PROBING > 0
|
715
|
719
|
// Insert Z measurement into probes[]. Keep it sorted ascending.
|
|
@@ -760,7 +764,7 @@ float Probe::run_z_probe(const bool sanity_check/*=true*/) {
|
760
|
764
|
|
761
|
765
|
#elif TOTAL_PROBING == 2
|
762
|
766
|
|
763
|
|
- const float z2 = current_position.z;
|
|
767
|
+ const float z2 = DIFF_TERN(HAS_DELTA_SENSORLESS_PROBING, current_position.z, largest_sensorless_adj);
|
764
|
768
|
|
765
|
769
|
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("2nd Probe Z:", z2, " Discrepancy:", first_probe_z - z2);
|
766
|
770
|
|
|
@@ -843,7 +847,7 @@ float Probe::probe_at_point(const_float_t rx, const_float_t ry, const ProbePtRai
|
843
|
847
|
SERIAL_ERROR_MSG(STR_ERR_PROBING_FAILED);
|
844
|
848
|
#endif
|
845
|
849
|
}
|
846
|
|
-
|
|
850
|
+ DEBUG_ECHOLNPGM("measured_z: ", measured_z);
|
847
|
851
|
return measured_z;
|
848
|
852
|
}
|
849
|
853
|
|
|
@@ -896,60 +900,39 @@ float Probe::probe_at_point(const_float_t rx, const_float_t ry, const ProbePtRai
|
896
|
900
|
}
|
897
|
901
|
|
898
|
902
|
/**
|
899
|
|
- * Change the current in the TMC drivers to N##_CURRENT_HOME. And we save the current configuration of each TMC driver.
|
|
903
|
+ * Set the sensorless Z offset
|
900
|
904
|
*/
|
901
|
|
- void Probe::set_homing_current(const bool onoff) {
|
902
|
|
- #define _defined(N) defined(N)
|
903
|
|
- #define HAS_CURRENT_HOME(N) (N##_CURRENT_HOME > 0 && N##_CURRENT_HOME != N##_CURRENT)
|
904
|
|
- #define _HOME_ELEM(N) HAS_CURRENT_HOME(N) ||
|
905
|
|
- #if MAIN_AXIS_MAP(_HOME_ELEM) 0
|
906
|
|
- #if ENABLED(DELTA)
|
907
|
|
- static int16_t saved_current_X, saved_current_Y;
|
908
|
|
- #endif
|
909
|
|
- #if HAS_CURRENT_HOME(Z)
|
910
|
|
- static int16_t saved_current_Z;
|
|
905
|
+ void Probe::set_offset_sensorless_adj(const_float_t sz) {
|
|
906
|
+ #if ENABLED(SENSORLESS_PROBING)
|
|
907
|
+ DEBUG_SECTION(pso, "Probe::set_offset_sensorless_adj", true);
|
|
908
|
+ #if HAS_DELTA_SENSORLESS_PROBING
|
|
909
|
+ if (test_sensitivity.x) offset_sensorless_adj.a = sz;
|
|
910
|
+ if (test_sensitivity.y) offset_sensorless_adj.b = sz;
|
911
|
911
|
#endif
|
912
|
|
- #if ((ENABLED(DELTA) && (HAS_CURRENT_HOME(X) || HAS_CURRENT_HOME(Y))) || HAS_CURRENT_HOME(Z))
|
913
|
|
- auto debug_current_on = [](PGM_P const s, const int16_t a, const int16_t b) {
|
914
|
|
- if (DEBUGGING(LEVELING)) { DEBUG_ECHOPGM_P(s); DEBUG_ECHOLNPGM(" current: ", a, " -> ", b); }
|
915
|
|
- };
|
|
912
|
+ if (test_sensitivity.z) offset_sensorless_adj.c = sz;
|
|
913
|
+ #endif
|
|
914
|
+ }
|
|
915
|
+
|
|
916
|
+ /**
|
|
917
|
+ * Refresh largest_sensorless_adj based on triggered endstops
|
|
918
|
+ */
|
|
919
|
+ void Probe::refresh_largest_sensorless_adj() {
|
|
920
|
+ #if ENABLED(SENSORLESS_PROBING)
|
|
921
|
+ DEBUG_SECTION(rso, "Probe::refresh_largest_sensorless_adj", true);
|
|
922
|
+ largest_sensorless_adj = -3; // A reference away from any real probe height
|
|
923
|
+ #if HAS_DELTA_SENSORLESS_PROBING
|
|
924
|
+ if (TEST(endstops.state(), X_MAX)) {
|
|
925
|
+ NOLESS(largest_sensorless_adj, offset_sensorless_adj.a);
|
|
926
|
+ DEBUG_ECHOLNPGM("Endstop_X: ", largest_sensorless_adj, " TowerX");
|
|
927
|
+ }
|
|
928
|
+ if (TEST(endstops.state(), Y_MAX)) {
|
|
929
|
+ NOLESS(largest_sensorless_adj, offset_sensorless_adj.b);
|
|
930
|
+ DEBUG_ECHOLNPGM("Endstop_Y: ", largest_sensorless_adj, " TowerY");
|
|
931
|
+ }
|
916
|
932
|
#endif
|
917
|
|
- if (onoff) {
|
918
|
|
- #if ENABLED(DELTA)
|
919
|
|
- #if HAS_CURRENT_HOME(X)
|
920
|
|
- saved_current_X = stepperX.getMilliamps();
|
921
|
|
- stepperX.rms_current(X_CURRENT_HOME);
|
922
|
|
- debug_current_on(PSTR("X"), saved_current_X, X_CURRENT_HOME);
|
923
|
|
- #endif
|
924
|
|
- #if HAS_CURRENT_HOME(Y)
|
925
|
|
- saved_current_Y = stepperY.getMilliamps();
|
926
|
|
- stepperY.rms_current(Y_CURRENT_HOME);
|
927
|
|
- debug_current_on(PSTR("Y"), saved_current_Y, Y_CURRENT_HOME);
|
928
|
|
- #endif
|
929
|
|
- #endif
|
930
|
|
- #if HAS_CURRENT_HOME(Z)
|
931
|
|
- saved_current_Z = stepperZ.getMilliamps();
|
932
|
|
- stepperZ.rms_current(Z_CURRENT_HOME);
|
933
|
|
- debug_current_on(PSTR("Z"), saved_current_Z, Z_CURRENT_HOME);
|
934
|
|
- #endif
|
935
|
|
- TERN_(IMPROVE_HOMING_RELIABILITY, planner.enable_stall_prevention(true));
|
936
|
|
- }
|
937
|
|
- else {
|
938
|
|
- #if ENABLED(DELTA)
|
939
|
|
- #if HAS_CURRENT_HOME(X)
|
940
|
|
- stepperX.rms_current(saved_current_X);
|
941
|
|
- debug_current_on(PSTR("X"), X_CURRENT_HOME, saved_current_X);
|
942
|
|
- #endif
|
943
|
|
- #if HAS_CURRENT_HOME(Y)
|
944
|
|
- stepperY.rms_current(saved_current_Y);
|
945
|
|
- debug_current_on(PSTR("Y"), Y_CURRENT_HOME, saved_current_Y);
|
946
|
|
- #endif
|
947
|
|
- #endif
|
948
|
|
- #if HAS_CURRENT_HOME(Z)
|
949
|
|
- stepperZ.rms_current(saved_current_Z);
|
950
|
|
- debug_current_on(PSTR("Z"), Z_CURRENT_HOME, saved_current_Z);
|
951
|
|
- #endif
|
952
|
|
- TERN_(IMPROVE_HOMING_RELIABILITY, planner.enable_stall_prevention(false));
|
|
933
|
+ if (TEST(endstops.state(), Z_MAX)) {
|
|
934
|
+ NOLESS(largest_sensorless_adj, offset_sensorless_adj.c);
|
|
935
|
+ DEBUG_ECHOLNPGM("Endstop_Z: ", largest_sensorless_adj, " TowerZ");
|
953
|
936
|
}
|
954
|
937
|
#endif
|
955
|
938
|
}
|