Browse Source

Introduce line_to_axis_pos(axis_codes axis, float where, float feed_rate = 0.0)

and use it in `homeaxis()` instead of `do_blocking_move_to_axis_pos()`.
`do_blocking_move_to_axis_pos` was wrong because it performed subdivided, delta-corrected moves for x- and y-axis.

The first common move for delta homing is like quick_home but for 3 towers.

Fix two warnings.
AnHardt 9 years ago
parent
commit
11c075c6b2
1 changed files with 44 additions and 37 deletions
  1. 44
    37
      Marlin/Marlin_main.cpp

+ 44
- 37
Marlin/Marlin_main.cpp View File

1613
 inline void line_to_current_position() {
1613
 inline void line_to_current_position() {
1614
   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);
1614
   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);
1615
 }
1615
 }
1616
+
1616
 inline void line_to_z(float zPosition) {
1617
 inline void line_to_z(float zPosition) {
1617
   planner.buffer_line(current_position[X_AXIS], current_position[Y_AXIS], zPosition, current_position[E_AXIS], MMM_TO_MMS(feedrate_mm_m), active_extruder);
1618
   planner.buffer_line(current_position[X_AXIS], current_position[Y_AXIS], zPosition, current_position[E_AXIS], MMM_TO_MMS(feedrate_mm_m), active_extruder);
1618
 }
1619
 }
1620
+
1621
+inline void line_to_axis_pos(AxisEnum axis, float where, float fr_mm_m = 0.0) {
1622
+  float old_feedrate_mm_m = feedrate_mm_m;
1623
+  current_position[axis] = where;
1624
+  feedrate_mm_m = (fr_mm_m != 0.0) ? fr_mm_m : homing_feedrate_mm_m[axis];
1625
+  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);
1626
+  stepper.synchronize(); // The lost one
1627
+  feedrate_mm_m = old_feedrate_mm_m;
1628
+}
1629
+
1619
 //
1630
 //
1620
 // line_to_destination
1631
 // line_to_destination
1621
 // Move the planner, not necessarily synced with current_position
1632
 // Move the planner, not necessarily synced with current_position
1708
   feedrate_mm_m = old_feedrate_mm_m;
1719
   feedrate_mm_m = old_feedrate_mm_m;
1709
 }
1720
 }
1710
 
1721
 
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
-
1716
 inline void do_blocking_move_to_x(float x, float fr_mm_m = 0.0) {
1722
 inline void do_blocking_move_to_x(float x, float fr_mm_m = 0.0) {
1717
   do_blocking_move_to(x, current_position[Y_AXIS], current_position[Z_AXIS], fr_mm_m);
1723
   do_blocking_move_to(x, current_position[Y_AXIS], current_position[Z_AXIS], fr_mm_m);
1718
 }
1724
 }
2425
   #endif
2431
   #endif
2426
 
2432
 
2427
   // Move towards the endstop until an endstop is triggered
2433
   // Move towards the endstop until an endstop is triggered
2428
-  do_blocking_move_to_axis_pos(axis, 1.5 * max_length(axis) * axis_home_dir, homing_feedrate_mm_m[axis]);
2434
+  line_to_axis_pos(axis, 1.5 * max_length(axis) * axis_home_dir);
2429
 
2435
 
2430
   // Set the axis position as setup for the move
2436
   // Set the axis position as setup for the move
2431
   current_position[axis] = 0;
2437
   current_position[axis] = 0;
2432
   sync_plan_position();
2438
   sync_plan_position();
2433
 
2439
 
2434
   // Move away from the endstop by the axis HOME_BUMP_MM
2440
   // Move away from the endstop by the axis HOME_BUMP_MM
2435
-  do_blocking_move_to_axis_pos(axis, -home_bump_mm(axis) * axis_home_dir, homing_feedrate_mm_m[axis]);
2436
-
2437
-  // Slow down the feedrate for the next move
2441
+  line_to_axis_pos(axis, -home_bump_mm(axis) * axis_home_dir);
2438
 
2442
 
2439
   // Move slowly towards the endstop until triggered
2443
   // Move slowly towards the endstop until triggered
2440
-  do_blocking_move_to_axis_pos(axis, 2 * home_bump_mm(axis) * axis_home_dir, set_homing_bump_feedrate(axis));
2444
+  line_to_axis_pos(axis, 2 * home_bump_mm(axis) * axis_home_dir, set_homing_bump_feedrate(axis));
2441
 
2445
 
2442
   #if ENABLED(DEBUG_LEVELING_FEATURE)
2446
   #if ENABLED(DEBUG_LEVELING_FEATURE)
2443
     if (DEBUGGING(LEVELING)) DEBUG_POS("> TRIGGER ENDSTOP", current_position);
2447
     if (DEBUGGING(LEVELING)) DEBUG_POS("> TRIGGER ENDSTOP", current_position);
2458
       sync_plan_position();
2462
       sync_plan_position();
2459
 
2463
 
2460
       // Move to the adjusted endstop height
2464
       // Move to the adjusted endstop height
2461
-      do_blocking_move_to_z(adj, homing_feedrate_mm_m[axis]);
2465
+      line_to_axis_pos(axis, adj);
2462
 
2466
 
2463
       if (lockZ1) stepper.set_z_lock(false); else stepper.set_z2_lock(false);
2467
       if (lockZ1) stepper.set_z_lock(false); else stepper.set_z2_lock(false);
2464
       stepper.set_homing_flag(false);
2468
       stepper.set_homing_flag(false);
2475
           DEBUG_POS("", current_position);
2479
           DEBUG_POS("", current_position);
2476
         }
2480
         }
2477
       #endif
2481
       #endif
2478
-      do_blocking_move_to_axis_pos(axis, endstop_adj[axis], set_homing_bump_feedrate(axis));
2482
+      line_to_axis_pos(axis, endstop_adj[axis]);
2479
     }
2483
     }
2480
   #endif
2484
   #endif
2481
 
2485
 
2825
   }
2829
   }
2826
 #endif
2830
 #endif
2827
 
2831
 
2832
+#if ENABLED(NOZZLE_PARK_FEATURE)
2833
+  #include "nozzle.h"
2834
+
2835
+  /**
2836
+   * G27: Park the nozzle
2837
+   */
2838
+  inline void gcode_G27() {
2839
+    // Don't allow nozzle parking without homing first
2840
+    if (axis_unhomed_error(true, true, true)) { return; }
2841
+    uint8_t const z_action = code_seen('P') ? code_value_ushort() : 0;
2842
+    Nozzle::park(z_action);
2843
+  }
2844
+#endif // NOZZLE_PARK_FEATURE
2845
+
2828
 #if ENABLED(QUICK_HOME)
2846
 #if ENABLED(QUICK_HOME)
2829
 
2847
 
2830
   static void quick_home_xy() {
2848
   static void quick_home_xy() {
2831
 
2849
 
2850
+    // Pretend the current position is 0,0
2851
+    current_position[X_AXIS] = current_position[Y_AXIS] = 0.0;
2852
+    sync_plan_position();
2853
+
2832
     #if ENABLED(DUAL_X_CARRIAGE)
2854
     #if ENABLED(DUAL_X_CARRIAGE)
2833
       int x_axis_home_dir = x_home_dir(active_extruder);
2855
       int x_axis_home_dir = x_home_dir(active_extruder);
2834
       extruder_duplication_enabled = false;
2856
       extruder_duplication_enabled = false;
2839
     float mlx = max_length(X_AXIS),
2861
     float mlx = max_length(X_AXIS),
2840
           mly = max_length(Y_AXIS),
2862
           mly = max_length(Y_AXIS),
2841
           mlratio = mlx > mly ? mly / mlx : mlx / mly,
2863
           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);
2864
+          fr_mm_m = min(homing_feedrate_mm_m[X_AXIS], homing_feedrate_mm_m[Y_AXIS]) * sqrt(sq(mlratio) + 1.0);
2843
 
2865
 
2844
     do_blocking_move_to_xy(1.5 * mlx * x_axis_home_dir, 1.5 * mly * home_dir(Y_AXIS), fr_mm_m);
2866
     do_blocking_move_to_xy(1.5 * mlx * x_axis_home_dir, 1.5 * mly * home_dir(Y_AXIS), fr_mm_m);
2845
     endstops.hit_on_purpose(); // clear endstop hit flags
2867
     endstops.hit_on_purpose(); // clear endstop hit flags
2846
-    current_position[X_AXIS] = current_position[Y_AXIS] = 0;
2868
+    current_position[X_AXIS] = current_position[Y_AXIS] = 0.0;
2847
 
2869
 
2848
   }
2870
   }
2849
 
2871
 
2850
 #endif // QUICK_HOME
2872
 #endif // QUICK_HOME
2851
 
2873
 
2852
-#if ENABLED(NOZZLE_PARK_FEATURE)
2853
-  #include "nozzle.h"
2854
-
2855
-  /**
2856
-   * G27: Park the nozzle
2857
-   */
2858
-  inline void gcode_G27() {
2859
-    // Don't allow nozzle parking without homing first
2860
-    if (axis_unhomed_error(true, true, true)) { return; }
2861
-    uint8_t const z_action = code_seen('P') ? code_value_ushort() : 0;
2862
-    Nozzle::park(z_action);
2863
-  }
2864
-#endif // NOZZLE_PARK_FEATURE
2865
-
2866
 /**
2874
 /**
2867
  * G28: Home all axes according to settings
2875
  * G28: Home all axes according to settings
2868
  *
2876
  *
2931
      */
2939
      */
2932
 
2940
 
2933
     // Pretend the current position is 0,0,0
2941
     // Pretend the current position is 0,0,0
2934
-    for (int i = X_AXIS; i <= Z_AXIS; i++) current_position[i] = 0;
2942
+    // This is like quick_home_xy() but for 3 towers.
2943
+    current_position[X_AXIS] = current_position[Y_AXIS] = current_position[Z_AXIS] = 0.0;
2935
     sync_plan_position();
2944
     sync_plan_position();
2936
 
2945
 
2937
     // Move all carriages up together until the first endstop is hit.
2946
     // Move all carriages up together until the first endstop is hit.
2938
-    for (int i = X_AXIS; i <= Z_AXIS; i++) destination[i] = 3 * (Z_MAX_LENGTH);
2947
+    current_position[X_AXIS] = current_position[Y_AXIS] = current_position[Z_AXIS] = 3.0 * (Z_MAX_LENGTH);
2939
     feedrate_mm_m = 1.732 * homing_feedrate_mm_m[X_AXIS];
2948
     feedrate_mm_m = 1.732 * homing_feedrate_mm_m[X_AXIS];
2940
-    line_to_destination();
2949
+    line_to_current_position();
2941
     stepper.synchronize();
2950
     stepper.synchronize();
2942
     endstops.hit_on_purpose(); // clear endstop hit flags
2951
     endstops.hit_on_purpose(); // clear endstop hit flags
2952
+    current_position[X_AXIS] = current_position[Y_AXIS] = current_position[Z_AXIS] = 0.0;
2943
 
2953
 
2944
-    // Destination reached
2945
-    for (int i = X_AXIS; i <= Z_AXIS; i++) current_position[i] = destination[i];
2946
-
2947
-    // take care of back off and rehome now we are all at the top
2954
+    // take care of back off and rehome. Now one carriage is at the top.
2948
     HOMEAXIS(X);
2955
     HOMEAXIS(X);
2949
     HOMEAXIS(Y);
2956
     HOMEAXIS(Y);
2950
     HOMEAXIS(Z);
2957
     HOMEAXIS(Z);
5325
     if (volumetric_enabled) {
5332
     if (volumetric_enabled) {
5326
       filament_size[target_extruder] = code_value_linear_units();
5333
       filament_size[target_extruder] = code_value_linear_units();
5327
       // make sure all extruders have some sane value for the filament size
5334
       // make sure all extruders have some sane value for the filament size
5328
-      for (int i = 0; i < COUNT(filament_size); i++)
5335
+      for (uint8_t i = 0; i < COUNT(filament_size); i++)
5329
         if (! filament_size[i]) filament_size[i] = DEFAULT_NOMINAL_FILAMENT_DIA;
5336
         if (! filament_size[i]) filament_size[i] = DEFAULT_NOMINAL_FILAMENT_DIA;
5330
     }
5337
     }
5331
   }
5338
   }
8695
 }
8702
 }
8696
 
8703
 
8697
 void calculate_volumetric_multipliers() {
8704
 void calculate_volumetric_multipliers() {
8698
-  for (int i = 0; i < COUNT(filament_size); i++)
8705
+  for (uint8_t i = 0; i < COUNT(filament_size); i++)
8699
     volumetric_multiplier[i] = calculate_volumetric_multiplier(filament_size[i]);
8706
     volumetric_multiplier[i] = calculate_volumetric_multiplier(filament_size[i]);
8700
 }
8707
 }

Loading…
Cancel
Save