Browse Source

Merge pull request #4356 from thinkyhead/rc_simpler_run_z_probe

Unify run_z_probe
Scott Lahteine 9 years ago
parent
commit
194d9521c3

+ 4
- 0
Marlin/Configuration.h View File

@@ -499,6 +499,10 @@
499 499
 
500 500
 // X and Y axis travel speed (mm/m) between probes
501 501
 #define XY_PROBE_SPEED 8000
502
+// Speed for the first approach when probing
503
+#define Z_PROBE_SPEED_FAST HOMING_FEEDRATE_Z
504
+// Speed for the second approach when probing
505
+#define Z_PROBE_SPEED_SLOW (Z_PROBE_SPEED_FAST / 2)
502 506
 
503 507
 //
504 508
 // Allen Key Probe is defined in the Delta example configurations.

+ 26
- 77
Marlin/Marlin_main.cpp View File

@@ -1591,7 +1591,7 @@ static void set_axis_is_at_home(AxisEnum axis) {
1591 1591
 /**
1592 1592
  * Some planner shorthand inline functions
1593 1593
  */
1594
-inline float set_homing_bump_feedrate(AxisEnum axis) {
1594
+inline float get_homing_bump_feedrate(AxisEnum axis) {
1595 1595
   const int homing_bump_divisor[] = HOMING_BUMP_DIVISOR;
1596 1596
   int hbd = homing_bump_divisor[axis];
1597 1597
   if (hbd < 1) {
@@ -1599,8 +1599,7 @@ inline float set_homing_bump_feedrate(AxisEnum axis) {
1599 1599
     SERIAL_ECHO_START;
1600 1600
     SERIAL_ECHOLNPGM("Warning: Homing Bump Divisor < 1");
1601 1601
   }
1602
-  feedrate_mm_m = homing_feedrate_mm_m[axis] / hbd;
1603
-  return feedrate_mm_m;
1602
+  return homing_feedrate_mm_m[axis] / hbd;
1604 1603
 }
1605 1604
 //
1606 1605
 // line_to_current_position
@@ -1620,7 +1619,7 @@ inline void line_to_axis_pos(AxisEnum axis, float where, float fr_mm_m = 0.0) {
1620 1619
   current_position[axis] = where;
1621 1620
   feedrate_mm_m = (fr_mm_m != 0.0) ? fr_mm_m : homing_feedrate_mm_m[axis];
1622 1621
   planner.buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], MMM_TO_MMS(feedrate_mm_m), active_extruder);
1623
-  stepper.synchronize(); // The lost one
1622
+  stepper.synchronize();
1624 1623
   feedrate_mm_m = old_feedrate_mm_m;
1625 1624
 }
1626 1625
 
@@ -2068,85 +2067,35 @@ static void clean_up_after_endstop_or_probe_move() {
2068 2067
   // at the height where the probe triggered.
2069 2068
   static float run_z_probe() {
2070 2069
 
2071
-    float old_feedrate_mm_m = feedrate_mm_m;
2072
-
2073 2070
     // Prevent stepper_inactive_time from running out and EXTRUDER_RUNOUT_PREVENT from extruding
2074 2071
     refresh_cmd_timeout();
2075 2072
 
2076
-    #if ENABLED(DELTA)
2077
-
2078
-      float start_z = current_position[Z_AXIS];
2079
-      long start_steps = stepper.position(Z_AXIS);
2080
-
2081
-      #if ENABLED(DEBUG_LEVELING_FEATURE)
2082
-        if (DEBUGGING(LEVELING)) DEBUG_POS("run_z_probe (DELTA) 1", current_position);
2083
-      #endif
2084
-
2085
-      // move down slowly until you find the bed
2086
-      feedrate_mm_m = homing_feedrate_mm_m[Z_AXIS] / 4;
2087
-      destination[Z_AXIS] = -10;
2088
-      prepare_move_to_destination_raw(); // this will also set_current_to_destination
2089
-      stepper.synchronize();
2090
-      endstops.hit_on_purpose(); // clear endstop hit flags
2091
-
2092
-      /**
2093
-       * We have to let the planner know where we are right now as it
2094
-       * is not where we said to go.
2095
-       */
2096
-      long stop_steps = stepper.position(Z_AXIS);
2097
-      float mm = start_z - float(start_steps - stop_steps) / planner.axis_steps_per_mm[Z_AXIS];
2098
-      current_position[Z_AXIS] = mm;
2099
-
2100
-      #if ENABLED(DEBUG_LEVELING_FEATURE)
2101
-        if (DEBUGGING(LEVELING)) DEBUG_POS("run_z_probe (DELTA) 2", current_position);
2102
-      #endif
2103
-
2104
-    #else // !DELTA
2105
-
2106
-      #if ENABLED(AUTO_BED_LEVELING_FEATURE)
2107
-        planner.bed_level_matrix.set_to_identity();
2108
-      #endif
2109
-
2110
-      feedrate_mm_m = homing_feedrate_mm_m[Z_AXIS];
2111
-
2112
-      // Move down until the Z probe (or endstop?) is triggered
2113
-      float zPosition = -(Z_MAX_LENGTH + 10);
2114
-      line_to_z(zPosition);
2115
-      stepper.synchronize();
2116
-
2117
-      // Tell the planner where we ended up - Get this from the stepper handler
2118
-      zPosition = stepper.get_axis_position_mm(Z_AXIS);
2119
-      planner.set_position_mm(
2120
-        current_position[X_AXIS], current_position[Y_AXIS], zPosition,
2121
-        current_position[E_AXIS]
2122
-      );
2123
-
2124
-      // move up the retract distance
2125
-      zPosition += home_bump_mm(Z_AXIS);
2126
-      line_to_z(zPosition);
2127
-      stepper.synchronize();
2128
-      endstops.hit_on_purpose(); // clear endstop hit flags
2129
-
2130
-      // move back down slowly to find bed
2131
-      set_homing_bump_feedrate(Z_AXIS);
2132
-
2133
-      zPosition -= home_bump_mm(Z_AXIS) * 2;
2134
-      line_to_z(zPosition);
2135
-      stepper.synchronize();
2136
-      endstops.hit_on_purpose(); // clear endstop hit flags
2137
-
2138
-      // Get the current stepper position after bumping an endstop
2139
-      current_position[Z_AXIS] = stepper.get_axis_position_mm(Z_AXIS);
2073
+    #if ENABLED(AUTO_BED_LEVELING_FEATURE)
2074
+      planner.bed_level_matrix.set_to_identity();
2075
+    #endif
2140 2076
 
2141
-      #if ENABLED(DEBUG_LEVELING_FEATURE)
2142
-        if (DEBUGGING(LEVELING)) DEBUG_POS("run_z_probe", current_position);
2143
-      #endif
2077
+    current_position[Z_AXIS] = -(Z_MAX_LENGTH + 10);
2078
+    do_blocking_move_to_z(current_position[Z_AXIS], Z_PROBE_SPEED_FAST);
2079
+    endstops.hit_on_purpose(); // clear endstop hit flags
2080
+    // Get the current stepper position after bumping an endstop
2081
+    current_position[Z_AXIS] = stepper.get_axis_position_mm(Z_AXIS);
2082
+    SYNC_PLAN_POSITION_KINEMATIC(); // tell the planner where we are      feedrate_mm_m = homing_feedrate_mm_m[Z_AXIS];
2144 2083
 
2145
-    #endif // !DELTA
2084
+    // move up the retract distance
2085
+    current_position[Z_AXIS] += home_bump_mm(Z_AXIS);
2086
+    do_blocking_move_to_z(current_position[Z_AXIS], Z_PROBE_SPEED_FAST);
2146 2087
 
2147
-    SYNC_PLAN_POSITION_KINEMATIC();
2088
+    // move back down slowly to find bed
2089
+    current_position[Z_AXIS] -= home_bump_mm(Z_AXIS) * 2;
2090
+    do_blocking_move_to_z(current_position[Z_AXIS], Z_PROBE_SPEED_SLOW);
2091
+    endstops.hit_on_purpose(); // clear endstop hit flags
2092
+    // Get the current stepper position after bumping an endstop
2093
+    current_position[Z_AXIS] = stepper.get_axis_position_mm(Z_AXIS);
2094
+    SYNC_PLAN_POSITION_KINEMATIC(); // tell the planner where we are
2148 2095
 
2149
-    feedrate_mm_m = old_feedrate_mm_m;
2096
+    #if ENABLED(DEBUG_LEVELING_FEATURE)
2097
+      if (DEBUGGING(LEVELING)) DEBUG_POS("run_z_probe", current_position);
2098
+    #endif
2150 2099
 
2151 2100
     return current_position[Z_AXIS];
2152 2101
   }
@@ -2431,7 +2380,7 @@ static void homeaxis(AxisEnum axis) {
2431 2380
   line_to_axis_pos(axis, -home_bump_mm(axis) * axis_home_dir);
2432 2381
 
2433 2382
   // Move slowly towards the endstop until triggered
2434
-  line_to_axis_pos(axis, 2 * home_bump_mm(axis) * axis_home_dir, set_homing_bump_feedrate(axis));
2383
+  line_to_axis_pos(axis, 2 * home_bump_mm(axis) * axis_home_dir, get_homing_bump_feedrate(axis));
2435 2384
 
2436 2385
   #if ENABLED(DEBUG_LEVELING_FEATURE)
2437 2386
     if (DEBUGGING(LEVELING)) DEBUG_POS("> TRIGGER ENDSTOP", current_position);

+ 4
- 0
Marlin/example_configurations/Cartesio/Configuration.h View File

@@ -499,6 +499,10 @@
499 499
 
500 500
 // X and Y axis travel speed (mm/m) between probes
501 501
 #define XY_PROBE_SPEED 8000
502
+// Speed for the first approach when probing
503
+#define Z_PROBE_SPEED_FAST HOMING_FEEDRATE_Z
504
+// Speed for the second approach when probing
505
+#define Z_PROBE_SPEED_SLOW (Z_PROBE_SPEED_FAST / 2)
502 506
 
503 507
 //
504 508
 // Allen Key Probe is defined in the Delta example configurations.

+ 4
- 0
Marlin/example_configurations/Felix/Configuration.h View File

@@ -481,6 +481,10 @@
481 481
 
482 482
 // X and Y axis travel speed (mm/m) between probes
483 483
 #define XY_PROBE_SPEED 8000
484
+// Speed for the first approach when probing
485
+#define Z_PROBE_SPEED_FAST HOMING_FEEDRATE_Z
486
+// Speed for the second approach when probing
487
+#define Z_PROBE_SPEED_SLOW (Z_PROBE_SPEED_FAST / 2)
484 488
 
485 489
 //
486 490
 // Allen Key Probe is defined in the Delta example configurations.

+ 4
- 0
Marlin/example_configurations/Felix/DUAL/Configuration.h View File

@@ -479,6 +479,10 @@
479 479
 
480 480
 // X and Y axis travel speed (mm/m) between probes
481 481
 #define XY_PROBE_SPEED 8000
482
+// Speed for the first approach when probing
483
+#define Z_PROBE_SPEED_FAST HOMING_FEEDRATE_Z
484
+// Speed for the second approach when probing
485
+#define Z_PROBE_SPEED_SLOW (Z_PROBE_SPEED_FAST / 2)
482 486
 
483 487
 //
484 488
 // Allen Key Probe is defined in the Delta example configurations.

+ 4
- 0
Marlin/example_configurations/Hephestos/Configuration.h View File

@@ -491,6 +491,10 @@
491 491
 
492 492
 // X and Y axis travel speed (mm/m) between probes
493 493
 #define XY_PROBE_SPEED 8000
494
+// Speed for the first approach when probing
495
+#define Z_PROBE_SPEED_FAST HOMING_FEEDRATE_Z
496
+// Speed for the second approach when probing
497
+#define Z_PROBE_SPEED_SLOW (Z_PROBE_SPEED_FAST / 2)
494 498
 
495 499
 //
496 500
 // Allen Key Probe is defined in the Delta example configurations.

+ 4
- 0
Marlin/example_configurations/Hephestos_2/Configuration.h View File

@@ -493,6 +493,10 @@
493 493
 
494 494
 // X and Y axis travel speed (mm/m) between probes
495 495
 #define XY_PROBE_SPEED 8000
496
+// Speed for the first approach when probing
497
+#define Z_PROBE_SPEED_FAST HOMING_FEEDRATE_Z
498
+// Speed for the second approach when probing
499
+#define Z_PROBE_SPEED_SLOW (Z_PROBE_SPEED_FAST / 2)
496 500
 
497 501
 //
498 502
 // Allen Key Probe is defined in the Delta example configurations.

+ 4
- 0
Marlin/example_configurations/K8200/Configuration.h View File

@@ -516,6 +516,10 @@
516 516
 
517 517
 // X and Y axis travel speed (mm/m) between probes
518 518
 #define XY_PROBE_SPEED 8000
519
+// Speed for the first approach when probing
520
+#define Z_PROBE_SPEED_FAST HOMING_FEEDRATE_Z
521
+// Speed for the second approach when probing
522
+#define Z_PROBE_SPEED_SLOW (Z_PROBE_SPEED_FAST / 2)
519 523
 
520 524
 //
521 525
 // Allen Key Probe is defined in the Delta example configurations.

+ 4
- 0
Marlin/example_configurations/K8400/Configuration.h View File

@@ -499,6 +499,10 @@
499 499
 
500 500
 // X and Y axis travel speed (mm/m) between probes
501 501
 #define XY_PROBE_SPEED 8000
502
+// Speed for the first approach when probing
503
+#define Z_PROBE_SPEED_FAST HOMING_FEEDRATE_Z
504
+// Speed for the second approach when probing
505
+#define Z_PROBE_SPEED_SLOW (Z_PROBE_SPEED_FAST / 2)
502 506
 
503 507
 //
504 508
 // Allen Key Probe is defined in the Delta example configurations.

+ 4
- 0
Marlin/example_configurations/K8400/Dual-head/Configuration.h View File

@@ -499,6 +499,10 @@
499 499
 
500 500
 // X and Y axis travel speed (mm/m) between probes
501 501
 #define XY_PROBE_SPEED 8000
502
+// Speed for the first approach when probing
503
+#define Z_PROBE_SPEED_FAST HOMING_FEEDRATE_Z
504
+// Speed for the second approach when probing
505
+#define Z_PROBE_SPEED_SLOW (Z_PROBE_SPEED_FAST / 2)
502 506
 
503 507
 //
504 508
 // Allen Key Probe is defined in the Delta example configurations.

+ 4
- 0
Marlin/example_configurations/RepRapWorld/Megatronics/Configuration.h View File

@@ -499,6 +499,10 @@
499 499
 
500 500
 // X and Y axis travel speed (mm/m) between probes
501 501
 #define XY_PROBE_SPEED 8000
502
+// Speed for the first approach when probing
503
+#define Z_PROBE_SPEED_FAST HOMING_FEEDRATE_Z
504
+// Speed for the second approach when probing
505
+#define Z_PROBE_SPEED_SLOW (Z_PROBE_SPEED_FAST / 2)
502 506
 
503 507
 //
504 508
 // Allen Key Probe is defined in the Delta example configurations.

+ 4
- 0
Marlin/example_configurations/RigidBot/Configuration.h View File

@@ -496,6 +496,10 @@
496 496
 
497 497
 // X and Y axis travel speed (mm/m) between probes
498 498
 #define XY_PROBE_SPEED 8000
499
+// Speed for the first approach when probing
500
+#define Z_PROBE_SPEED_FAST HOMING_FEEDRATE_Z
501
+// Speed for the second approach when probing
502
+#define Z_PROBE_SPEED_SLOW (Z_PROBE_SPEED_FAST / 2)
499 503
 
500 504
 //
501 505
 // Allen Key Probe is defined in the Delta example configurations.

+ 4
- 0
Marlin/example_configurations/SCARA/Configuration.h View File

@@ -507,6 +507,10 @@
507 507
 
508 508
 // X and Y axis travel speed (mm/m) between probes
509 509
 #define XY_PROBE_SPEED 8000
510
+// Speed for the first approach when probing
511
+#define Z_PROBE_SPEED_FAST HOMING_FEEDRATE_Z
512
+// Speed for the second approach when probing
513
+#define Z_PROBE_SPEED_SLOW (Z_PROBE_SPEED_FAST / 2)
510 514
 
511 515
 //
512 516
 // Allen Key Probe is defined in the Delta example configurations.

+ 4
- 0
Marlin/example_configurations/TAZ4/Configuration.h View File

@@ -520,6 +520,10 @@
520 520
 
521 521
 // X and Y axis travel speed (mm/m) between probes
522 522
 #define XY_PROBE_SPEED 8000
523
+// Speed for the first approach when probing
524
+#define Z_PROBE_SPEED_FAST HOMING_FEEDRATE_Z
525
+// Speed for the second approach when probing
526
+#define Z_PROBE_SPEED_SLOW (Z_PROBE_SPEED_FAST / 2)
523 527
 
524 528
 //
525 529
 // Allen Key Probe is defined in the Delta example configurations.

+ 4
- 0
Marlin/example_configurations/WITBOX/Configuration.h View File

@@ -491,6 +491,10 @@
491 491
 
492 492
 // X and Y axis travel speed (mm/m) between probes
493 493
 #define XY_PROBE_SPEED 8000
494
+// Speed for the first approach when probing
495
+#define Z_PROBE_SPEED_FAST HOMING_FEEDRATE_Z
496
+// Speed for the second approach when probing
497
+#define Z_PROBE_SPEED_SLOW (Z_PROBE_SPEED_FAST / 2)
494 498
 
495 499
 //
496 500
 // Allen Key Probe is defined in the Delta example configurations.

+ 4
- 0
Marlin/example_configurations/adafruit/ST7565/Configuration.h View File

@@ -499,6 +499,10 @@
499 499
 
500 500
 // X and Y axis travel speed (mm/m) between probes
501 501
 #define XY_PROBE_SPEED 8000
502
+// Speed for the first approach when probing
503
+#define Z_PROBE_SPEED_FAST HOMING_FEEDRATE_Z
504
+// Speed for the second approach when probing
505
+#define Z_PROBE_SPEED_SLOW (Z_PROBE_SPEED_FAST / 2)
502 506
 
503 507
 //
504 508
 // Allen Key Probe is defined in the Delta example configurations.

+ 4
- 0
Marlin/example_configurations/delta/biv2.5/Configuration.h View File

@@ -541,6 +541,10 @@
541 541
 
542 542
 // X and Y axis travel speed (mm/m) between probes
543 543
 #define XY_PROBE_SPEED 4000
544
+// Speed for the first approach when probing
545
+#define Z_PROBE_SPEED_FAST HOMING_FEEDRATE_Z
546
+// Speed for the second approach when probing
547
+#define Z_PROBE_SPEED_SLOW (Z_PROBE_SPEED_FAST / 2)
544 548
 
545 549
 // Allen key retractable z-probe as seen on many Kossel delta printers - http://reprap.org/wiki/Kossel#Automatic_bed_leveling_probe
546 550
 // Deploys by touching z-axis belt. Retracts by pushing the probe down. Uses Z_MIN_PIN.

+ 4
- 0
Marlin/example_configurations/delta/generic/Configuration.h View File

@@ -541,6 +541,10 @@
541 541
 
542 542
 // X and Y axis travel speed (mm/m) between probes
543 543
 #define XY_PROBE_SPEED 4000
544
+// Speed for the first approach when probing
545
+#define Z_PROBE_SPEED_FAST HOMING_FEEDRATE_Z
546
+// Speed for the second approach when probing
547
+#define Z_PROBE_SPEED_SLOW (Z_PROBE_SPEED_FAST / 2)
544 548
 
545 549
 // Allen key retractable z-probe as seen on many Kossel delta printers - http://reprap.org/wiki/Kossel#Automatic_bed_leveling_probe
546 550
 // Deploys by touching z-axis belt. Retracts by pushing the probe down. Uses Z_MIN_PIN.

+ 4
- 0
Marlin/example_configurations/delta/kossel_mini/Configuration.h View File

@@ -541,6 +541,10 @@
541 541
 
542 542
 // X and Y axis travel speed (mm/m) between probes
543 543
 #define XY_PROBE_SPEED 4000
544
+// Speed for the first approach when probing
545
+#define Z_PROBE_SPEED_FAST HOMING_FEEDRATE_Z
546
+// Speed for the second approach when probing
547
+#define Z_PROBE_SPEED_SLOW (Z_PROBE_SPEED_FAST / 2)
544 548
 
545 549
 // Allen key retractable z-probe as seen on many Kossel delta printers - http://reprap.org/wiki/Kossel#Automatic_bed_leveling_probe
546 550
 // Deploys by touching z-axis belt. Retracts by pushing the probe down. Uses Z_MIN_PIN.

+ 4
- 0
Marlin/example_configurations/delta/kossel_pro/Configuration.h View File

@@ -532,6 +532,10 @@
532 532
 
533 533
 // X and Y axis travel speed (mm/m) between probes
534 534
 #define XY_PROBE_SPEED 8000
535
+// Speed for the first approach when probing
536
+#define Z_PROBE_SPEED_FAST HOMING_FEEDRATE_Z
537
+// Speed for the second approach when probing
538
+#define Z_PROBE_SPEED_SLOW (Z_PROBE_SPEED_FAST / 2)
535 539
 
536 540
 // Allen key retractable z-probe as seen on many Kossel delta printers - http://reprap.org/wiki/Kossel#Automatic_bed_leveling_probe
537 541
 // Deploys by touching z-axis belt. Retracts by pushing the probe down. Uses Z_MIN_PIN.

+ 4
- 0
Marlin/example_configurations/delta/kossel_xl/Configuration.h View File

@@ -539,6 +539,10 @@
539 539
 
540 540
 // X and Y axis travel speed (mm/m) between probes
541 541
 #define XY_PROBE_SPEED 8000
542
+// Speed for the first approach when probing
543
+#define Z_PROBE_SPEED_FAST HOMING_FEEDRATE_Z
544
+// Speed for the second approach when probing
545
+#define Z_PROBE_SPEED_SLOW (Z_PROBE_SPEED_FAST / 2)
542 546
 
543 547
 // Allen key retractable z-probe as seen on many Kossel delta printers - http://reprap.org/wiki/Kossel#Automatic_bed_leveling_probe
544 548
 // Deploys by touching z-axis belt. Retracts by pushing the probe down. Uses Z_MIN_PIN.

+ 4
- 0
Marlin/example_configurations/makibox/Configuration.h View File

@@ -502,6 +502,10 @@
502 502
 
503 503
 // X and Y axis travel speed (mm/m) between probes
504 504
 #define XY_PROBE_SPEED 8000
505
+// Speed for the first approach when probing
506
+#define Z_PROBE_SPEED_FAST HOMING_FEEDRATE_Z
507
+// Speed for the second approach when probing
508
+#define Z_PROBE_SPEED_SLOW (Z_PROBE_SPEED_FAST / 2)
505 509
 
506 510
 //
507 511
 // Allen Key Probe is defined in the Delta example configurations.

+ 4
- 0
Marlin/example_configurations/tvrrug/Round2/Configuration.h View File

@@ -489,6 +489,10 @@
489 489
 
490 490
 // X and Y axis travel speed (mm/m) between probes
491 491
 #define XY_PROBE_SPEED 8000
492
+// Speed for the first approach when probing
493
+#define Z_PROBE_SPEED_FAST HOMING_FEEDRATE_Z
494
+// Speed for the second approach when probing
495
+#define Z_PROBE_SPEED_SLOW (Z_PROBE_SPEED_FAST / 2)
492 496
 
493 497
 //
494 498
 // Allen Key Probe is defined in the Delta example configurations.

Loading…
Cancel
Save