Browse Source

Use blocking_move, current_position in G28 homing

Scott Lahteine 9 years ago
parent
commit
1e57a6af73
1 changed files with 19 additions and 30 deletions
  1. 19
    30
      Marlin/Marlin_main.cpp

+ 19
- 30
Marlin/Marlin_main.cpp View File

1594
 /**
1594
 /**
1595
  * Some planner shorthand inline functions
1595
  * Some planner shorthand inline functions
1596
  */
1596
  */
1597
-inline void set_homing_bump_feedrate(AxisEnum axis) {
1597
+inline float set_homing_bump_feedrate(AxisEnum axis) {
1598
   const int homing_bump_divisor[] = HOMING_BUMP_DIVISOR;
1598
   const int homing_bump_divisor[] = HOMING_BUMP_DIVISOR;
1599
   int hbd = homing_bump_divisor[axis];
1599
   int hbd = homing_bump_divisor[axis];
1600
   if (hbd < 1) {
1600
   if (hbd < 1) {
1603
     SERIAL_ECHOLNPGM("Warning: Homing Bump Divisor < 1");
1603
     SERIAL_ECHOLNPGM("Warning: Homing Bump Divisor < 1");
1604
   }
1604
   }
1605
   feedrate_mm_m = homing_feedrate_mm_m[axis] / hbd;
1605
   feedrate_mm_m = homing_feedrate_mm_m[axis] / hbd;
1606
+  return feedrate_mm_m;
1606
 }
1607
 }
1607
 //
1608
 //
1608
 // line_to_current_position
1609
 // line_to_current_position
1707
   feedrate_mm_m = old_feedrate_mm_m;
1708
   feedrate_mm_m = old_feedrate_mm_m;
1708
 }
1709
 }
1709
 
1710
 
1711
+inline void do_blocking_move_to_axis_pos(AxisEnum axis, float where, float fr_mm_m = 0.0) {
1712
+  current_position[axis] = where;
1713
+  do_blocking_move_to(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], fr_mm_m);
1714
+}
1715
+
1710
 inline void do_blocking_move_to_x(float x, float fr_mm_m = 0.0) {
1716
 inline void do_blocking_move_to_x(float x, float fr_mm_m = 0.0) {
1711
   do_blocking_move_to(x, current_position[Y_AXIS], current_position[Z_AXIS], fr_mm_m);
1717
   do_blocking_move_to(x, current_position[Y_AXIS], current_position[Z_AXIS], fr_mm_m);
1712
 }
1718
 }
2419
   #endif
2425
   #endif
2420
 
2426
 
2421
   // Move towards the endstop until an endstop is triggered
2427
   // Move towards the endstop until an endstop is triggered
2422
-  destination[axis] = 1.5 * max_length(axis) * axis_home_dir;
2428
+  do_blocking_move_to_axis_pos(axis, 1.5 * max_length(axis) * axis_home_dir, homing_feedrate_mm_m[axis]);
2423
-  feedrate_mm_m = homing_feedrate_mm_m[axis];
2424
-  line_to_destination();
2425
-  stepper.synchronize();
2426
 
2429
 
2427
   // Set the axis position as setup for the move
2430
   // Set the axis position as setup for the move
2428
   current_position[axis] = 0;
2431
   current_position[axis] = 0;
2429
   sync_plan_position();
2432
   sync_plan_position();
2430
 
2433
 
2431
   // Move away from the endstop by the axis HOME_BUMP_MM
2434
   // Move away from the endstop by the axis HOME_BUMP_MM
2432
-  destination[axis] = -home_bump_mm(axis) * axis_home_dir;
2435
+  do_blocking_move_to_axis_pos(axis, -home_bump_mm(axis) * axis_home_dir, homing_feedrate_mm_m[axis]);
2433
-  line_to_destination();
2434
-  stepper.synchronize();
2435
 
2436
 
2436
   // Slow down the feedrate for the next move
2437
   // Slow down the feedrate for the next move
2437
-  set_homing_bump_feedrate(axis);
2438
 
2438
 
2439
   // Move slowly towards the endstop until triggered
2439
   // Move slowly towards the endstop until triggered
2440
-  destination[axis] = 2 * home_bump_mm(axis) * axis_home_dir;
2440
+  do_blocking_move_to_axis_pos(axis, 2 * home_bump_mm(axis) * axis_home_dir, set_homing_bump_feedrate(axis));
2441
-  line_to_destination();
2442
-  stepper.synchronize();
2443
 
2441
 
2444
   #if ENABLED(DEBUG_LEVELING_FEATURE)
2442
   #if ENABLED(DEBUG_LEVELING_FEATURE)
2445
     if (DEBUGGING(LEVELING)) DEBUG_POS("> TRIGGER ENDSTOP", current_position);
2443
     if (DEBUGGING(LEVELING)) DEBUG_POS("> TRIGGER ENDSTOP", current_position);
2460
       sync_plan_position();
2458
       sync_plan_position();
2461
 
2459
 
2462
       // Move to the adjusted endstop height
2460
       // Move to the adjusted endstop height
2463
-      feedrate_mm_m = homing_feedrate_mm_m[axis];
2461
+      do_blocking_move_to_z(adj, homing_feedrate_mm_m[axis]);
2464
-      destination[Z_AXIS] = adj;
2465
-      line_to_destination();
2466
-      stepper.synchronize();
2467
 
2462
 
2468
       if (lockZ1) stepper.set_z_lock(false); else stepper.set_z2_lock(false);
2463
       if (lockZ1) stepper.set_z_lock(false); else stepper.set_z2_lock(false);
2469
       stepper.set_homing_flag(false);
2464
       stepper.set_homing_flag(false);
2474
     // retrace by the amount specified in endstop_adj
2469
     // retrace by the amount specified in endstop_adj
2475
     if (endstop_adj[axis] * axis_home_dir < 0) {
2470
     if (endstop_adj[axis] * axis_home_dir < 0) {
2476
       sync_plan_position();
2471
       sync_plan_position();
2477
-      destination[axis] = endstop_adj[axis];
2478
       #if ENABLED(DEBUG_LEVELING_FEATURE)
2472
       #if ENABLED(DEBUG_LEVELING_FEATURE)
2479
         if (DEBUGGING(LEVELING)) {
2473
         if (DEBUGGING(LEVELING)) {
2480
           SERIAL_ECHOPAIR("> endstop_adj = ", endstop_adj[axis]);
2474
           SERIAL_ECHOPAIR("> endstop_adj = ", endstop_adj[axis]);
2481
-          DEBUG_POS("", destination);
2475
+          DEBUG_POS("", current_position);
2482
         }
2476
         }
2483
       #endif
2477
       #endif
2484
-      line_to_destination();
2478
+      do_blocking_move_to_axis_pos(axis, endstop_adj[axis], set_homing_bump_feedrate(axis));
2485
-      stepper.synchronize();
2486
     }
2479
     }
2487
   #endif
2480
   #endif
2488
 
2481
 
2836
 
2829
 
2837
   static void quick_home_xy() {
2830
   static void quick_home_xy() {
2838
 
2831
 
2839
-    current_position[X_AXIS] = current_position[Y_AXIS] = 0;
2840
-
2841
     #if ENABLED(DUAL_X_CARRIAGE)
2832
     #if ENABLED(DUAL_X_CARRIAGE)
2842
       int x_axis_home_dir = x_home_dir(active_extruder);
2833
       int x_axis_home_dir = x_home_dir(active_extruder);
2843
       extruder_duplication_enabled = false;
2834
       extruder_duplication_enabled = false;
2845
       int x_axis_home_dir = home_dir(X_AXIS);
2836
       int x_axis_home_dir = home_dir(X_AXIS);
2846
     #endif
2837
     #endif
2847
 
2838
 
2848
-    float mlx = max_length(X_AXIS), mly = max_length(Y_AXIS),
2839
+    float mlx = max_length(X_AXIS),
2849
-          mlratio = mlx > mly ? mly / mlx : mlx / mly;
2840
+          mly = max_length(Y_AXIS),
2841
+          mlratio = mlx > mly ? mly / mlx : mlx / mly,
2842
+          fr_mm_m = min(homing_feedrate_mm_m[X_AXIS], homing_feedrate_mm_m[Y_AXIS]) * sqrt(sq(mlratio) + 1);
2850
 
2843
 
2851
-    destination[X_AXIS] = 1.5 * mlx * x_axis_home_dir;
2844
+    do_blocking_move_to_xy(1.5 * mlx * x_axis_home_dir, 1.5 * mly * home_dir(Y_AXIS), fr_mm_m);
2852
-    destination[Y_AXIS] = 1.5 * mly * home_dir(Y_AXIS);
2853
-    feedrate_mm_m = min(homing_feedrate_mm_m[X_AXIS], homing_feedrate_mm_m[Y_AXIS]) * sqrt(sq(mlratio) + 1);
2854
-    line_to_destination();
2855
-    stepper.synchronize();
2856
     endstops.hit_on_purpose(); // clear endstop hit flags
2845
     endstops.hit_on_purpose(); // clear endstop hit flags
2846
+    current_position[X_AXIS] = current_position[Y_AXIS] = 0;
2857
 
2847
 
2858
-    destination[X_AXIS] = destination[Y_AXIS] = 0;
2859
   }
2848
   }
2860
 
2849
 
2861
 #endif // QUICK_HOME
2850
 #endif // QUICK_HOME

Loading…
Cancel
Save